cvs: php4 /ext/pfpro pfpro.c
| From: | David Croft | Date: | Wed, 19 Jul 2000 18:55:11 +0000 |
| Subject: | cvs: php4 /ext/pfpro pfpro.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-818@lists.php.net to get a copy of this message | ||
david Wed Jul 19 11:55:11 2000 EDT
Modified files:
/php4/ext/pfpro pfpro.c
Log:
automatically initialise library at first use if necessary
automatically cleanup library at request end if user hasn't done so
libpfpro library version shown on phpinfo()
Index: php4/ext/pfpro/pfpro.c
diff -u php4/ext/pfpro/pfpro.c:1.2 php4/ext/pfpro/pfpro.c:1.3
--- php4/ext/pfpro/pfpro.c:1.2 Fri Jul 14 22:08:21 2000
+++ php4/ext/pfpro/pfpro.c Wed Jul 19 11:55:11 2000
@@ -17,14 +17,20 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pfpro.c,v 1.2 2000/07/15 05:08:21 david Exp $ */
+/* $Id: pfpro.c,v 1.3 2000/07/19 18:55:11 david Exp $ */
-/* Note: I've left the globals and ini-file handling stuff in
- as I've yet to decide whether this is a good way to place "default"
- stuff like hosts and proxies */
+/* TODO:
+ *
+ * 1. Ini file entries for default host, port, proxy address, port,
+ * proxy logon, proxy password - John
+ *
+ * 2. User-friendly wrapper functions for sale, authorise, capture
+ * and void - David
+ *
+ * 3. Update documentation for the above.
+ *
+ */
-/* Status: Working. */
-
#include "php.h"
#include "php_ini.h"
#include "php_pfpro.h"
@@ -88,11 +94,21 @@
PHP_RINIT_FUNCTION(pfpro)
{
+ PFPROLS_FETCH();
+
+ PFPROG(initialised) = 0;
+
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(pfpro)
{
+ PFPROLS_FETCH();
+
+ if (PFPROG(initialised) == 1) {
+ PNCleanup();
+ }
+
return SUCCESS;
}
@@ -101,6 +117,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_end();
/*
@@ -128,12 +145,16 @@
Initialises the Payflow Pro library */
PHP_FUNCTION(pfpro_init)
{
+ PFPROLS_FETCH();
+
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
PNInit();
+ PFPROG(initialised) = 1;
+
RETURN_TRUE;
}
/* }}} */
@@ -144,12 +165,16 @@
Shuts down the Payflow Pro library */
PHP_FUNCTION(pfpro_cleanup)
{
+ PFPROLS_FETCH();
+
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
PNCleanup();
+ PFPROG(initialised) = 0;
+
RETURN_TRUE;
}
/* }}} */
@@ -178,6 +203,8 @@
char response[512] = "";
+ PFPROLS_FETCH();
+
if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 8) {
WRONG_PARAM_COUNT;
}
@@ -253,6 +280,13 @@
memset(response, 0, sizeof(response));
+ /* Initialise the library if needed */
+
+ if (PFPROG(initialised) == 0) {
+ PNInit();
+ PFPROG(initialised) = 1;
+ }
+
/* Perform the transaction */
ProcessPNTransaction(address, port, proxyAddress, proxyPort, proxyLogon, proxyPassword, parmlist,
strlen(parmlist), timeout, response);
@@ -304,6 +338,7 @@
*sp1, *sp2, *sp_end,
*pdelim1="&", *pdelim2="=";
+ PFPROLS_FETCH();
if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 8) {
WRONG_PARAM_COUNT;
@@ -496,6 +531,13 @@
memset(response, 0, sizeof(response));
+ /* Initialise the library if needed */
+
+ if (PFPROG(initialised) == 0) {
+ PNInit();
+ PFPROG(initialised) = 1;
+ }
+
/* Perform the transaction */
ProcessPNTransaction(address, port, proxyAddress, proxyPort, proxyLogon, proxyPassword, parmlist,
parmlength, timeout, response);
@@ -583,9 +625,7 @@
/* }}} */
-
#endif /* HAVE_PFPRO */
-
/*
* Local variables: