Lines Matching full:state

33     LSX_PARAM_OUT            lsx_getopt_t * state)          /* State object to initialize */  in lsx_getopt_init()  argument
40 assert(state); in lsx_getopt_init()
41 if (state) in lsx_getopt_init()
49 memset(state, 0, sizeof(*state)); in lsx_getopt_init()
53 state->argc = argc; in lsx_getopt_init()
54 state->argv = argv; in lsx_getopt_init()
55 state->shortopts = in lsx_getopt_init()
59 state->longopts = longopts; in lsx_getopt_init()
60 state->flags = flags; in lsx_getopt_init()
61 state->curpos = NULL; in lsx_getopt_init()
62 state->ind = first; in lsx_getopt_init()
63 state->opt = '?'; in lsx_getopt_init()
64 state->arg = NULL; in lsx_getopt_init()
65 state->lngind = -1; in lsx_getopt_init()
71 LSX_PARAM_INOUT lsx_getopt_t * state) in CheckCurPosEnd() argument
73 if (!state->curpos[0]) in CheckCurPosEnd()
75 state->curpos = NULL; in CheckCurPosEnd()
76 state->ind++; in CheckCurPosEnd()
82 LSX_PARAM_INOUT lsx_getopt_t * state) in lsx_getopt() argument
85 assert(state); in lsx_getopt()
86 if (!state) in lsx_getopt()
88 lsx_fail("lsx_getopt called with state=NULL"); in lsx_getopt()
92 assert(state->argc >= 0); in lsx_getopt()
93 assert(state->argv != NULL); in lsx_getopt()
94 assert(state->shortopts); in lsx_getopt()
95 assert(state->ind >= 0); in lsx_getopt()
96 assert(state->ind <= state->argc + 1); in lsx_getopt()
98 oerr = 0 != (state->flags & lsx_getopt_flag_opterr); in lsx_getopt()
99 state->opt = 0; in lsx_getopt()
100 state->arg = NULL; in lsx_getopt()
101 state->lngind = -1; in lsx_getopt()
103 if (state->argc < 0 || in lsx_getopt()
104 !state->argv || in lsx_getopt()
105 !state->shortopts || in lsx_getopt()
106 state->ind < 0) in lsx_getopt()
109 state->curpos = NULL; in lsx_getopt()
113 state->argc <= state->ind || in lsx_getopt()
114 !state->argv[state->ind] || in lsx_getopt()
115 state->argv[state->ind][0] != '-' || in lsx_getopt()
116 state->argv[state->ind][1] == '\0') in lsx_getopt()
118 state->curpos = NULL; in lsx_getopt()
121 else if (state->argv[state->ind][1] == '-' && state->argv[state->ind][2] == '\0') in lsx_getopt()
123 state->curpos = NULL; in lsx_getopt()
124 state->ind++; in lsx_getopt()
129 char const * current = state->argv[state->ind]; in lsx_getopt()
132 if (state->curpos == NULL || in lsx_getopt()
133 state->curpos <= param || in lsx_getopt()
134 param + strlen(param) <= state->curpos) in lsx_getopt()
136 state->curpos = NULL; in lsx_getopt()
138 if (state->longopts && in lsx_getopt()
139 (param[0] == '-' || (state->flags & lsx_getopt_flag_longonly))) in lsx_getopt()
158 for (pCur = state->longopts; pCur->name; pCur++) in lsx_getopt()
174 state->ind++; in lsx_getopt()
180 state->arg = param + nameLen + 1; in lsx_getopt()
195 state->arg = state->argv[state->ind]; in lsx_getopt()
196 state->ind++; in lsx_getopt()
197 if (state->ind > state->argc) in lsx_getopt()
205 … return state->shortopts[0] == ':' ? ':' : '?'; /* Missing required value. */ in lsx_getopt()
209 state->lngind = pMatch - state->longopts; in lsx_getopt()
226 state->ind++; in lsx_getopt()
234 for (pCur = state->longopts; pCur->name; pCur++) in lsx_getopt()
242 state->ind++; in lsx_getopt()
248 state->curpos = param; in lsx_getopt()
251 state->opt = state->curpos[0]; in lsx_getopt()
252 if (state->opt == ':') in lsx_getopt()
256 lsx_warn("option `%c' not recognized", state->opt); in lsx_getopt()
258 state->curpos++; in lsx_getopt()
259 CheckCurPosEnd(state); in lsx_getopt()
264 char const * pShortopt = strchr(state->shortopts, state->opt); in lsx_getopt()
265 state->curpos++; in lsx_getopt()
271 lsx_warn("option `%c' not recognized", state->opt); in lsx_getopt()
273 CheckCurPosEnd(state); in lsx_getopt()
276 else if (pShortopt[1] == ':' && state->curpos[0]) in lsx_getopt()
278 state->arg = state->curpos; in lsx_getopt()
279 state->curpos = NULL; in lsx_getopt()
280 state->ind++; in lsx_getopt()
281 return state->opt; in lsx_getopt()
285 state->curpos = NULL; in lsx_getopt()
286 state->ind++; in lsx_getopt()
287 state->arg = state->argv[state->ind]; in lsx_getopt()
288 state->ind++; in lsx_getopt()
289 if (state->ind <= state->argc) in lsx_getopt()
291 return state->opt; in lsx_getopt()
298 state->opt); in lsx_getopt()
300 return state->shortopts[0] == ':' ? ':' : '?'; in lsx_getopt()
305 CheckCurPosEnd(state); in lsx_getopt()
306 return state->opt; in lsx_getopt()
331 lsx_getopt_t state; in main() local
332 lsx_getopt_init(argc, argv, "abc:d:v::0123456789", longopts, sox_true, 1, &state); in main()
334 while (-1 != (ch = lsx_getopt(&state))) in main()
340 state.ind, in main()
341 state.opt, in main()
342 state.lngind, in main()
343 state.arg ? state.arg : "NULL"); in main()