]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use paths.h when available and ensure that we can disable our glue easily.
authorRoy Marples <roy@marples.name>
Thu, 15 May 2008 16:30:16 +0000 (16:30 +0000)
committerRoy Marples <roy@marples.name>
Thu, 15 May 2008 16:30:16 +0000 (16:30 +0000)
common.c
common.h

index cad633eef57569154ea426e546452e17e26c7fa5..93a35d02d1472bad3458cea17dc6827550cfeab6 100644 (file)
--- a/common.c
+++ b/common.c
  * SUCH DAMAGE.
  */
 
+#include <sys/param.h>
 #include <sys/time.h>
 
 #include <errno.h>
 #include <fcntl.h>
+#ifdef BSD
+#  include <paths.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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));
index 90d84fe9db011e5ccf770bad7850e67082288202..f11053212f35c7c9bdfa541224809264915a739c 100644 (file)
--- a/common.h
+++ b/common.h
 # 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);