OFP  1.0
Option and Flag Parser
ofp.h
Go to the documentation of this file.
1 
9 #ifndef OFP_H
10 #define OFP_H
11 
12 
13 /* C headers */
14 #include <setjmp.h>
15 
16 
17 #ifdef __cplusplus
18  #define OFP_ENUMTYPE : int
19 #else
20  #define OFP_ENUMTYPE
21 #endif
22 
23 
24 /*
25 *
26 * Macros
27 *
28 */
29 
30 
35 #define ofp_on_ferror(S) if(setjmp((S)->ferrbuf))
36 
37 
42 #define ofp_any_error(S) ((S)->errtop > 0)
43 
44 #ifndef OFP_API
48  #define OFP_API __declspec(dllexport)
49 #endif /* OFP_API */
50 
51 
52 #ifndef OFP_PREFIX_DEFAULT
57  #define OFP_PREFIX_DEFAULT '/'
58 #endif /* OFP_PREFIX_DEFULT */
59 
60 
61 /*
62 *
63 * Typedefs
64 *
65 */
66 
67 
68 typedef unsigned int ofp_uint;
69 
70 #ifdef __cplusplus
71  enum ofp_argument_type_e OFP_ENUMTYPE;
72  enum ofp_argument_priority_e OFP_ENUMTYPE;
73  enum ofp_errorcode_e OFP_ENUMTYPE;
74 #endif
75 
76 /* enum typedefs */
77 typedef enum ofp_argument_type_e ofp_argument_type;
78 typedef enum ofp_argument_priority_e ofp_argument_priority;
79 typedef enum ofp_errorcode_e ofp_errorcode;
80 
81 /* struct typedefs */
82 typedef struct ofp_argument_s ofp_argument;
83 typedef struct ofp_error_s ofp_error;
84 typedef struct ofp_state_s ofp_state;
85 
89 typedef void (*ofp_Cfunction) (ofp_argument *arg, ofp_errorcode ec);
90 
91 
92 /*******************************************************************************************************************************************************
93 * *
94 * Function declarations *
95 * *
96 ********************************************************************************************************************************************************/
97 
98 
99 /*
100 *
101 * State
102 *
103 */
104 
105 OFP_API ofp_state* ofp_state_new (char **argv, int argc, ofp_argument_priority prty, ofp_uint maxuda);
106 OFP_API void ofp_state_free (ofp_state *S);
107 
108  /* error */
109 OFP_API void ofp_state_error_throw (ofp_state *S, ofp_errorcode ec);
110 
111 
112 /*
113 *
114 * Argument
115 *
116 */
117 
118 OFP_API ofp_argument* ofp_argument_register (ofp_state *S, ofp_argument_type t, ofp_argument_priority prty, int r, ofp_Cfunction ef, char *id, ofp_uint len, char *desc);
119 
120  /* error */
121 OFP_API void ofp_argument_error_push (ofp_state *S, ofp_argument *arg, ofp_errorcode ec);
122 
123 
124 /*
125 *
126 * Option
127 *
128 */
129 
130 
131 OFP_API int ofp_option_enumval (ofp_argument *arg, ofp_uint count, ...);
132 
133 
134 /*
135 *
136 * Parser
137 *
138 */
139 
140 OFP_API void ofp_parser_parse (ofp_state *S);
141 
142 
143 /*
144 *
145 * Memory
146 *
147 */
148 
149 
150 OFP_API void* ofp_memory_allocate (ofp_state *S, ofp_uint size);
151 
152  /* array */
153 OFP_API void ofp_memory_array_admissible (ofp_state *S, ofp_uint top, ofp_uint limit, ofp_errorcode ferr);
154 
155 
156 #endif /* OFP_H */
OFP_API void ofp_state_free(ofp_state *S)
Definition: state.c:85
OFP_API void ofp_memory_array_admissible(ofp_state *S, ofp_uint top, ofp_uint limit, ofp_errorcode ferr)
Definition: mem.c:61
OFP_API void ofp_argument_error_push(ofp_state *S, ofp_argument *arg, ofp_errorcode ec)
Definition: argument.c:77
OFP_API int ofp_option_enumval(ofp_argument *arg, ofp_uint count,...)
Definition: option.c:42
void(* ofp_Cfunction)(ofp_argument *arg, ofp_errorcode ec)
Pointer to C function used for argument error handling.
Definition: ofp.h:89
OFP_API void * ofp_memory_allocate(ofp_state *S, ofp_uint size)
Definition: mem.c:34
OFP_API void ofp_state_error_throw(ofp_state *S, ofp_errorcode ec)
Definition: state.c:108
OFP_API ofp_state * ofp_state_new(char **argv, int argc, ofp_argument_priority prty, ofp_uint maxuda)
Definition: state.c:34
OFP_API void ofp_parser_parse(ofp_state *S)
Definition: parser.c:93
OFP_API ofp_argument * ofp_argument_register(ofp_state *S, ofp_argument_type t, ofp_argument_priority prty, int r, ofp_Cfunction ef, char *id, ofp_uint len, char *desc)
Definition: argument.c:31
#define OFP_API
API's visibility and/or linkage.
Definition: ofp.h:48
Definition: argument.h:34
Definition: error.h:40
Definition: state.h:23
ofp_uint maxuda
maximum UDA count
Definition: state.h:25
ofp_errorcode ferr
fatal error code
Definition: state.h:45
int argc
UIA count.
Definition: state.h:28
ofp_argument_priority prty
parsing priority
Definition: state.h:26
char ** argv
UIA values.
Definition: state.h:29