# HG changeset patch # User John Tsiombikas # Date 1469583100 -10800 # Node ID f971dfa66076cbecc1260e507aaae76021c38bf1 # Parent 9c73004c7af3eb1446b8bd4533dbdf02a8f2d870 foo diff -r 9c73004c7af3 -r f971dfa66076 example/example.c --- a/example/example.c Fri Nov 20 17:05:39 2015 +0200 +++ b/example/example.c Wed Jul 27 04:31:40 2016 +0300 @@ -15,7 +15,7 @@ {'b', "bar", OPT_BAR, "bar also does nothing"}, {0, "xyzzy", OPT_XYZZY, "xyzzy doesn't have a short option"}, {'h', "help", OPT_HELP, "print usage and exit"}, - {0, 0, -1, 0} /* terminate with id=-1 */ + OPTCFG_OPTIONS_END }; int foo, bar; diff -r 9c73004c7af3 -r f971dfa66076 src/optcfg.h --- a/src/optcfg.h Fri Nov 20 17:05:39 2015 +0200 +++ b/src/optcfg.h Wed Jul 27 04:31:40 2016 +0300 @@ -2,6 +2,8 @@ #ifndef LIBOPTCFG_H_ #define LIBOPTCFG_H_ +#include + struct optcfg; struct optcfg_option { @@ -11,9 +13,15 @@ char *desc; /* text description for printing usage information */ }; +#define OPTCFG_OPTIONS_END {0, 0, -1, 0} + typedef int (*optcfg_opt_callback)(struct optcfg *oc, int opt, void *cls); typedef int (*optcfg_arg_callback)(struct optcfg *oc, const char *arg, void *cls); +#ifdef __cplusplus +extern "C" { +#endif + /* initialize the optcfg object with a valid option vector terminated by an * entry with an opt value of -1 (other fields ignored for termination purposes) * @@ -21,7 +29,7 @@ * struct optcfg_option options[] = { * {'f', "foo", OPT_FOO, "Makes sure the foo is bar"}, * {'h', "help", OPT_HELP, "Print usage information and exit"}, - * {0, 0, -1, 0} + * OPTCFG_OPTIONS_END * }; * struct optcfg *oc = optcfg_init(options); */ @@ -75,5 +83,8 @@ int optcfg_int_value(char *str, int *valret); int optcfg_float_value(char *str, float *valret); +#ifdef __cplusplus +} +#endif #endif /* LIBOPTCFG_H_ */