Пример #1
0
void read_params(int argc, char **argv, struct config_t *p_config)
{
    char *arg;
    int ret;

    /* set default parameters */
    p_config->conffile[0] = 0;
    p_config->print[0] = 0;
    p_config->xmloutput = 0;
    p_config->sortoutput = 0;
    p_config->chain = 0;
    p_config->infile = 0;
    p_config->outfile = stdout;
    p_config->org_output = 0;

    /* set up command line parameters */

    while ((ret = options("c:op:sx", argv, argc, &arg)) != -2)
    {
        switch (ret)
        {
        case 'c':
            strcpy(p_config->conffile, arg);
            break;
        case 'p':
            strcpy(p_config->print, arg);
            break;
        case 's':
            p_config->sortoutput = 1;
            break;
        case 'x':
            p_config->xmloutput = 1;
            break;
        case 'o':
            p_config->org_output = 1;
            break;
        case 0:
            if (p_config->infile)
            {
                fprintf(stderr, "yaz-icu: only one input file may be given\n");
                print_option_error(p_config);
            }
            p_config->infile = fopen(arg, "r");
            if (!p_config->infile)
            {
                fprintf(stderr, "yaz-icu: cannot open %s : %s\n",
                        arg, strerror(errno));
                exit(1);
            }
            break;
        default:
            fprintf(stderr, "yaz_icu: invalid option: %s\n", arg);
            print_option_error(p_config);
        }
    }

    if (p_config->infile == 0)
        p_config->infile = stdin;

    if (!strlen(p_config->conffile) && !strlen(p_config->print))
        print_option_error(p_config);
}
Пример #2
0
void read_params(int argc, char **argv, struct parameters_t *p_parameters){
    char *arg;
    int ret;
    while ((ret = options("h:q:c:t:p:bgn:", argv, argc, &arg)) != -2)
    {
        switch (ret)
        {
        case 'h':
            strcpy(p_parameters->host, arg);
            break;
        case 'q':
            strcpy(p_parameters->query, arg);
            break;
        case 'p':
            strcpy(p_parameters->proxy, arg);
            break;
        case 'c':
            p_parameters->concurrent = atoi(arg);
            break;
#if 0
            case 't':
            p_parameters->timeout = atoi(arg);
            break;
#endif
        case 'b':
            p_parameters->piggypack = 1;
                    break;
        case 'g':
            p_parameters->gnuplot = 1;
                    break;
        case 'n':
            p_parameters->repeat = atoi(arg);
                    break;
        case 0:
            print_option_error();
            break;
        default:
            print_option_error();
        }
    }

    if(0){
        printf("zoom-benchmark\n");
        printf("   host:       %s \n", p_parameters->host);
        printf("   query:      %s \n", p_parameters->query);
        printf("   concurrent: %d \n", p_parameters->concurrent);
        printf("   repeat:     %d \n", p_parameters->repeat);
#if 0
        printf("   timeout:    %d \n", p_parameters->timeout);
#endif
        printf("   proxy:      %s \n", p_parameters->proxy);
        printf("   piggypack:  %d \n\n", p_parameters->piggypack);
        printf("   gnuplot:    %d \n\n", p_parameters->gnuplot);
    }

    if (! strlen(p_parameters->host))
        print_option_error();
    if (! strlen(p_parameters->query))
        print_option_error();
    if (! (p_parameters->concurrent > 0))
        print_option_error();
    if (! (p_parameters->repeat > 0))
        print_option_error();
    if (! (p_parameters->timeout >= 0))
        print_option_error();
    if (! ( p_parameters->concurrent <= 4096))
        print_option_error();
}