summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-27 19:44:52 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-29 19:01:41 -0500
commitd848b9cbfa0ba72381363accce481600169df2eb (patch)
tree184f2aab672e083fd5112947ac6ccd89de257ca2
parentd9e5e694ea7841045975426163c96fc9f71e6f7d (diff)
Move generic specifier functions to shared
No functional change. This makes it possible to use them in install.c.
-rw-r--r--src/core/unit-printf.c36
-rw-r--r--src/shared/specifier.c36
-rw-r--r--src/shared/specifier.h6
3 files changed, 41 insertions, 37 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index a58c96c238..3aa735e5b2 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -211,42 +211,6 @@ static char *specifier_user_shell(char specifier, void *data, void *userdata) {
return strdup(shell);
}
-static char *specifier_machine_id(char specifier, void *data, void *userdata) {
- sd_id128_t id;
- char *buf;
- int r;
-
- r = sd_id128_get_machine(&id);
- if (r < 0)
- return NULL;
-
- buf = new(char, 33);
- if (!buf)
- return NULL;
-
- return sd_id128_to_string(id, buf);
-}
-
-static char *specifier_boot_id(char specifier, void *data, void *userdata) {
- sd_id128_t id;
- char *buf;
- int r;
-
- r = sd_id128_get_boot(&id);
- if (r < 0)
- return NULL;
-
- buf = new(char, 33);
- if (!buf)
- return NULL;
-
- return sd_id128_to_string(id, buf);
-}
-
-static char *specifier_host_name(char specifier, void *data, void *userdata) {
- return gethostname_malloc();
-}
-
char *unit_name_printf(Unit *u, const char* format) {
/*
diff --git a/src/shared/specifier.c b/src/shared/specifier.c
index 599027cd47..7577c91052 100644
--- a/src/shared/specifier.c
+++ b/src/shared/specifier.c
@@ -109,3 +109,39 @@ char *specifier_printf(const char *text, const Specifier table[], void *userdata
char* specifier_string(char specifier, void *data, void *userdata) {
return strdup(strempty(data));
}
+
+char *specifier_machine_id(char specifier, void *data, void *userdata) {
+ sd_id128_t id;
+ char *buf;
+ int r;
+
+ r = sd_id128_get_machine(&id);
+ if (r < 0)
+ return NULL;
+
+ buf = new(char, 33);
+ if (!buf)
+ return NULL;
+
+ return sd_id128_to_string(id, buf);
+}
+
+char *specifier_boot_id(char specifier, void *data, void *userdata) {
+ sd_id128_t id;
+ char *buf;
+ int r;
+
+ r = sd_id128_get_boot(&id);
+ if (r < 0)
+ return NULL;
+
+ buf = new(char, 33);
+ if (!buf)
+ return NULL;
+
+ return sd_id128_to_string(id, buf);
+}
+
+char *specifier_host_name(char specifier, void *data, void *userdata) {
+ return gethostname_malloc();
+}
diff --git a/src/shared/specifier.h b/src/shared/specifier.h
index 25a27a423f..0440dcac48 100644
--- a/src/shared/specifier.h
+++ b/src/shared/specifier.h
@@ -31,4 +31,8 @@ typedef struct Specifier {
char *specifier_printf(const char *text, const Specifier table[], void *userdata);
-char* specifier_string(char specifier, void *data, void *userdata);
+char *specifier_string(char specifier, void *data, void *userdata);
+
+char *specifier_machine_id(char specifier, void *data, void *userdata);
+char *specifier_boot_id(char specifier, void *data, void *userdata);
+char *specifier_host_name(char specifier, void *data, void *userdata);