Lines Matching defs:state
52 void ares_getopt_init(ares_getopt_state_t *state, int nargc, const char **nargv)
54 memset(state, 0, sizeof(*state));
55 state->opterr = 1;
56 state->optind = 1;
57 state->place = EMSG;
58 state->argc = nargc;
59 state->argv = nargv;
66 int ares_getopt(ares_getopt_state_t *state, const char *ostr)
71 if (!*state->place) {
72 if (state->optind >= state->argc) {
75 state->place = state->argv[state->optind];
76 if (*(state->place) != '-') {
79 state->place++;
82 if (*(state->place) == '-') {
83 state->optind++;
88 if (!*(state->place)) {
89 state->optopt = 0;
95 state->optopt = *(state->place);
96 state->place++;
97 oli = strchr(ostr, state->optopt);
100 if (!(*state->place)) {
101 ++state->optind;
103 if (state->opterr) {
105 state->optopt);
112 state->optarg = NULL;
113 if (!*state->place) {
114 ++state->optind;
118 if (*state->place) { /* no white space */
119 state->optarg = state->place;
120 } else if (state->argc <= ++state->optind) { /* no arg */
121 state->place = EMSG;
125 if (state->opterr) {
127 __FILE__, state->optopt);
131 state->optarg = state->argv[state->optind];
133 state->place = EMSG;
134 ++state->optind;
136 return state->optopt; /* dump back option letter */