xref: /minix3/external/bsd/blacklist/port/getprogname.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc #ifdef HAVE_CONFIG_H
2*0a6a1f1dSLionel Sambuc #include "config.h"
3*0a6a1f1dSLionel Sambuc #endif
4*0a6a1f1dSLionel Sambuc #include <string.h>
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc extern char *__progname;
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc const char *
getprogname(void)9*0a6a1f1dSLionel Sambuc getprogname(void)
10*0a6a1f1dSLionel Sambuc {
11*0a6a1f1dSLionel Sambuc 	return __progname;
12*0a6a1f1dSLionel Sambuc }
13*0a6a1f1dSLionel Sambuc 
14*0a6a1f1dSLionel Sambuc void
setprogname(char * p)15*0a6a1f1dSLionel Sambuc setprogname(char *p)
16*0a6a1f1dSLionel Sambuc {
17*0a6a1f1dSLionel Sambuc 	char *q;
18*0a6a1f1dSLionel Sambuc 	if (p == NULL)
19*0a6a1f1dSLionel Sambuc 		return;
20*0a6a1f1dSLionel Sambuc 	if ((q = strrchr(p, '/')) != NULL)
21*0a6a1f1dSLionel Sambuc 		__progname = ++q;
22*0a6a1f1dSLionel Sambuc 	else
23*0a6a1f1dSLionel Sambuc 		__progname = p;
24*0a6a1f1dSLionel Sambuc }
25