Skip to content

Commit 2b0df36

Browse files
committed
MFH: New parameter parsing API
1 parent 57b9a64 commit 2b0df36

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

ext/snmp/winsnmp.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,32 @@ DLEXPORT zend_module_entry *get_module() { return &snmp_module_entry; }
5757

5858
/* {{{ _php_snmp
5959
*/
60-
void _php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
61-
zval *a1, *a2, *a3;
62-
INT operation;
63-
LPSTR agent;
64-
LPSTR community;
65-
RFC1157VarBindList variableBindings;
66-
LPSNMP_MGR_SESSION session;
67-
68-
INT timeout = TIMEOUT;
69-
INT retries = RETRIES;
70-
71-
BYTE requestType;
72-
AsnInteger errorStatus;
73-
AsnInteger errorIndex;
74-
AsnObjectIdentifier oid;
75-
char *chkPtr = NULL;
76-
77-
if (zend_get_parameters_ex(3, &a1, &a2, &a3) == FAILURE) {
78-
WRONG_PARAM_COUNT;
60+
void _php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st)
61+
{
62+
INT operation;
63+
64+
RFC1157VarBindList variableBindings;
65+
LPSNMP_MGR_SESSION session;
66+
67+
char *agent, *community, *object_id;
68+
int agent_len, community_len, object_id_len;
69+
70+
INT timeout = TIMEOUT;
71+
INT retries = RETRIES;
72+
73+
BYTE requestType;
74+
AsnInteger errorStatus;
75+
AsnInteger errorIndex;
76+
AsnObjectIdentifier oid;
77+
78+
char *chkPtr = NULL;
79+
80+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &agent, &agent_len, &community, &community_len, &object_id, &object_id_len) == FAILURE) {
81+
return;
7982
}
80-
convert_to_string_ex(a1);
81-
convert_to_string_ex(a2);
82-
convert_to_string_ex(a3);
83-
84-
agent=Z_STRVAL_PP(a1);
85-
community=Z_STRVAL_PP(a2);
86-
operation=st;
87-
SnmpMgrStrToOid(Z_STRVAL_PP(a3), &oid);
83+
84+
operation = st;
85+
SnmpMgrStrToOid(object_id, &oid);
8886

8987
/*
9088
I've limited this to only one oid, but we can create a

0 commit comments

Comments
 (0)