diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-06-24 12:47:09 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-06-24 12:47:09 -0400 |
commit | f0df110ba42a6d23cb222069e4c2a4712d48d9f1 (patch) | |
tree | 6065cecd996ef7720aa8dfc942d5ec639bb91060 /src/bfstd.c | |
parent | 5c3572dc323527a5c168cc12a31b730e0749002d (diff) | |
download | bfs-f0df110ba42a6d23cb222069e4c2a4712d48d9f1.tar.xz |
bfstd: Add a getprogname() wrapper
Diffstat (limited to 'src/bfstd.c')
-rw-r--r-- | src/bfstd.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/bfstd.c b/src/bfstd.c index 0e8ba5f..1f4bbb2 100644 --- a/src/bfstd.c +++ b/src/bfstd.c @@ -143,6 +143,21 @@ char *xgetdelim(FILE *file, char delim) { } } +const char *xgetprogname(void) { + const char *cmd = NULL; +#if __GLIBC__ + cmd = program_invocation_short_name; +#elif BSD + cmd = getprogname(); +#endif + + if (!cmd) { + cmd = BFS_COMMAND; + } + + return cmd; +} + /** Compile and execute a regular expression for xrpmatch(). */ static int xrpregex(nl_item item, const char *response) { const char *pattern = nl_langinfo(item); |