diff options
author | 2013-05-31 20:59:23 +0000 | |
---|---|---|
committer | 2013-05-31 20:59:23 +0000 | |
commit | c88a5da8d030200b8cd1975909513546a59d2e10 (patch) | |
tree | 9641762fbc8aaeed900ca90eaea02b5ff5c6ebfc /lib/libc/gen/setprogname.c | |
parent | open up some races. if pool_debug == 2, force a yield() whenever waitok. (diff) | |
download | wireguard-openbsd-c88a5da8d030200b8cd1975909513546a59d2e10.tar.xz wireguard-openbsd-c88a5da8d030200b8cd1975909513546a59d2e10.zip |
Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.
Bump libc minor now (there will be more upcoming changes).
input from tedu@
get it in deraadt@
Diffstat (limited to 'lib/libc/gen/setprogname.c')
-rw-r--r-- | lib/libc/gen/setprogname.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c new file mode 100644 index 00000000000..c8625f0498a --- /dev/null +++ b/lib/libc/gen/setprogname.c @@ -0,0 +1,33 @@ +/* $OpenBSD: setprogname.c,v 1.1 2013/05/31 20:59:24 ajacoutot Exp $ */ +/* + * Copyright (c) 2013 Antoine Jacoutot <ajacoutot@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdlib.h> +#include <string.h> + +extern const char *__progname; + +void +setprogname(const char *progname) +{ + const char *tmpn; + + tmpn = strrchr(progname, '/'); + if (tmpn == NULL) + __progname = progname; + else + tmpn + 1; +} |