liboptcfg

diff src/optcfg.h @ 3:f971dfa66076

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 27 Jul 2016 04:31:40 +0300
parents 9c73004c7af3
children a6f127f3408d
line diff
     1.1 --- a/src/optcfg.h	Fri Nov 20 17:05:39 2015 +0200
     1.2 +++ b/src/optcfg.h	Wed Jul 27 04:31:40 2016 +0300
     1.3 @@ -2,6 +2,8 @@
     1.4  #ifndef LIBOPTCFG_H_
     1.5  #define LIBOPTCFG_H_
     1.6  
     1.7 +#include <stdio.h>
     1.8 +
     1.9  struct optcfg;
    1.10  
    1.11  struct optcfg_option {
    1.12 @@ -11,9 +13,15 @@
    1.13  	char *desc;	/* text description for printing usage information */
    1.14  };
    1.15  
    1.16 +#define OPTCFG_OPTIONS_END	{0, 0, -1, 0}
    1.17 +
    1.18  typedef int (*optcfg_opt_callback)(struct optcfg *oc, int opt, void *cls);
    1.19  typedef int (*optcfg_arg_callback)(struct optcfg *oc, const char *arg, void *cls);
    1.20  
    1.21 +#ifdef __cplusplus
    1.22 +extern "C" {
    1.23 +#endif
    1.24 +
    1.25  /* initialize the optcfg object with a valid option vector terminated by an
    1.26   * entry with an opt value of -1 (other fields ignored for termination purposes)
    1.27   *
    1.28 @@ -21,7 +29,7 @@
    1.29   *   struct optcfg_option options[] = {
    1.30   *       {'f', "foo", OPT_FOO, "Makes sure the foo is bar"},
    1.31   *       {'h', "help", OPT_HELP, "Print usage information and exit"},
    1.32 - *       {0, 0, -1, 0}
    1.33 + *       OPTCFG_OPTIONS_END
    1.34   *   };
    1.35   *   struct optcfg *oc = optcfg_init(options);
    1.36   */
    1.37 @@ -75,5 +83,8 @@
    1.38  int optcfg_int_value(char *str, int *valret);
    1.39  int optcfg_float_value(char *str, float *valret);
    1.40  
    1.41 +#ifdef __cplusplus
    1.42 +}
    1.43 +#endif
    1.44  
    1.45  #endif	/* LIBOPTCFG_H_ */