}
void firm_init_options(const char *arg_prefix, int argc, const char **argv) {
- /* parse any init files for firm */
- lc_opts_init("firm", firm_opt_get_root(), arg_prefix, argc, argv);
+ /* parse commandline */
+ lc_opt_from_argv(firm_opt_get_root(), arg_prefix, argc, argv, NULL);
}
void init_firm(const firm_parameter_t *param)
return ret;
}
+static int lc_opts_default_error_handler(const char *prefix, const lc_opt_err_info_t *err)
+{
+ fprintf(stderr, "%s: %s; %s\n", prefix, err->msg, err->arg);
+ return 0;
+}
+
int lc_opt_from_argv(const lc_opt_entry_t *root,
const char *opt_prefix,
int argc, const char *argv[],
int i;
int options_set = 0;
+ if (handler == NULL)
+ handler = lc_opts_default_error_handler;
+
for(i = 0; i < argc; ++i) {
options_set |= lc_opt_from_single_arg(root, opt_prefix, argv[i], handler);
}
return env;
}
-static int lc_opts_default_error_handler(const char *prefix, const lc_opt_err_info_t *err)
-{
- fprintf(stderr, "%s: %s; %s\n", prefix, err->msg, err->arg);
- return 0;
-}
-
-void lc_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_prefix, int argc, const char **argv)
+void lc_opt_default_configs(const char *ini_name)
{
FILE *f;
char path[MAX_PATH];
/* Process ini file in user's home. */
f = fopen(path, "rt");
if (f) {
- fprintf(stderr, "Warning: Automatically reading options from '%s'\n", path);
lc_opt_from_file(path, f, lc_opts_default_error_handler);
fclose(f);
}
/* Process ini file in current directory. */
f = fopen(local_ini_file, "rt");
if (f) {
- fprintf(stderr, "Warning: Automatically reading options from '%s'\n", local_ini_file);
lc_opt_from_file(local_ini_file, f, lc_opts_default_error_handler);
fclose(f);
}
-
- /* process arguments from the command line */
- lc_opt_from_argv(root, arg_prefix, argc, argv, lc_opts_default_error_handler);
}
const lc_arg_env_t *lc_opt_get_arg_env(void);
/**
- * Standard procedure for options initialization.
- * @param cmnt_name Base name for the file.
- * @param root The option's root.
- * @param arg_prefix A prefix that is added to each option.
- * @param argc Number of entries in @p argv.
- * @param argv A stadard argument vector.
- *
* This function tries to open a ini file in the user's homedir
* (On win32 this is \Documents and Settings\Application Data)
* which is called .<ini_name>rc (on win32 <ini_name>.ini)
*
* and an ini file in the current directory which is called <ini_name>.ini on
* both systems.
- * Afterwards, the argument vectors are processed.
*/
-void lc_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_prefix, int argc, const char **argv);
+void lc_opt_default_configs(const char *init_name);
#endif