summaryrefslogtreecommitdiffstats
path: root/src/userdb/userdbctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-05-02 14:26:21 +0200
committerLennart Poettering <lennart@poettering.net>2024-06-12 18:42:22 +0200
commit309a747fa6cfeac0a0165543f23a924866727c9b (patch)
treea51242aa3ac87243c0614bf93d27e9083182e485 /src/userdb/userdbctl.c
parentjson: merge json_dispatch_path() + json_dispatch_absolute_path() (diff)
downloadsystemd-309a747fa6cfeac0a0165543f23a924866727c9b.tar.xz
systemd-309a747fa6cfeac0a0165543f23a924866727c9b.zip
libsystemd: turn json.[ch] into a public API
This is preparation for making our Varlink API a public API. Since our Varlink API is built on top of our JSON API we need to make that public first (it's a nice API, but JSON APIs there are already enough, this is purely about the Varlink angle). I made most of the json.h APIs public, and just placed them in sd-json.h. Sometimes I wasn't so sure however, since the underlying data structures would have to be made public too. If in doubt I didn#t risk it, and moved the relevant API to src/libsystemd/sd-json/json-util.h instead (without any sd_* symbol prefixes). This is mostly a giant search/replace patch.
Diffstat (limited to 'src/userdb/userdbctl.c')
-rw-r--r--src/userdb/userdbctl.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c
index 1718419407..b2013bf80d 100644
--- a/src/userdb/userdbctl.c
+++ b/src/userdb/userdbctl.c
@@ -36,7 +36,7 @@ static PagerFlags arg_pager_flags = 0;
static bool arg_legend = true;
static char** arg_services = NULL;
static UserDBFlags arg_userdb_flags = 0;
-static JsonFormatFlags arg_json_format_flags = JSON_FORMAT_OFF;
+static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
static bool arg_chain = false;
STATIC_DESTRUCTOR_REGISTER(arg_services, strv_freep);
@@ -86,7 +86,7 @@ static int show_user(UserRecord *ur, Table *table) {
break;
case OUTPUT_JSON:
- json_variant_dump(ur->json, arg_json_format_flags, NULL, 0);
+ sd_json_variant_dump(ur->json, arg_json_format_flags, NULL, 0);
break;
case OUTPUT_FRIENDLY:
@@ -486,7 +486,7 @@ static int show_group(GroupRecord *gr, Table *table) {
}
case OUTPUT_JSON:
- json_variant_dump(gr->json, arg_json_format_flags, NULL, 0);
+ sd_json_variant_dump(gr->json, arg_json_format_flags, NULL, 0);
break;
case OUTPUT_FRIENDLY:
@@ -780,15 +780,15 @@ static int show_membership(const char *user, const char *group, Table *table) {
break;
case OUTPUT_JSON: {
- _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
- r = json_build(&v, JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("user", JSON_BUILD_STRING(user)),
- JSON_BUILD_PAIR("group", JSON_BUILD_STRING(group))));
+ r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("user", SD_JSON_BUILD_STRING(user)),
+ SD_JSON_BUILD_PAIR("group", SD_JSON_BUILD_STRING(group))));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
- json_variant_dump(v, arg_json_format_flags, NULL, NULL);
+ sd_json_variant_dump(v, arg_json_format_flags, NULL, NULL);
break;
}
@@ -1200,7 +1200,7 @@ static int parse_argv(int argc, char *argv[]) {
} else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid --output= mode: %s", optarg);
- arg_json_format_flags = arg_output == OUTPUT_JSON ? JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR_AUTO : JSON_FORMAT_OFF;
+ arg_json_format_flags = arg_output == OUTPUT_JSON ? SD_JSON_FORMAT_PRETTY|SD_JSON_FORMAT_COLOR_AUTO : SD_JSON_FORMAT_OFF;
break;
case ARG_JSON:
@@ -1208,11 +1208,11 @@ static int parse_argv(int argc, char *argv[]) {
if (r <= 0)
return r;
- arg_output = FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF) ? _OUTPUT_INVALID : OUTPUT_JSON;
+ arg_output = FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF) ? _OUTPUT_INVALID : OUTPUT_JSON;
break;
case 'j':
- arg_json_format_flags = JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR_AUTO;
+ arg_json_format_flags = SD_JSON_FORMAT_PRETTY|SD_JSON_FORMAT_COLOR_AUTO;
arg_output = OUTPUT_JSON;
break;