int
parse_config_file(char *file_name)
{
	FILE *fp;
	char line[MAX_PATH];
	char *ptr;
	int end;

	fp = fopen(file_name, "r");
	if (fp == NULL) {
		err_msg("Failed to open config file\n");
		return -1;
	}

	while (fgets(line, MAX_PATH, fp) != NULL) {
		if (instance > MAX_NUM_INSTANCE) {
			err_msg("No more instances!!\n");
			break;
		}

		ptr = skip_unwanted(line);
		end = parse_options(ptr, &input_arg[instance].cmd,
					&input_arg[instance].mode);
		if (end == 100) {
			instance++;
		}
	}

	fclose(fp);
	return 0;
}
예제 #2
0
int Iputool::parse_config_file(char *file_name, Iputool::ipu_test_handle_t *test_handle)
{
        FILE *fp;
        char line[128];
        char *ptr;

        fp = fopen(file_name, "r");
        if (fp == NULL) {
                printf("Failed to open config file\n");
                return -1;
        }

        printf("\nGet config from config file %s:\n\n", file_name);

        while (fgets(line, MAX_PATH, fp) != NULL) {
                ptr = skip_unwanted(line);
                parse_options(ptr, test_handle);
        }

        printf("\n");

        fclose(fp);
        return 0;
}