Skip to content

Commit

Permalink
configparser: switched traymonitor to new class initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed May 15, 2018
1 parent 66d57be commit 0b94df5
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 56 deletions.
5 changes: 1 addition & 4 deletions core/src/console/console.cc
Expand Up @@ -51,13 +51,10 @@

/* Exported variables */
ConsoleResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = NULL; /* Our Global config */
ConfigurationParser *my_config = nullptr; /* Our Global config */

//extern int rl_catch_signals;

/* Imported functions */
extern bool ParseConsConfig(ConfigurationParser *config, const char *configfile, int exit_code);

/* Forward referenced functions */
static void TerminateConsole(int sig);
static int check_resources();
Expand Down
10 changes: 5 additions & 5 deletions core/src/console/console_conf.cc
Expand Up @@ -358,11 +358,11 @@ ConfigurationParser *InitConsConfig(const char *configfile, int exit_code)
{
return new ConfigurationParser (
configfile,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
exit_code,
(void *)&res_all,
res_all_size,
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/dbcheck.cc
Expand Up @@ -68,7 +68,7 @@ static const char *backend_directory = _PATH_BAREOS_BACKENDDIR;
#endif

DirectorResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = NULL; /* Our Global config */
ConfigurationParser *my_config = nullptr; /* Our Global config */

#define MAX_ID_LIST_LEN 10000000

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/dird.cc
Expand Up @@ -90,7 +90,7 @@ static alist *reload_table = NULL;

/* Globals Exported */
DirectorResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = NULL; /* Our Global config */
ConfigurationParser *my_config = nullptr; /* Our Global config */
char *configfile = NULL;
void *start_heap;

Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/dird_conf.cc
Expand Up @@ -4399,8 +4399,8 @@ ConfigurationParser *InitDirConfig(const char *configfile, int exit_code)
{
return new ConfigurationParser (
configfile,
NULL,
NULL,
nullptr,
nullptr,
InitResourceCb,
ParseConfigCb,
PrintConfigCb,
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/testfind.cc
Expand Up @@ -50,7 +50,7 @@ static int trunc_path = 0;
static int attrs = 0;

DirectorResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = NULL; /* Our Global config */
ConfigurationParser *my_config = nullptr; /* Our Global config */

static JobControlRecord *jcr;

Expand Down
3 changes: 1 addition & 2 deletions core/src/filed/filed.cc
Expand Up @@ -38,15 +38,14 @@

/* Imported Functions */
extern void *handle_connection_request(void *dir_sock);
extern bool ParseFdConfig(const char *configfile, int exit_code);
extern void prtmsg(void *sock, const char *fmt, ...);

/* Forward referenced functions */
static bool check_resources();

/* Exported variables */
ClientResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = NULL; /* Our Global config */
ConfigurationParser *my_config = nullptr; /* Our Global config */

bool no_signals = false;
bool backup_only_mode = false;
Expand Down
11 changes: 3 additions & 8 deletions core/src/filed/filed_conf.cc
Expand Up @@ -607,11 +607,11 @@ ConfigurationParser *InitFdConfig(const char *configfile, int exit_code)
{
return new ConfigurationParser (
configfile,
NULL,
NULL,
nullptr,
nullptr,
InitResourceCb,
ParseConfigCb,
NULL,
nullptr,
exit_code,
(void *)&res_all,
res_all_size,
Expand All @@ -623,11 +623,6 @@ ConfigurationParser *InitFdConfig(const char *configfile, int exit_code)
"bareos-fd.d");
}

bool ParseFdConfig(ConfigurationParser *config, const char *configfile, int exit_code)
{
return config->ParseConfig();
}

/**
* Print configuration file schema in json format
*/
Expand Down
6 changes: 2 additions & 4 deletions core/src/lib/parse_conf.h
Expand Up @@ -474,8 +474,8 @@ class DLL_IMP_EXP ConfigurationParser {
const char *resourcetype, const char *name,
bool error_if_exits = false, bool create_directories = false);
private:
ConfigurationParser(const ConfigurationParser&) {};
ConfigurationParser operator=(const ConfigurationParser&) {};
ConfigurationParser(const ConfigurationParser&) = delete;
ConfigurationParser operator=(const ConfigurationParser&) = delete;

protected:
const char *config_default_filename_; /* default config filename, that is used, if no filename is given */
Expand All @@ -493,8 +493,6 @@ class DLL_IMP_EXP ConfigurationParser {
int GetResourceTableIndex(int resource_type);
};

ConfigurationParser *new_config_parser();

DLL_IMP_EXP void prtmsg(void *sock, const char *fmt, ...);

/*
Expand Down
13 changes: 5 additions & 8 deletions core/src/qt-tray-monitor/tray-monitor.cc
Expand Up @@ -34,10 +34,7 @@
#include "monitoritemthread.h"
#include "lib/bsignal.h"

ConfigurationParser *my_config = NULL; /* Our Global config */

/* Imported function from tray_conf.cpp */
extern bool ParseTmonConfig(ConfigurationParser *config, const char *configfile, int exit_code);
ConfigurationParser *my_config = nullptr; /* Our Global config */

/* Static variables */
static QApplication* app = NULL;
Expand Down Expand Up @@ -196,17 +193,17 @@ int main(int argc, char *argv[])
if (cl.export_config_schema) {
PoolMem buffer;

my_config = new_config_parser();
InitTmonConfig(my_config, cl.configfile, M_ERROR_TERM);
my_config = InitTmonConfig(cl.configfile, M_ERROR_TERM);
my_config->ParseConfig();
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());
fflush(stdout);
exit(0);
}

// read the config file
my_config = new_config_parser();
ParseTmonConfig(my_config, cl.configfile, M_ERROR_TERM);
my_config = InitTmonConfig(cl.configfile, M_ERROR_TERM);
my_config->ParseConfig();

if (cl.export_config) {
my_config->DumpResources(prtmsg, NULL);
Expand Down
27 changes: 11 additions & 16 deletions core/src/qt-tray-monitor/tray_conf.cc
Expand Up @@ -372,29 +372,24 @@ bool SaveResource(int type, ResourceItem *items, int pass)
return (error == 0);
}

void InitTmonConfig(ConfigurationParser *config, const char *configfile, int exit_code)
ConfigurationParser *InitTmonConfig(const char *configfile, int exit_code)
{
config->init(configfile,
NULL,
NULL,
NULL,
NULL,
NULL,
return new ConfigurationParser(
configfile,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
exit_code,
(void *)&res_all,
res_all_size,
R_FIRST,
R_LAST,
resources,
res_head);
config->SetDefaultConfigFilename(CONFIG_FILE);
config->SetConfigIncludeDir("tray-monitor.d");
}

bool ParseTmonConfig(ConfigurationParser *config, const char *configfile, int exit_code)
{
InitTmonConfig(config, configfile, exit_code);
return config->ParseConfig();
res_head,
CONFIG_FILE,
"tray-monitor.d");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion core/src/qt-tray-monitor/tray_conf.h
Expand Up @@ -137,7 +137,7 @@ union UnionOfResources {
~UnionOfResources() {}
};

void InitTmonConfig(ConfigurationParser *config, const char *configfile, int exit_code);
ConfigurationParser *InitTmonConfig(const char *configfile, int exit_code);
bool PrintConfigSchemaJson(PoolMem &buffer);

#endif /* TRAY_CONF_H_INCLUDED */
6 changes: 3 additions & 3 deletions core/src/stored/stored_conf.cc
Expand Up @@ -911,11 +911,11 @@ ConfigurationParser *InitSdConfig(const char *configfile, int exit_code)
{
return new ConfigurationParser(
configfile,
NULL,
NULL,
nullptr,
nullptr,
InitResourceCb,
ParseConfigCb,
NULL,
nullptr,
exit_code,
(void *)&res_all,
res_all_size,
Expand Down

0 comments on commit 0b94df5

Please sign in to comment.