[PHP4BETA] CVS update: php4/functions

From: Date: Wed, 21 Apr 1999 17:11:01 +0000
Subject: [PHP4BETA] CVS update: php4/functions
Groups: php.version4 
Request: Send a blank email to php-version4+get-229@lists.php.net to get a copy of this message
Date: Wednesday April 21, 1999 @ 13:11 Author: sas Update of /repository/php4/functions In directory php:/tmp/cvs-serv10645/functions Modified Files: msql.c php3_snmp.h snmp.c Log Message: port some fixes, add compat routines Index: php4/functions/msql.c diff -c php4/functions/msql.c:1.4 php4/functions/msql.c:1.5 *** php4/functions/msql.c:1.4 Fri Apr 16 20:37:10 1999 --- php4/functions/msql.c Wed Apr 21 13:11:01 1999 *************** *** 27,33 **** +----------------------------------------------------------------------+ */ ! /* $Id: msql.c,v 1.4 1999/04/17 00:37:10 ssb Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif --- 27,33 ---- +----------------------------------------------------------------------+ */ ! /* $Id: msql.c,v 1.5 1999/04/21 17:11:01 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif *************** *** 95,105 **** --- 95,111 ---- {"msql_fetch_field", php3_msql_fetch_field, NULL}, {"msql_field_seek", php3_msql_field_seek, NULL}, {"msql_free_result", php3_msql_free_result, NULL}, + {"msql_field_name", php3_msql_field_name, NULL}, + {"msql_field_table", php3_msql_field_table, NULL}, + {"msql_field_len", php3_msql_field_len, NULL}, + {"msql_field_type", php3_msql_field_type, NULL}, + {"msql_field_flags", php3_msql_field_flags, NULL}, {"msql_fieldname", php3_msql_field_name, NULL}, {"msql_fieldtable", php3_msql_field_table, NULL}, {"msql_fieldlen", php3_msql_field_len, NULL}, {"msql_fieldtype", php3_msql_field_type, NULL}, {"msql_fieldflags", php3_msql_field_flags, NULL}, + {"msql_regcase", php3_sql_regcase, NULL}, {"msql_affected_rows", php3_msql_affected_rows, NULL}, /* for downwards compatability */ Index: php4/functions/php3_snmp.h diff -c php4/functions/php3_snmp.h:1.1.1.1 php4/functions/php3_snmp.h:1.2 *** php4/functions/php3_snmp.h:1.1.1.1 Wed Apr 7 17:04:29 1999 --- php4/functions/php3_snmp.h Wed Apr 21 13:11:01 1999 *************** *** 26,32 **** | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: php3_snmp.h,v 1.1.1.1 1999/04/07 21:04:29 zeev Exp $ */ #ifndef _PHP3_SNMP_H #define _PHP3_SNMP_H --- 26,32 ---- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: php3_snmp.h,v 1.2 1999/04/21 17:11:01 sas Exp $ */ #ifndef _PHP3_SNMP_H #define _PHP3_SNMP_H *************** *** 43,50 **** #define snmp_module_ptr &snmp_module_entry extern int php3i_snmp_init(INIT_FUNC_ARGS); ! extern void php3_snmpget(INTERNAL_FUNCTION_PARAMETERS); ! extern void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS); extern void php3_info_snmp(void); #else --- 43,51 ---- #define snmp_module_ptr &snmp_module_entry extern int php3i_snmp_init(INIT_FUNC_ARGS); ! extern PHP_FUNCTION(snmpget); ! extern PHP_FUNCTION(snmpwalk); ! extern PHP_FUNCTION(snmprealwalk); extern void php3_info_snmp(void); #else Index: php4/functions/snmp.c diff -c php4/functions/snmp.c:1.1.1.1 php4/functions/snmp.c:1.2 *** php4/functions/snmp.c:1.1.1.1 Wed Apr 7 17:04:36 1999 --- php4/functions/snmp.c Wed Apr 21 13:11:01 1999 *************** *** 26,32 **** | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: snmp.c,v 1.1.1.1 1999/04/07 21:04:36 zeev Exp $ */ #include "php.h" #if defined(COMPILE_DL) --- 26,32 ---- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: snmp.c,v 1.2 1999/04/21 17:11:01 sas Exp $ */ #include "php.h" #if defined(COMPILE_DL) *************** *** 83,90 **** void sprint_variable(char *, oid *, int, struct variable_list *); function_entry snmp_functions[] = { ! {"snmpget", php3_snmpget, NULL}, ! {"snmpwalk", php3_snmpwalk, NULL}, {NULL,NULL,NULL} }; --- 83,91 ---- void sprint_variable(char *, oid *, int, struct variable_list *); function_entry snmp_functions[] = { ! PHP_FE(snmpget, NULL) ! PHP_FE(snmpwalk, NULL) ! PHP_FE(snmprealwalk, NULL) {NULL,NULL,NULL} }; *************** *** 113,118 **** --- 114,120 ---- * * st=1 GET * st=2 WALK + * st=3 WALK (returns OIDs additionally) */ void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) { pval *a1, *a2, *a3, *a4, *a5; *************** *** 125,130 **** --- 127,133 ---- int status, count,rootlen=0,gotroot=0; oid root[MAX_NAME_LEN]; char buf[2048]; + char buf2[2048]; int keepwalking=1; long timeout=SNMP_DEFAULT_TIMEOUT; long retries=SNMP_DEFAULT_RETRIES; *************** *** 146,152 **** } objid=a3->value.str.val; ! if (st==2) { /* walk */ rootlen = MAX_NAME_LEN; if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */ if (read_objid(objid, root, &rootlen)) { --- 149,155 ---- } objid=a3->value.str.val; ! if (st>=2) { /* walk */ rootlen = MAX_NAME_LEN; if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */ if (read_objid(objid, root, &rootlen)) { *************** *** 166,172 **** session.peername = a1->value.str.val; session.version = SNMP_VERSION_1; ! session.community = (u_char *)a2->value.str.val; session.community_len = a2->value.str.len; session.retries = retries; session.timeout = timeout; --- 169,181 ---- session.peername = a1->value.str.val; session.version = SNMP_VERSION_1; ! /* ! * FIXME: potential memory leak ! * This is a workaround for an "artifact" (Mike Slifcak) ! * in (at least) ucd-snmp 3.6.1 which frees ! * memory it did not allocate ! */ ! session.community = (u_char *) strdup(a2->value.str.val); session.community_len = a2->value.str.len; session.retries = retries; session.timeout = timeout; *************** *** 178,184 **** php3_error(E_WARNING,"Couldn't open snmp\n"); RETURN_FALSE; } ! if (st==2) { memmove((char *)name, (char *)root, rootlen * sizeof(oid)); name_length = rootlen; /* prepare result array */ --- 187,193 ---- php3_error(E_WARNING,"Couldn't open snmp\n"); RETURN_FALSE; } ! if (st>=2) { memmove((char *)name, (char *)root, rootlen * sizeof(oid)); name_length = rootlen; /* prepare result array */ *************** *** 188,194 **** while(keepwalking) { keepwalking=0; if (st==1) pdu = snmp_pdu_create(SNMP_MSG_GET); ! else if (st==2) pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); if (st==1) { name_length = MAX_NAME_LEN; --- 197,203 ---- while(keepwalking) { keepwalking=0; if (st==1) pdu = snmp_pdu_create(SNMP_MSG_GET); ! else if (st>=2) pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); if (st==1) { name_length = MAX_NAME_LEN; *************** *** 204,210 **** if (status == STAT_SUCCESS) { if (response->errstat == SNMP_ERR_NOERROR) { for(vars = response->variables; vars; vars = vars->next_variable) { ! if (st==2 && (vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid)))) continue; /* not part of this subtree */ sprint_value(buf,vars->name, vars->name_length, vars); --- 213,219 ---- if (status == STAT_SUCCESS) { if (response->errstat == SNMP_ERR_NOERROR) { for(vars = response->variables; vars; vars = vars->next_variable) { ! if (st>=2 && (vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid)))) continue; /* not part of this subtree */ sprint_value(buf,vars->name, vars->name_length, vars); *************** *** 216,221 **** --- 225,235 ---- } else if (st==2) { /* Add to returned array */ add_next_index_string(return_value,buf,1); + } else if (st==3) { + sprint_objid(buf2, name, name_length); + add_assoc_string(return_value,buf2,buf,1); + } + if (st>=2) { if (vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT && vars->type != SNMP_NOSUCHINSTANCE) { memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); name_length = vars->name_length; *************** *** 234,240 **** } if (st==1) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) goto retry; ! } else if (st==2) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) goto retry; } RETURN_FALSE; --- 248,254 ---- } if (st==1) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) goto retry; ! } else if (st>=2) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) goto retry; } RETURN_FALSE; *************** *** 263,268 **** --- 277,290 ---- Return all objects under the specified object id */ void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS) { return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2); + } + /* }}} */ + + /* {{{ proto string snmprealwalk(string host, string community, string object_id [, int timeout [, int retries]]) + Return all objects including their respective object id withing the specified one */ + PHP_FUNCTION(snmprealwalk) + { + return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3); } /* }}} */ -- PHP 4 Beta

« previous php.version4 (#229) next »