mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
- Remove some stale code
- Fix spelling mistakes - Add build-time version detection - Add support for v3 Verisign SDK @ pfpro extension now supports version 3 of the Verisign SDK (John Donagher)
This commit is contained in:
parent
ba49860cc8
commit
0f42480b48
3 changed files with 74 additions and 49 deletions
|
@ -5,17 +5,23 @@ PHP_ARG_WITH(pfpro, whether to include Verisign Payflow Pro support,
|
|||
[ --with-pfpro[=DIR] Include Verisign Payflow Pro support])
|
||||
|
||||
if test "$PHP_PFPRO" != "no"; then
|
||||
PFPRO_LIB=libpfpro.so
|
||||
PFPRO_HDR=pfpro.h
|
||||
|
||||
for i in /usr/local /usr $PHP_PFPRO; do
|
||||
if test -r $i/pfpro.h; then
|
||||
if test -r $i/$PFPRO_HDR; then
|
||||
PFPRO_INC_DIR=$i
|
||||
elif test -r $i/include/pfpro.h; then
|
||||
elif test -r $i/include/$PFPRO_HDR; then
|
||||
PFPRO_INC_DIR=$i/include
|
||||
elif test -r $i/lib/$PFPRO_HDR; then
|
||||
PFPRO_INC_DIR=$i/lib
|
||||
elif test -r $i/bin/$PFPRO_HDR; then
|
||||
PFPRO_INC_DIR=$i/bin
|
||||
fi
|
||||
|
||||
if test -r $i/libpfpro.so; then
|
||||
if test -r $i/$PFPRO_LIB; then
|
||||
PFPRO_LIB_DIR=$i
|
||||
elif test -r $i/lib/libpfpro.so; then
|
||||
elif test -r $i/lib/$PFPRO_LIB; then
|
||||
PFPRO_LIB_DIR=$i/lib
|
||||
fi
|
||||
done
|
||||
|
@ -32,7 +38,19 @@ if test "$PHP_PFPRO" != "no"; then
|
|||
./configure --with-pfpro=<pfpro-dir> if necessary)
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT(found in $PFPRO_LIB_DIR)
|
||||
PFPRO_VERSION3=`nm $PFPRO_LIB_DIR/$PFPRO_LIB | awk '{print $3}' | grep ^pfpro > /dev/null && echo 1 || echo 0`
|
||||
PFPRO_VERSION2=`nm $PFPRO_LIB_DIR/$PFPRO_LIB | awk '{print $3}' | grep ^PN > /dev/null && echo 1 || echo 0`
|
||||
|
||||
if test "$PFPRO_VERSION3" -eq 1 ; then
|
||||
PFPRO_VERSION=3
|
||||
elif test "$PFPRO_VERSION2" -eq 1 ; then
|
||||
PFPRO_VERSION=2
|
||||
else
|
||||
AC_MSG_ERROR(The pfpro extension requires version 2 or 3 of the SDK)
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(PFPRO_VERSION, $PFPRO_VERSION, [Version of SDK])
|
||||
dnl AC_MSG_RESULT(found in $PFPRO_LIB_DIR)
|
||||
|
||||
PHP_ADD_INCLUDE($PFPRO_INC_DIR)
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ PHP_RSHUTDOWN_FUNCTION(pfpro)
|
|||
PFPROLS_FETCH();
|
||||
|
||||
if (PFPROG(initialized) == 1) {
|
||||
PNCleanup();
|
||||
pfproCleanup();
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
@ -119,7 +119,7 @@ PHP_MINFO_FUNCTION(pfpro)
|
|||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "Verisign Payflow Pro support", "enabled");
|
||||
php_info_print_table_row(2, "libpfpro version", PNVersion());
|
||||
php_info_print_table_row(2, "libpfpro version", pfproVersion());
|
||||
php_info_print_table_end();
|
||||
|
||||
DISPLAY_INI_ENTRIES();
|
||||
|
@ -134,12 +134,12 @@ PHP_FUNCTION(pfpro_version)
|
|||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
RETURN_STRING(PNVersion(), 1);
|
||||
RETURN_STRING((char *)pfproVersion(), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void pfpro_init()
|
||||
Initialises the Payflow Pro library */
|
||||
Initializes the Payflow Pro library */
|
||||
PHP_FUNCTION(pfpro_init)
|
||||
{
|
||||
PFPROLS_FETCH();
|
||||
|
@ -148,7 +148,7 @@ PHP_FUNCTION(pfpro_init)
|
|||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
PNInit();
|
||||
pfproInit();
|
||||
|
||||
PFPROG(initialized) = 1;
|
||||
|
||||
|
@ -166,7 +166,7 @@ PHP_FUNCTION(pfpro_cleanup)
|
|||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
PNCleanup();
|
||||
pfproCleanup();
|
||||
|
||||
PFPROG(initialized) = 0;
|
||||
|
||||
|
@ -180,7 +180,7 @@ PHP_FUNCTION(pfpro_process_raw)
|
|||
{
|
||||
zval ***args;
|
||||
|
||||
char *parmlist;
|
||||
char *parmlist = NULL;
|
||||
char *address = NULL;
|
||||
int port = PFPROG(defaultport);
|
||||
int timeout = PFPROG(defaulttimeout);
|
||||
|
@ -191,10 +191,12 @@ PHP_FUNCTION(pfpro_process_raw)
|
|||
|
||||
int freeaddress = 0;
|
||||
|
||||
/* No, I don't like that Signio tell you to use a
|
||||
fixed length buffer either */
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
char response[512] = "";
|
||||
#else
|
||||
int context;
|
||||
char *response;
|
||||
#endif
|
||||
|
||||
PFPROLS_FETCH();
|
||||
|
||||
|
@ -269,20 +271,28 @@ PHP_FUNCTION(pfpro_process_raw)
|
|||
printf("Proxy password: >%s<\n", proxyPassword);
|
||||
#endif
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
/* Blank the response buffer */
|
||||
|
||||
memset(response, 0, sizeof(response));
|
||||
#endif
|
||||
|
||||
/* Initialise the library if needed */
|
||||
/* Initialize the library if needed */
|
||||
|
||||
if (PFPROG(initialized) == 0) {
|
||||
PNInit();
|
||||
pfproInit();
|
||||
PFPROG(initialized) = 1;
|
||||
}
|
||||
|
||||
/* Perform the transaction */
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
ProcessPNTransaction(address, port, proxyAddress, proxyPort, proxyLogon, proxyPassword, parmlist, strlen(parmlist), timeout, response);
|
||||
#else
|
||||
pfproCreateContext(&context, address, port, timeout, proxyAddress, proxyPort, proxyLogon, proxyPassword);
|
||||
pfproSubmitTransaction(context, parmlist, strlen(parmlist), &response);
|
||||
//pfproCompleteTransaction(response);
|
||||
pfproDestroyContext(context);
|
||||
#endif
|
||||
|
||||
if (freeaddress) {
|
||||
efree(address);
|
||||
|
@ -304,6 +314,7 @@ PHP_FUNCTION(pfpro_process)
|
|||
zval **entry;
|
||||
int pass;
|
||||
|
||||
char *parmlist = NULL;
|
||||
char *address = NULL;
|
||||
int port = PFPROG(defaultport);
|
||||
int timeout = PFPROG(defaulttimeout);
|
||||
|
@ -312,22 +323,21 @@ PHP_FUNCTION(pfpro_process)
|
|||
char *proxyLogon = PFPROG(proxylogon);
|
||||
char *proxyPassword = PFPROG(proxypassword);
|
||||
|
||||
int parmlength = 0;
|
||||
int freeaddress = 0;
|
||||
|
||||
char *parmlist = NULL;
|
||||
int parmlength = 0;
|
||||
|
||||
/* No, I don't like that Signio tell you to use a
|
||||
fixed length buffer either */
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
char response[512] = "";
|
||||
#else
|
||||
int context;
|
||||
char *response;
|
||||
#endif
|
||||
|
||||
char tmpbuf[128];
|
||||
char *rsppos, *valpos;
|
||||
|
||||
char buf[128], sbuf[128];
|
||||
char *p1, *p2, *p_end, /* Pointers for string manipulation */
|
||||
*sp1, *sp2, *sp_end,
|
||||
*sp1, *sp2,
|
||||
*pdelim1="&", *pdelim2="=";
|
||||
|
||||
PFPROLS_FETCH();
|
||||
|
@ -514,43 +524,34 @@ PHP_FUNCTION(pfpro_process)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
/* Blank the response buffer */
|
||||
|
||||
memset(response, 0, sizeof(response));
|
||||
#endif
|
||||
|
||||
/* Initialise the library if needed */
|
||||
/* Initialize the library if needed */
|
||||
|
||||
if (PFPROG(initialized) == 0) {
|
||||
PNInit();
|
||||
pfproInit();
|
||||
PFPROG(initialized) = 1;
|
||||
}
|
||||
|
||||
/* Perform the transaction */
|
||||
|
||||
ProcessPNTransaction(address, port, proxyAddress, proxyPort, proxyLogon, proxyPassword, parmlist, parmlength, timeout, response);
|
||||
#if PFPRO_VERSION < 3
|
||||
ProcessPNTransaction(address, port, proxyAddress, proxyPort, proxyLogon, proxyPassword, parmlist, strlen(parmlist), timeout, response);
|
||||
#else
|
||||
pfproCreateContext(&context, address, port, timeout, proxyAddress, proxyPort, proxyLogon, proxyPassword);
|
||||
pfproSubmitTransaction(context, parmlist, strlen(parmlist), &response);
|
||||
//pfproCompleteTransaction(response);
|
||||
pfproDestroyContext(context);
|
||||
#endif
|
||||
|
||||
if (freeaddress) {
|
||||
efree(address);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* Decode the response back into a PHP array */
|
||||
|
||||
rsppos = strtok(response, "&");
|
||||
|
||||
do {
|
||||
valpos = strchr(rsppos, '=');
|
||||
if (valpos) {
|
||||
strncpy(tmpbuf, rsppos, valpos - rsppos);
|
||||
tmpbuf[valpos - rsppos] = 0;
|
||||
add_assoc_string(return_value, tmpbuf, valpos + 1, 1);
|
||||
}
|
||||
|
||||
} while (rsppos = strtok(NULL, "&"));
|
||||
#else
|
||||
|
||||
|
||||
/* This final chunk of code is to walk the string returned by Signio
|
||||
and build a string array to return to the user */
|
||||
|
||||
|
@ -606,7 +607,6 @@ PHP_FUNCTION(pfpro_process)
|
|||
add_assoc_string(return_value, &buf[0], &sbuf[0], 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: David Croft <david@infotrek.co.uk> |
|
||||
| Authors: David Croft <david@infotrek.co.uk> |
|
||||
| John Donagher <john@webmeta.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@ -32,6 +33,12 @@ extern zend_module_entry pfpro_module_entry;
|
|||
#define PHP_PFPRO_API
|
||||
#endif
|
||||
|
||||
#if PFPRO_VERSION < 3
|
||||
#define pfproVersion() PNVersion()
|
||||
#define pfproInit() PNInit()
|
||||
#define pfproCleanup() PNCleanup()
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(pfpro);
|
||||
PHP_MSHUTDOWN_FUNCTION(pfpro);
|
||||
PHP_RINIT_FUNCTION(pfpro);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue