diff options
-rw-r--r-- | compat/getprogname.c | 16 | ||||
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | have/Makefile | 1 | ||||
-rw-r--r-- | have/__progname.c | 11 |
4 files changed, 33 insertions, 4 deletions
diff --git a/compat/getprogname.c b/compat/getprogname.c index ea7c2a3..7386263 100644 --- a/compat/getprogname.c +++ b/compat/getprogname.c @@ -16,7 +16,19 @@ #include "../config.h" -#if HAVE_PROGRAM_INVOCATION_SHORT_NAME +#if HAVE___PROGNAME + +#include <stddef.h> + +extern char *__progname; + +const char * +getprogname(void) +{ + return __progname; +} + +#elif HAVE_PROGRAM_INVOCATION_SHORT_NAME #include <errno.h> @@ -29,7 +41,7 @@ getprogname(void) } #else - +# warning Found no way to get the program name, will use "gmid" for all utilities. const char * getprogname(void) { @@ -287,6 +287,10 @@ if [ ${HAVE_ENDIAN_H} -eq 0 -a \ exit 1 fi +runtest getprogname GETPROGNAME || \ +runtest __progname __PROGNAME || \ +runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME -D_GNU_SOURCE || true + runtest arc4random ARC4RANDOM || true runtest arc4random_buf ARC4RANDOM_BUF || true runtest err ERR || true @@ -294,14 +298,12 @@ runtest explicit_bzero EXPLICIT_BZERO || true runtest freezero FREEZERO || true runtest getdtablecount GETDTABLECOUNT || true runtest getdtablesize GETDTABLESIZE || true -runtest getprogname GETPROGNAME || true runtest imsg IMSG "" -lutil libimsg || true runtest landlock LANDLOCK || true runtest libevent LIBEVENT "" -levent libevent_core|| true runtest memmem MEMMEM -D_GNU_SOURCE || true runtest openssl OPENSSL "" '-lcrypto -lssl' 'libcrypto libssl' || true runtest pr_set_name PR_SET_NAME || true -runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME -D_GNU_SOURCE || true runtest queue_h QUEUE_H || true runtest reallocarray REALLOCARRAY -D_OPENBSD_SOURCE || true runtest recallocarray RECALLOCARRAY || true @@ -448,6 +450,9 @@ cat <<__HEREDOC__ # define SYSCONFDIR "${SYSCONFDIR}" #endif +#define HAVE___PROGNAME ${HAVE___PROGNAME:-0} +#define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME:-0} + __HEREDOC__ if [ ${HAVE_ENDIAN_H} -eq 1 ]; then diff --git a/have/Makefile b/have/Makefile index bc9d7c5..3bb5f8f 100644 --- a/have/Makefile +++ b/have/Makefile @@ -5,6 +5,7 @@ DISTFILES = ASN1_time_parse.c \ SSL_CTX_load_verify_mem.c \ SSL_CTX_use_certificate_chain_mem.c \ X509_LOOKUP_mem.c \ + __progname.c \ arc4random.c \ arc4random_buf.c \ endian_h.c \ diff --git a/have/__progname.c b/have/__progname.c new file mode 100644 index 0000000..dbef94c --- /dev/null +++ b/have/__progname.c @@ -0,0 +1,11 @@ +/* public domain */ + +#include <stdio.h> + +extern const char *__progname; + +int +main(void) +{ + puts(__progname); +} |