sniper          Wed Jul 16 05:28:48 2003 EDT

  Modified files:              
    /php-src/ext/snmp   php_snmp.h snmp.c 
  Log:
  - Added snmp_read_mib() which reads a MIB file into the active MIB tree. 
  
  
Index: php-src/ext/snmp/php_snmp.h
diff -u php-src/ext/snmp/php_snmp.h:1.20 php-src/ext/snmp/php_snmp.h:1.21
--- php-src/ext/snmp/php_snmp.h:1.20    Mon Jul 14 14:10:22 2003
+++ php-src/ext/snmp/php_snmp.h Wed Jul 16 05:28:47 2003
@@ -20,7 +20,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_snmp.h,v 1.20 2003/07/14 18:10:22 harrie Exp $ */
+/* $Id: php_snmp.h,v 1.21 2003/07/16 09:28:47 sniper Exp $ */
 
 #ifndef PHP_SNMP_H
 #define PHP_SNMP_H
@@ -59,6 +59,9 @@
 
 PHP_FUNCTION(snmp_set_valueretrieval);
 PHP_FUNCTION(snmp_get_valueretrieval);
+
+PHP_FUNCTION(snmp_read_mib);
+
 
 ZEND_BEGIN_MODULE_GLOBALS(snmp)
       int valueretrieval;
Index: php-src/ext/snmp/snmp.c
diff -u php-src/ext/snmp/snmp.c:1.83 php-src/ext/snmp/snmp.c:1.84
--- php-src/ext/snmp/snmp.c:1.83        Wed Jul 16 02:03:46 2003
+++ php-src/ext/snmp/snmp.c     Wed Jul 16 05:28:47 2003
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: snmp.c,v 1.83 2003/07/16 06:03:46 sniper Exp $ */
+/* $Id: snmp.c,v 1.84 2003/07/16 09:28:47 sniper Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -136,6 +136,8 @@
        PHP_FE(snmp3_set, NULL)
        PHP_FE(snmp_set_valueretrieval, NULL)
        PHP_FE(snmp_get_valueretrieval, NULL)
+
+       PHP_FE(snmp_read_mib, NULL)
        {NULL,NULL,NULL}
 };
 /* }}} */
@@ -1053,6 +1055,31 @@
 PHP_FUNCTION(snmp_get_valueretrieval)
 {
        RETURN_LONG(SNMP_G(valueretrieval));
+}
+/* }}} */
+
+/* {{{ proto int snmp_read_mib(string filename)
+   Reads and parses a MIB file into the active MIB tree. */
+PHP_FUNCTION(snmp_read_mib)
+{
+       zval **filename;
+
+       if (ZEND_NUM_ARGS() != 1 ||
+               zend_get_parameters_ex(ZEND_NUM_ARGS(), &filename) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       convert_to_string_ex(filename);
+
+       /* Prevent read_mib() from printing any errors. */
+       snmp_disable_stderrlog();
+       
+       if (!read_mib(Z_STRVAL_PP(filename))) {
+               char *error = strerror(errno);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading MIB 
file '%s': %s", Z_STRVAL_PP(filename), error);
+               RETURN_FALSE;
+       }
+       RETURN_TRUE;
 }
 /* }}} */
 



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

Reply via email to