mirror of
https://github.com/systemd/systemd.git
synced 2025-03-23 10:50:16 +03:00
vconsole-util: Introduce vconsole_serialize()
Preparation for reuse in systemd-firstboot.
This commit is contained in:
parent
6d0f502736
commit
c4b4d42cae
@ -298,27 +298,7 @@ int vconsole_write_data(Context *c) {
|
||||
if (r < 0 && r != -ENOENT)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "KEYMAP", empty_to_null(c->vc.keymap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "KEYMAP_TOGGLE", empty_to_null(c->vc.toggle));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "XKBLAYOUT", empty_to_null(xc->layout));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "XKBMODEL", empty_to_null(xc->model));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "XKBVARIANT", empty_to_null(xc->variant));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(&l, "XKBOPTIONS", empty_to_null(xc->options));
|
||||
r = vconsole_serialize(&c->vc, xc, &l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "kbd-util.h"
|
||||
@ -570,3 +571,39 @@ int find_language_fallback(const char *lang, char **ret) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int vconsole_serialize(const VCContext *vc, const X11Context *xc, char ***env) {
|
||||
int r;
|
||||
|
||||
/* This function modifies the passed strv in place. */
|
||||
|
||||
assert(vc);
|
||||
assert(xc);
|
||||
assert(env);
|
||||
|
||||
r = strv_env_assign(env, "KEYMAP", empty_to_null(vc->keymap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(env, "KEYMAP_TOGGLE", empty_to_null(vc->toggle));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(env, "XKBLAYOUT", empty_to_null(xc->layout));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(env, "XKBMODEL", empty_to_null(xc->model));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(env, "XKBVARIANT", empty_to_null(xc->variant));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_env_assign(env, "XKBOPTIONS", empty_to_null(xc->options));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -38,3 +38,5 @@ typedef int (*X11VerifyCallback)(const X11Context *xc);
|
||||
|
||||
int vconsole_convert_to_x11(const VCContext *vc, X11VerifyCallback verify, X11Context *ret);
|
||||
int x11_convert_to_vconsole(const X11Context *xc, VCContext *ret);
|
||||
|
||||
int vconsole_serialize(const VCContext *vc, const X11Context *xc, char ***ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user