Skip to content

Commit

Permalink
config: added global and static methods from res.cc to ConfigurationP…
Browse files Browse the repository at this point in the history
…arser

- methods now working on the respective object instead of one global object
  (that was at this point my_config)
- left methods from BareosResource untouched
  • Loading branch information
franku committed Aug 31, 2018
1 parent b53d741 commit 2e82d69
Show file tree
Hide file tree
Showing 8 changed files with 2,309 additions and 2,224 deletions.
4 changes: 2 additions & 2 deletions core/src/console/console_conf.cc
Expand Up @@ -141,7 +141,7 @@ void DumpResource(int type, CommonResourceHeader *reshdr,
bool recurse = true;

if (res == NULL) {
sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), res_to_str(type), type);
sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), my_config->res_to_str(type), type);
return;
}
if (type < 0) { /* no recursion */
Expand Down Expand Up @@ -364,7 +364,7 @@ bool SaveResource(int type, ResourceItem *items, int pass)
}
}
last->next = (CommonResourceHeader *)res;
Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.name());
Dmsg2(90, "Inserting %s res: %s\n", my_config->res_to_str(type), res->res_dir.name());
}
}
return (error == 0);
Expand Down
32 changes: 16 additions & 16 deletions core/src/dird/dird_conf.cc
Expand Up @@ -1313,7 +1313,7 @@ bool ValidateResource(int res_type, ResourceItem *items, BareosResource *res)
if (!BitIsSet(i, res->hdr.item_present)) {
Jmsg(NULL, M_ERROR, 0,
_("\"%s\" directive in %s \"%s\" resource is required, but not found.\n"),
items[i].name, res_to_str(res_type), res->name());
items[i].name, my_config->res_to_str(res_type), res->name());
return false;
}
}
Expand All @@ -1322,7 +1322,7 @@ bool ValidateResource(int res_type, ResourceItem *items, BareosResource *res)
* If this triggers, take a look at lib/parse_conf.h
*/
if (i >= MAX_RES_ITEMS) {
Emsg1(M_ERROR, 0, _("Too many items in %s resource\n"), res_to_str(res_type));
Emsg1(M_ERROR, 0, _("Too many items in %s resource\n"), my_config->res_to_str(res_type));
return false;
}
}
Expand Down Expand Up @@ -2763,7 +2763,7 @@ static void StoreDevice(LEX *lc, ResourceItem *item, int index, int pass)
res->res_dev.hdr.name = bstrdup(lc->str);
res_head[rindex] = (CommonResourceHeader *)res; /* store first entry */
Dmsg3(900, "Inserting first %s res: %s index=%d\n",
res_to_str(R_DEVICE), res->res_dir.name(), rindex);
my_config->res_to_str(R_DEVICE), res->res_dir.name(), rindex);
} else {
CommonResourceHeader *next;
/*
Expand All @@ -2781,15 +2781,15 @@ static void StoreDevice(LEX *lc, ResourceItem *item, int index, int pass)
res->res_dev.hdr.name = bstrdup(lc->str);
next->next = (CommonResourceHeader *)res;
Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n",
res_to_str(R_DEVICE), res->res_dir.name(), rindex, pass);
my_config->res_to_str(R_DEVICE), res->res_dir.name(), rindex, pass);
}
}

ScanToEol(lc);
SetBit(index, res_all.hdr.item_present);
ClearBit(index, res_all.hdr.inherit_content);
} else {
StoreResource(CFG_TYPE_ALIST_RES, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_ALIST_RES, lc, item, index, pass);
}
}

Expand Down Expand Up @@ -2999,10 +2999,10 @@ static void StoreAutopassword(LEX *lc, ResourceItem *item, int index, int pass)
*/
switch (item->code) {
case 1:
StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
break;
default:
StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
break;
}
break;
Expand All @@ -3011,10 +3011,10 @@ static void StoreAutopassword(LEX *lc, ResourceItem *item, int index, int pass)
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
break;
default:
StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
break;
}
break;
Expand All @@ -3023,18 +3023,18 @@ static void StoreAutopassword(LEX *lc, ResourceItem *item, int index, int pass)
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
break;
default:
StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
break;
}
break;
case R_CATALOG:
StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_CLEARPASSWORD, lc, item, index, pass);
break;
default:
StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
my_config->StoreResource(CFG_TYPE_MD5PASSWORD, lc, item, index, pass);
break;
}
}
Expand Down Expand Up @@ -3854,7 +3854,7 @@ void DumpResource(int type, CommonResourceHeader *ures,
UaContext *ua = (UaContext *)sock;

if (!res) {
sendit(sock, _("No %s resource defined\n"), res_to_str(type));
sendit(sock, _("No %s resource defined\n"), my_config->res_to_str(type));
return;
}

Expand Down Expand Up @@ -4434,7 +4434,7 @@ bool SaveResource(int type, ResourceItem *items, int pass)
memcpy(res, &res_all, resources[rindex].size);
if (!res_head[rindex]) {
res_head[rindex] = (CommonResourceHeader *)res; /* store first entry */
Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
Dmsg3(900, "Inserting first %s res: %s index=%d\n", my_config->res_to_str(type),
res->res_dir.name(), rindex);
} else {
CommonResourceHeader *next, *last;
Expand All @@ -4456,7 +4456,7 @@ bool SaveResource(int type, ResourceItem *items, int pass)
}
}
last->next = (CommonResourceHeader *)res;
Dmsg4(900, _("Inserting %s res: %s index=%d pass=%d\n"), res_to_str(type),
Dmsg4(900, _("Inserting %s res: %s index=%d pass=%d\n"), my_config->res_to_str(type),
res->res_dir.name(), rindex, pass);
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions core/src/filed/filed_conf.cc
Expand Up @@ -353,7 +353,7 @@ void DumpResource(int type, CommonResourceHeader *reshdr,
int recurse = 1;

if (res == NULL) {
sendit(sock, "No record for %d %s\n", type, res_to_str(type));
sendit(sock, "No record for %d %s\n", type, my_config->res_to_str(type));
return;
}

Expand Down Expand Up @@ -688,7 +688,7 @@ bool SaveResource(int type, ResourceItem *items, int pass)
}
}
last->next = (CommonResourceHeader *)res;
Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
Dmsg2(90, "Inserting %s res: %s\n", my_config->res_to_str(type),
res->res_dir.name());
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/include/baconfig.h
Expand Up @@ -331,8 +331,8 @@ do { int errstat; if ((errstat=RwlWriteunlock(&(x)))) \
strerror(errstat)); \
} while(0)

#define LockRes() b_LockRes(__FILE__, __LINE__)
#define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
#define LockRes() my_config->b_LockRes(__FILE__, __LINE__)
#define UnlockRes() my_config->b_UnlockRes(__FILE__, __LINE__)

#ifdef DEBUG_MEMSET
#define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
Expand Down

0 comments on commit 2e82d69

Please sign in to comment.