const char *typestr = NULL;
const char *errstr;
int alias_type = UNSPEC;
- bool need_newline = true;
id_t id;
- debug_decl(print_member_json, SUDOERS_DEBUG_UTIL)
+ debug_decl(print_member_json_int, SUDOERS_DEBUG_UTIL)
/* Most of the time we print a string. */
value.type = JSON_STRING;
struct alias *a;
struct member *m;
+ /* Print each member of the alias. */
if ((a = alias_get(parse_tree, value.u.string, alias_type)) != NULL) {
TAILQ_FOREACH(m, &a->members, entries) {
print_member_json_int(fp, parse_tree, m->name, m->type,
last_one && TAILQ_NEXT(m, entries) == NULL, indent, true);
}
alias_put(a);
- need_newline = false;
}
- } else if (negated) {
- print_indent(fp, indent);
- fputs("{\n", fp);
- indent += 4;
- print_pair_json(fp, NULL, typestr, &value, ",\n", indent);
- value.type = JSON_BOOL;
- value.u.boolean = true;
- print_pair_json(fp, NULL, "negated", &value, "\n", indent);
- indent -= 4;
- print_indent(fp, indent);
- putc('}', fp);
} else {
- print_pair_json(fp, "{ ", typestr, &value, " }", indent);
- }
- if (need_newline) {
+ if (negated) {
+ print_indent(fp, indent);
+ fputs("{\n", fp);
+ indent += 4;
+ print_pair_json(fp, NULL, typestr, &value, ",\n", indent);
+ value.type = JSON_BOOL;
+ value.u.boolean = true;
+ print_pair_json(fp, NULL, "negated", &value, "\n", indent);
+ indent -= 4;
+ print_indent(fp, indent);
+ putc('}', fp);
+ } else {
+ print_pair_json(fp, "{ ", typestr, &value, " }", indent);
+ }
+
if (!last_one)
putc(',', fp);
putc('\n', fp);