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