Skip to content

Commit

Permalink
Promote the BRSRES::print_config() method.
Browse files Browse the repository at this point in the history
Lets make BRSRES::print_config() a generic method that is in the shared
library and can be used by each daemon for printing the generic types
support by libbareoscfg and allow specific printing via an additional
callback that is initialized on init of the CONFIG class.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 0519a4b commit e603344
Show file tree
Hide file tree
Showing 21 changed files with 849 additions and 706 deletions.
14 changes: 7 additions & 7 deletions src/console/console.c
Expand Up @@ -47,7 +47,8 @@
#endif

/* Exported variables */
CONRES *me = NULL; /* my resource */
CONRES *me = NULL; /* Our Global resource */
CONFIG *my_config = NULL; /* Our Global config */

//extern int rl_catch_signals;

Expand Down Expand Up @@ -82,7 +83,6 @@ static int numdir;
static POOLMEM *args;
static char *argk[MAX_CMD_ARGS];
static char *argv[MAX_CMD_ARGS];
static CONFIG *config;
static bool file_selection = false;

/* Command prototypes */
Expand Down Expand Up @@ -1181,8 +1181,8 @@ int main(int argc, char *argv[])
configfile = bstrdup(CONFIG_FILE);
}

config = new_config_parser();
parse_cons_config(config, configfile, M_ERROR_TERM);
my_config = new_config_parser();
parse_cons_config(my_config, configfile, M_ERROR_TERM);

if (init_crypto() != 0) {
Emsg0(M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n"));
Expand Down Expand Up @@ -1399,9 +1399,9 @@ static void terminate_console(int sig)
}
already_here = true;
stop_watchdog();
config->free_resources();
free(config);
config = NULL;
my_config->free_resources();
free(my_config);
my_config = NULL;
cleanup_crypto();
free_pool_memory(args);
if (!no_conio) {
Expand Down
16 changes: 13 additions & 3 deletions src/console/console_conf.c
Expand Up @@ -321,8 +321,18 @@ void save_resource(int type, RES_ITEM *items, int pass)

bool parse_cons_config(CONFIG *config, const char *configfile, int exit_code)
{
config->init(configfile, NULL, NULL, NULL, NULL, exit_code,
(void *)&res_all, res_all_size, r_first,
r_last, resources, res_head);
config->init(configfile,
NULL,
NULL,
NULL,
NULL,
NULL,
exit_code,
(void *)&res_all,
res_all_size,
r_first,
r_last,
resources,
res_head);
return config->parse_config();
}

0 comments on commit e603344

Please sign in to comment.