UserInterface/Do_Mutual_Exlcude_Test [ Functions ]

FUNCTION

Check all the options to see if combinations of options are used that mutually exclude each other, such as --singledoc and --multidoc.

SYNOPSIS

static int Do_Mutual_Exlcude_Test(
    struct RB_Option_Test *cur_option_test )

INPUTS

SOURCE

{
    int                 n = 0;
    unsigned int        parameter_nr = 0;
    int                 result = EXIT_SUCCESS;

    assert( cur_option_test );

    for ( parameter_nr = 0;
          parameter_nr < configuration.options.number; parameter_nr++ )
    {
        struct RB_Option_Name *option_name = cur_option_test->option_group;

        for ( ; option_name; option_name = option_name->next )
        {
            if ( RB_Str_Case_Cmp
                 ( configuration.options.names[parameter_nr],
                   option_name->name ) == 0 )
            {
                ++n;
            }
        }
    }

    /* Only one of the options in the group may be used */
    if ( n > 1 )
    {
        fprintf( stderr, "The options: " );
        for ( parameter_nr = 0;
              parameter_nr < configuration.options.number; parameter_nr++ )
        {
            struct RB_Option_Name *option_name =
                cur_option_test->option_group;
            for ( ; option_name; option_name = option_name->next )
            {
                if ( RB_Str_Case_Cmp
                     ( configuration.options.names[parameter_nr],
                       option_name->name ) == 0 )
                {

                    fprintf( stderr, "%s ",
                             configuration.options.names[parameter_nr] );
                }
            }
        }
        fprintf( stderr, "cannot be used together.\n" );
        result = EXIT_FAILURE;
    }

    return result;
}