*/
int r_first = R_FIRST;
int r_last = R_LAST;
-pthread_mutex_t res_mutex = PTHREAD_MUTEX_INITIALIZER;
+static RES *sres_head[R_LAST - R_FIRST + 1];
+RES **res_head = sres_head;
+
/* Forward referenced subroutines */
* then move it to allocated memory when the resource
* scan is complete.
*/
+#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN)
+extern "C" { // work around visual compiler mangling variables
+ URES res_all;
+ int res_all_size = sizeof(res_all);
+}
+#else
URES res_all;
int res_all_size = sizeof(res_all);
+#endif
/* Definition of records permitted within each
* resource with the routine to process the record
*/
/* Client or File daemon "Global" resources */
-static struct res_items cli_items[] = {
+static RES_ITEM cli_items[] = {
{"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
{"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
{"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
{"messages", store_res, ITEM(res_client.messages), R_MSGS, 0, 0},
{"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0},
{"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
+ {"maximumnetworkbuffersize", store_pint, ITEM(res_client.max_network_buffer_size), 0, 0, 0},
{NULL, NULL, NULL, 0, 0, 0}
};
/* Directors that can use our services */
-static struct res_items dir_items[] = {
+static RES_ITEM dir_items[] = {
{"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0},
{"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0},
{"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
};
/* Message resource */
-extern struct res_items msgs_items[];
+extern RES_ITEM msgs_items[];
/*
* This is the master resource definition.
* It must have one item for each of the resources.
*/
-struct s_res resources[] = {
- {"director", dir_items, R_DIRECTOR, NULL},
- {"filedaemon", cli_items, R_CLIENT, NULL},
- {"client", cli_items, R_CLIENT, NULL}, /* alias for filedaemon */
- {"messages", msgs_items, R_MSGS, NULL},
- {NULL, NULL, 0, NULL}
+RES_TABLE resources[] = {
+ {"director", dir_items, R_DIRECTOR},
+ {"filedaemon", cli_items, R_CLIENT},
+ {"client", cli_items, R_CLIENT}, /* alias for filedaemon */
+ {"messages", msgs_items, R_MSGS},
+ {NULL, NULL, 0}
};
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
int recurse = 1;
* resource chain is traversed. Mainly we worry about freeing
* allocated strings (names).
*/
-void free_resource(int type)
+void free_resource(RES *sres, int type)
{
- URES *res;
RES *nres;
- int rindex = type - r_first;
-
- res = (URES *)resources[rindex].res_head;
+ URES *res = (URES *)sres;
if (res == NULL) {
return;
if (res) {
free(res);
}
- resources[rindex].res_head = nres;
if (nres) {
- free_resource(type);
+ free_resource(nres, type);
}
}
* the resource. If this is pass 2, we update any resource
* pointers (currently only in the Job resource).
*/
-void save_resource(int type, struct res_items *items, int pass)
+void save_resource(int type, RES_ITEM *items, int pass)
{
URES *res;
int rindex = type - r_first;
if (!error) {
res = (URES *)malloc(size);
memcpy(res, &res_all, size);
- if (!resources[rindex].res_head) {
- resources[rindex].res_head = (RES *)res; /* store first entry */
+ if (!res_head[rindex]) {
+ res_head[rindex] = (RES *)res; /* store first entry */
} else {
RES *next;
/* Add new res to end of chain */
- for (next=resources[rindex].res_head; next->next; next=next->next)
- { }
+ for (next=res_head[rindex]; next->next; next=next->next) {
+ if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
+ Emsg2(M_ERROR_TERM, 0,
+ _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+ resources[rindex].name, res->res_dir.hdr.name);
+ }
+ }
next->next = (RES *)res;
Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
res->res_dir.hdr.name);