Skip to content

Commit

Permalink
print config file schema without valid config file
Browse files Browse the repository at this point in the history
print config file schema even without a valid configuration file.
  • Loading branch information
joergsteffens authored and Marco van Wieringen committed Oct 6, 2014
1 parent 727273b commit 2f2896a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/dird/dird.c
Expand Up @@ -271,6 +271,15 @@ int main (int argc, char *argv[])
drop(uid, gid, false); /* reduce privileges if requested */
}

if (export_config_schema) {
my_config = new_config_parser();
init_dir_config(my_config, configfile, M_ERROR_TERM);
POOL_MEM buffer;
print_config_schema_json(buffer);
printf( "%s\n", buffer.c_str() );
goto bail_out;
}

my_config = new_config_parser();
parse_dir_config(my_config, configfile, M_ERROR_TERM);

Expand All @@ -284,13 +293,6 @@ int main (int argc, char *argv[])
goto bail_out;
}

if (export_config_schema) {
POOL_MEM buffer;
print_config_schema_json(buffer);
printf( "%s\n", buffer.c_str() );
goto bail_out;
}

if (!test_config) { /* we don't need to do this block in test mode */
if (background) {
daemon_start();
Expand Down
8 changes: 7 additions & 1 deletion src/dird/dird_conf.c
Expand Up @@ -3503,7 +3503,7 @@ static void print_config_cb(RES_ITEM *items, int i, POOL_MEM &cfg_str)
}
}

bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code)
void init_dir_config(CONFIG *config, const char *configfile, int exit_code)
{
config->init(configfile,
NULL,
Expand All @@ -3518,5 +3518,11 @@ bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code)
R_LAST,
resources,
res_head);
}

bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code)
{
init_dir_config( config, configfile, exit_code );

return config->parse_config();
}
2 changes: 2 additions & 0 deletions src/dird/dird_conf.h
Expand Up @@ -620,6 +620,8 @@ class RUNRES: public BRSRES {
bool last_set; /* last week of month */
};

void init_dir_config(CONFIG *config, const char *configfile, int exit_code);

#define GetPoolResWithName(x) ((POOLRES *)GetResWithName(R_POOL, (x)))
#define GetStoreResWithName(x) ((STORERES *)GetResWithName(R_STORAGE, (x)))
#define GetClientResWithName(x) ((CLIENTRES *)GetResWithName(R_CLIENT, (x)))
Expand Down

0 comments on commit 2f2896a

Please sign in to comment.