On 17/07/07, Wes Hardaker <[EMAIL PROTECTED]> wrote:
Well, we're in various states of partial agreement.  So I punted and
released rc3 as is.

Wimp!

                         I don't mind doing an immediate rc4 if we get a
patch everyone agrees on.

I offer the following (two-patch) patch for consideration.
  The first part adds checks for 'chown()' and 'localtime_r()'
functions to the configure mechanism.
  The second part uses the results of these checks to
handle the two code fragments that triggered the problem.

This patch allows things to compile successfully under MinGW.

Dave
Index: configure.in
===================================================================
--- configure.in	(revision 16592)
+++ configure.in	(working copy)
@@ -3668,6 +3668,8 @@
 AC_CHECK_FUNCS(mktime stime times sysconf)
 # missing from hp-ux
 AC_CHECK_FUNCS(if_nametoindex)
+# missing from MinGW
+AC_CHECK_FUNCS(chown localtime_r)
 
 AC_MSG_CHECKING([[for SIOCGIFADDR in sys/ioctl.h]])
 AC_CACHE_VAL(cv_sys_ioctl_h_has_SIOCGIFADDR,
Index: configure
===================================================================
--- configure	(revision 16592)
+++ configure	(working copy)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 16579 .
+# From configure.in Revision: 16585 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for Net-SNMP 5.4.1.rc1.
 #
@@ -41349,7 +41349,111 @@
 fi
 done
 
+# missing from MinGW
 
+
+for ac_func in chown localtime_r
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
 echo "$as_me:$LINENO: checking for SIOCGIFADDR in sys/ioctl.h" >&5
 echo $ECHO_N "checking for SIOCGIFADDR in sys/ioctl.h... $ECHO_C" >&6
 if test "${cv_sys_ioctl_h_has_SIOCGIFADDR+set}" = set; then
Index: include/net-snmp/net-snmp-config.h.in
===================================================================
--- include/net-snmp/net-snmp-config.h.in	(revision 16592)
+++ include/net-snmp/net-snmp-config.h.in	(working copy)
@@ -296,6 +296,9 @@
 /* Define to 1 if you have the `cgetnext' function. */
 #undef HAVE_CGETNEXT
 
+/* Define to 1 if you have the `chown' function. */
+#undef HAVE_CHOWN
+
 /* Define to 1 if the system has the type `Counter64'. */
 #undef HAVE_COUNTER64
 
@@ -489,6 +492,9 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
+/* Define to 1 if you have the `localtime_r' function. */
+#undef HAVE_LOCALTIME_R
+
 /* Define to 1 if you have the `lrand48' function. */
 #undef HAVE_LRAND48
 
Index: agent/snmpd.c
===================================================================
--- agent/snmpd.c	(revision 16592)
+++ agent/snmpd.c	(working copy)
@@ -949,8 +949,10 @@
     gid = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID, 
 			     NETSNMP_DS_AGENT_GROUPID);
     
+#ifdef HAVE_CHOWN
     if ( uid != 0 || gid != 0 )
         chown( cptr, uid, gid );
+#endif
 
 #ifdef HAVE_SETGID
     if ((gid = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID, 
Index: agent/mibgroup/disman/schedule/schedCore.c
===================================================================
--- agent/mibgroup/disman/schedule/schedCore.c	(revision 16592)
+++ agent/mibgroup/disman/schedule/schedCore.c	(working copy)
@@ -239,6 +239,20 @@
 }
 
 
+#ifndef HAVE_LOCALTIME_R
+struct tm *
+localtime_r(const time_t *timep, struct tm *result) {
+    struct tm *tmp;
+
+    tmp = localtime( timep );
+    if ( tmp && result ) {
+        memcpy( result, tmp, sizeof(struct tm));
+    }
+
+    return (tmp ? result : NULL );
+}
+#endif
+
 /*
  * determine the time for the next scheduled action of a given entry
  */
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to