int i;
for (i=0; jobtypes[i].type_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == jobtypes[i].job_type) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, jobtypes[i].type_name));
return;
}
int i;
for (i=0; tapelabels[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == tapelabels[i].token) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, tapelabels[i].name));
return;
}
int i;
for (i=0; joblevels[i].level_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == joblevels[i].level) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, joblevels[i].level_name));
return;
}
int i;
for (i=0; ReplaceOptions[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == ReplaceOptions[i].token) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, ReplaceOptions[i].name));
return;
}
int i;
for (i=0; migtypes[i].type_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == migtypes[i].job_type) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, migtypes[i].type_name));
return;
}
static void display_actiononpurge(HPKT &hpkt)
{
- sendit(NULL, "\n \"%s\":", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\":", hpkt.ritem->name);
if (*(uint32_t *)(hpkt.ritem->value) | ON_PURGE_TRUNCATE) {
- sendit(NULL, "\"Truncate\"");
+ hpkt.sendit(hpkt, "\"Truncate\"");
} else {
- sendit(NULL, "null");
+ hpkt.sendit(hpkt, "null");
}
}
static void display_acl(HPKT &hpkt)
{
- sendit(NULL, "\n \"%s\":", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\":", hpkt.ritem->name);
hpkt.list = ((alist **)hpkt.ritem->value)[hpkt.ritem->code];
display_alist(hpkt);
}
int i, j, k;
alist *list;
- sendit(NULL, " \"Options\": [ \n {\n");
+ hpkt.sendit(hpkt, " \"Options\": [ \n {\n");
for (i=0; i<ie->num_opts; i++) {
FOPTS *fo = ie->opts_list[i];
if (!first_opt) {
- sendit(NULL, ",\n {\n");
+ hpkt.sendit(hpkt, ",\n {\n");
}
first_dir = true;
for (j=0; options_items[j].name; j++) {
}
if (list->size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", options_items[j].name);
+ hpkt.sendit(hpkt, " \"%s\":", options_items[j].name);
hpkt.list = list;
display_alist(hpkt);
first_dir = false;
}
if (list->size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", options_items[j].name);
+ hpkt.sendit(hpkt, " \"%s\":", options_items[j].name);
hpkt.list = list;
display_alist(hpkt);
first_dir = false;
list = &fo->base;
if (list->size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", options_items[j].name);
+ hpkt.sendit(hpkt, " \"%s\":", options_items[j].name);
hpkt.list = list;
display_alist(hpkt);
first_dir = false;
strip_long_opts(lopts, fo->opts);
if (strstr(lopts, FS_options[k].option)) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\": %s", options_items[j].name,
+ hpkt.sendit(hpkt, " \"%s\": %s", options_items[j].name,
quote_string(hpkt.edbuf, FS_options[k].name));
found = true;
break;
*end = 0; /* terminate this string */
}
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\": %s", options_items[j].name,
+ hpkt.sendit(hpkt, " \"%s\": %s", options_items[j].name,
quote_string(hpkt.edbuf, pos));
found = true;
if (end) { /* Still have other options to parse */
} else if (options_items[j].handler == store_plugin) {
if (fo->plugin) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\": %s", options_items[j].name,
+ hpkt.sendit(hpkt, " \"%s\": %s", options_items[j].name,
quote_string(hpkt.edbuf, fo->plugin));
first_dir = false;
first_opt = false;
list = &fo->fstype;
if (list->size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", options_items[j].name);
+ hpkt.sendit(hpkt, " \"%s\":", options_items[j].name);
hpkt.list = list;
display_alist(hpkt);
first_dir = false;
list = &fo->drivetype;
if (list->size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", options_items[j].name);
+ hpkt.sendit(hpkt, " \"%s\":", options_items[j].name);
hpkt.list = list;
display_alist(hpkt);
first_dir = false;
}
}
}
- sendit(NULL, "\n }");
+ hpkt.sendit(hpkt, "\n }");
}
- sendit(NULL, "\n ]");
+ hpkt.sendit(hpkt, "\n ]");
}
/*
if (hpkt.ritem->code == 0) { /* Include */
INCEXE *ie;
- sendit(NULL, "\n \"%s\": [{\n", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\": [{\n", hpkt.ritem->name);
for (j=0; j<fs->num_includes; j++) {
if (j > 0) {
- sendit(NULL, ",\n {\n");
+ hpkt.sendit(hpkt, ",\n {\n");
}
first_dir = true;
ie = fs->include_items[j];
for (i=0; newinc_items[i].name; i++) {
if (strcasecmp(newinc_items[i].name, "File") == 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", newinc_items[i].name);
+ hpkt.sendit(hpkt, " \"%s\":", newinc_items[i].name);
first_dir = false;
hpkt.list = &ie->name_list;
display_alist(hpkt);
} if (strcasecmp(newinc_items[i].name, "Plugin") == 0 &&
ie->plugin_list.size() > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\":", newinc_items[i].name);
+ hpkt.sendit(hpkt, " \"%s\":", newinc_items[i].name);
first_dir = false;
hpkt.list = &ie->plugin_list;
display_alist(hpkt);
} if (strcasecmp(newinc_items[i].name, "Options") == 0 &&
ie->num_opts > 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
display_options(hpkt, ie);
} if (strcasecmp(newinc_items[i].name, "ExcludeDirContaining") == 0 &&
ie->ignoredir) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\": %s ", newinc_items[i].name,
+ hpkt.sendit(hpkt, " \"%s\": %s ", newinc_items[i].name,
quote_string(hpkt.edbuf, ie->ignoredir));
first_dir = false;
}
}
- sendit(NULL, "\n }");
+ hpkt.sendit(hpkt, "\n }");
}
- sendit(NULL, "]");
+ hpkt.sendit(hpkt, "]");
} else {
/* Exclude */
- sendit(NULL, "\n \"%s\": {\n", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\": {\n", hpkt.ritem->name);
first_dir = true;
for (int i=0; newinc_items[i].name; i++) {
INCEXE *ie;
if (strcasecmp(newinc_items[i].name, "File") == 0) {
if (!first_dir) {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
- sendit(NULL, " \"%s\": ", newinc_items[i].name);
+ hpkt.sendit(hpkt, " \"%s\": ", newinc_items[i].name);
first_dir = false;
ie = fs->exclude_items[0];
hpkt.list = &ie->name_list;
display_alist(hpkt);
}
}
- sendit(NULL, "\n }");
+ hpkt.sendit(hpkt, "\n }");
}
}
return false;
}
- sendit(NULL, "\n \"Runscript\": [\n");
+ hpkt.sendit(hpkt, "\n \"Runscript\": [\n");
foreach_alist(script, *runscripts) {
if (first) {
- sendit(NULL, " {\n");
+ hpkt.sendit(hpkt, " {\n");
} else {
- sendit(NULL, ",\n {\n");
+ hpkt.sendit(hpkt, ",\n {\n");
}
if (script->when == SCRIPT_Any) {
- sendit(NULL, " \"RunsWhen\": \"Always\",\n");
+ hpkt.sendit(hpkt, " \"RunsWhen\": \"Always\",\n");
} else if (script->when == SCRIPT_After) {
- sendit(NULL, " \"RunsWhen\": \"After\",\n");
+ hpkt.sendit(hpkt, " \"RunsWhen\": \"After\",\n");
} else if (script->when == SCRIPT_Before) {
- sendit(NULL, " \"RunsWhen\": \"Before\",\n");
+ hpkt.sendit(hpkt, " \"RunsWhen\": \"Before\",\n");
} else if (script->when == SCRIPT_AfterVSS) {
- sendit(NULL, " \"RunsWhen\": \"AfterVSS\",\n");
+ hpkt.sendit(hpkt, " \"RunsWhen\": \"AfterVSS\",\n");
}
if (script->fail_on_error != def->fail_on_error) {
- sendit(NULL, " \"FailJobOnError\": %s,\n", script->fail_on_error?"true":"false");
+ hpkt.sendit(hpkt, " \"FailJobOnError\": %s,\n", script->fail_on_error?"true":"false");
}
if (script->on_success != def->on_success) {
- sendit(NULL, " \"RunsOnSuccess\": %s,\n", script->on_success?"true":"false");
+ hpkt.sendit(hpkt, " \"RunsOnSuccess\": %s,\n", script->on_success?"true":"false");
}
if (script->on_failure != def->on_failure) {
- sendit(NULL, " \"RunsOnFailure\": %s,\n", script->on_failure?"true":"false");
+ hpkt.sendit(hpkt, " \"RunsOnFailure\": %s,\n", script->on_failure?"true":"false");
}
if (script->is_local()) {
- sendit(NULL, " \"RunsOnClient\": false,\n");
+ hpkt.sendit(hpkt, " \"RunsOnClient\": false,\n");
}
if (script->command) {
- sendit(NULL, " \"%s\": %s\n",
+ hpkt.sendit(hpkt, " \"%s\": %s\n",
(script->cmd_type == SHELL_CMD)?"Command":"Console",
quote_string(hpkt.edbuf, script->command));
}
- sendit(NULL, " }");
+ hpkt.sendit(hpkt, " }");
first = false;
}
- sendit(NULL, "\n ]\n");
+ hpkt.sendit(hpkt, "\n ]\n");
free_runscript(def);
return true;
}
bool first_run = true;
RES *res;
- sendit(NULL, "\n \"%s\": [\n", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\": [\n", hpkt.ritem->name);
for ( ; run; run=run->next) {
- if (!first_run) sendit(NULL, ",\n");
+ if (!first_run) hpkt.sendit(hpkt, ",\n");
first_run = false;
first = true;
- sendit(NULL, " {\n");
+ hpkt.sendit(hpkt, " {\n");
/* First do override fields */
for (i=0; RunFields[i].name; i++) {
switch (RunFields[i].token) {
case 'f': /* FullPool */
if (run->full_pool) {
res = (RES *)run->full_pool;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
case 'i': /* IncrementalPool */
if (run->inc_pool) {
res = (RES *)run->inc_pool;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
case 'd': /* Differential Pool */
if (run->diff_pool) {
res = (RES *)run->diff_pool;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
case 'N': /* Next Pool */
if (run->next_pool) {
res = (RES *)run->next_pool;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
//if (run->level_set) {
for (j=0; joblevels[j].level_name; j++) {
if ((int)run->level == joblevels[j].level) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": \"%s\"", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": \"%s\"", RunFields[i].name,
joblevels[j].level_name);
first = false;
}
case 'P': /* Pool */
if (run->pool) {
res = (RES *)run->pool;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
case 'S': /* Storage */
if (run->storage) {
res = (RES *)run->storage;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
case 'M': /* Messages */
if (run->msgs) {
res = (RES *)run->msgs;
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
quote_string(hpkt.edbuf, res->name));
first = false;
}
break;
case 'p': /* priority */
if (run->priority_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %d", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %d", RunFields[i].name,
run->Priority);
first = false;
}
break;
case 's': /* Spool Data */
if (run->spool_data_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
run->spool_data?"true":"false");
first = false;
}
break;
case 'W': /* Write Part After Job */
if (run->write_part_after_job_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
run->write_part_after_job?"true":"false");
first = false;
}
break;
case 'm': /* MaxRunScheduledTime */
if (run->MaxRunSchedTime_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %lld", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %lld", RunFields[i].name,
run->MaxRunSchedTime);
first = false;
}
break;
case 'a': /* Accurate */
if (run->accurate_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %s", RunFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %s", RunFields[i].name,
run->accurate?"true":"false");
first = false;
}
} /* End all RunFields (overrides) */
/* Now handle timing */
if (byte_is_set(run->hour, sizeof(run->hour))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Hour\":");
- display_bit_array(run->hour, 24);
- sendit(NULL, ",\n \"Minute\": %d", run->minute);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Hour\":");
+ display_bit_array(hpkt, run->hour, 24);
+ hpkt.sendit(hpkt, ",\n \"Minute\": %d", run->minute);
first = false;
}
/* bit 32 is used to store the keyword LastDay, so we look up to 0-31 */
if (byte_is_set(run->mday, sizeof(run->mday))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Day\":");
- display_bit_array(run->mday, 31);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Day\":");
+ display_bit_array(hpkt, run->mday, 31);
first = false;
}
if (run->last_day_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"LastDay\": 1");
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"LastDay\": 1");
first = false;
}
if (byte_is_set(run->month, sizeof(run->month))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Month\":");
- display_bit_array(run->month, 12);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Month\":");
+ display_bit_array(hpkt, run->month, 12);
first = false;
}
if (byte_is_set(run->wday, sizeof(run->wday))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"DayOfWeek\":");
- display_bit_array(run->wday, 7);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"DayOfWeek\":");
+ display_bit_array(hpkt, run->wday, 7);
first = false;
}
if (byte_is_set(run->wom, sizeof(run->wom))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"WeekOfMonth\":");
- display_bit_array(run->wom, 6);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"WeekOfMonth\":");
+ display_bit_array(hpkt, run->wom, 6);
first = false;
}
if (byte_is_set(run->woy, sizeof(run->woy))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"WeekOfYear\":");
- display_bit_array(run->woy, 54);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"WeekOfYear\":");
+ display_bit_array(hpkt, run->woy, 54);
first = false;
}
- sendit(NULL, "\n }");
+ hpkt.sendit(hpkt, "\n }");
} /* End this Run directive */
- sendit(NULL, "\n ]");
+ hpkt.sendit(hpkt, "\n ]");
}
/*
/* List resources and directives */
if (filter->do_only_data) {
/* Skip the Name */
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
/*
* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... }
* or print a single item
*/
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "{");
+ hpkt.sendit(hpkt, "{");
} else {
/* [ { "Client": { "Name": "aa",.. } }, { "Director": { "Name": "bb", ... } } ]*/
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
}
first_res = true;
}
if (first_res) {
- sendit(NULL, "\n");
+ hpkt.sendit(hpkt, "\n");
} else {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
/* Find where the Name is defined, should always be 0 */
}
if (filter->do_only_data) {
- sendit(NULL, " {");
+ hpkt.sendit(hpkt, " {");
} else if (filter->do_one) {
/* Nothing to print */
/* Search and display Name, should be the first item */
for (item=0; items[item].name; item++) {
if (strcmp(items[item].name, "Name") == 0) {
- sendit(NULL, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
+ hpkt.sendit(hpkt, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
break;
}
}
} else {
/* Begin new resource */
- sendit(NULL, "{\n \"%s\": {", resources[resinx].name);
+ hpkt.sendit(hpkt, "{\n \"%s\": {", resources[resinx].name);
}
first_res = false;
continue;
}
if (first_directive++ > 0) {
- sendit(NULL, ",");
+ hpkt.sendit(hpkt, ",");
}
/* 1: found, 0: not found, -1 found but empty */
} else if (items[item].handler == store_coll_type) {
display_collector_types(hpkt);
} else {
- sendit(NULL, "\n \"%s\": null", items[item].name);
+ hpkt.sendit(hpkt, "\n \"%s\": null", items[item].name);
}
} else { /* end if is present */
/* For some directive, the bitmap is not set (like addresses) */
&& items[item].handler == store_bool /* yes or no */
&& *(bool *)(items[item].value) == true)
{
- if (first_directive++ > 0) sendit(NULL, ",");
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
if (*(items[item-1].value) == NULL) {
- sendit(NULL, "\n \"Autochanger\": %s", quote_string(hpkt.edbuf2, *items[name_pos].value));
+ hpkt.sendit(hpkt, "\n \"Autochanger\": %s", quote_string(hpkt.edbuf2, *items[name_pos].value));
} else {
STORE *r = (STORE *)*(items[item-1].value);
- sendit(NULL, "\n \"Autochanger\": %s", quote_string(hpkt.edbuf2, r->name()));
+ hpkt.sendit(hpkt, "\n \"Autochanger\": %s", quote_string(hpkt.edbuf2, r->name()));
}
}
}
if (strcmp(resources[resinx].name, "Director") == 0) {
if (strcmp(items[item].name, "DirPort") == 0) {
if (get_first_port_host_order(director->DIRaddrs) != items[item].default_value) {
- if (first_directive++ > 0) sendit(NULL, ",");
- sendit(NULL, "\n \"DirPort\": %d",
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
+ hpkt.sendit(hpkt, "\n \"DirPort\": %d",
get_first_port_host_order(director->DIRaddrs));
}
char buf[500];
get_first_address(director->DIRaddrs, buf, sizeof(buf));
if (strcmp(buf, "0.0.0.0") != 0) {
- if (first_directive++ > 0) sendit(NULL, ",");
- sendit(NULL, "\n \"DirAddress\": \"%s\"", buf);
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
+ hpkt.sendit(hpkt, "\n \"DirAddress\": \"%s\"", buf);
}
} else if (strcmp(items[item].name, "DirSourceAddress") == 0 && director->DIRsrc_addr) {
char buf[500];
get_first_address(director->DIRsrc_addr, buf, sizeof(buf));
if (strcmp(buf, "0.0.0.0") != 0) {
- if (first_directive++ > 0) sendit(NULL, ",");
- sendit(NULL, "\n \"DirSourceAddress\": \"%s\"", buf);
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
+ hpkt.sendit(hpkt, "\n \"DirSourceAddress\": \"%s\"", buf);
}
}
}
/* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... } */
if (filter->do_only_data || filter->do_list) {
- sendit(NULL, "\n }"); /* Finish the Resource with a single } */
+ hpkt.sendit(hpkt, "\n }"); /* Finish the Resource with a single } */
} else {
if (filter->do_one) {
/* don't print anything */
} else if (first_directive > 0) {
- sendit(NULL, "\n }\n}"); /* end of resource */
+ hpkt.sendit(hpkt, "\n }\n}"); /* end of resource */
} else {
- sendit(NULL, "}\n}");
+ hpkt.sendit(hpkt, "}\n}");
}
}
} /* End loop over all resources of this type */
} /* End loop all resource types */
if (filter->do_only_data) {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
/* In list context, we are dealing with a hash */
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "\n}\n");
+ hpkt.sendit(hpkt, "\n}\n");
} else {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
}
term_hpkt(hpkt);
}
int i;
for (i=0; ciphertypes[i].type_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == ciphertypes[i].type_value) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
ciphertypes[i].type_name);
return;
}
int i;
for (i=0; digesttypes[i].type_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == digesttypes[i].type_value) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
digesttypes[i].type_name);
return;
}
bool first = true;
bool first_run = true;
- sendit(NULL, "\n \"%s\": [\n", hpkt.ritem->name);
+ hpkt.sendit(hpkt, "\n \"%s\": [\n", hpkt.ritem->name);
for ( ; run; run=run->next) {
- if (!first_run) sendit(NULL, ",\n");
+ if (!first_run) hpkt.sendit(hpkt, ",\n");
first_run = false;
first = true;
- sendit(NULL, " {\n");
+ hpkt.sendit(hpkt, " {\n");
/* First do override fields */
for (i=0; ConnectFields[i].name; i++) {
switch (ConnectFields[i].token) {
case 'm': /* MaxConnectTime */
if (run->MaxConnectTime_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"%s\": %lld", ConnectFields[i].name,
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"%s\": %lld", ConnectFields[i].name,
run->MaxConnectTime);
first = false;
}
} /* End all ConnectFields (overrides) */
/* Now handle timing */
if (byte_is_set(run->hour, sizeof(run->hour))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Hour\":");
- display_bit_array(run->hour, 24);
- sendit(NULL, ",\n \"Minute\": %d", run->minute);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Hour\":");
+ display_bit_array(hpkt, run->hour, 24);
+ hpkt.sendit(hpkt, ",\n \"Minute\": %d", run->minute);
first = false;
}
/* bit 32 is used to store the keyword LastDay, so we look up to 0-31 */
if (byte_is_set(run->mday, sizeof(run->mday))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Day\":");
- display_bit_array(run->mday, 31);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Day\":");
+ display_bit_array(hpkt, run->mday, 31);
first = false;
}
if (run->last_day_set) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"LastDay\": 1");
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"LastDay\": 1");
first = false;
}
if (byte_is_set(run->month, sizeof(run->month))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"Month\":");
- display_bit_array(run->month, 12);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"Month\":");
+ display_bit_array(hpkt, run->month, 12);
first = false;
}
if (byte_is_set(run->wday, sizeof(run->wday))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"DayOfWeek\":");
- display_bit_array(run->wday, 7);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"DayOfWeek\":");
+ display_bit_array(hpkt, run->wday, 7);
first = false;
}
if (byte_is_set(run->wom, sizeof(run->wom))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"WeekOfMonth\":");
- display_bit_array(run->wom, 6);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"WeekOfMonth\":");
+ display_bit_array(hpkt, run->wom, 6);
first = false;
}
if (byte_is_set(run->woy, sizeof(run->woy))) {
- if (!first) sendit(NULL, ",\n");
- sendit(NULL, " \"WeekOfYear\":");
- display_bit_array(run->woy, 54);
+ if (!first) hpkt.sendit(hpkt, ",\n");
+ hpkt.sendit(hpkt, " \"WeekOfYear\":");
+ display_bit_array(hpkt, run->woy, 54);
first = false;
}
- sendit(NULL, "\n }");
+ hpkt.sendit(hpkt, "\n }");
} /* End this Run directive */
- sendit(NULL, "\n ]");
+ hpkt.sendit(hpkt, "\n ]");
}
/*
me = (CLIENT *)GetNextRes(R_CLIENT, NULL);
if (filter->do_only_data) {
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
/* List resources and directives */
/* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... }
* or print a single item
*/
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "{");
+ hpkt.sendit(hpkt, "{");
} else {
/* [ { "Client": { "Name": "aa",.. } }, { "Director": { "Name": "bb", ... } } ]*/
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
}
first_res = true;
first_directive = 0;
if (filter->do_only_data) {
- sendit(NULL, " {");
+ hpkt.sendit(hpkt, " {");
} else if (filter->do_one) {
/* Nothing to print */
/* Search and display Name, should be the first item */
for (item=0; items[item].name; item++) {
if (strcmp(items[item].name, "Name") == 0) {
- sendit(NULL, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
+ hpkt.sendit(hpkt, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
break;
}
}
} else {
/* Begin new resource */
- sendit(NULL, "{\n \"%s\": {", resources[resinx].name);
+ hpkt.sendit(hpkt, "{\n \"%s\": {", resources[resinx].name);
}
/* dirtry trick for a deprecated directive */
/* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... } */
if (filter->do_only_data || filter->do_list) {
- sendit(NULL, "\n }"); /* Finish the Resource with a single } */
+ hpkt.sendit(hpkt, "\n }"); /* Finish the Resource with a single } */
} else {
if (filter->do_one) {
/* don't print anything */
} else if (first_directive > 0) {
- sendit(NULL, "\n }\n}"); /* end of resource */
+ hpkt.sendit(hpkt, "\n }\n}"); /* end of resource */
} else {
- sendit(NULL, "}\n}");
+ hpkt.sendit(hpkt, "}\n}");
}
}
first_res = false;
} /* End loop all resource types */
if (filter->do_only_data) {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
/* In list context, we are dealing with a hash */
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "\n}\n");
+ hpkt.sendit(hpkt, "\n}\n");
} else {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
}
term_hpkt(hpkt);
}
regex_t directive_reg;
};
-static void sendit(void *sock, const char *fmt, ...)
+void bjson_sendit(HPKT &hpkt, const char *fmt, ...)
{
- char buf[3000];
va_list arg_ptr;
+ bool done=false;
+
+ while (!done) {
+ uint32_t len = sizeof_pool_memory(hpkt.out);
+ va_start(arg_ptr, fmt);
+ // The return value of our bvsnprintf() doesn't represent
+ // the full length of the string, we need to check it afterward
+ bvsnprintf(hpkt.out, len, (char *)fmt, arg_ptr);
+ va_end(arg_ptr);
+
+ if (strlen(hpkt.out) >= (len - 1)) {
+ // We got an overflow, we need more room to display the output
+ hpkt.out = check_pool_memory_size(hpkt.out, len*2);
+
+ } else {
+ done = true;
+ }
+ }
- va_start(arg_ptr, fmt);
- bvsnprintf(buf, sizeof(buf), (char *)fmt, arg_ptr);
- va_end(arg_ptr);
- fputs(buf, stdout);
+ fputs(hpkt.out, stdout);
fflush(stdout);
}
memset(&hpkt, 0, sizeof(hpkt));
hpkt.edbuf = get_pool_memory(PM_EMSG);
hpkt.edbuf2 = get_pool_memory(PM_EMSG);
+ hpkt.out = get_pool_memory(PM_EMSG);
hpkt.json = true;
hpkt.hfunc = HF_DISPLAY;
- hpkt.sendit = sendit;
+ hpkt.sendit = bjson_sendit;
}
void term_hpkt(HPKT &hpkt)
{
free_pool_memory(hpkt.edbuf);
free_pool_memory(hpkt.edbuf2);
+ free_pool_memory(hpkt.out);
memset(&hpkt, 0, sizeof(hpkt));
}
}
}
if (!found) {
- sendit(NULL, "No find for type=%d\n", i);
+ bjson_sendit(hpkt, "No find for type=%d\n", i);
}
count++;
}
}
}
if (!found) {
- sendit(NULL, "No find for type=%d in second loop\n", i);
+ bjson_sendit(hpkt, "No find for type=%d in second loop\n", i);
}
} else if (i == M_SAVED) {
/* Saved is not set by default, users must explicitly use it
if (!hpkt.in_store_msg) {
hpkt.in_store_msg = true;
- sendit(NULL, "\n \"Destinations\": [");
+ bjson_sendit(hpkt, "\n \"Destinations\": [");
}
for (dest=msgs->dest_chain; dest; dest=dest->next) {
if (dest->dest_code == hpkt.ritem->code) {
- if (!first) sendit(NULL, ",");
+ if (!first) bjson_sendit(hpkt, ",");
first = false;
edit_msg_types(hpkt, dest);
switch (hpkt.ritem->code) {
case MD_SYSLOG:
case MD_CONSOLE:
case MD_CATALOG:
- sendit(NULL, "\n {\n \"Type\": \"%s\","
+ bjson_sendit(hpkt, "\n {\n \"Type\": \"%s\","
"\n \"MsgTypes\": %s\n }",
hpkt.ritem->name, hpkt.edbuf);
break;
case MD_DIRECTOR:
case MD_FILE:
case MD_APPEND:
- sendit(NULL, "\n {\n \"Type\": \"%s\","
+ bjson_sendit(hpkt, "\n {\n \"Type\": \"%s\","
"\n \"MsgTypes\": %s,\n",
hpkt.ritem->name, hpkt.edbuf);
- sendit(NULL, " \"Where\": [%s]\n }",
+ bjson_sendit(hpkt, " \"Where\": [%s]\n }",
quote_where(hpkt.edbuf, dest->where));
break;
/* Now we edit MsgTypes, Where, and Command */
case MD_OPERATOR:
case MD_MAIL_ON_ERROR:
case MD_MAIL_ON_SUCCESS:
- sendit(NULL, "\n {\n \"Type\": \"%s\","
+ bjson_sendit(hpkt, "\n {\n \"Type\": \"%s\","
"\n \"MsgTypes\": %s,\n",
hpkt.ritem->name, hpkt.edbuf);
- sendit(NULL, " \"Where\": [%s],\n",
+ bjson_sendit(hpkt, " \"Where\": [%s],\n",
quote_where(hpkt.edbuf, dest->where));
- sendit(NULL, " \"Command\": %s\n }",
+ bjson_sendit(hpkt, " \"Command\": %s\n }",
quote_string(hpkt.edbuf, dest->mail_cmd));
break;
default:
{
if (hpkt.in_store_msg) {
hpkt.in_store_msg = false;
- sendit(NULL, "\n ]");
+ bjson_sendit(hpkt, "\n ]");
}
}
void display_alist(HPKT &hpkt)
{
edit_alist(hpkt);
- sendit(NULL, "%s", hpkt.edbuf);
+ bjson_sendit(hpkt, "%s", hpkt.edbuf);
}
bool display_alist_str(HPKT &hpkt)
if (!hpkt.list) {
return false;
}
- sendit(NULL, "\n \"%s\":", hpkt.ritem->name);
+ bjson_sendit(hpkt, "\n \"%s\":", hpkt.ritem->name);
display_alist(hpkt);
return true;
}
if (!list) {
return false;
}
- sendit(NULL, "\n \"%s\":", hpkt.ritem->name);
- sendit(NULL, " [");
+ bjson_sendit(hpkt, "\n \"%s\":", hpkt.ritem->name);
+ bjson_sendit(hpkt, " [");
foreach_alist(res, list) {
if (!f) {
- sendit(NULL, ", ");
+ bjson_sendit(hpkt, ", ");
}
- sendit(NULL, "%s", quote_string(hpkt.edbuf, res->name));
+ bjson_sendit(hpkt, "%s", quote_string(hpkt.edbuf, res->name));
f = false;
}
- sendit(NULL, "]");
+ bjson_sendit(hpkt, "]");
return true;
}
RES *res;
res = (RES *)*hpkt.ritem->value;
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, res->name));
}
void display_string_pair(HPKT &hpkt)
{
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, *hpkt.ritem->value));
}
void display_int32_pair(HPKT &hpkt)
{
char ed1[50];
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
edit_int64(*(int32_t *)hpkt.ritem->value, ed1));
}
void display_int64_pair(HPKT &hpkt)
{
char ed1[50];
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
edit_int64(*(int64_t *)hpkt.ritem->value, ed1));
}
void display_bool_pair(HPKT &hpkt)
{
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
((*(bool *)(hpkt.ritem->value)) == 0)?"false":"true");
}
void display_bit_pair(HPKT &hpkt)
{
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
((*(uint32_t *)(hpkt.ritem->value) & hpkt.ritem->code)
== 0)?"false":"true");
}
return found;
}
-void display_bit_array(char *array, int num)
+void display_bit_array(HPKT &hpkt, char *array, int num)
{
int i;
bool first = true;
- sendit(NULL, " [");
+ bjson_sendit(hpkt, " [");
for (i=0; i<num; i++) {
if (bit_is_set(i, array)) {
- if (!first) sendit(NULL, ", ");
+ if (!first) bjson_sendit(hpkt, ", ");
first = false;
- sendit(NULL, "%d", i);
+ bjson_sendit(hpkt, "%d", i);
}
}
- sendit(NULL, "]");
+ bjson_sendit(hpkt, "]");
}
void display_collector_types(HPKT &hpkt)
int i;
for (i=0; collectortypes[i].type_name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == collectortypes[i].coll_type) {
- sendit(NULL, "\n \"%s\": %s", hpkt.ritem->name,
+ bjson_sendit(hpkt, "\n \"%s\": %s", hpkt.ritem->name,
quote_string(hpkt.edbuf, collectortypes[i].type_name));
return;
}
/* Forward referenced functions */
void terminate_stored(int sig);
static int check_resources();
-static void sendit(void *sock, const char *fmt, ...);
static void dump_json(display_filter *filter);
#define CONFIG_FILE "bacula-sd.conf" /* Default config file */
/* Global static variables */
static CONFIG *config;
-
+static void sendit(void *sock, const char *fmt, ...);
static void usage()
{
int i;
for (i=0; dev_types[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == dev_types[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
dev_types[i].name);
return;
}
int i;
for (i=0; tapelabels[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == tapelabels[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
tapelabels[i].name);
return;
}
int i;
for (i=0; cloud_drivers[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == cloud_drivers[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
cloud_drivers[i].name);
return;
}
int i;
for (i=0; dedup_drivers[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == dedup_drivers[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
dedup_drivers[i].name);
return;
}
int i;
for (i=0; proto_opts[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == proto_opts[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
proto_opts[i].name);
return;
}
int i;
for (i=0; trunc_opts[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == trunc_opts[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
trunc_opts[i].name);
return;
}
int i;
for (i=0; uri_opts[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == uri_opts[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
uri_opts[i].name);
return;
}
int i;
for (i=0; upload_opts[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == upload_opts[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
upload_opts[i].name);
return;
}
int i;
for (i=0; restore_prio_opts[i].name; i++) {
if (*(int32_t *)(hpkt.ritem->value) == restore_prio_opts[i].token) {
- sendit(NULL, "\n \"%s\": \"%s\"", hpkt.ritem->name,
+ hpkt.sendit(hpkt, "\n \"%s\": \"%s\"", hpkt.ritem->name,
restore_prio_opts[i].name);
return;
}
init_hpkt(hpkt);
if (filter->do_only_data) {
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
/* List resources and directives */
/* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... }
* or print a single item
*/
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "{");
+ hpkt.sendit(hpkt, "{");
} else {
/* [ { "Device": { "Name": "aa",.. } }, { "Director": { "Name": "bb", ... } } ]*/
- sendit(NULL, "[");
+ hpkt.sendit(hpkt, "[");
}
first_res = true;
}
if (first_res) {
- sendit(NULL, "\n");
+ hpkt.sendit(hpkt, "\n");
} else {
- sendit(NULL, ",\n");
+ hpkt.sendit(hpkt, ",\n");
}
if (filter->do_only_data) {
- sendit(NULL, " {");
+ hpkt.sendit(hpkt, " {");
} else if (filter->do_one) {
/* Nothing to print */
/* Search and display Name, should be the first item */
for (item=0; items[item].name; item++) {
if (strcmp(items[item].name, "Name") == 0) {
- sendit(NULL, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
+ hpkt.sendit(hpkt, "%s: {\n", quote_string(hpkt.edbuf2, *items[item].value));
break;
}
}
} else {
/* Begin new resource */
- sendit(NULL, "{\n \"%s\": {", resources[resinx].name);
+ hpkt.sendit(hpkt, "{\n \"%s\": {", resources[resinx].name);
}
first_res = false;
if (me && strcmp(resources[resinx].name, "Storage") == 0) {
if (strcmp(items[item].name, "SdPort") == 0) {
if (get_first_port_host_order(me->sdaddrs) != items[item].default_value) {
- if (first_directive++ > 0) sendit(NULL, ",");
- sendit(NULL, "\n \"SdPort\": %d",
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
+ hpkt.sendit(hpkt, "\n \"SdPort\": %d",
get_first_port_host_order(me->sdaddrs));
}
} else if (me && strcmp(items[item].name, "SdAddress") == 0) {
char buf[500];
get_first_address(me->sdaddrs, buf, sizeof(buf));
if (strcmp(buf, "0.0.0.0") != 0) {
- if (first_directive++ > 0) sendit(NULL, ",");
- sendit(NULL, "\n \"SdAddress\": \"%s\"", buf);
+ if (first_directive++ > 0) hpkt.sendit(hpkt, ",");
+ hpkt.sendit(hpkt, "\n \"SdAddress\": \"%s\"", buf);
}
}
}
/* { "aa": { "Name": "aa",.. }, "bb": { "Name": "bb", ... } */
if (filter->do_only_data || filter->do_list) {
- sendit(NULL, "\n }"); /* Finish the Resource with a single } */
+ hpkt.sendit(hpkt, "\n }"); /* Finish the Resource with a single } */
} else {
if (filter->do_one) {
/* don't print anything */
} else if (first_directive > 0) {
- sendit(NULL, "\n }\n}"); /* end of resource */
+ hpkt.sendit(hpkt, "\n }\n}"); /* end of resource */
} else {
- sendit(NULL, "}\n }");
+ hpkt.sendit(hpkt, "}\n }");
}
}
} /* End loop all resource types */
if (filter->do_only_data) {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
/* In list context, we are dealing with a hash */
} else if (filter->do_one || filter->do_list) {
- sendit(NULL, "\n}\n");
+ hpkt.sendit(hpkt, "\n}\n");
} else {
- sendit(NULL, "\n]\n");
+ hpkt.sendit(hpkt, "\n]\n");
}
term_hpkt(hpkt);
}