summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-24 12:47:09 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-24 12:47:09 -0400
commitf0df110ba42a6d23cb222069e4c2a4712d48d9f1 (patch)
tree6065cecd996ef7720aa8dfc942d5ec639bb91060 /src/bfstd.c
parent5c3572dc323527a5c168cc12a31b730e0749002d (diff)
downloadbfs-f0df110ba42a6d23cb222069e4c2a4712d48d9f1.tar.xz
bfstd: Add a getprogname() wrapper
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c15
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);