The override mechanism uses a NULL-terminated array of strings, each of which is in the same format as an entry in the parameter file. The type tdrp_override_t is provided, along with a series of functions, to make it easy to create and use the override list.
paramdef boolean { p_descr = "Option to print debugging messages"; } debug;The the paramfile could have the following entry:
debug = FALSE;Suppose a -debug appears on the command line. The following code fragment shows how you could set up and use the override:
/* initialize before parsing the command line */ tdrp_override_t override; TDRP_init_override(&override); /* in the arg parsing code */ char tmp_str[BUFSIZ]; int i; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-debug")) { sprintf(tmp_str, "debug = TRUE;"); TDRP_add_override(&override, tmp_str); } } /* loading the parameters */ char *params_file_path; _tdrp_struct params; if (_tdrp_load_from_args(argc, argv, ¶ms, override.list, ¶ms_file_path)) { fprintf(stderr, "ERROR - Problems with params file '%s'\n", params_file_path); exit(-1); } /* free up the override list */ TDRP_free_override(&override);Each string in the override list is appended as a line to to the lines in the param file. The entry:
debug = FALSE;will still exist in the param file. However, this will be superceded by the line:
debug = TRUE;appended from the override list. Hence the debug value will be set to TRUE.