diff options
Diffstat (limited to 'ext/mcve/mcve.c')
-rw-r--r-- | ext/mcve/mcve.c | 169 |
1 files changed, 140 insertions, 29 deletions
diff --git a/ext/mcve/mcve.c b/ext/mcve/mcve.c index eb7664278..bf5c9779d 100644 --- a/ext/mcve/mcve.c +++ b/ext/mcve/mcve.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mcve.c,v 1.28.2.2 2005/01/09 21:05:16 sniper Exp $ */ +/* $Id: mcve.c,v 1.28.2.5 2005/07/26 08:38:25 hyanantha Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -27,8 +27,6 @@ #if PHP_WIN32 #include "config.w32.h" -#elif defined NETWARE -#include "config.nw.h" #else #include <php_config.h> #endif @@ -62,6 +60,10 @@ function_entry mcve_functions[] = { PHP_FE(m_setdropfile, NULL) PHP_FE(m_setip, NULL) PHP_FE(m_setssl, NULL) +#if LIBMONETRA_VERSION >= 050000 + PHP_FE(m_setssl_cafile, NULL) + PHP_FE(m_responsekeys, NULL) +#endif PHP_FE(m_setssl_files, NULL) PHP_FE(m_settimeout, NULL) PHP_FE(m_setblocking, NULL) @@ -73,6 +75,10 @@ function_entry mcve_functions[] = { PHP_FE(m_connect, NULL) PHP_FE(m_transnew, NULL) PHP_FE(m_transparam, NULL) +#if LIBMONETRA_VERSION >= 050000 + PHP_FE(m_transkeyval, NULL) + PHP_FE(m_validateidentifier, NULL) +#endif PHP_FE(m_transsend, NULL) PHP_FE(m_ping, NULL) PHP_FE(m_responseparam, NULL) @@ -550,7 +556,7 @@ PHP_MINIT_FUNCTION(mcve) PHP_MINFO_FUNCTION(mcve) { php_info_print_table_start(); - php_info_print_table_row(2, "mcve support", "enabled"); + php_info_print_table_row(2, "mcve/monetra support", "enabled"); php_info_print_table_row(2, "version", PHP_MCVE_VERSION); php_info_print_table_end(); } @@ -589,6 +595,11 @@ PHP_FUNCTION(m_initconn) MCVE_InitConn(conn); +/* Since the identifiers are pointer addresses, we need to validate it by + * checking our linked list in PHP, since we don't want to cause segfaults */ +#if LIBMONETRA_VERSION >= 050000 + M_ValidateIdentifier(conn, 1); +#endif ZEND_REGISTER_RESOURCE(return_value, conn, le_conn); } /* }}} */ @@ -727,6 +738,31 @@ PHP_FUNCTION(m_setssl) } /* }}} */ +#if LIBMONETRA_VERSION >= 050000 +/* {{{ proto int m_setssl_cafile(resource conn, string cafile) + Set SSL CA (Certificate Authority) file for verification of server + certificate +*/ +PHP_FUNCTION(m_setssl_cafile) +{ + MCVE_CONN *conn; + int retval; + zval **arg1, **arg2; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) + WRONG_PARAM_COUNT; + + + ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection", le_conn); + convert_to_string_ex(arg2); + + retval = M_SetSSL_CAfile(conn, Z_STRVAL_PP(arg2)); + + RETURN_LONG(retval); +} +/* }}} */ +#endif + /* {{{ proto int m_setssl_files(resource conn, string sslkeyfile, string sslcertfile) Set certificate key files and certificates if server requires client certificate verification @@ -890,7 +926,7 @@ PHP_FUNCTION(m_connect) PHP_FUNCTION(m_connectionerror) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) @@ -903,7 +939,7 @@ PHP_FUNCTION(m_connectionerror) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -965,8 +1001,53 @@ PHP_FUNCTION(m_transnew) } /* }}} */ +#if LIBMONETRA_VERSION >= 050000 +/* {{{ proto int m_validateidentifier(resource conn, int tf) + Whether or not to validate the passed identifier on any transaction it is passed to +*/ +PHP_FUNCTION(m_validateidentifier) +{ + MCVE_CONN *conn; + int retval; + zval **arg1, **arg2; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) + WRONG_PARAM_COUNT; + + ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection", le_conn); + + convert_to_long_ex(arg2); + retval = M_ValidateIdentifier(conn, (int)Z_LVAL_PP(arg2)); + RETURN_LONG(retval); +} +/* }}} */ + +/* {{{ proto int m_transkeyval(resource conn, long identifier, string key, string value) + Add key/value pair to a transaction. Replaces deprecated transparam() */ +PHP_FUNCTION(m_transkeyval) +{ + MCVE_CONN *conn; + int retval; + zval **arg1, **arg2, **arg3, **arg4; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) + WRONG_PARAM_COUNT; + + ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection", le_conn); + + convert_to_long_ex(arg2); + convert_to_string_ex(arg3); + convert_to_string_ex(arg4); + + retval = M_TransKeyVal(conn, (long)Z_LVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_STRVAL_PP(arg4)); + + RETURN_LONG(retval); +} +/* }}} */ +#endif + /* {{{ proto int m_transparam(resource conn, long identifier, int key, ...) - Add a parameter to a transaction */ + Add a parameter to a transaction (deprecated) */ PHP_FUNCTION(m_transparam) { MCVE_CONN *conn; @@ -1076,7 +1157,7 @@ PHP_FUNCTION(m_transsend) PHP_FUNCTION(m_responseparam) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2, **arg3; if (ZEND_NUM_ARGS() != 3 || @@ -1093,17 +1174,47 @@ PHP_FUNCTION(m_responseparam) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); + } +} +/* }}} */ + +#if LIBMONETRA_VERSION >= 050000 +/* {{{ proto array m_responsekeys(resource conn, long identifier) + Returns array of strings which represents the keys that can be used + for response parameters on this transaction +*/ +PHP_FUNCTION(m_responsekeys) +{ + MCVE_CONN *conn; + char **retval; + int num_keys, i; + zval **arg1, **arg2; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) + WRONG_PARAM_COUNT; + + ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection", le_conn); + convert_to_long_ex(arg2); + + array_init(return_value); + + retval=M_ResponseKeys(conn, Z_LVAL_PP(arg2), &num_keys); + if (retval != NULL) { + for (i=0; i<num_keys; i++) + add_next_index_string(return_value, retval[i], 1); + M_FreeResponseKeys(retval, num_keys); } } /* }}} */ +#endif /* {{{ proto string m_getuserparam(resource conn, long identifier, int key) Get a user response parameter */ PHP_FUNCTION(m_getuserparam) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2, **arg3; if (ZEND_NUM_ARGS() != 3 || @@ -1120,7 +1231,7 @@ PHP_FUNCTION(m_getuserparam) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -1279,7 +1390,7 @@ PHP_FUNCTION(m_transactionid) PHP_FUNCTION(m_transactionauth) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) @@ -1294,7 +1405,7 @@ PHP_FUNCTION(m_transactionauth) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -1304,7 +1415,7 @@ PHP_FUNCTION(m_transactionauth) PHP_FUNCTION(m_transactiontext) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) @@ -1318,7 +1429,7 @@ PHP_FUNCTION(m_transactiontext) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -1877,7 +1988,7 @@ PHP_FUNCTION(m_bt) PHP_FUNCTION(m_getcell) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2, **arg3, **arg4; if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) @@ -1894,7 +2005,7 @@ PHP_FUNCTION(m_getcell) if (retval == NULL) { RETURN_STRING("", 1); } else { - RETURN_STRING(retval, 1); + RETURN_STRING(estrdup(retval), 0); } } /* }}} */ @@ -1904,7 +2015,7 @@ PHP_FUNCTION(m_getcell) PHP_FUNCTION(m_getcellbynum) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2, **arg3, **arg4; if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) @@ -1921,7 +2032,7 @@ PHP_FUNCTION(m_getcellbynum) if (retval == NULL) { RETURN_STRING("", 1); } else { - RETURN_STRING(retval, 1); + RETURN_STRING(estrdup(retval), 0); } } /* }}} */ @@ -2015,7 +2126,7 @@ PHP_FUNCTION(m_parsecommadelimited) PHP_FUNCTION(m_getcommadelimited) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) @@ -2027,7 +2138,7 @@ PHP_FUNCTION(m_getcommadelimited) retval = MCVE_GetCommaDelimited(conn, Z_LVAL_PP(arg2)); - RETURN_STRING(retval, 1); + RETURN_STRING(estrdup(retval), 0); } /* }}} */ @@ -2036,7 +2147,7 @@ PHP_FUNCTION(m_getcommadelimited) PHP_FUNCTION(m_getheader) { MCVE_CONN *conn; - char *retval; + const char *retval; zval **arg1, **arg2, **arg3; if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) @@ -2049,7 +2160,7 @@ PHP_FUNCTION(m_getheader) retval = MCVE_GetHeader(conn, Z_LVAL_PP(arg2), Z_LVAL_PP(arg3)); - RETURN_STRING(retval, 1); + RETURN_STRING(estrdup(retval), 0); } /* }}} */ @@ -2337,7 +2448,7 @@ PHP_FUNCTION(m_uwait) Get a textual representation of the return_code */ PHP_FUNCTION(m_text_code) { - char *retval; + const char *retval; zval **arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) @@ -2350,7 +2461,7 @@ PHP_FUNCTION(m_text_code) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -2359,7 +2470,7 @@ PHP_FUNCTION(m_text_code) Get a textual representation of the return_avs */ PHP_FUNCTION(m_text_avs) { - char *retval; + const char *retval; zval **arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) @@ -2372,7 +2483,7 @@ PHP_FUNCTION(m_text_avs) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ @@ -2381,7 +2492,7 @@ PHP_FUNCTION(m_text_avs) Get a textual representation of the return_cv */ PHP_FUNCTION(m_text_cv) { - char *retval; + const char *retval; zval **arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) @@ -2394,7 +2505,7 @@ PHP_FUNCTION(m_text_cv) if (retval == NULL) { RETVAL_STRING("",1); } else { - RETVAL_STRING(retval, 1); + RETVAL_STRING(estrdup(retval), 0); } } /* }}} */ |