Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rb9d22f7 r117c21c  
    88/* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */
    99#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
    10         { name, summary, usage, description, ctx, \
     10        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    1111          NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL }
    1212
    1313/* fn is "void foo(void)" */
    1414#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
    15         { name, summary, usage, description, ctx, \
     15        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    1616          NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL }
    1717
    1818/* fn is "void foo(int)" */
    1919#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
    20         { name, summary, usage, description, ctx, \
     20        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    2121          NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL }
    2222
    2323#define OWLCMD_ALIAS(name, actualname) \
    24         { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
    25           actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
     24        { g_strdup(name), g_strdup(OWL_CMD_ALIAS_SUMMARY_PREFIX actualname), g_strdup(""), g_strdup(""), OWL_CTX_ANY, \
     25          g_strdup(actualname), NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    2626
    2727/* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */
    2828#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
    29         { name, summary, usage, description, ctx, \
     29        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3030          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL }
    3131
    3232/* fn is "void foo(void)" */
    3333#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
    34         { name, summary, usage, description, ctx, \
     34        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3535          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL }
    3636
    3737/* fn is "void foo(int)" */
    3838#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
    39         { name, summary, usage, description, ctx, \
     39        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    4040          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL }
    4141
    4242
    43 const owl_cmd commands_to_init[]
    44   = {
     43int owl_cmd_add_defaults(owl_cmddict *cd)
     44{
     45  owl_cmd commands_to_init[] = {
     46
    4547  OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY,
    4648              "send a login or logout notification",
     
    654656              "show subscriptions / show subs\n"
    655657              "show terminal\n"
     658              "show timers\n"
    656659              "show variables\n"
    657660              "show variable <variable>\n"
     
    10361039  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    10371040
    1038 };
     1041  };
     1042
     1043  int ret = owl_cmddict_add_from_list(cd, commands_to_init);
     1044  owl_cmd *cmd;
     1045  for (cmd = commands_to_init; cmd->name != NULL; cmd++)
     1046    owl_cmd_cleanup(cmd);
     1047  return ret;
     1048}
    10391049
    10401050void owl_command_info(void)
     
    22242234  } else if (!strcmp(argv[1], "styles")) {
    22252235    owl_function_show_styles();
     2236  } else if (!strcmp(argv[1], "timers")) {
     2237    owl_function_show_timers();
    22262238  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
    22272239    owl_function_getsubs();
Note: See TracChangeset for help on using the changeset viewer.