Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
steam
systemd
Commits
d848b9cb
Commit
d848b9cb
authored
Jan 27, 2013
by
Zbigniew Jędrzejewski-Szmek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move generic specifier functions to shared
No functional change. This makes it possible to use them in install.c.
parent
d9e5e694
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
37 deletions
+41
-37
src/core/unit-printf.c
src/core/unit-printf.c
+0
-36
src/shared/specifier.c
src/shared/specifier.c
+36
-0
src/shared/specifier.h
src/shared/specifier.h
+5
-1
No files found.
src/core/unit-printf.c
View file @
d848b9cb
...
...
@@ -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
)
{
/*
...
...
src/shared/specifier.c
View file @
d848b9cb
...
...
@@ -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
();
}
src/shared/specifier.h
View file @
d848b9cb
...
...
@@ -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
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment