From: Jule Anger Date: Thu, 31 Mar 2022 08:17:47 +0000 (+0200) Subject: smbstatus: add method add_section_to_json X-Git-Tag: samba-4.17.0rc1~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a64c9078746aaea0757a8bb480b77ce55d1a4168;p=thirdparty%2Fsamba.git smbstatus: add method add_section_to_json The method adds an empty json object (value) under a given section name (key) to a given json object. Signed-off-by: Jule Anger Reviewed-by: Ralph Boehme --- diff --git a/source3/utils/status_json.c b/source3/utils/status_json.c index b2ade6bc69b..e9e04026a15 100644 --- a/source3/utils/status_json.c +++ b/source3/utils/status_json.c @@ -26,3 +26,22 @@ #include #include "audit_logging.h" /* various JSON helpers */ #include "auth/common_auth.h" + +int add_section_to_json(struct traverse_state *state, + const char *key) +{ + struct json_object empty_json; + int result; + + empty_json = json_new_object(); + if (json_is_invalid(&empty_json)) { + return -1; + } + + result = json_add_object(&state->root_json, key, &empty_json); + if (result < 0) { + return -1; + } + + return result; +} diff --git a/source3/utils/status_json.h b/source3/utils/status_json.h index bb42acd16bd..abae91c65a9 100644 --- a/source3/utils/status_json.h +++ b/source3/utils/status_json.h @@ -22,4 +22,7 @@ #ifndef STATUS_JSON_H #define STATUS_JSON_H +int add_section_to_json(struct traverse_state *state, + const char *key); + #endif diff --git a/source3/utils/status_json_dummy.c b/source3/utils/status_json_dummy.c index 0854eb70ef4..0f6dd832705 100644 --- a/source3/utils/status_json_dummy.c +++ b/source3/utils/status_json_dummy.c @@ -22,3 +22,9 @@ #include "../libcli/security/security.h" #include "librpc/gen_ndr/open_files.h" #include "status_json.h" + +int add_section_to_json(struct traverse_state *state, + const char *key) +{ + return 0; +}