hpkt.ritem = &items[item];
if (bit_is_set(item, res_all.hdr.item_present)) {
if (!first_directive) printf(",");
- if (display_global_item(hpkt)) {
+ /* 1: found, 0: not found, -1 found but empty */
+ int ret = display_global_item(hpkt);
+ if (ret == -1) {
+ /* Do not print a comma after this empty directive */
+ first_directive = 0;
+ } else if (ret == 1) {
/* Fall-through wanted */
+
} else {
printf("\n \"%s\": null", items[item].name);
}
}
continue;
}
+ if (first_directive++ > 0) {
+ sendit(NULL, ",");
+ }
- if (first_directive++ > 0) sendit(NULL, ",");
- if (display_global_item(hpkt)) {
+ /* 1: found, 0: not found, -1 found but empty */
+ int ret = display_global_item(hpkt);
+ if (ret == -1) {
+ /* Do not print a comma after this empty directive */
+ first_directive = 0;
+ } else if (ret == 1) {
/* Fall-through wanted */
+
} else if (items[item].handler == store_jobtype) {
display_jobtype(hpkt);
} else if (items[item].handler == store_label) {
hpkt.ritem = &items[item];
if (bit_is_set(item, res_all.hdr.item_present)) {
if (first_directive++ > 0) printf(",");
- if (display_global_item(hpkt)) {
+ /* 1: found, 0: not found, -1 found but empty */
+ int ret = display_global_item(hpkt);
+ if (ret == -1) {
+ /* Do not print a comma after this empty directive */
+ first_directive = 0;
+ } else if (ret == 1) {
/* Fall-through wanted */
+
} else if (items[item].handler == store_cipher_type) {
display_cipher(hpkt);
} else if (items[item].handler == store_digest_type) {
pm_strcat(hpkt.edbuf, "]");
}
-bool display_global_item(HPKT &hpkt)
+/* -1 nothing displayed, 1 found, 0 not found */
+int display_global_item(HPKT &hpkt)
{
bool found = true;
-
+ bool has_something = true;
if (hpkt.ritem->handler == store_res) {
display_res(hpkt);
} else if (hpkt.ritem->handler == store_str ||
} else if (hpkt.ritem->handler == store_bool) {
display_bool_pair(hpkt);
} else if (hpkt.ritem->handler == store_msgs) {
- display_msgs(hpkt);
+ has_something = display_msgs(hpkt);
} else if (hpkt.ritem->handler == store_bit) {
display_bit_pair(hpkt);
} else if (hpkt.ritem->handler == store_alist_res) {
- found = display_alist_res(hpkt); /* In some cases, the list is null... */
+ has_something = display_alist_res(hpkt); /* In some cases, the list is null... */
} else if (hpkt.ritem->handler == store_alist_str) {
- found = display_alist_str(hpkt); /* In some cases, the list is null... */
+ has_something = display_alist_str(hpkt); /* In some cases, the list is null... */
} else {
found = false;
}
- return found;
+ if (found) {
+ return has_something ? 1 : -1;
+ } else {
+ return 0;
+ }
}
/*
* Called here for each store_msgs resource
*/
-void display_msgs(HPKT &hpkt)
+bool display_msgs(HPKT &hpkt)
{
MSGS *msgs = (MSGS *)hpkt.ritem->value; /* Message res */
DEST *dest; /* destination chain */
sendit(NULL, " \"Command\": %s\n }",
quote_string(hpkt.edbuf, dest->mail_cmd));
break;
+ default:
+ Dmsg1(50, "got %d\n", hpkt.ritem->code);
}
}
}
+ return (first == false); // We found nothing to display
}
/*
void strip_long_opts(char *out, const char *in);
void edit_alist(HPKT &hpkt);
void edit_msg_types(HPKT &hpkt, DEST *dest);
-void display_msgs(HPKT &hpkt);
+bool display_msgs(HPKT &hpkt);
void display_alist(HPKT &hpkt);
bool display_alist_str(HPKT &hpkt);
bool display_alist_res(HPKT &hpkt);
void display_last(HPKT &hpkt);
void init_hpkt(HPKT &hpkt);
void term_hpkt(HPKT &hpkt);
-bool display_global_item(HPKT &hpkt);
+int display_global_item(HPKT &hpkt); //
void display_collector_types(HPKT &hpkt);
/* bsys.c */
hpkt.ritem = &items[item];
if (bit_is_set(item, res_all.hdr.item_present)) {
if (first_directive++ > 0) printf(",");
- if (display_global_item(hpkt)) {
+
+ /* 1: found, 0: not found, -1 found but empty */
+ int ret = display_global_item(hpkt);
+ if (ret == -1) {
+ /* Do not print a comma after this empty directive */
+ first_directive = 0;
+ } else if (ret == 1) {
/* Fall-through wanted */
+
} else if (items[item].handler == store_maxblocksize) {
display_int32_pair(hpkt);
} else if (items[item].handler == store_devtype) {