summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad House <bradmssw@php.net>2002-02-27 19:46:59 +0000
committerBrad House <bradmssw@php.net>2002-02-27 19:46:59 +0000
commit20219b1e24ac1360bc2e4dcc60117691949d95b0 (patch)
treecea0a2b2aac0d5eed03edd28b85a082f9f7d66a5
parent313a3602bb8c25b1a060bd5cfae87d546f32ccf2 (diff)
downloadphp-git-20219b1e24ac1360bc2e4dcc60117691949d95b0.tar.gz
Initial MCVE extension added (Credit Card Processing)
-rw-r--r--ext/mcve/CREDITS8
-rw-r--r--ext/mcve/Makefile.in8
-rw-r--r--ext/mcve/config.m425
-rw-r--r--ext/mcve/mcve.c1846
-rw-r--r--ext/mcve/mcve.php12
-rw-r--r--ext/mcve/php_mcve.h89
-rw-r--r--ext/mcve/tests/001.phpt23
-rw-r--r--ext/mcve/tests/mcve_simple_test.php19
-rw-r--r--ext/mcve/tests/mcve_test1.php83
-rw-r--r--ext/mcve/tests/mcve_test2.php68
10 files changed, 2181 insertions, 0 deletions
diff --git a/ext/mcve/CREDITS b/ext/mcve/CREDITS
new file mode 100644
index 0000000000..6db49c69ca
--- /dev/null
+++ b/ext/mcve/CREDITS
@@ -0,0 +1,8 @@
+Authors:
+Brad House <brad@mainstreetsoftworks.com>
+Chris Faulhaber <jedgar@fxp.org>
+
+BugFixes:
+- Memory leak when mcve_destroyconn() not called:
+ Steven Schoch <cardhelp@starnet.com>
+
diff --git a/ext/mcve/Makefile.in b/ext/mcve/Makefile.in
new file mode 100644
index 0000000000..30aaba8bda
--- /dev/null
+++ b/ext/mcve/Makefile.in
@@ -0,0 +1,8 @@
+# $Id$
+
+LTLIBRARY_NAME = libmcve.la
+LTLIBRARY_SOURCES = mcve.c
+LTLIBRARY_SHARED_NAME = mcve.la
+LTLIBRARY_SHARED_LIBADD = $(MCVE_SHARED_LIBADD)
+
+include $(top_srcdir)/build/dynlib.mk
diff --git a/ext/mcve/config.m4 b/ext/mcve/config.m4
new file mode 100644
index 0000000000..62d4f7e391
--- /dev/null
+++ b/ext/mcve/config.m4
@@ -0,0 +1,25 @@
+dnl config.m4 for PHP4 MCVE Extension
+
+PHP_ARG_WITH(mcve, for MCVE support,
+[ --with-mcve[=DIR] Include MCVE support])
+
+if test "$PHP_MCVE" != "no"; then
+ if test -r $PHP_MCVE/include/mcve.h; then
+ MCVE_DIR=$PHP_MCVE
+ else
+ for i in /usr /usr/local /usr/local/mcve ; do
+ if test -r $i/include/mcve.h; then
+ MCVE_DIR=$i
+ fi
+ done
+ fi
+
+ if test -z "$MCVE_DIR"; then
+ AC_MSG_ERROR(not found. Please check your MCVE installation; mcve.h NOT FOUND)
+ fi
+
+ PHP_ADD_INCLUDE($MCVE_DIR/include)
+ PHP_ADD_LIBRARY_WITH_PATH(mcve, $MCVE_DIR/lib, MCVE_SHARED_LIBADD)
+ PHP_EXTENSION(mcve, $ext_shared)
+ PHP_SUBST(MCVE_SHARED_LIBADD)
+fi
diff --git a/ext/mcve/mcve.c b/ext/mcve/mcve.c
new file mode 100644
index 0000000000..20688c0584
--- /dev/null
+++ b/ext/mcve/mcve.c
@@ -0,0 +1,1846 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Brad House <brad@mainstreetsoftworks.com> |
+ | Chris Faulhaber <jedgar@fxp.org> |
+ +----------------------------------------------------------------------+
+*/
+
+/* standard php include(s) */
+#include "php.h"
+#include "ext/standard/head.h"
+#include "ext/standard/php_standard.h"
+#include "ext/standard/info.h"
+
+/* local include(s) */
+#include <mcve.h>
+
+/* local php include(s) */
+#include "php_mcve.h"
+
+/* {{{ globals */
+static int le_conn; /* connection resource */
+static int le_user; /* store add/edit/get user information */
+
+static int mcve_init; /* For Safe Memory Dealocation */
+/* }}} */
+
+/* {{{ extension definition structures */
+static unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
+
+function_entry php_mcve_functions[] = {
+ PHP_FE(mcve_initengine, NULL)
+ PHP_FE(mcve_initconn, NULL)
+ PHP_FE(mcve_deleteresponse, NULL)
+ PHP_FE(mcve_destroyconn, NULL)
+ PHP_FE(mcve_setdropfile, NULL)
+ PHP_FE(mcve_setip, NULL)
+ PHP_FE(mcve_setssl, NULL)
+ PHP_FE(mcve_settimeout, NULL)
+ PHP_FE(mcve_connect, NULL)
+ PHP_FE(mcve_returnstatus, NULL)
+ PHP_FE(mcve_returncode, NULL)
+ PHP_FE(mcve_transactionssent, NULL)
+ PHP_FE(mcve_transactionitem, NULL)
+ PHP_FE(mcve_transactionbatch, NULL)
+ PHP_FE(mcve_transactionid, NULL)
+ PHP_FE(mcve_transactionauth, NULL)
+ PHP_FE(mcve_transactiontext, NULL)
+ PHP_FE(mcve_transactionavs, NULL)
+ PHP_FE(mcve_transactioncv, NULL)
+ PHP_FE(mcve_monitor, NULL)
+ PHP_FE(mcve_transinqueue, NULL)
+ PHP_FE(mcve_checkstatus, NULL)
+ PHP_FE(mcve_completeauthorizations, second_arg_force_ref)
+ PHP_FE(mcve_sale, NULL)
+ PHP_FE(mcve_preauth, NULL)
+ PHP_FE(mcve_void, NULL)
+ PHP_FE(mcve_preauthcompletion, NULL)
+ PHP_FE(mcve_force, NULL)
+ PHP_FE(mcve_override, NULL)
+ PHP_FE(mcve_return, NULL)
+ PHP_FE(mcve_iscommadelimited, NULL)
+ PHP_FE(mcve_parsecommadelimited, NULL)
+ PHP_FE(mcve_getcommadelimited, NULL)
+ PHP_FE(mcve_getcell, NULL)
+ PHP_FE(mcve_getcellbynum, NULL)
+ PHP_FE(mcve_numcolumns, NULL)
+ PHP_FE(mcve_numrows, NULL)
+ PHP_FE(mcve_getheader, NULL)
+ PHP_FE(mcve_destroyengine, NULL)
+ PHP_FE(mcve_settle, NULL)
+ PHP_FE(mcve_gut, NULL)
+ PHP_FE(mcve_gl, NULL)
+ PHP_FE(mcve_gft, NULL)
+ PHP_FE(mcve_qc, NULL)
+ PHP_FE(mcve_ub, NULL)
+ PHP_FE(mcve_chkpwd, NULL)
+ PHP_FE(mcve_bt, NULL)
+/* Administrator Functions */
+ PHP_FE(mcve_chngpwd, NULL)
+ PHP_FE(mcve_listusers, NULL)
+ PHP_FE(mcve_adduser, NULL)
+ PHP_FE(mcve_enableuser, NULL)
+ PHP_FE(mcve_disableuser, NULL)
+ PHP_FE(mcve_getuserarg, NULL)
+ PHP_FE(mcve_adduserarg, NULL)
+ PHP_FE(mcve_deleteusersetup, NULL)
+ PHP_FE(mcve_initusersetup, NULL)
+ PHP_FE(mcve_deluser, NULL)
+ PHP_FE(mcve_edituser, NULL)
+ PHP_FE(mcve_liststats, NULL)
+
+ { NULL, NULL, NULL }
+};
+
+zend_module_entry php_mcve_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ "MCVE", /* module name */
+ php_mcve_functions, /* struct of functions (see above) */
+ PHP_MINIT(mcve), /* module initialization functions */
+ NULL, /* module shutdown functions */
+ NULL, /* request initialization functions */
+ NULL, /* request shutdown functions */
+ PHP_MINFO(mcve), /* declare the info function for phpinfo() */
+#if ZEND_MODULE_API_NO >= 20010901
+ PHP_MCVE_VERSION, /* declare MCVE version number */
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+
+/* }}} */
+
+/* declare the module for dynamic loading */
+ZEND_GET_MODULE(php_mcve)
+
+/* {{{ MCVE_CONN destructor */
+static void _free_mcve_conn(zend_rsrc_list_entry *rsrc)
+{
+ MCVE_CONN *conn;
+
+ conn = (MCVE_CONN *)rsrc->ptr;
+ MCVE_DestroyConn(conn);
+ efree(conn);
+}
+/* }}} */
+
+/* {{{ module initialization */
+PHP_MINIT_FUNCTION(mcve)
+{
+ /* register the MCVE_CONN destructor */
+ le_conn = zend_register_list_destructors_ex(_free_mcve_conn, NULL,
+ "mcve connection", module_number);
+
+ /* set up the mcve defines */
+ REGISTER_LONG_CONSTANT("MCVE_UNUSED", MCVE_UNUSED, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_PENDING", MCVE_PENDING, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_DONE", MCVE_DONE, MCVE_CONST);
+
+ REGISTER_LONG_CONSTANT("MCVE_GOOD", MCVE_GOOD, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_BAD", MCVE_BAD, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_STREET", MCVE_STREET, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_ZIP", MCVE_ZIP, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_UNKNOWN", MCVE_UNKNOWN, MCVE_CONST);
+
+ REGISTER_LONG_CONSTANT("MCVE_ERROR", MCVE_ERROR, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_FAIL", MCVE_FAIL, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_SUCCESS", MCVE_SUCCESS, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_AUTH", MCVE_AUTH, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_DENY", MCVE_DENY, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_CALL", MCVE_CALL, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_DUPL", MCVE_DUPL, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_PKUP", MCVE_PKUP, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_RETRY", MCVE_RETRY, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_SETUP", MCVE_SETUP, MCVE_CONST);
+
+ REGISTER_LONG_CONSTANT("MCVE_SALE", MCVE_SALE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_PREAUTH", MCVE_PREAUTH, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_FORCE", MCVE_FORCE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_OVERRIDE", MCVE_OVERRIDE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_RETURN", MCVE_RETURN, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_SETTLE", MCVE_SETTLE, MCVE_CONST);
+
+ REGISTER_LONG_CONSTANT("MCVE_PROC", MCVE_PROC, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_USER", MCVE_USER, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_PWD", MCVE_PWD, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_INDCODE", MCVE_INDCODE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_MERCHID", MCVE_MERCHID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_BANKID", MCVE_BANKID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_TERMID", MCVE_TERMID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_CLIENTNUM", MCVE_CLIENTNUM, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_STOREID", MCVE_STOREID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_AGENTID", MCVE_AGENTID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_CHAINID", MCVE_CHAINID, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_ZIPCODE", MCVE_ZIPCODE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_TIMEZONE", MCVE_TIMEZONE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_MERCHCAT", MCVE_MERCHCAT, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_MERNAME", MCVE_MERNAME, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_MERCHLOC", MCVE_MERCHLOC, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_STATECODE", MCVE_STATECODE, MCVE_CONST);
+ REGISTER_LONG_CONSTANT("MCVE_SERVICEPHONE", MCVE_SERVICEPHONE, MCVE_CONST);
+
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ module information */
+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 ssl support",
+#ifdef ENABLE_SSL
+ "enabled");
+#else
+ "disabled");
+#endif
+ php_info_print_table_row(2, "version", PHP_MCVE_VERSION);
+ php_info_print_table_end();
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_initengine(char *location)
+
+ Ready the client for IP/SSL Communication
+*/
+PHP_FUNCTION(mcve_initengine)
+{
+ int ret;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(arg);
+
+ if (mcve_init) {
+ MCVE_DestroyEngine();
+ }
+ ret = MCVE_InitEngine(Z_STRVAL_PP(arg));
+ mcve_init = 1;
+
+ RETURN_LONG(ret);
+}
+/* }}} */
+
+/* {{{ proto int mcve_initengine(string cafile)
+
+ create and initialize an MCVE_CONN structure
+*/
+PHP_FUNCTION(mcve_initconn)
+{
+ MCVE_CONN *conn;
+
+ conn = emalloc(sizeof(MCVE_CONN));
+
+ MCVE_InitConn(conn);
+
+ ZEND_REGISTER_RESOURCE(return_value, conn, le_conn);
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_deleteresponse(int conn, int identifier)
+
+ Delete specified transaction from MCVE_CONN structure
+*/
+PHP_FUNCTION(mcve_deleteresponse)
+{
+ MCVE_CONN *conn;
+ 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);
+
+ MCVE_DeleteResponse(conn, Z_LVAL_PP(arg2));
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto void mcve_destroyconn(int conn);
+
+ Destroy the connection and MCVE_CONN structure
+*/
+PHP_FUNCTION(mcve_destroyconn)
+{
+ MCVE_CONN *conn;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg, -1, "mcve connection",
+ le_conn);
+
+ MCVE_DestroyConn(conn);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int mcve_setdropfile(int conn, string directory)
+
+ Set the connection method to Drop-File
+*/
+PHP_FUNCTION(mcve_setdropfile)
+{
+ 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 = MCVE_SetDropFile(conn, Z_STRVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_setip(int conn, string host, int port)
+
+ Set the connection method to IP
+*/
+PHP_FUNCTION(mcve_setip)
+{
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 ||
+ zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_long_ex(arg3);
+
+ retval = MCVE_SetIP(conn, Z_STRVAL_PP(arg2), Z_LVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_setssl(int conn, string host, int port)
+
+ Set the connection method to SSL
+*/
+PHP_FUNCTION(mcve_setssl)
+{
+#ifdef ENABLE_SSL
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 ||
+ zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_long_ex(arg3);
+
+ retval = MCVE_SetSSL(conn, Z_STRVAL_PP(arg2), Z_LVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+#else
+ RETURN_LONG(MCVE_FAIL);
+#endif
+}
+/* }}} */
+
+/* {{{ proto int mcve_settimeout(int conn, int seconds)
+
+ Set maximum transaction time (per trans)
+*/
+PHP_FUNCTION(mcve_settimeout)
+{
+ 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 = MCVE_SetTimeout(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_connect(int conn)
+
+ Establish the connection to MCVE
+*/
+PHP_FUNCTION(mcve_connect)
+{
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg, -1, "mcve connection",
+ le_conn);
+
+ retval = MCVE_Connect(conn);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transactionssent(int conn)
+
+ Check to see if outgoing buffer is clear
+*/
+PHP_FUNCTION(mcve_transactionssent)
+{
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg, -1, "mcve connection",
+ le_conn);
+
+ retval = MCVE_TransactionsSent(conn);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_returnstatus(int conn, int identifier)
+
+ Check to see if the transaction was successful
+*/
+PHP_FUNCTION(mcve_returnstatus)
+{
+ 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 = MCVE_ReturnStatus(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_returncode(int conn, int identifier)
+
+ Grab the exact return code from the transaction
+*/
+PHP_FUNCTION(mcve_returncode)
+{
+ 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 = MCVE_ReturnCode(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transactionitem(int conn, int identifier)
+
+ Get the ITEM number in the associated batch for this transaction
+*/
+PHP_FUNCTION(mcve_transactionitem)
+{
+ 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 = MCVE_TransactionItem(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transactionavs(int conn, int identifier)
+
+ Get the Address Verification return status
+*/
+PHP_FUNCTION(mcve_transactionavs)
+{
+ 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 = MCVE_TransactionAVS(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_transactioncv(int conn, int identifier)
+
+ Get the CVC2/CVV2/CID return status
+*/
+PHP_FUNCTION(mcve_transactioncv)
+{
+ 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 = MCVE_TransactionCV(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transactionbatch(int conn, int identifier)
+
+ Get the batch number associated with the transaction
+*/
+PHP_FUNCTION(mcve_transactionbatch)
+{
+ 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 = MCVE_TransactionBatch(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transactionid(int conn, int identifier)
+
+ Get the unique system id for the transaction
+*/
+PHP_FUNCTION(mcve_transactionid)
+{
+ 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 = MCVE_TransactionID(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto string mcve_transactionauth(int conn, int identifier)
+
+ Get the authorization number returned for the transaction (alpha-numeric)
+*/
+PHP_FUNCTION(mcve_transactionauth)
+{
+ MCVE_CONN *conn;
+ char *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 = MCVE_TransactionAuth(conn, Z_LVAL_PP(arg2));
+
+ if (retval == NULL) {
+ RETVAL_STRING("",1);
+ } else {
+ RETVAL_STRING(retval, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto string mcve_transactiontext(int conn, int identifier)
+
+ Get verbiage (text) return from MCVE or processing institution
+*/
+PHP_FUNCTION(mcve_transactiontext)
+{
+ MCVE_CONN *conn;
+ char *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 = MCVE_TransactionText(conn, Z_LVAL_PP(arg2));
+ if (retval == NULL) {
+ RETVAL_STRING("",1);
+ } else {
+ RETVAL_STRING(retval, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto int mcve_monitor(int conn)
+
+ Perform communication with MCVE (send/receive data) Non-blocking
+*/
+PHP_FUNCTION(mcve_monitor)
+{
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg, -1, "mcve connection",
+ le_conn);
+
+ retval = MCVE_Monitor(conn);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_transinqueue(int conn)
+
+ Number of transactions in client-queue
+*/
+PHP_FUNCTION(mcve_transinqueue)
+{
+ MCVE_CONN *conn;
+ int retval;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg, -1, "mcve connection",
+ le_conn);
+
+ retval = MCVE_TransInQueue(conn);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_checkstatus(int conn, int identifier)
+
+ Check to see if a transaction has completed
+*/
+PHP_FUNCTION(mcve_checkstatus)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_CheckStatus(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_completeauthorizations(int conn, int &array)
+
+ Number of complete authorizations in queue, returning an
+ array of their identifiers
+*/
+PHP_FUNCTION(mcve_completeauthorizations)
+{
+ MCVE_CONN *conn;
+ long i, *list, listnum;
+ zval **arg1, **arg2;
+
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2))
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ listnum = MCVE_CompleteAuthorizations(conn, &list);
+
+ if (listnum) {
+ /* should use ZVAL_DESTRUCTOR */
+ pval_destructor(*arg2);
+ array_init(*arg2);
+ for (i = 0; i < listnum; i++)
+ add_index_long(*arg2, i, list[i]);
+ free(list);
+ }
+
+ RETURN_LONG(listnum);
+}
+/* }}} */
+
+/* {{{ proto int mcve_sale(int conn, string username, string password,
+ string trackdata, string account, string expdate, double amount,
+ string street, string zip, string cv, string comments,
+ string clerkid, string stationid, int ptrannum)
+
+ Send a SALE to MCVE
+*/
+PHP_FUNCTION(mcve_sale)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8;
+ zval **arg9, **arg10, **arg11, **arg12, **arg13, **arg14;
+
+ if (ZEND_NUM_ARGS() != 14 || zend_get_parameters_ex(14, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11,
+ &arg12, &arg13, &arg14) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_double_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+ convert_to_string_ex(arg12);
+ convert_to_string_ex(arg13);
+ convert_to_long_ex(arg14);
+
+ retval = MCVE_Sale(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6),
+ Z_DVAL_PP(arg7), Z_STRVAL_PP(arg8), Z_STRVAL_PP(arg9),
+ Z_STRVAL_PP(arg10), Z_STRVAL_PP(arg11), Z_STRVAL_PP(arg12),
+ Z_STRVAL_PP(arg13), Z_LVAL_PP(arg14));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_preauth(int conn, string username, string password,
+ string trackdata, string account, string expdate, double amount,
+ string street, string zip, string cv, string comments,
+ string clerkid, string stationid, int ptrannum)
+
+ Send a PREAUTHORIZATION to MCVE
+*/
+PHP_FUNCTION(mcve_preauth)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8;
+ zval **arg9, **arg10, **arg11, **arg12, **arg13, **arg14;
+
+ if (ZEND_NUM_ARGS() != 14 || zend_get_parameters_ex(14, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11,
+ &arg12, &arg13, &arg14) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_double_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+ convert_to_string_ex(arg12);
+ convert_to_string_ex(arg13);
+ convert_to_long_ex(arg14);
+
+ retval = MCVE_PreAuth(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6),
+ Z_DVAL_PP(arg7), Z_STRVAL_PP(arg8), Z_STRVAL_PP(arg9),
+ Z_STRVAL_PP(arg10), Z_STRVAL_PP(arg11), Z_STRVAL_PP(arg12),
+ Z_STRVAL_PP(arg13), Z_LVAL_PP(arg14));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_override(int conn, string username, string password,
+ string trackdata, string account, string expdate, double amount,
+ string street, string zip, string cv, string comments, string clerkid,
+ string stationid, int ptrannum)
+
+ Send an OVERRIDE to MCVE
+*/
+PHP_FUNCTION(mcve_override)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8;
+ zval **arg9, **arg10, **arg11, **arg12, **arg13, **arg14;
+
+ if (ZEND_NUM_ARGS() != 14 || zend_get_parameters_ex(14, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11,
+ &arg12, &arg13, &arg14) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_double_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+ convert_to_string_ex(arg12);
+ convert_to_string_ex(arg13);
+ convert_to_long_ex(arg14);
+
+ retval = MCVE_Override(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6),
+ Z_DVAL_PP(arg7), Z_STRVAL_PP(arg8), Z_STRVAL_PP(arg9),
+ Z_STRVAL_PP(arg10), Z_STRVAL_PP(arg11), Z_STRVAL_PP(arg12),
+ Z_STRVAL_PP(arg13), Z_LVAL_PP(arg14));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_void(int conn, string username, string password,
+ int sid, int ptrannum)
+
+ VOID a transaction in the settlement queue
+*/
+PHP_FUNCTION(mcve_void)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5;
+
+ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2,
+ &arg3, &arg4, &arg5) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_long_ex(arg4);
+ convert_to_long_ex(arg5);
+
+ retval = MCVE_Void(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_LVAL_PP(arg4), Z_LVAL_PP(arg5));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_preauthcompletion(int conn, string username,
+ string password, double finalamount, int sid, int ptrannum)
+
+ Complete a PREAUTHORIZATION... Ready it for settlement
+*/
+PHP_FUNCTION(mcve_preauthcompletion)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6;
+
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_double_ex(arg4);
+ convert_to_long_ex(arg5);
+ convert_to_long_ex(arg6);
+
+ retval = MCVE_PreAuthCompletion(conn, Z_STRVAL_PP(arg2),
+ Z_STRVAL_PP(arg3), Z_DVAL_PP(arg4), Z_LVAL_PP(arg5),
+ Z_LVAL_PP(arg6));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_force(int conn, string username, string password,
+ string trackdata, string account, string expdate, double amount,
+ string authcode, string comments, string clerkid, string stationid,
+ int ptrannum)
+
+ Send a FORCE to MCVE. (typically, a phone-authorization)
+*/
+PHP_FUNCTION(mcve_force)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8;
+ zval **arg9, **arg10, **arg11, **arg12;
+
+ if (ZEND_NUM_ARGS() != 12 || zend_get_parameters_ex(12, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11,
+ &arg12) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_double_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+ convert_to_long_ex(arg12);
+
+ retval = MCVE_Force(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6),
+ Z_DVAL_PP(arg7), Z_STRVAL_PP(arg8), Z_STRVAL_PP(arg9),
+ Z_STRVAL_PP(arg10), Z_STRVAL_PP(arg11), Z_LVAL_PP(arg12));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_return(int conn, string username, string password,
+ string trackdata, string account, string expdate, double amount,
+ string comments, string clerkid, string stationid, int ptrannum)
+
+ Issue a RETURN or CREDIT to MCVE
+*/
+PHP_FUNCTION(mcve_return)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8;
+ zval **arg9, **arg10, **arg11;
+
+ if (ZEND_NUM_ARGS() != 11 || zend_get_parameters_ex(11, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_double_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_long_ex(arg11);
+
+ retval = MCVE_Return(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6),
+ Z_DVAL_PP(arg7), Z_STRVAL_PP(arg8), Z_STRVAL_PP(arg9),
+ Z_STRVAL_PP(arg10), Z_LVAL_PP(arg11));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_settle(int conn, string username, string password,
+ string batch)
+
+ Issue a settlement command to do a batch deposit
+*/
+PHP_FUNCTION(mcve_settle)
+{
+ MCVE_CONN *conn;
+ long 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_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+
+ retval = MCVE_Settle(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_STRVAL_PP(arg4));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* proto int mcve_ub(int conn, string username, string password)
+
+ Get a list of all Unsettled batches
+*/
+PHP_FUNCTION(mcve_ub)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_Ub(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_qc(int conn, string username, string password,
+ string clerkid, string stationid, string comments, int ptrannum)
+
+ Audit MCVE for a list of transactions in the outgoing queue
+*/
+PHP_FUNCTION(mcve_qc)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7;
+
+ if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_string_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_long_ex(arg7);
+
+
+ retval = MCVE_Qc(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_STRVAL_PP(arg4), Z_STRVAL_PP(arg5), Z_STRVAL_PP(arg6), Z_LVAL_PP(arg7));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_gut(int conn, string username, string password, int type,
+ string account, string clerkid, string stationid, string comments,
+ int ptrannum, string startdate, string enddate)
+
+ Audit MCVE for Unsettled Transactions
+*/
+PHP_FUNCTION(mcve_gut)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8, **arg9, **arg10, **arg11;
+
+ if (ZEND_NUM_ARGS() != 11 || zend_get_parameters_ex(11, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_long_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_string_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_long_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+
+ retval = MCVE_Gut(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_LVAL_PP(arg4), Z_STRVAL_PP(arg5),Z_STRVAL_PP(arg6),
+ Z_STRVAL_PP(arg7),Z_STRVAL_PP(arg8),Z_LVAL_PP(arg9),Z_STRVAL_PP(arg10),Z_STRVAL_PP(arg11));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_gl(int conn, string username, string password, int type,
+ string account, string batch, string clerkid, string stationid,
+ string comments, int ptrannum, string startdate, string enddate)
+
+ Audit MCVE for settled transactions
+*/
+PHP_FUNCTION(mcve_gl)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8, **arg9, **arg10, **arg11, **arg12;
+
+ if (ZEND_NUM_ARGS() != 12 || zend_get_parameters_ex(12, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11, &arg12) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_long_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_string_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_string_ex(arg9);
+ convert_to_long_ex(arg10);
+ convert_to_string_ex(arg11);
+ convert_to_string_ex(arg12);
+
+ retval = MCVE_Gl(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_LVAL_PP(arg4), Z_STRVAL_PP(arg5),
+ Z_STRVAL_PP(arg6),Z_STRVAL_PP(arg7),Z_STRVAL_PP(arg8),Z_STRVAL_PP(arg9),Z_LVAL_PP(arg10),
+ Z_STRVAL_PP(arg11),Z_STRVAL_PP(arg12));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_gft(int conn, string username, string password, int type,
+ string account, string clerkid, string stationid, string comments,
+ int ptrannum, string startdate, string enddate)
+
+ Audit MCVE for Failed transactions
+*/
+PHP_FUNCTION(mcve_gft)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8, **arg9, **arg10, **arg11;
+
+ if (ZEND_NUM_ARGS() != 11 || zend_get_parameters_ex(11, &arg1, &arg2,
+ &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+ convert_to_long_ex(arg4);
+ convert_to_string_ex(arg5);
+ convert_to_string_ex(arg6);
+ convert_to_string_ex(arg7);
+ convert_to_string_ex(arg8);
+ convert_to_long_ex(arg9);
+ convert_to_string_ex(arg10);
+ convert_to_string_ex(arg11);
+
+ retval = MCVE_Gft(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3), Z_LVAL_PP(arg4),Z_STRVAL_PP(arg5),
+ Z_STRVAL_PP(arg6),Z_STRVAL_PP(arg7),Z_STRVAL_PP(arg8),Z_LVAL_PP(arg9),Z_STRVAL_PP(arg10),Z_STRVAL_PP(arg11));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_chkpwd(int conn, string username, string password)
+
+ Verify Password
+*/
+PHP_FUNCTION(mcve_chkpwd)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_Chkpwd(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_bt(int conn, string username, string password)
+
+ Get unsettled batch totals
+*/
+PHP_FUNCTION(mcve_bt)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_Bt(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+
+/* {{{ proto string mcve_getcell(int conn, int identifier, string column,
+ int row)
+
+ Get a specific cell from a comma delimited response
+ by column name
+*/
+PHP_FUNCTION(mcve_getcell)
+{
+ MCVE_CONN *conn;
+ char *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_long_ex(arg4);
+
+ retval = MCVE_GetCell(conn, Z_LVAL_PP(arg2), Z_STRVAL_PP(arg3),
+ Z_LVAL_PP(arg4));
+
+ if (retval == NULL) {
+ RETURN_STRING("", 1);
+ } else {
+ RETURN_STRING(retval, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto string mcve_getcell(int conn, int identifier, int column, int row)
+
+ Get a specific cell from a comma delimited response
+ by column number
+*/
+PHP_FUNCTION(mcve_getcellbynum)
+{
+ MCVE_CONN *conn;
+ char *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_long_ex(arg3);
+ convert_to_long_ex(arg4);
+
+ retval = MCVE_GetCellByNum(conn, Z_LVAL_PP(arg2), Z_LVAL_PP(arg3),
+ Z_LVAL_PP(arg4));
+
+ if (retval == NULL) {
+ RETURN_STRING("", 1);
+ } else {
+ RETURN_STRING(retval, 1);
+ }
+}
+/* }}} */
+
+
+/* {{{ proto int mcve_numcolumns(int conn, int identifier)
+
+ Number of columns returned in a comma delimited response
+*/
+PHP_FUNCTION(mcve_numcolumns)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_NumColumns(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_numrows(int conn, int identifier)
+
+ Number of rows returned in a comma delimited response
+*/
+PHP_FUNCTION(mcve_numrows)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_NumRows(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_iscommadelimited(int conn, int identifier)
+
+ Checks to see if response is comma delimited
+*/
+PHP_FUNCTION(mcve_iscommadelimited)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_IsCommaDelimited(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_parsecommadelimited(int conn, int identifier)
+
+ Parse the comma delimited response so mcve_getcell, etc will work
+*/
+PHP_FUNCTION(mcve_parsecommadelimited)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_ParseCommaDelimited(conn, Z_LVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto string mcve_getcommadelimited(int conn, int identifier)
+
+ Get the RAW comma delimited data returned from MCVE
+*/
+PHP_FUNCTION(mcve_getcommadelimited)
+{
+ MCVE_CONN *conn;
+ char *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 = MCVE_GetCommaDelimited(conn, Z_LVAL_PP(arg2));
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+
+/* {{{ proto string mcve_getheader(int conn, int identifier, int column_num)
+
+ Get the name of the column in a comma-delimited response
+*/
+PHP_FUNCTION(mcve_getheader)
+{
+ MCVE_CONN *conn;
+ char *retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 ||
+ zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_long_ex(arg2);
+ convert_to_long_ex(arg3);
+
+ retval = MCVE_GetHeader(conn, Z_LVAL_PP(arg2), Z_LVAL_PP(arg3));
+
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+
+/* {{{ proto void mcve_destroyengine()
+
+ Free memory associated with IP/SSL connectivity
+*/
+PHP_FUNCTION(mcve_destroyengine)
+{
+ MCVE_DestroyEngine();
+ mcve_init = 0;
+}
+/* }}} */
+
+/* {{{ proto int mcve_chngpwd(int conn, string admin_password, string new_password)
+
+ Change the system administrator's password
+*/
+PHP_FUNCTION(mcve_chngpwd)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_Chngpwd(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_listusers(int conn, string admin_password)
+
+ List all users on MCVE system
+*/
+PHP_FUNCTION(mcve_listusers)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_ListUsers(conn, Z_STRVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_enableuser(int conn, string admin_password, string username)
+
+ Enable an inactive MCVE user account
+*/
+PHP_FUNCTION(mcve_enableuser)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_EnableUser(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_disableuser(int conn, string admin_password, string username)
+
+ Disable an active MCVE user account
+*/
+PHP_FUNCTION(mcve_disableuser)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_DisableUser(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_deluser(int conn, string admin_password, string username)
+
+ Delete an MCVE user account
+*/
+PHP_FUNCTION(mcve_deluser)
+{
+ MCVE_CONN *conn;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+
+ convert_to_string_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_DelUser(conn, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_liststats(int conn, string admin_password)
+
+ List statistics for all users on MCVE system
+*/
+PHP_FUNCTION(mcve_liststats)
+{
+ MCVE_CONN *conn;
+ long 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 = MCVE_ListStats(conn, Z_STRVAL_PP(arg2));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_initusersetup()
+
+ Initialize structure to store user data
+*/
+PHP_FUNCTION(mcve_initusersetup)
+{
+ MCVE_UserSetup *usersetup;
+
+ usersetup = emalloc(sizeof(MCVE_UserSetup));
+
+ MCVE_InitUserSetup(usersetup);
+
+ ZEND_REGISTER_RESOURCE(return_value, usersetup, le_user);
+}
+/* }}} */
+
+/* {{{ proto void mcve_deleteusersetup(int usersetup)
+
+ Deallocate data associated with usersetup structure
+*/
+PHP_FUNCTION(mcve_deleteusersetup)
+{
+ MCVE_UserSetup *usersetup;
+ zval **arg;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(usersetup, MCVE_UserSetup *, arg, -1, "mcve user setup",
+ le_user);
+
+ MCVE_DeleteUserSetup(usersetup);
+ efree(usersetup);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int mcve_adduserarg(int usersetup, int argtype, string argval)
+
+ Add a value to user configuration structure
+*/
+PHP_FUNCTION(mcve_adduserarg)
+{
+ MCVE_UserSetup *usersetup;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(usersetup, MCVE_UserSetup *, arg1, -1, "mcve user setup",
+ le_user);
+
+ convert_to_long_ex(arg2);
+ convert_to_string_ex(arg3);
+
+ retval = MCVE_AddUserArg(usersetup, Z_LVAL_PP(arg2), Z_STRVAL_PP(arg3));
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto string mcve_getuserarg(int usersetup, int argtype)
+
+ Grab a value from usersetup structure
+*/
+PHP_FUNCTION(mcve_getuserarg)
+{
+ MCVE_UserSetup *usersetup;
+ char *retval;
+ zval **arg1, **arg2;
+
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(usersetup, MCVE_UserSetup *, arg1, -1, "mcve user setup",
+ le_user);
+
+ convert_to_long_ex(arg2);
+
+ retval = MCVE_GetUserArg(usersetup, Z_LVAL_PP(arg2));
+
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+
+/* {{{ proto int mcve_adduser(int conn, string admin_password, int usersetup)
+
+ Add an MCVE user using usersetup structure
+*/
+PHP_FUNCTION(mcve_adduser)
+{
+ MCVE_CONN *conn;
+ MCVE_UserSetup *usersetup;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+ ZEND_FETCH_RESOURCE(usersetup, MCVE_UserSetup *, arg3, -1, "mcve user setup",
+ le_user);
+
+ convert_to_string_ex(arg2);
+
+ retval = MCVE_AddUser(conn, Z_STRVAL_PP(arg2), usersetup);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* {{{ proto int mcve_edituser(int conn, string admin_password, int usersetup)
+
+ Edit MCVE user using usersetup structure
+*/
+PHP_FUNCTION(mcve_edituser)
+{
+ MCVE_CONN *conn;
+ MCVE_UserSetup *usersetup;
+ long retval;
+ zval **arg1, **arg2, **arg3;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2,
+ &arg3) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ ZEND_FETCH_RESOURCE(conn, MCVE_CONN *, arg1, -1, "mcve connection",
+ le_conn);
+ ZEND_FETCH_RESOURCE(usersetup, MCVE_UserSetup *, arg3, -1, "mcve user setup",
+ le_user);
+
+ convert_to_string_ex(arg2);
+
+ retval = MCVE_EditUser(conn, Z_STRVAL_PP(arg2), usersetup);
+
+ RETURN_LONG(retval);
+}
+/* }}} */
+
+/* END OF MCVE PHP EXTENSION */
+
diff --git a/ext/mcve/mcve.php b/ext/mcve/mcve.php
new file mode 100644
index 0000000000..f749220b32
--- /dev/null
+++ b/ext/mcve/mcve.php
@@ -0,0 +1,12 @@
+<?
+$module = 'MCVE';
+if(!extension_loaded($module)) {
+ dl('mcve.so');
+}
+$functions = get_extension_funcs($module);
+echo "Functions available in the $module extension:<br>\n";
+foreach($functions as $func) {
+ echo $func."<br>\n";
+}
+echo "<br>\n";
+?>
diff --git a/ext/mcve/php_mcve.h b/ext/mcve/php_mcve.h
new file mode 100644
index 0000000000..cac182c709
--- /dev/null
+++ b/ext/mcve/php_mcve.h
@@ -0,0 +1,89 @@
+/*
+ * basic mcve php module
+ *
+ * $Id$
+ */
+
+#ifndef _PHP_MCVE_H
+#define _PHP_MCVE_H
+
+extern zend_module_entry php_mcve_module_entry;
+
+#define mcve_module_ptr &php_mcve_module_entry
+#define phpext_mcve_ptr mcve_module_ptr
+
+//#if COMPILE_DL
+// DLEXPORT zend_module_entry *get_module(void) { return
+//&php_mcve_module_entry; }
+//#endif
+
+
+#define PHP_MCVE_VERSION "1.0"
+
+#define MCVE_CONST (CONST_CS | CONST_PERSISTENT)
+
+PHP_MINIT_FUNCTION(mcve);
+PHP_MINFO_FUNCTION(mcve);
+
+PHP_FUNCTION(mcve_initengine);
+PHP_FUNCTION(mcve_initconn);
+PHP_FUNCTION(mcve_deleteresponse);
+PHP_FUNCTION(mcve_destroyconn);
+PHP_FUNCTION(mcve_setdropfile);
+PHP_FUNCTION(mcve_setip);
+PHP_FUNCTION(mcve_setssl);
+PHP_FUNCTION(mcve_settimeout);
+PHP_FUNCTION(mcve_connect);
+PHP_FUNCTION(mcve_returnstatus);
+PHP_FUNCTION(mcve_returncode);
+PHP_FUNCTION(mcve_transactionssent);
+PHP_FUNCTION(mcve_transactionitem);
+PHP_FUNCTION(mcve_transactionbatch);
+PHP_FUNCTION(mcve_transactionid);
+PHP_FUNCTION(mcve_transactionauth);
+PHP_FUNCTION(mcve_transactionavs);
+PHP_FUNCTION(mcve_transactioncv);
+PHP_FUNCTION(mcve_transactiontext);
+PHP_FUNCTION(mcve_monitor);
+PHP_FUNCTION(mcve_transinqueue);
+PHP_FUNCTION(mcve_checkstatus);
+PHP_FUNCTION(mcve_completeauthorizations);
+PHP_FUNCTION(mcve_sale);
+PHP_FUNCTION(mcve_preauth);
+PHP_FUNCTION(mcve_override);
+PHP_FUNCTION(mcve_void);
+PHP_FUNCTION(mcve_preauthcompletion);
+PHP_FUNCTION(mcve_force);
+PHP_FUNCTION(mcve_return);
+PHP_FUNCTION(mcve_iscommadelimited);
+PHP_FUNCTION(mcve_parsecommadelimited);
+PHP_FUNCTION(mcve_getcommadelimited);
+PHP_FUNCTION(mcve_getcell);
+PHP_FUNCTION(mcve_getcellbynum);
+PHP_FUNCTION(mcve_numcolumns);
+PHP_FUNCTION(mcve_numrows);
+PHP_FUNCTION(mcve_getheader);
+PHP_FUNCTION(mcve_destroyengine);
+PHP_FUNCTION(mcve_settle);
+PHP_FUNCTION(mcve_qc);
+PHP_FUNCTION(mcve_gut);
+PHP_FUNCTION(mcve_gft);
+PHP_FUNCTION(mcve_ub);
+PHP_FUNCTION(mcve_gl);
+PHP_FUNCTION(mcve_chkpwd);
+PHP_FUNCTION(mcve_bt);
+
+PHP_FUNCTION(mcve_chngpwd);
+PHP_FUNCTION(mcve_listusers);
+PHP_FUNCTION(mcve_adduser);
+PHP_FUNCTION(mcve_enableuser);
+PHP_FUNCTION(mcve_disableuser);
+PHP_FUNCTION(mcve_getuserarg);
+PHP_FUNCTION(mcve_adduserarg);
+PHP_FUNCTION(mcve_deleteusersetup);
+PHP_FUNCTION(mcve_initusersetup);
+PHP_FUNCTION(mcve_deluser);
+PHP_FUNCTION(mcve_edituser);
+PHP_FUNCTION(mcve_liststats);
+#endif /* _PHP_MCVE_H */
+
diff --git a/ext/mcve/tests/001.phpt b/ext/mcve/tests/001.phpt
new file mode 100644
index 0000000000..c41eaa18ca
--- /dev/null
+++ b/ext/mcve/tests/001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Check for mcve presence
+--SKIPIF--
+<?php if (!extension_loaded("MCVE")) print "skip"; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+echo "mcve extension is available";
+/*
+ you can add regression tests for your extension here
+
+ the output of your test code has to be equal to the
+ text in the --EXPECT-- section below for the tests
+ to pass, differences between the output and the
+ expected text are interpreted as failure
+
+ see php4/tests/README for further information on
+ writing regression tests
+*/
+?>
+--EXPECT--
+mcve extension is available
diff --git a/ext/mcve/tests/mcve_simple_test.php b/ext/mcve/tests/mcve_simple_test.php
new file mode 100644
index 0000000000..3a1c4f0601
--- /dev/null
+++ b/ext/mcve/tests/mcve_simple_test.php
@@ -0,0 +1,19 @@
+<?php
+
+ MCVE_InitEngine(NULL);
+ $conn=MCVE_InitConn();
+ if (MCVE_SetIP($conn, "testbox.mcve.com", 8333)) {
+ echo "Set connection Properly";
+ } else {
+ echo "Failed Setting method";
+ exit();
+ }
+ if (!MCVE_Connect($conn)) {
+ echo "<BR>Could not connect<BR>";
+ } else {
+ echo "<BR>Connection Established<BR>";
+ }
+ MCVE_DestroyConn($conn);
+ MCVE_DestroyEngine();
+
+?>
diff --git a/ext/mcve/tests/mcve_test1.php b/ext/mcve/tests/mcve_test1.php
new file mode 100644
index 0000000000..a4f7dba8d6
--- /dev/null
+++ b/ext/mcve/tests/mcve_test1.php
@@ -0,0 +1,83 @@
+<HTML>
+<BODY>
+<?php
+
+// MCVE Config stuff
+$username="vitale";
+$password="test";
+// 1:IP or 2:SSL
+$method=2;
+$host="testbox.mcve.com";
+$port=8444; //8444 is typically SSL and 8333 is standard
+// End config stuff
+
+
+if (!$account)
+ $account="4012888888881";
+if (!$exp)
+ $exp="0512";
+if (!$amount)
+ $amount=12.00;
+
+function flush_buffer()
+{
+ for ($i=0; $i<2048; $i++) {
+ echo " ";
+ }
+ flush();
+}
+
+
+dl("./php_mcve.so");
+
+ echo "Initializing MCVE<BR>";
+ flush_buffer();
+ mcve_initengine("./CAfile.pem");
+ $conn=mcve_initconn();
+ if ($method == 1)
+ $ret=mcve_setip($conn, $host, $port);
+ else if ($method == 2)
+ $ret=mcve_setssl($conn, $host, $port);
+
+ if (!$ret) {
+ echo "Could not set method<BR>";
+ exit(1);
+ }
+ echo "Connection method and location set<BR>";
+ flush_buffer();
+ if (!mcve_connect($conn)) {
+ echo "Connection Failed<BR>";
+ exit(1);
+ }
+ echo "Connection Established<BR>";
+ flush_buffer();
+ $identifier=mcve_sale($conn, $username, $password, NULL, $account, $exp,
+ $amount, NULL, NULL, NULL, NULL, NULL, NULL, 001);
+ echo "Transaction Sent: CC: $account EXP: $exp AMOUNT: $amount<BR>";
+ flush_buffer();
+ while (mcve_checkstatus($conn, $identifier) != MCVE_DONE) {
+ mcve_monitor($conn);
+ }
+ echo "Transaction Complete<BR>";
+ flush_buffer();
+ $status=mcve_returnstatus($conn, $identifier);
+ if ($status == MCVE_SUCCESS) {
+ $text=mcve_transactiontext($conn, $identifier);
+ $auth=mcve_transactionauth($conn, $identifier);
+ echo "Transaction Authorized<BR>";
+ echo "Auth: $auth<BR>";
+ echo "Text: $text<BR>";
+ } else if ($status == MCVE_FAIL) {
+ $text=mcve_transactiontext($conn, $identifier);
+ echo "Transaction Denied<BR>";
+ echo "Text: $text<BR>";
+ } else
+ echo "Transaction error<BR>";
+ flush_buffer();
+ mcve_destroyconn($conn);
+ mcve_destroyengine();
+
+?>
+</BODY>
+</HTML>
+
diff --git a/ext/mcve/tests/mcve_test2.php b/ext/mcve/tests/mcve_test2.php
new file mode 100644
index 0000000000..4cb251b538
--- /dev/null
+++ b/ext/mcve/tests/mcve_test2.php
@@ -0,0 +1,68 @@
+<?
+ #
+ # $Id$
+ #
+
+$connect_type = "IP";
+
+dl("php_mcve.so");
+
+$conn = MCVE_InitConn();
+print "MCVE_InitConn() returned $conn<br>\n";
+
+if ($connect_type == "IP") {
+ MCVE_SetIP($conn, "localhost", 8333) or
+ die("MCVE_SetIP() failed");
+ print "MCVE_SetIP() successful<br>\n";
+} else {
+ MCVE_SetDropFile($conn, "/var/mcve/trans") or
+ die("MCVE_SetDropFile() failed");
+ print "MCVE_SetDropFile() successful<br>\n";
+}
+
+MCVE_Connect($conn) or
+ die("MCVE_Connect() failed");
+print "MCVE_Connect() successful<br>\n";
+
+# send a request
+$ident = MCVE_Sale($conn, "test", "test", NULL, "5454545454545454",
+ "1205", 11.00, NULL, NULL, NULL, NULL, "me", NULL, 54321);
+if ($ident == -1)
+ die("MCVE_Sale() failed");
+else
+ print "Identifier: $ident<br>\n";
+
+$ident = MCVE_Sale($conn, "test", "test", NULL, "5454545454545454",
+ "1205", 12.00, NULL, NULL, NULL, NULL, "me", NULL, 54321);
+if ($ident == -1)
+ die("MCVE_Sale() failed");
+else
+ print "Identifier: $ident<br>\n";
+
+$pending = 0;
+$complete = -1;
+while ($pending != $complete) {
+ sleep(2);
+
+ MCVE_Monitor($conn);
+
+ $pending = MCVE_TransInQueue($conn);
+ print "Transactions pending: $pending<br>\n";
+
+ $complete = MCVE_CompleteAuthorizations($conn, &$list);
+ print "Authorizations complete: $complete<br>\n";
+
+ flush();
+}
+
+for ($i = 0; $i < $complete; $i++) {
+ $status = MCVE_CheckStatus($conn, $i);
+ print "Transaction #" . $list[$i] . " complete: $status<br>\n";
+}
+
+MCVE_DestroyConn($conn);
+print "MCVE_DestroyConn() completed<br>\n";
+
+#phpinfo();
+
+?>