chiark / gitweb /
bdec822225d8e4d1e2bb80880a1651b73c16c614
[elogind.git] / src / basic / musl_missing.c
1 #ifndef __GLIBC__
2 #include <string.h>
3 #include "util.h"
4
5 char *program_invocation_name       = NULL;
6 char *program_invocation_short_name = NULL;
7 #endif // __GLIBC__
8
9 #include "musl_missing.h"
10
11 static void elogind_free_program_name(void) {
12 #ifndef __GLIBC__
13         if (program_invocation_name)
14                 program_invocation_name       = mfree(program_invocation_name);
15         if (program_invocation_short_name)
16                 program_invocation_short_name = mfree(program_invocation_short_name);
17 #endif // __GLIBC__
18 }
19
20 void elogind_set_program_name(const char* pcall) {
21         assert(pcall && pcall[0]);
22         elogind_free_program_name();
23 #ifndef __GLIBC__
24         program_invocation_name       = strdup(pcall);
25         program_invocation_short_name = strdup(basename(pcall));
26         atexit(elogind_free_program_name);
27 #endif // __GLIBC__
28 }
29