// file: get_0.C // #include "./process_data.h" // define the command line options char *options[] = { "-parameter_file", "-output_file", "\0", }; //----------------------------------------------------------------------------- // function: get_option_values_C // // arguments: // char* output_file: (output) output filename // char* input_file: (output) input filename // char* param_file: (output) parameter filename // int argc: (input) number of command line arguments // char** argv: (input) command line arguments // // returns: // L_TRUE if no error was encounterd //----------------------------------------------------------------------------- int get_option_values_C(char* output_file, char* input_file, char* param_file, int argc, char** argv) { // declare local variables // int opt_index = 0; // loop over options, decoding each one // while (*options[opt_index] != NULL) { // loop over command line options // increment counters by 2 (skipping over value) // for (int arg_index=1; arg_index<(argc-(int)1); arg_index+=2) { // check for a partial match // if (strstr(options[opt_index], argv[arg_index]) != NULL) { // assign options - this is bad code! it is too hardcoded! // if (opt_index == (int)0) {strcpy(param_file, argv[arg_index+1]);} else if (opt_index == (int)1) {strcpy(output_file, argv[arg_index+1]);} } } // increment counters // opt_index++; } // assign the input filename (again - bad code!) // strcpy(input_file, argv[argc-(int)1]); // exit gracefully // return L_TRUE; }