Browse Source

- Added snmp_read_mib() which reads a MIB file into the active MIB tree.

PEAR_1_4DEV
foobar 23 years ago
parent
commit
704a7e5653
  1. 3
      ext/snmp/php_snmp.h
  2. 27
      ext/snmp/snmp.c

3
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)

27
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
/*

Loading…
Cancel
Save