sniper          Mon Oct 14 20:43:34 2002 EDT

  Modified files:              
    /php4/ext/snmp      config.m4 snmp.c 
  Log:
  Make this thing to compile with net-snmp-5.0.x
  
  
Index: php4/ext/snmp/config.m4
diff -u php4/ext/snmp/config.m4:1.26 php4/ext/snmp/config.m4:1.27
--- php4/ext/snmp/config.m4:1.26        Sat Jun  1 16:14:58 2002
+++ php4/ext/snmp/config.m4     Mon Oct 14 20:43:34 2002
@@ -1,11 +1,38 @@
 dnl
-dnl $Id: config.m4,v 1.26 2002/06/01 20:14:58 sr Exp $
+dnl $Id: config.m4,v 1.27 2002/10/15 00:43:34 sniper Exp $
 dnl
 
 PHP_ARG_WITH(snmp,for SNMP support,
 [  --with-snmp[=DIR]       Include SNMP support.])
 
-  if test "$PHP_SNMP" != "no"; then
+if test "$PHP_SNMP" != "no"; then
+
+  dnl
+  dnl Try net-snmp first
+  dnl
+  if test "$PHP_SNMP" = "yes"; then
+    AC_PATH_PROG(SNMP_CONFIG,net-snmp-config,,[/usr/local/bin:$PATH])
+  else
+    SNMP_CONFIG="$PHP_SNMP/bin/net-snmp-config"
+  fi
+
+  if test -x "$SNMP_CONFIG"; then
+    SNMP_LIBS=`$SNMP_CONFIG --netsnmp-libs`
+    SNMP_LIBS="$SNMP_LIBS `$SNMP_CONFIG --external-libs`"
+    SNMP_PREFIX=`$SNMP_CONFIG --prefix`
+
+    if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then
+      PHP_ADD_INCLUDE(${SNMP_PREFIX}/include)
+      PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD)
+      AC_DEFINE(HAVE_NET_SNMP,1,[ ])
+    else
+      AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp 
+installation.])
+    fi
+  else 
+
+    dnl
+    dnl Try ucd-snmp if net-snmp test failed
+    dnl
 
     if test "$PHP_SNMP" = "yes"; then
       for i in /usr/include /usr/local/include; do
@@ -60,14 +87,14 @@
     fi
 
     AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ])
-
-    AC_DEFINE(HAVE_SNMP,1,[ ])
     PHP_ADD_INCLUDE($SNMP_INCDIR)
     PHP_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD)
-
-    PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
-    PHP_SUBST(SNMP_SHARED_LIBADD)
   fi
+
+  PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
+  PHP_SUBST(SNMP_SHARED_LIBADD)
+  AC_DEFINE(HAVE_SNMP,1,[ ])
+fi
 
 
 AC_MSG_CHECKING(whether to enable UCD SNMP hack)
Index: php4/ext/snmp/snmp.c
diff -u php4/ext/snmp/snmp.c:1.61 php4/ext/snmp/snmp.c:1.62
--- php4/ext/snmp/snmp.c:1.61   Sun Oct 13 22:46:52 2002
+++ php4/ext/snmp/snmp.c        Mon Oct 14 20:43:34 2002
@@ -17,7 +17,7 @@
 |          Steven Lawrance <[EMAIL PROTECTED]>                |
 +----------------------------------------------------------------------+
 */
-/* $Id: snmp.c,v 1.61 2002/10/14 02:46:52 sniper Exp $ */
+/* $Id: snmp.c,v 1.62 2002/10/15 00:43:34 sniper Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,6 +26,9 @@
 #include "php.h"
 #include "ext/standard/info.h"
 #include "php_snmp.h"
+
+#if HAVE_SNMP
+
 #include <sys/types.h>
 #ifdef PHP_WIN32
 #include <winsock.h>
@@ -60,7 +63,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#if HAVE_SNMP
 
 #ifndef __P
 #ifdef __GNUC__
@@ -70,6 +72,11 @@
 #endif
 #endif
 
+#ifdef HAVE_NET_SNMP
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#define VersionInfo NetSnmpVersionInfo
+#else
 #ifdef HAVE_DEFAULT_STORE_H
 #include "default_store.h"
 #endif
@@ -81,6 +88,7 @@
 #include "parse.h"
 #include "mib.h"
 #include "version.h"
+#endif
 
 /* ucd-snmp 3.3.1 changed the name of a few #defines... They've been changed back to 
the original ones in 3.5.3! */
 #ifndef SNMP_MSG_GET
@@ -329,7 +337,11 @@
                                        }
 
                                        if (st != 11) {
-                                               sprint_value((struct sbuf 
*)buf,vars->name, vars->name_length, vars);
+#ifdef HAVE_NET_SNMP
+                                               snprint_value(buf, strlen(buf), 
+vars->name, vars->name_length, vars);
+#else
+                                               sprint_value((struct sbuf *) 
+buf,vars->name, vars->name_length, vars);
+#endif
                                        }
 
                                        if (st == 1) {
@@ -337,7 +349,11 @@
                                        } else if (st == 2) {
                                                
add_next_index_string(return_value,buf,1); /* Add to returned array */
                                        } else if (st == 3)  {
+#ifdef HAVE_NET_SNMP
+                                               snprint_objid(buf2, strlen(buf2), 
+vars->name, vars->name_length);
+#else
                                                sprint_objid((struct sbuf *)buf2, 
vars->name, vars->name_length);
+#endif
                                                
add_assoc_string(return_value,buf2,buf,1);
                                        }
                                        if (st >= 2 && st != 11) {
@@ -356,7 +372,11 @@
                                                for (count=1, vars = 
response->variables; vars && count != response->errindex;
                                                vars = vars->next_variable, count++);
                                                if (vars) {
+#ifdef HAVE_NET_SNMP
+                                                       snprint_objid(buf, 
+strlen(buf), vars->name, vars->name_length);
+#else
                                                        sprint_objid((struct sbuf 
*)buf,vars->name, vars->name_length);
+#endif
                                                }
                                                php_error(E_WARNING,"This name does 
not exist: %s\n",buf);
                                        }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to