core: move service_context_build_json() to varlink-service.c
Move the existing (partial) service context builder from varlink-unit.c into its own varlink-service.c file, following the pattern established by other unit type context builders (varlink-path.c, varlink-scope.c, etc.). No functional change.
This commit is contained in:
@@ -76,6 +76,7 @@ libcore_sources = files(
|
||||
'varlink-mount.c',
|
||||
'varlink-path.c',
|
||||
'varlink-scope.c',
|
||||
'varlink-service.c',
|
||||
'varlink-socket.c',
|
||||
'varlink-swap.c',
|
||||
'varlink-timer.c',
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "json-util.h"
|
||||
#include "service.h"
|
||||
#include "varlink-common.h"
|
||||
#include "varlink-service.h"
|
||||
|
||||
/* TODO: This covers only a small subset of a service object's properties. Extend to make more available to
|
||||
* consumers like Unit.StartTransient */
|
||||
int service_context_build_json(sd_json_variant **ret, const char *name, void *userdata) {
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
Service *s = ASSERT_PTR(SERVICE(u));
|
||||
assert(ret);
|
||||
|
||||
return sd_json_buildo(
|
||||
ret,
|
||||
JSON_BUILD_PAIR_ENUM("Type", service_type_to_string(s->type)),
|
||||
JSON_BUILD_PAIR_CALLBACK_NON_NULL("ExecStart", exec_command_list_build_json, s->exec_command[SERVICE_EXEC_START]),
|
||||
SD_JSON_BUILD_PAIR_BOOLEAN("RemainAfterExit", s->remain_after_exit));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "core-forward.h"
|
||||
|
||||
int service_context_build_json(sd_json_variant **ret, const char *name, void *userdata);
|
||||
+1
-14
@@ -31,6 +31,7 @@
|
||||
#include "varlink-mount.h"
|
||||
#include "varlink-path.h"
|
||||
#include "varlink-scope.h"
|
||||
#include "varlink-service.h"
|
||||
#include "varlink-socket.h"
|
||||
#include "varlink-swap.h"
|
||||
#include "varlink-timer.h"
|
||||
@@ -119,20 +120,6 @@ static int unit_conditions_build_json(sd_json_variant **ret, const char *name, v
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO: This covers only a small subset of a service object's properties. Extend to make more available to
|
||||
* consumers like Unit.StartTransient */
|
||||
static int service_context_build_json(sd_json_variant **ret, const char *name, void *userdata) {
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
Service *s = ASSERT_PTR(SERVICE(u));
|
||||
assert(ret);
|
||||
|
||||
return sd_json_buildo(
|
||||
ret,
|
||||
JSON_BUILD_PAIR_ENUM("Type", service_type_to_string(s->type)),
|
||||
JSON_BUILD_PAIR_CALLBACK_NON_NULL("ExecStart", exec_command_list_build_json, s->exec_command[SERVICE_EXEC_START]),
|
||||
SD_JSON_BUILD_PAIR_BOOLEAN("RemainAfterExit", s->remain_after_exit));
|
||||
}
|
||||
|
||||
static int unit_context_build_json(sd_json_variant **ret, const char *name, void *userdata) {
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user