cvs: php4 /ext/pfpro config.m4 pfpro.c php_pfpro.h

From: Date: Tue, 01 May 2001 05:04:42 +0000
Subject: cvs: php4 /ext/pfpro config.m4 pfpro.c php_pfpro.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5414@lists.php.net to get a copy of this message
jdonagher Mon Apr 30 22:04:42 2001 EDT Modified files: /php4/ext/pfpro config.m4 pfpro.c php_pfpro.h Log: - 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)

Index: php4/ext/pfpro/config.m4 diff -u php4/ext/pfpro/config.m4:1.4 php4/ext/pfpro/config.m4:1.5 --- php4/ext/pfpro/config.m4:1.4 Tue Mar 27 12:34:39 2001 +++ php4/ext/pfpro/config.m4 Mon Apr 30 22:04:42 2001 @@ -1,21 +1,27 @@ -dnl $Id: config.m4,v 1.4 2001/03/27 20:34:39 sniper Exp $ +dnl $Id: config.m4,v 1.5 2001/05/01 05:04:42 jdonagher Exp $ dnl config.m4 for extension pfpro 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 @@ ./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) Index: php4/ext/pfpro/pfpro.c diff -u php4/ext/pfpro/pfpro.c:1.10 php4/ext/pfpro/pfpro.c:1.11 --- php4/ext/pfpro/pfpro.c:1.10 Wed Mar 21 12:07:18 2001 +++ php4/ext/pfpro/pfpro.c Mon Apr 30 22:04:42 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pfpro.c,v 1.10 2001/03/21 20:07:18 andi Exp $ */ +/* $Id: pfpro.c,v 1.11 2001/05/01 05:04:42 jdonagher Exp $ */ /* {{{ includes */ #include "php.h" @@ -107,7 +107,7 @@ PFPROLS_FETCH(); if (PFPROG(initialized) == 1) { - PNCleanup(); + pfproCleanup(); } return SUCCESS; @@ -119,7 +119,7 @@ { 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 @@ 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 @@ WRONG_PARAM_COUNT; } - PNInit(); + pfproInit(); PFPROG(initialized) = 1; @@ -166,7 +166,7 @@ WRONG_PARAM_COUNT; } - PNCleanup(); + pfproCleanup(); PFPROG(initialized) = 0; @@ -180,7 +180,7 @@ { zval ***args; - char *parmlist; + char *parmlist = NULL; char *address = NULL; int port = PFPROG(defaultport); int timeout = PFPROG(defaulttimeout); @@ -190,11 +190,13 @@ char *proxyPassword = PFPROG(proxypassword); 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 @@ 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 @@ zval **entry; int pass; + char *parmlist = NULL; char *address = NULL; int port = PFPROG(defaultport); int timeout = PFPROG(defaulttimeout); @@ -312,22 +323,21 @@ char *proxyLogon = PFPROG(proxylogon); char *proxyPassword = PFPROG(proxypassword); - 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 */ + int freeaddress = 0; +#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 @@ 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 @@ add_assoc_string(return_value, &buf[0], &sbuf[0], 1); } -#endif } /* }}} */ Index: php4/ext/pfpro/php_pfpro.h diff -u php4/ext/pfpro/php_pfpro.h:1.7 php4/ext/pfpro/php_pfpro.h:1.8 --- php4/ext/pfpro/php_pfpro.h:1.7 Wed Mar 21 12:07:18 2001 +++ php4/ext/pfpro/php_pfpro.h Mon Apr 30 22:04:42 2001 @@ -12,11 +12,12 @@ | 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> | +----------------------------------------------------------------------+ */ -/* $Id: php_pfpro.h,v 1.7 2001/03/21 20:07:18 andi Exp $ */ +/* $Id: php_pfpro.h,v 1.8 2001/05/01 05:04:42 jdonagher Exp $ */ #ifndef PHP_PFPRO_H #define PHP_PFPRO_H @@ -30,6 +31,12 @@ #define PHP_PFPRO_API __declspec(dllexport) #else #define PHP_PFPRO_API +#endif + +#if PFPRO_VERSION < 3 +#define pfproVersion() PNVersion() +#define pfproInit() PNInit() +#define pfproCleanup() PNCleanup() #endif PHP_MINIT_FUNCTION(pfpro);
« previous php.cvs (#5414) next »