UserInterface/General_Find_Parameterized_Option [ Functions ]

FUNCTION

Search for an option of the form

     --a_option_name a_value

SYNOPSIS

static char        *General_Find_Parameterized_Option(
    int n,
    char **options,
    char *optionname )

INPUTS

RESULT

NULL if the option is not found, a pointer to the value otherwise.

NOTES

Results in a Panic if the option is found but no value is specified.

SOURCE

{
    int                 parameter_nr;
    char               *value = NULL;

    for ( parameter_nr = 0; parameter_nr < n; parameter_nr++ )
    {
        if ( !RB_Str_Case_Cmp( options[parameter_nr], optionname ) )
        {
            if ( parameter_nr < n - 1 )
            {
                value = options[parameter_nr + 1];
                if ( ( value[0] == '-' ) && ( value[1] == '-' ) )
                {
                    value = NULL;
                }
            }
            else
            {
                /* to few parameters. */
            }
            if ( !value )
            {
                RB_Panic( "you must be more specific"
                          " with the %s option\n", optionname );
            }
        }
    }
    return value;
}