From: foobar Date: Wed, 16 Jul 2003 09:28:47 +0000 (+0000) Subject: - Added snmp_read_mib() which reads a MIB file into the active MIB tree. X-Git-Tag: BEFORE_ARG_INFO~223 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=704a7e5653d5c1872482115c871cb3eaf00c2c96;p=php - Added snmp_read_mib() which reads a MIB file into the active MIB tree. --- diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h index 1cb69fbd90..4ad5791e81 100644 --- a/ext/snmp/php_snmp.h +++ b/ext/snmp/php_snmp.h @@ -60,6 +60,9 @@ PHP_FUNCTION(snmp3_set); PHP_FUNCTION(snmp_set_valueretrieval); PHP_FUNCTION(snmp_get_valueretrieval); +PHP_FUNCTION(snmp_read_mib); + + ZEND_BEGIN_MODULE_GLOBALS(snmp) int valueretrieval; ZEND_END_MODULE_GLOBALS(snmp) diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 5b322802aa..8ab63897f3 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -136,6 +136,8 @@ function_entry snmp_functions[] = { 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} }; /* }}} */ @@ -1056,6 +1058,31 @@ PHP_FUNCTION(snmp_get_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; +} +/* }}} */ + #endif /*