openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/src/groupadd.c
static void process_flags(int argc, char** argv)
{
    /*
     * Parse the command line options.
     */
    char* cp;
    int c;
    static struct option long_options[] = {
        {"force", no_argument, NULL, 'f'},
        {"gid", required_argument, NULL, 'g'},
        {"help", no_argument, NULL, 'h'},
        {"key", required_argument, NULL, 'K'},
        {"non-unique", no_argument, NULL, 'o'},
        {"password", required_argument, NULL, 'p'},
        {"system", no_argument, NULL, 'r'},
        {"root", required_argument, NULL, 'R'},
        {"prefix", required_argument, NULL, 'P'},
        {NULL, 0, NULL, '\0'}};

    while ((c = getopt_long(argc, argv, "fg:hK:op:rR:P:", long_options,
                            NULL)) != -1)
    {
        switch (c)
        {
            case 'f':
                /*
                 * "force" - do nothing, just exit(0), if the
                 * specified group already exists. With -g, if
                 * specified gid already exists, choose another
                 * (unique) gid (turn off -g). Based on the RedHat's
                 * patch from shadow-utils-970616-9.
                 */
                fflg = true;
                break;
            case 'g':
                gflg = true;
                if ((get_gid(optarg, &group_id) == 0) ||
                    (group_id == (gid_t)-1))
                {
                    fprintf(stderr, _("%s: invalid group ID '%s'\n"), Prog,
                            optarg);
                    exit(E_BAD_ARG);
                }
                break;
            case 'h':
                usage(E_SUCCESS);
                /*@notreached@*/ break;
            case 'K':
                /*
                 * override login.defs defaults (-K name=value)
                 * example: -K GID_MIN=100 -K GID_MAX=499
                 * note: -K GID_MIN=10,GID_MAX=499 doesn't work yet
                 */
                cp = strchr(optarg, '=');
                if (NULL == cp)
                {
                    fprintf(stderr, _("%s: -K requires KEY=VALUE\n"), Prog);
                    exit(E_BAD_ARG);
                }
                /* terminate name, point to value */
                *cp++ = '\0';
                if (putdef_str(optarg, cp) < 0)
                {
                    exit(E_BAD_ARG);
                }
                break;
            case 'o':
                oflg = true;
                break;
            case 'p':
                pflg = true;
                group_passwd = optarg;
                break;
            case 'r':
                rflg = true;
                break;
            case 'R': /* no-op, handled in process_root_flag () */
                break;
            case 'P': /* no-op, handled in process_prefix_flag () */
                break;
            default:
                usage(E_USAGE);
        }
    }

    /*
     * Check the flags consistency
     */
    if (optind != argc - 1)
    {
        usage(E_USAGE);
    }
    group_name = argv[optind];

    check_flags();
}
/*
 * process_flags - parse the command line options
 *
 *	It will not return if an error is encountered.
 */
parse the command line options
It will not return if an error is encountered.
parse the command line options It will not return if an error is encountered .
static void process_flags(int argc, char** argv)
{
    char* cp;
    int c;
    static struct option long_options[] = {
        {"force", no_argument, NULL, 'f'},
        {"gid", required_argument, NULL, 'g'},
        {"help", no_argument, NULL, 'h'},
        {"key", required_argument, NULL, 'K'},
        {"non-unique", no_argument, NULL, 'o'},
        {"password", required_argument, NULL, 'p'},
        {"system", no_argument, NULL, 'r'},
        {"root", required_argument, NULL, 'R'},
        {"prefix", required_argument, NULL, 'P'},
        {NULL, 0, NULL, '\0'}};
    while ((c = getopt_long(argc, argv, "fg:hK:op:rR:P:", long_options,
                            NULL)) != -1)
    {
        switch (c)
        {
            case 'f':
                fflg = true;
                break;
            case 'g':
                gflg = true;
                if ((get_gid(optarg, &group_id) == 0) ||
                    (group_id == (gid_t)-1))
                {
                    fprintf(stderr, _("%s: invalid group ID '%s'\n"), Prog,
                            optarg);
                    exit(E_BAD_ARG);
                }
                break;
            case 'h':
                usage(E_SUCCESS);
                 break;
            case 'K':
                cp = strchr(optarg, '=');
                if (NULL == cp)
                {
                    fprintf(stderr, _("%s: -K requires KEY=VALUE\n"), Prog);
                    exit(E_BAD_ARG);
                }
                *cp++ = '\0';
                if (putdef_str(optarg, cp) < 0)
                {
                    exit(E_BAD_ARG);
                }
                break;
            case 'o':
                oflg = true;
                break;
            case 'p':
                pflg = true;
                group_passwd = optarg;
                break;
            case 'r':
                rflg = true;
                break;
            case 'R': 
                break;
            case 'P': 
                break;
            default:
                usage(E_USAGE);
        }
    }
    if (optind != argc - 1)
    {
        usage(E_USAGE);
    }
    group_name = argv[optind];
    check_flags();
}
static void process_flags ( int argc , char * * argv ) { char * cp ; int c ; static struct option long_options [ ] = { { " " , no_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { NULL , 0 , NULL , ' \0 ' } } ; while ( ( c = getopt_long ( argc , argv , " " , long_options , NULL ) ) != -1 ) { switch ( c ) { case ' ' : fflg = true ; break ; case ' ' : gflg = true ; if ( ( get_gid ( optarg , & group_id ) == 0 ) || ( group_id == ( gid_t ) - 1 ) ) { fprintf ( stderr , _ ( " \n " ) , Prog , optarg ) ; exit ( E_BAD_ARG ) ; } break ; case ' ' : usage ( E_SUCCESS ) ; break ; case ' ' : cp = strchr ( optarg , ' ' ) ; if ( NULL == cp ) { fprintf ( stderr , _ ( " \n " ) , Prog ) ; exit ( E_BAD_ARG ) ; } * cp ++ = ' \0 ' ; if ( putdef_str ( optarg , cp ) < 0 ) { exit ( E_BAD_ARG ) ; } break ; case ' ' : oflg = true ; break ; case ' ' : pflg = true ; group_passwd = optarg ; break ; case ' ' : rflg = true ; break ; case ' ' : break ; case ' ' : break ; default : usage ( E_USAGE ) ; } } if ( optind != argc - 1 ) { usage ( E_USAGE ) ; } group_name = argv [ optind ] ; check_flags ( ) ; }
process_flags - parse the command line options
      It will not return if an error is encountered.
process_flags - parse the command line options It will not return if an error is encountered .
/*
     * Parse the command line options.
     */ /*
                 * "force" - do nothing, just exit(0), if the
                 * specified group already exists. With -g, if
                 * specified gid already exists, choose another
                 * (unique) gid (turn off -g). Based on the RedHat's
                 * patch from shadow-utils-970616-9.
                 */ /*@notreached@*/ /*
                 * override login.defs defaults (-K name=value)
                 * example: -K GID_MIN=100 -K GID_MAX=499
                 * note: -K GID_MIN=10,GID_MAX=499 doesn't work yet
                 */ /* terminate name, point to value */ /* no-op, handled in process_root_flag () */ /* no-op, handled in process_prefix_flag () */ /*
     * Check the flags consistency
     */