X-Git-Url: http://git.asbjorn.it/?p=debian%2Fdhcpd-pools.git;a=blobdiff_plain;f=src%2Fdhcpd-pools.h;h=4bb9d2b873ea7d5d03517826d084b5816f36c00a;hp=6d8df201494b8a9a7c788ad56ff8694e033ba92d;hb=d54721b3a44a87be75b83860a955ddc7a0ec6b3d;hpb=a10396710e32659e82032b84a5468be52c3996d5 diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 6d8df20..4bb9d2b 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -24,13 +24,46 @@ #define _POSIX_SOURCE 1 #define POSIXLY_CORRECT 1 -#ifdef HAVE_STDLIB_H +#ifdef HAVE_STDLIB_H #include #else extern void exit(); extern char *malloc(); #endif /* STDC_HEADERS */ +#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME +# ifdef HAVE___PROGNAME +extern char *__progname; +# define program_invocation_short_name __progname +# else /* HAVE___PROGNAME */ +# ifdef HAVE_GETEXECNAME +# include +# define program_invocation_short_name \ + prog_inv_sh_nm_from_file(getexecname(), 0) +# else /* HAVE_GETEXECNAME */ +# define program_invocation_short_name \ + prog_inv_sh_nm_from_file(__FILE__, 1) +# endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */ +static char prog_inv_sh_nm_buf[256]; +static inline char *prog_inv_sh_nm_from_file(char *f, char stripext) +{ + char *t; + if ((t = strrchr(f, '/')) != NULL) { + t++; + } else { + t = f; + } + strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1); + prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0'; + + if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL) { + *t = '\0'; + } + return prog_inv_sh_nm_buf; +} +# endif +#endif + /* Structures and unions */ struct configuration_t { char *dhcpdconf_file;