diff options
author | foobar <sniper@php.net> | 2003-07-16 09:28:47 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2003-07-16 09:28:47 +0000 |
commit | 704a7e5653d5c1872482115c871cb3eaf00c2c96 (patch) | |
tree | deb625d15ebd92c2098c6b749b472f6b6fc74d66 /ext/snmp | |
parent | e10dbc607c49def182dc7631cf87005271bc4be7 (diff) | |
download | php-git-704a7e5653d5c1872482115c871cb3eaf00c2c96.tar.gz |
- Added snmp_read_mib() which reads a MIB file into the active MIB tree.
Diffstat (limited to 'ext/snmp')
-rw-r--r-- | ext/snmp/php_snmp.h | 3 | ||||
-rw-r--r-- | ext/snmp/snmp.c | 27 |
2 files changed, 30 insertions, 0 deletions
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 /* |