Lines Matching refs:state

450  * Initialize a state block for processing by elfedit_getopt().
453 * state - State block to initialize
465 elfedit_getopt_init(elfedit_getopt_state_t *state,
470 state->go_argc = argc;
471 state->go_argv = argv;
472 state->go_optarg = cmd->cmd_opt;
473 state->go_idmask = 0;
474 state->go_done = 0;
475 state->go_sglgrp = NULL;
484 * state - Getopt state, which must have been previously initialized
490 * for state). If there are no more options to process, NULL is returned.
496 * - The caller should not access the contents of state directly.
502 elfedit_getopt(elfedit_getopt_state_t *state)
506 int argc = *(state->go_argc);
507 const char **argv = *(state->go_argv);
516 if (state->go_sglgrp == NULL) {
524 if ((state->go_optarg == NULL) || state->go_done ||
526 state->go_done = 1;
538 (*state->go_argc)--;
539 (*state->go_argv)++;
548 for (optarg = state->go_optarg; optarg->oa_name != NULL; ) {
585 (*state->go_argc) = --argc;
586 (*state->go_argv) = ++argv;
589 if (item.oai_excmask & state->go_idmask)
593 state->go_idmask |= item.oai_idmask;
594 state->go_ret.gor_idmask = item.oai_idmask;
599 state->go_ret.gor_value = argv[0];
600 (*state->go_argc)--;
601 (*state->go_argv)++;
603 state->go_ret.gor_value = NULL;
607 state->go_ret.gor_value);
608 return (&state->go_ret);
618 (*state->go_argc)--;
619 (*state->go_argv)++;
622 if (sgl_with_value.excmask & state->go_idmask)
625 state->go_idmask |= sgl_with_value.ret.gor_idmask;
626 state->go_ret = sgl_with_value.ret;
629 state->go_ret.gor_value);
631 return (&state->go_ret);
639 state->go_sglgrp = argstr + 1; /* Skip '-' */
647 if (state->go_sglgrp != NULL) {
648 int ch = *state->go_sglgrp++;
651 if (*state->go_sglgrp == '\0') {
652 (*state->go_argc)--;
653 (*state->go_argv)++;
654 state->go_sglgrp = NULL;
657 for (optarg = state->go_optarg; optarg->oa_name != NULL; ) {
670 if (item.oai_excmask & state->go_idmask)
674 state->go_idmask |= item.oai_idmask;
675 state->go_ret.gor_idmask = item.oai_idmask;
676 state->go_ret.gor_value = NULL;
677 return (&state->go_ret);