Example #1
0
/* parse every config line */
static int
parse_line(char *buff)
{
    char   *token;
    int     i; 

    if ((token = strtok(buff, W_SPACE)) == NULL) {
        /* ignore empty lines */
        (void) 0;

    } else if (token[0] == '#') {
        /* ignore comment lines */
        (void) 0;

    } else if (strstr(token, "mod_")) {
        parse_mod(token);

    } else if (strstr(token, "spec_")) {
        special_mod(token);

    } else if (!strcmp(token, "output_interface")) {
        parse_string(conf.output_interface);

    } else if (!strcmp(token, "output_file_path")) {
        parse_string(conf.output_file_path);

    } else if (!strcmp(token, "output_db_addr")) {
        parse_string(conf.output_db_addr);

    } else if (!strcmp(token, "output_db_mod")) {
        parse_add_string(conf.output_db_mod);

    } else if (!strcmp(token, "output_tcp_mod")) {
        parse_add_string(conf.output_tcp_mod);
    } else if (!strcmp(token, "output_tcp_addr")) {
        for(i = 0; i < MAX_TCP_ADDR_NUM; i++){
            parse_string(conf.output_tcp_addr[i]);
            if(conf.output_tcp_addr[i][0] != 0){
                conf.output_tcp_addr_num++;
            } else {
                break;
            }
        }
    } else if (!strcmp(token, "output_tcp_merge")) {
        parse_string(conf.output_tcp_merge);

    } else if (!strcmp(token, "output_nagios_mod")) {
        parse_add_string(conf.output_nagios_mod);

    } else if (!strcmp(token, "output_stdio_mod")) {
        parse_add_string(conf.output_stdio_mod);

    } else if (!strcmp(token, "debug_level")) {
        set_debug_level();

    } else if (!strcmp(token, "include")) {
        get_include_conf();

    } else if (!strcmp(token, "server_addr")) {
        parse_string(conf.server_addr);

    } else if (!strcmp(token, "server_port")) {
        parse_int(&conf.server_port);

    } else if (!strcmp(token, "cycle_time")) {
        parse_int(&conf.cycle_time);

    } else if (!strcmp(token, "max_day")) {
        parse_int(&conf.print_max_day);

    } else if (!strcmp(token, "send_nsca_cmd")) {
        parse_string(conf.send_nsca_cmd);

    } else if (!strcmp(token, "send_nsca_conf")) {
        parse_string(conf.send_nsca_conf);

    } else if (!strcmp(token, "threshold")) {
        get_threshold();

    } else {
        return 0;
    }
    return 1;
}
Example #2
0
/* parse every config line */
static int
parse_line(char *buff)
{
    char   *token;

    if ((token = strtok(buff, W_SPACE)) == NULL) {
        /* ignore empty lines */
        (void) 0;

    } else if (strstr(token, "mod_")) {
        parse_mod(token);

    } else if (strstr(token, "spec_")) {
        special_mod(token);

    } else if (!strcmp(token, "output_interface")) {
        parse_string(conf.output_interface);

    } else if (!strcmp(token, "output_file_path")) {
        parse_string(conf.output_file_path);

    } else if (!strcmp(token, "output_db_addr")) {
        parse_string(conf.output_db_addr);

    } else if (!strcmp(token, "output_db_mod")) {
        parse_add_string(conf.output_db_mod);

    } else if (!strcmp(token, "output_nagios_mod")) {
        parse_add_string(conf.output_nagios_mod);

    } else if (!strcmp(token, "output_stdio_mod")) {
        parse_add_string(conf.output_stdio_mod);

    } else if (!strcmp(token, "debug_level")) {
        set_debug_level();

    } else if (!strcmp(token, "include")) {
        get_include_conf();

    } else if (!strcmp(token, "server_addr")) {
        parse_string(conf.server_addr);

    } else if (!strcmp(token, "server_port")) {
        parse_int(conf.server_port);

    } else if (!strcmp(token, "cycle_time")) {
        parse_int(conf.cycle_time);

    } else if (!strcmp(token, "send_nsca_cmd")) {
        parse_string(conf.send_nsca_cmd);

    } else if (!strcmp(token, "send_nsca_conf")) {
        parse_string(conf.send_nsca_conf);

    } else if (!strcmp(token, "threshold")) {
        get_threshold();

    } else {
        return 0;
    }
    return 1;
}