[Box Backup-commit] COMMIT r1975 - in box/chris/general: . lib/server

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sat, 8 Dec 2007 23:44:18 +0000 (UTC)


Author: chris
Date: 2007-12-08 23:44:17 +0000 (Sat, 08 Dec 2007)
New Revision: 1975

Modified:
   box/chris/general/configure.ac
   box/chris/general/lib/server/Daemon.cpp
Log:
Fix getopt reset for solaris and maybe other platforms. See
http://lists.debian.org/debian-glibc/2004/10/msg00070.html.
(merges [1930] [1974] plus local change for Win32)


Modified: box/chris/general/configure.ac
===================================================================
--- box/chris/general/configure.ac	2007-12-08 23:40:29 UTC (rev 1974)
+++ box/chris/general/configure.ac	2007-12-08 23:44:17 UTC (rev 1975)
@@ -42,6 +42,11 @@
 AC_DEFINE_UNQUOTED([PERL_EXECUTABLE], ["$TARGET_PERL"], 
 	[Location of the perl executable])
 
+AC_CHECK_PROGS([AR],     [ar],    
+	[AC_MSG_ERROR([[cannot find ar executable]])])
+AC_CHECK_PROGS([RANLIB], [ranlib],
+	[AC_MSG_ERROR([[cannot find ranlib executable]])])
+
 ### Checks for libraries.
 
 case $target_os in
@@ -137,6 +142,7 @@
 
 AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, u_int64_t])
 AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t])
+
 AC_HEADER_STDBOOL
 AC_C_CONST
 AC_C_BIGENDIAN
@@ -146,15 +152,24 @@
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+
 AC_CHECK_MEMBERS([struct stat.st_flags])
 AC_CHECK_MEMBERS([struct stat.st_mtimespec])
 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,, [[
   #include <sys/types.h>
   #include <netinet/in.h>
   ]])
+
 AC_CHECK_DECLS([INFTIM],,, [[#include <poll.h>]])
 AC_CHECK_DECLS([SO_PEERCRED],,, [[#include <sys/socket.h>]])
 AC_CHECK_DECLS([O_BINARY],,,)
+
+AC_CHECK_DECLS([optreset],,, [[#include <getopt.h>]])
+AC_CHECK_DECL([dirfd],
+	[],
+	AC_DEFINE([dirfd(x)], [(x)->d_fd], [dirfd() replacement for Solaris]),
+	[#include <getopt.h>])
+
 AC_HEADER_TIME
 AC_STRUCT_TM
 AX_CHECK_DIRENT_D_TYPE

Modified: box/chris/general/lib/server/Daemon.cpp
===================================================================
--- box/chris/general/lib/server/Daemon.cpp	2007-12-08 23:40:29 UTC (rev 1974)
+++ box/chris/general/lib/server/Daemon.cpp	2007-12-08 23:44:17 UTC (rev 1975)
@@ -276,11 +276,13 @@
 	// reset getopt, just in case anybody used it before.
 	// unfortunately glibc and BSD differ on this point!
 	// http://www.ussg.iu.edu/hypermail/linux/kernel/0305.3/0262.html
-	#ifdef __GLIBC__
+	#if HAVE_DECL_OPTRESET == 1 || defined WIN32
+		optind = 1;
+		optreset = 1;
+	#elif defined __GLIBC__
 		optind = 0;
-	#else
+	#else // Solaris, any others?
 		optind = 1;
-		optreset = 1;
 	#endif
 
 	while((c = getopt(argc, (char * const *)argv,