1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Zbigniew Jędrzejewski-Szmek
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "specifier.h"
26 #include "unit-name.h"
27 #include "install-printf.h"
29 static char *specifier_prefix_and_instance(char specifier, void *data, void *userdata) {
30 InstallInfo *i = userdata;
33 return unit_name_to_prefix_and_instance(i->name);
36 static char *specifier_prefix(char specifier, void *data, void *userdata) {
37 InstallInfo *i = userdata;
40 return unit_name_to_prefix(i->name);
43 static char *specifier_instance(char specifier, void *data, void *userdata) {
44 InstallInfo *i = userdata;
50 r = unit_name_to_instance(i->name, &instance);
59 char *install_full_printf(InstallInfo *i, const char *format) {
61 /* This is similar to unit_full_printf() but does not support
62 * anything path-related.
64 * %n: the full id of the unit (foo@bar.waldo)
65 * %N: the id of the unit without the suffix (foo@bar)
66 * %p: the prefix (foo)
67 * %i: the instance (bar)
69 * %U the UID of the configured user or running user
70 * %u the username of the configured user or running user
71 * %m the machine ID of the running system
72 * %H the host name of the running system
73 * %b the boot ID of the running system
76 const Specifier table[] = {
77 { 'n', specifier_string, i->name },
78 { 'N', specifier_prefix_and_instance, NULL },
79 { 'p', specifier_prefix, NULL },
80 { 'i', specifier_instance, NULL },
82 // { 'U', specifier_user_name, NULL },
83 // { 'u', specifier_user_name, NULL },
85 { 'm', specifier_machine_id, NULL },
86 { 'H', specifier_host_name, NULL },
87 { 'b', specifier_boot_id, NULL },
94 return specifier_printf(format, table, i);