Changeset fcc0936
- Timestamp:
- Jun 19, 2011, 1:12:55 AM (13 years ago)
- 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. - Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cmd.c
r4c7c21f rd4c3284 5 5 #include "owl.h" 6 6 7 extern const owl_cmd commands_to_init[];8 9 7 /**************************************************************************/ 10 8 /***************************** COMMAND DICT *******************************/ … … 13 11 int owl_cmddict_setup(owl_cmddict *cd) { 14 12 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); 17 14 } 18 15 -
commands.c
r697221f rdf7301c 8 8 /* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */ 9 9 #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, \ 11 11 NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL } 12 12 13 13 /* fn is "void foo(void)" */ 14 14 #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, \ 16 16 NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL } 17 17 18 18 /* fn is "void foo(int)" */ 19 19 #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, \ 21 21 NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL } 22 22 23 23 #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 } 26 26 27 27 /* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */ 28 28 #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, \ 30 30 NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL } 31 31 32 32 /* fn is "void foo(void)" */ 33 33 #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, \ 35 35 NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL } 36 36 37 37 /* fn is "void foo(int)" */ 38 38 #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, \ 40 40 NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL } 41 41 42 42 43 const owl_cmd commands_to_init[] 44 = { 43 int owl_cmd_add_defaults(owl_cmddict *cd) 44 { 45 owl_cmd commands_to_init[] = { 46 45 47 OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY, 46 48 "send a login or logout notification", … … 1037 1039 { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } 1038 1040 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 } 1040 1049 1041 1050 void owl_command_info(void) -
configure.ac
rfe73d0c r4798b36 130 130 AX_CFLAGS_WARN_ALL([AM_CFLAGS]) 131 131 AX_C_CHECK_FLAG([-Wstrict-prototypes],[],[],[AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"]) 132 AX_C_CHECK_FLAG([-Wwrite-strings],[],[],[AM_CFLAGS="$AM_CFLAGS -Wwrite-strings"]) 132 133 133 134 dnl Shut gcc up about zero-length format strings; the warning's apparently for -
owl.h
rfe73d0c r24a791f 233 233 void *pval_default; /* for types other and string */ 234 234 int ival_default; /* for types int and bool */ 235 c har *validsettings;/* documentation of valid settings */235 const char *validsettings; /* documentation of valid settings */ 236 236 char *summary; /* summary of usage */ 237 237 char *description; /* detailed description */ -
variable.c
r4c7c21f r81a5686 7 7 8 8 #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, \ 10 10 NULL, NULL, NULL, NULL, NULL, NULL } 11 11 12 12 #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, \ 14 14 validate, set, NULL, get, NULL, NULL } 15 15 16 16 #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, \ 18 18 NULL, NULL, NULL, NULL, NULL, NULL } 19 19 20 20 #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, \ 22 22 validate, set, NULL, get, NULL, NULL } 23 23 24 24 #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, \ 26 26 NULL, NULL, NULL, NULL, NULL, NULL } 27 27 28 28 #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, \ 30 30 NULL, NULL, NULL, NULL, NULL, NULL } 31 31 32 32 #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, \ 34 34 validate, set, NULL, get, NULL, NULL } 35 35 … … 38 38 * correspond to the values that may be specified. */ 39 39 #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, \ 41 41 owl_variable_enum_validate, \ 42 42 NULL, owl_variable_enum_set_fromstring, \ … … 45 45 46 46 #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, \ 48 48 validate, \ 49 49 set, owl_variable_enum_set_fromstring, \ … … 51 51 NULL } 52 52 53 static owl_variable variables_to_init[] = { 53 int owl_variable_add_defaults(owl_vardict *vd) 54 { 55 owl_variable variables_to_init[] = { 54 56 55 57 OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off", … … 439 441 NULL, NULL, NULL, NULL, NULL, NULL } 440 442 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 } 442 451 443 452 /**************************************************************************/ … … 558 567 559 568 int owl_variable_dict_setup(owl_vardict *vd) { 569 owl_dict_create(vd); 570 return owl_variable_add_defaults(vd); 571 } 572 573 int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init) 574 { 560 575 owl_variable *var, *cur; 561 owl_dict_create(vd);562 576 for (var = variables_to_init; var->name != NULL; var++) { 563 577 cur = g_new(owl_variable, 1); … … 584 598 if (!cur->delete_fn) 585 599 cur->delete_fn = owl_variable_delete_default; 600 cur->pval_default = g_strdup(var->pval_default); 586 601 cur->set_fn(cur, cur->pval_default); 587 602 break; … … 718 733 } 719 734 720 void owl_variable_ delete(owl_variable *v)735 void owl_variable_cleanup(owl_variable *v) 721 736 { 722 737 if (v->delete_fn) v->delete_fn(v); … … 724 739 g_free(v->summary); 725 740 g_free(v->description); 741 if (v->type == OWL_VARIABLE_STRING) 742 g_free(v->pval_default); 743 } 744 745 void owl_variable_delete(owl_variable *v) 746 { 747 owl_variable_cleanup(v); 726 748 g_free(v); 727 749 }
Note: See TracChangeset
for help on using the changeset viewer.