options.h
Go to the documentation of this file.
1 #ifndef H_OPTIONS
2 #define H_OPTIONS
3 
4 #include <stdio.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 
12  /* Sets the banner for the help message. (pointer is kept) */
13  void options_banner(const char*message);
14 
15  struct option;
16  struct option_alternative;
17 
18  struct option* options_allocate(int n);
19 
20  void options_int (struct option*, const char* name,
21  int *p, int def_value, const char*desc);
22 
23  void options_double (struct option*, const char* name,
24  double *p, double def_value, const char*desc);
25 
26  void options_string (struct option*, const char* name,
27  const char** p,const char*def_balue,const char*desc);
28 
29  void options_alternative(struct option*, const char*name, struct option_alternative*alt,
30  int*value, const char*desc);
31 
33  int options_parse_args(struct option*ops, int argc, const char* argv[]);
34 
36  int options_parse_file(struct option*ops, const char*pwd, const char*file);
37 
38  void options_print_help(struct option*ops, FILE*where);
39 
40 
44 
45 #define OPTIONS_NAME_MAXSIZE 32
46 #define OPTIONS_VALUE_MAXSIZE 256
47 
48 
49 struct option {
51  const char * name;
52  const char * desc;
53 
56 
70  void * value_pointer;
71 
72 
74  int * set_pointer;
75 
78 };
79 
81  const char *label;
82  int value;
83  const char *desc;
84 };
85 
86 
88 struct option * options_find(struct option*ops, const char * name);
89 
91 int options_requires_argument(struct option*o);
92 
94 void options_set_passed(struct option*o);
95 
97 int options_try_pair(struct option*ops, const char*name, const char*value);
98 
100 int options_set(struct option*op, const char*value);
101 
102 int options_valid(struct option*op);
103 
104 void options_dump(struct option * options, FILE*f, int write_desc);
105 
106 int options_parse_stream(struct option*ops, const char*pwd, FILE*file);
107 
109 char * strdup_(const char *s);
111 int get_double(double*p, const char*s);
113 int get_int(int*p, const char*s);
114 /* Find next empty slot in the array. XXX farlo meglio */
115 struct option* options_next_empty(struct option*ops);
116 
117 
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 
124 
125 #endif
int get_int(int *p, const char *s)
Definition: options.c:47
const char * desc
Definition: options.h:83
int * set_pointer
Definition: options.h:74
int options_parse_file(struct option *ops, const char *pwd, const char *file)
Definition: options.c:180
void options_set_passed(struct option *o)
Definition: options.c:120
option_type
Definition: options.h:43
int get_double(double *p, const char *s)
Definition: options.c:58
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
struct option * options_next_empty(struct option *ops)
char * strdup_(const char *s)
Definition: options.c:38
struct option * ops
Definition: rb_sm.c:31
int options_requires_argument(struct option *o)
Definition: options.c:126
struct option_alternative alt[4]
Definition: test_options.c:13
Definition: options.h:49
const char * label
Definition: options.h:81
struct option * options_allocate(int n)
struct @0 p
const char * name
Definition: options.h:51
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
struct option_alternative * alternative
Definition: options.h:77
void * value_pointer
Definition: options.h:70
void options_print_help(struct option *ops, FILE *where)
Definition: options.c:398
void options_alternative(struct option *, const char *name, struct option_alternative *alt, int *value, const char *desc)
enum option_type type
Definition: options.h:55
void options_banner(const char *message)
Definition: options.c:33
int options_try_pair(struct option *ops, const char *name, const char *value)
Definition: options.c:228
int options_set(struct option *op, const char *value)
Definition: options.c:242
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
int options_parse_stream(struct option *ops, const char *pwd, FILE *file)
Definition: options.c:131
int options_parse_args(struct option *ops, int argc, const char *argv[])
Definition: options.c:66
const char * desc
Definition: options.h:52
int options_valid(struct option *op)
Definition: options.c:238
struct option * options_find(struct option *ops, const char *name)
Definition: options.c:219
void options_dump(struct option *options, FILE *f, int write_desc)
Definition: options.c:332


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23