Changeset fcc0936


Ignore:
Timestamp:
Jun 19, 2011, 1:12:55 AM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
fe73d0c (diff), 4798b36 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 4798b3653fae047b4c94e9ea07237195446b2991 into fe73d0c8bf42966a7f576c0ee9158753d7685592
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    r4c7c21f rd4c3284  
    55#include "owl.h"
    66
    7 extern const owl_cmd commands_to_init[];
    8 
    97/**************************************************************************/
    108/***************************** COMMAND DICT *******************************/
     
    1311int owl_cmddict_setup(owl_cmddict *cd) {
    1412  owl_cmddict_init(cd);
    15   if (0 != owl_cmddict_add_from_list(cd, commands_to_init)) return(-1);
    16   return(0);
     13  return owl_cmd_add_defaults(cd);
    1714}
    1815
  • commands.c

    r697221f rdf7301c  
    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",
     
    10371039  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    10381040
    1039 };
     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}
    10401049
    10411050void owl_command_info(void)
  • configure.ac

    rfe73d0c r4798b36  
    130130AX_CFLAGS_WARN_ALL([AM_CFLAGS])
    131131AX_C_CHECK_FLAG([-Wstrict-prototypes],[],[],[AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"])
     132AX_C_CHECK_FLAG([-Wwrite-strings],[],[],[AM_CFLAGS="$AM_CFLAGS -Wwrite-strings"])
    132133
    133134dnl Shut gcc up about zero-length format strings; the warning's apparently for
  • owl.h

    rfe73d0c r24a791f  
    233233  void *pval_default;  /* for types other and string */
    234234  int   ival_default;  /* for types int and bool     */
    235   char *validsettings;          /* documentation of valid settings */
     235  const char *validsettings;    /* documentation of valid settings */
    236236  char *summary;                /* summary of usage */
    237237  char *description;            /* detailed description */
  • variable.c

    r4c7c21f r81a5686  
    77
    88#define OWLVAR_BOOL(name,default,summary,description) \
    9         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
     9        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    1010        NULL, NULL, NULL, NULL, NULL, NULL }
    1111
    1212#define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \
    13         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
     13        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    1414        validate, set, NULL, get, NULL, NULL }
    1515
    1616#define OWLVAR_INT(name,default,summary,description) \
    17         { name, OWL_VARIABLE_INT, NULL, default, "<int>", summary,description, NULL, \
     17        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \
    1818        NULL, NULL, NULL, NULL, NULL, NULL }
    1919
    2020#define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \
    21         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     21        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    2222        validate, set, NULL, get, NULL, NULL }
    2323
    2424#define OWLVAR_PATH(name,default,summary,description) \
    25         { name, OWL_VARIABLE_STRING, default, 0, "<path>", summary,description,  NULL, \
     25        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description),  NULL, \
    2626        NULL, NULL, NULL, NULL, NULL, NULL }
    2727
    2828#define OWLVAR_STRING(name,default,summary,description) \
    29         { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
     29        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \
    3030        NULL, NULL, NULL, NULL, NULL, NULL }
    3131
    3232#define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
    33         { name, OWL_VARIABLE_STRING, default, 0, validset, summary,description, NULL, \
     33        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \
    3434        validate, set, NULL, get, NULL, NULL }
    3535
     
    3838 * correspond to the values that may be specified. */
    3939#define OWLVAR_ENUM(name,default,summary,description,validset) \
    40         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     40        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    4141        owl_variable_enum_validate, \
    4242        NULL, owl_variable_enum_set_fromstring, \
     
    4545
    4646#define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \
    47         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     47        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    4848        validate, \
    4949        set, owl_variable_enum_set_fromstring, \
     
    5151        NULL }
    5252
    53 static owl_variable variables_to_init[] = {
     53int owl_variable_add_defaults(owl_vardict *vd)
     54{
     55  owl_variable variables_to_init[] = {
    5456
    5557  OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off",
     
    439441    NULL, NULL, NULL, NULL, NULL, NULL }
    440442
    441 };
     443  };
     444
     445  int ret = owl_variable_dict_add_from_list(vd, variables_to_init);
     446  owl_variable *var;
     447  for (var = variables_to_init; var->name != NULL; var++)
     448    owl_variable_cleanup(var);
     449  return ret;
     450}
    442451
    443452/**************************************************************************/
     
    558567
    559568int owl_variable_dict_setup(owl_vardict *vd) {
     569  owl_dict_create(vd);
     570  return owl_variable_add_defaults(vd);
     571}
     572
     573int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init)
     574{
    560575  owl_variable *var, *cur;
    561   owl_dict_create(vd);
    562576  for (var = variables_to_init; var->name != NULL; var++) {
    563577    cur = g_new(owl_variable, 1);
     
    584598      if (!cur->delete_fn)
    585599        cur->delete_fn = owl_variable_delete_default;
     600      cur->pval_default = g_strdup(var->pval_default);
    586601      cur->set_fn(cur, cur->pval_default);
    587602      break;
     
    718733}
    719734
    720 void owl_variable_delete(owl_variable *v)
     735void owl_variable_cleanup(owl_variable *v)
    721736{
    722737  if (v->delete_fn) v->delete_fn(v);
     
    724739  g_free(v->summary);
    725740  g_free(v->description);
     741  if (v->type == OWL_VARIABLE_STRING)
     742    g_free(v->pval_default);
     743}
     744
     745void owl_variable_delete(owl_variable *v)
     746{
     747  owl_variable_cleanup(v);
    726748  g_free(v);
    727749}
Note: See TracChangeset for help on using the changeset viewer.