aboutsummaryrefslogtreecommitdiff
path: root/src/rc-misc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc-misc.h')
-rw-r--r--src/rc-misc.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rc-misc.h b/src/rc-misc.h
index 570d7e79..bcc6b544 100644
--- a/src/rc-misc.h
+++ b/src/rc-misc.h
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <stdbool.h>
+#include <string.h>
#ifndef LIB
# define LIB "lib"
@@ -118,4 +119,14 @@ bool rc_conf_yesno (const char *var);
char **env_filter (void);
char **env_config (void);
+/* cbasename never modifies the argument. As such, if there is a trailing
+ * slash then an empty string is returned. */
+static inline const char *cbasename (const char *argv0) {
+ char *l = strrchr (argv0, '/');
+
+ if (l)
+ return (++l);
+ return (argv0);
+}
+
#endif