From: Roy Marples Date: Thu, 15 May 2008 16:30:16 +0000 (+0000) Subject: Use paths.h when available and ensure that we can disable our glue easily. X-Git-Tag: v4.0.2~390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72bda00bdcb980720a94f662471d6b524f925e16;p=thirdparty%2Fdhcpcd.git Use paths.h when available and ensure that we can disable our glue easily. --- diff --git a/common.c b/common.c index cad633ee..93a35d02 100644 --- a/common.c +++ b/common.c @@ -25,10 +25,14 @@ * SUCH DAMAGE. */ +#include #include #include #include +#ifdef BSD +# include +#endif #include #include #include @@ -69,7 +73,8 @@ get_line(char **line, size_t *len, FILE *fp) /* OK, this should be in dhcpcd.c * It's here to make dhcpcd more readable */ -#ifndef HAVE_SRANDOMDEV +#if HAVE_SRANDOMDEV +#else void srandomdev(void) { int fd; @@ -86,7 +91,8 @@ void srandomdev(void) #endif /* strlcpy is nice, shame glibc does not define it */ -#ifndef HAVE_STRLCPY +#if HAVE_STRLCPY +#else size_t strlcpy(char *dst, const char *src, size_t size) { @@ -109,7 +115,8 @@ strlcpy(char *dst, const char *src, size_t size) } #endif -#ifndef HAVE_CLOSEFROM +#if HAVE_CLOSEFROM +#else int closefrom(int fd) { @@ -129,7 +136,7 @@ close_fds(void) { int fd; - if ((fd = open("/dev/null", O_RDWR)) == -1) + if ((fd = open(_PATH_DEVNULL, O_RDWR)) == -1) return -1; dup2(fd, fileno(stdin)); diff --git a/common.h b/common.h index 90d84fe9..f1105321 100644 --- a/common.h +++ b/common.h @@ -40,22 +40,28 @@ # define _unused #endif -#define HAVE_STRLCPY +#ifndef HAVE_STRLCPY +# define HAVE_STRLCPY 1 +#endif /* Only GLIBC doesn't support strlcpy */ #ifdef __GLIBC__ -# if ! defined(__UCLIBC__) && ! defined (__dietlibc__) +# if !defined(__UCLIBC__) && !defined (__dietlibc__) # undef HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); # endif #endif -#define HAVE_SRANDOMDEV +#ifndef HAVE_SRANDOMDEV +# define HAVE_SRANDOMDEV 1 +#endif #if defined(__GLIBC__) || defined(__NetBSD__) # undef HAVE_SRANDOMDEV void srandomdev(void); #endif -#define HAVE_CLOSEFROM +#ifndef HAVE_CLOSEFROM +#define HAVE_CLOSEFROM 1 +#endif #if defined(__linux__) || defined(__FreeBSD__) # undef HAVE_CLOSEFROM int closefrom(int);