Lines Matching full:state
50 struct getopt_state *state; in getopt_init() local
52 state = getopt_state_get(); in getopt_init()
54 state->opterr = 1; in getopt_init()
55 state->optind = 1; in getopt_init()
56 state->optopt = 0; in getopt_init()
57 state->optreset = 0; in getopt_init()
58 state->optarg = NULL; in getopt_init()
60 state->place = ""; /* EMSG */ in getopt_init()
63 state->nonopt_start = -1; /* first non option argument (for permute) */ in getopt_init()
64 state->nonopt_end = -1; /* first option after non options (for permute) */ in getopt_init()
80 struct getopt_state *state; in getopt() local
83 /* get getopt state of the current thread */ in getopt()
84 state = getopt_state_get(); in getopt()
86 if (state->optreset || *state->place == 0) { /* update scanning pointer */ in getopt()
87 state->optreset = 0; in getopt()
88 state->place = nargv[state->optind]; in getopt()
89 if (state->optind >= nargc || *state->place++ != '-') { in getopt()
91 state->place = EMSG; in getopt()
92 z_getopt_global_state_update(state); in getopt()
95 state->optopt = *state->place++; in getopt()
96 if (state->optopt == '-' && *state->place == 0) { in getopt()
98 ++state->optind; in getopt()
99 state->place = EMSG; in getopt()
100 z_getopt_global_state_update(state); in getopt()
103 if (state->optopt == 0) { in getopt()
107 state->place = EMSG; in getopt()
109 z_getopt_global_state_update(state); in getopt()
112 state->optopt = '-'; in getopt()
115 state->optopt = *state->place++; in getopt()
119 oli = strchr(ostr, state->optopt); in getopt()
120 if (state->optopt == ':' || oli == NULL) { in getopt()
121 if (*state->place == 0) { in getopt()
122 ++state->optind; in getopt()
124 if (state->opterr && *ostr != ':') { in getopt()
125 LOG_DBG("illegal option -- %c", state->optopt); in getopt()
127 z_getopt_global_state_update(state); in getopt()
134 state->optarg = NULL; in getopt()
135 if (*state->place == 0) { in getopt()
136 ++state->optind; in getopt()
142 if (*state->place) { in getopt()
143 state->optarg = state->place; in getopt()
144 } else if (nargc > ++state->optind) { in getopt()
145 state->optarg = nargv[state->optind]; in getopt()
148 state->place = EMSG; in getopt()
150 z_getopt_global_state_update(state); in getopt()
153 if (state->opterr) { in getopt()
155 state->optopt); in getopt()
157 z_getopt_global_state_update(state); in getopt()
160 state->place = EMSG; in getopt()
161 ++state->optind; in getopt()
163 z_getopt_global_state_update(state); in getopt()
164 return state->optopt; /* return option letter */ in getopt()