xref: /freebsd/lib/libc/gen/setprogname.c (revision c45f3b47c8315dba98fb8333ff15b5178a80b7de)
1cd18ccdcSDima Dorfman #if defined(LIBC_RCS) && !defined(lint)
2cd18ccdcSDima Dorfman static const char rcsid[] =
3cd18ccdcSDima Dorfman   "$FreeBSD$";
4cd18ccdcSDima Dorfman #endif /* LIBC_RCS and not lint */
5cd18ccdcSDima Dorfman 
6c45f3b47SRuslan Ermilov #include <stdlib.h>
780578ef3SJacques Vidrine #include <string.h>
880578ef3SJacques Vidrine 
9cd18ccdcSDima Dorfman extern const char *__progname;
10cd18ccdcSDima Dorfman 
11cd18ccdcSDima Dorfman void
12cd18ccdcSDima Dorfman setprogname(const char *progname)
13cd18ccdcSDima Dorfman {
14c45f3b47SRuslan Ermilov 	const char *p;
15cd18ccdcSDima Dorfman 
1680578ef3SJacques Vidrine 	p = strrchr(progname, '/');
17dbdb228cSJacques Vidrine 	__progname = p ? p + 1 : progname;
18cd18ccdcSDima Dorfman }
19