2000-08-08 22:36:56 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-12-11 15:32:16 +00:00
| PHP Version 4 |
2000-08-08 22:36:56 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-12-11 15:32:16 +00:00
| Copyright ( c ) 1997 - 2002 The PHP Group |
2000-08-08 22:36:56 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| 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 . |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2002-02-28 08:29:35 +00:00
| Authors : Brendan W . McAdams < bmcadams @ php . net > |
| Doug DeJulio < ddj @ redhat . com > |
2000-08-08 22:36:56 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2000-10-05 18:20:06 +00:00
*/
/*
2000-08-08 22:36:56 +00:00
* cvvs . c $ Revision $ - PHP4 Interface to the RedHat CCVS API
* - - - - - - -
* Interfaces RedHat ' s CCVS [ Credit Card Verification System ] < http : //www.redhat.com/products/ccvs/>
* This code is ported from an original php3 interface written by RedHat ' s Doug DeJulio < ddj @ redhat . com >
2000-10-05 18:20:06 +00:00
* The code was subsequently ported to the Zend API by Brendan W . McAdams < bmcadams @ php . net >
2000-08-08 22:36:56 +00:00
* - - - - - - -
*/
2000-10-05 18:20:06 +00:00
/*
* Code started on 2000.07 .24 @ 09.04 . EST by Brendan W . McAdams < bmcadams @ php . net >
2000-08-08 22:36:56 +00:00
* $ Revision $
*/
static char const cvsid [ ] = " $Id$ " ;
# include <php.h>
# include <stdlib.h>
# include <string.h>
# include <ccvs.h>
2000-08-09 17:43:04 +00:00
2000-10-05 18:20:06 +00:00
/*
2000-08-09 17:43:04 +00:00
* Create the Zend Internal hash construct to track this modules functions
*
* In case anyone is wondering why we use ccvs_ < action > instead of cv_ < action > ,
2000-10-05 18:20:06 +00:00
* it ' s because we are directly importing functions of the actual CCVS , which uses functions that are
2000-08-09 17:43:04 +00:00
* cv_ < action > , and we had problems implementing ZEND_NAMED_FE calls ( bug in NAMED_FE ? investigate
* later ) . We don ' t want our PHP calls to conflict with the C calls in the CCVS API .
2000-10-05 18:20:06 +00:00
*
* BWM - 2000.07 .27 @ 16.41 . EST - Added FALIAS Calls . While I ' m of the opinion that naming the
* functions in PHP ccvs_ < action > is much more readable and clear to anyone reading the code than
* cv_ < action > , It strikes me that many people coming from php3 - > php4 will need backwards
2000-08-09 17:43:04 +00:00
* compatibility . It was kind of careless to simply change the function calls ( There were reasons other
2000-10-05 18:20:06 +00:00
* than readability behind this ; the ZEND_NAMED_FE macro was misbehaving ) and not provide for
* backwards compatibility - this * IS * an API and should scale with compatibility .
*
2000-08-09 17:43:04 +00:00
*/
2000-08-10 20:23:33 +00:00
function_entry ccvs_functions [ ] = {
2001-08-11 16:39:07 +00:00
PHP_FE ( ccvs_init , NULL )
PHP_FALIAS ( cv_init , ccvs_init , NULL )
PHP_FE ( ccvs_done , NULL )
PHP_FALIAS ( cv_done , ccvs_done , NULL )
PHP_FE ( ccvs_new , NULL )
PHP_FALIAS ( cv_new , ccvs_new , NULL )
PHP_FE ( ccvs_add , NULL )
PHP_FALIAS ( cv_add , ccvs_add , NULL )
PHP_FE ( ccvs_delete , NULL )
PHP_FALIAS ( cv_delete , ccvs_delete , NULL )
PHP_FE ( ccvs_auth , NULL )
PHP_FALIAS ( cv_auth , ccvs_auth , NULL )
PHP_FE ( ccvs_return , NULL )
PHP_FALIAS ( cv_return , ccvs_return , NULL )
PHP_FE ( ccvs_reverse , NULL )
PHP_FALIAS ( cv_reverse , ccvs_reverse , NULL )
PHP_FE ( ccvs_sale , NULL )
PHP_FALIAS ( cv_sale , ccvs_sale , NULL )
PHP_FE ( ccvs_void , NULL )
PHP_FALIAS ( cv_void , ccvs_void , NULL )
PHP_FE ( ccvs_status , NULL )
PHP_FALIAS ( cv_status , ccvs_status , NULL )
PHP_FE ( ccvs_count , NULL )
PHP_FALIAS ( cv_count , ccvs_count , NULL )
PHP_FE ( ccvs_lookup , NULL )
PHP_FALIAS ( cv_lookup , ccvs_lookup , NULL )
PHP_FE ( ccvs_report , NULL )
PHP_FALIAS ( cv_report , ccvs_report , NULL )
PHP_FE ( ccvs_command , NULL )
PHP_FALIAS ( cv_command , ccvs_command , NULL )
PHP_FE ( ccvs_textvalue , NULL )
PHP_FALIAS ( cv_textvalue , ccvs_textvalue , NULL )
{ NULL , NULL , NULL }
2000-08-09 17:43:04 +00:00
} ;
/* End function declarations */
/* Zend Engine Exports - module information */
/* Declare our module to the Zend engine */
zend_module_entry ccvs_module_entry = {
2001-10-11 23:33:59 +00:00
STANDARD_MODULE_HEADER ,
2000-08-09 17:43:04 +00:00
" CCVS " ,
ccvs_functions ,
2001-08-11 16:39:07 +00:00
NULL , NULL , NULL , NULL ,
2000-08-09 17:43:04 +00:00
PHP_MINFO ( ccvs ) ,
2001-10-11 23:33:59 +00:00
NO_VERSION_YET ,
2000-10-05 18:20:06 +00:00
STANDARD_MODULE_PROPERTIES
} ;
2001-10-11 23:33:59 +00:00
# ifdef COMPILE_DL_CCVS
ZEND_GET_MODULE ( ccvs )
2001-05-22 21:33:17 +00:00
# endif
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
/* Full Functions (The actual CCVS functions and any internal php hooked functions such as MINFO) */
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_init(string name)
2001-12-17 10:59:52 +00:00
Initialize CCVS for use */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_init ) /* cv_init() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * name ;
2000-08-08 22:36:56 +00:00
void * vsess ;
char * p ;
2000-10-05 18:20:06 +00:00
if ( ( ZEND_NUM_ARGS ( ) ! = 1 ) | | ( zend_get_parameters_ex ( 1 , & name ) ! = SUCCESS ) )
2000-08-08 22:36:56 +00:00
/* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( name ) ;
2001-09-25 21:58:48 +00:00
vsess = cv_init ( Z_STRVAL_PP ( name ) ) ;
2000-10-05 18:20:06 +00:00
/*
* - - In the case that we don ' t run error checking on the return value . . . - -
* On 32 bit systems a failure of the cv_init call returns 0 , 0 , 0 , 0 ; on 64 bit systems its 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
2000-08-08 22:36:56 +00:00
* This unconsistent error ( not to mention a string of comma seperated zeros in and of itself ) is hard to
2000-10-05 18:20:06 +00:00
* Trap for in PHP ( or any language ) . However , we can also grab cv_init to return CV_SESS_BAD on
* failure at the C API level , and return a set , fixed error code to the user which the user then knows to
2000-08-08 22:36:56 +00:00
* trap for . . . e . g . a NULL Value which PHP can then trap by :
* if ( ! ( $ string = cv_init ( $ config ) ) { or some such . . .
*/
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
if ( vsess = = CV_SESS_BAD ) /* if the cv_init() call failed... */
2000-10-05 18:20:06 +00:00
{
2000-08-08 22:36:56 +00:00
p = " " ; /* set p, the value we will return, to NULL */
2000-10-05 18:20:06 +00:00
}
2000-08-08 22:36:56 +00:00
else /* we got a valid session returned, which means it worked */
{
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
p = hks_ptr_ptrtostring ( vsess ) ; /* Convert the (void*) into a string representation. */
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
}
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
RETVAL_STRING ( p , 1 ) ;
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
free ( p ) ;
return ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_done(string sess)
2001-12-17 10:59:52 +00:00
Terminate CCVS engine and do cleanup work */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_done ) /* cv_done() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * sess ;
2000-08-08 22:36:56 +00:00
void * vsess ;
if ( ( ZEND_NUM_ARGS ( ) ! = 1 ) | | ( zend_get_parameters_ex ( 1 , & sess ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( sess ) ;
/* Convert from the string representation back to a (void*) */
2001-09-25 21:58:48 +00:00
vsess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( sess ) ) ;
2000-08-08 22:36:56 +00:00
cv_done ( vsess ) ;
RETURN_STRING ( " OK " , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_new(string session, string invoice)
2001-12-17 10:59:52 +00:00
Create a new , blank transaction */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_new ) /* cv_new() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
2001-04-22 23:40:34 +00:00
if ( ! Z_STRVAL_PP ( psess ) ) {
2002-06-26 07:24:47 +00:00
php_error ( E_WARNING , " %s(): Invalid session " , get_active_function_name ( TSRMLS_C ) ) ;
2001-04-22 23:40:34 +00:00
RETURN_FALSE ;
}
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
2000-08-08 22:36:56 +00:00
r = cv_new ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_add(string session, string invoice, string argtype, string argval)
2001-12-17 10:59:52 +00:00
Add data to a transaction */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_add ) /* cv_add() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
zval * * pargtype ;
zval * * pargval ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
int argtype ;
char * argval ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 4 ) | | ( zend_get_parameters_ex ( 4 , & psess , & pinvoice , & pargtype , & pargval ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
/* Get meaningful arguments. */
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
convert_to_string_ex ( pargtype ) ;
convert_to_string_ex ( pargval ) ;
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
invoice = Z_STRVAL_PP ( pinvoice ) ;
argtype = cv_str2arg ( Z_STRVAL_PP ( pargtype ) ) ;
argval = Z_STRVAL_PP ( pargval ) ;
2000-08-08 22:36:56 +00:00
r = cv_add ( sess , invoice , argtype , argval ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
/*
2000-10-05 18:20:06 +00:00
* cv_create can ' t be implemented because of vararg limits in PHP3 ' s C API .
2000-08-08 22:36:56 +00:00
* ( COMMENT BY DDJ [ from original code ] )
*
2000-10-05 18:20:06 +00:00
* BWM : I looked into this , checking in on what cv_create was ; it is a deprecated function left in for
2000-08-08 22:36:56 +00:00
* backwards compatibility according
* to the CCVS C API ref . I didn ' t try to implement it for that reason . If anyone needs it , they can add it in
* themselves I ' m sure .
*/
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_delete(string session, string invoice)
2001-12-17 10:59:52 +00:00
Delete a transaction */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_delete ) /* cv_delete() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_delete ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_auth(string session, string invoice)
2001-12-17 10:59:52 +00:00
Perform credit authorization test on a transaction */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_auth ) /* cv_auth() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_auth ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_return(string session, string invoice)
2001-12-17 10:59:52 +00:00
Transfer funds from the merchant to the credit card holder */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_return ) /* cv_return() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_return ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_reverse(string session, string invoice)
2001-12-17 10:59:52 +00:00
Perform a full reversal on an already - processed authorization */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_reverse ) /* cv_reverse() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_reverse ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_sale(string session, string invoice)
2001-12-17 10:59:52 +00:00
Transfer funds from the credit card holder to the merchant */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_sale ) /* cv_sale() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
2000-11-20 17:32:46 +00:00
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
2000-08-08 22:36:56 +00:00
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_sale ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_void(string session, string invoice)
2001-12-17 10:59:52 +00:00
Perform a full reversal on a completed transaction */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_void ) /* cv_void() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_void ( sess , invoice ) ;
RETURN_STRING ( cv_ret2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_status(string session, string invoice)
2001-12-17 10:59:52 +00:00
Check the status of an invoice */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_status ) /* cv_status() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * pinvoice ;
2000-08-08 22:36:56 +00:00
void * sess ;
char * invoice ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & pinvoice ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( pinvoice ) ;
2001-09-25 21:58:48 +00:00
invoice = Z_STRVAL_PP ( pinvoice ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_status ( sess , invoice ) ;
RETURN_STRING ( cv_stat2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto int ccvs_count(string session, string type)
2001-12-17 10:59:52 +00:00
Find out how many transactions of a given type are stored in the system */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_count ) /* cv_count() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * ptype ;
2000-08-08 22:36:56 +00:00
void * sess ;
int type ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & ptype ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
convert_to_string_ex ( ptype ) ;
2001-09-25 21:58:48 +00:00
type = cv_str2stat ( Z_STRVAL_PP ( ptype ) ) ;
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_count ( sess , type ) ;
RETURN_LONG ( r ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_lookup(string session, string invoice, int inum)
2001-12-17 10:59:52 +00:00
Look up an item of a particular type in the database */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_lookup ) /* cv_lookup() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * ptype ;
zval * * pinum ;
2000-08-08 22:36:56 +00:00
void * sess ;
int type ;
long inum ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 3 ) | | ( zend_get_parameters_ex ( 3 , & psess , & ptype , & pinum ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_string_ex ( ptype ) ;
2001-09-25 21:58:48 +00:00
type = cv_str2stat ( Z_STRVAL_PP ( ptype ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_long_ex ( pinum ) ;
2001-09-25 21:58:48 +00:00
inum = Z_LVAL_PP ( pinum ) ;
2000-08-08 22:36:56 +00:00
r = cv_lookup ( sess , type , inum ) ;
RETURN_STRING ( cv_textvalue ( sess ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_report(string session, string type)
2001-12-17 10:59:52 +00:00
Return the status of the background communication process */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_report ) /* cv_report() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * ptype ;
2000-08-08 22:36:56 +00:00
void * sess ;
int type ;
long inum ;
register int r ;
if ( ( ZEND_NUM_ARGS ( ) ! = 2 ) | | ( zend_get_parameters_ex ( 2 , & psess , & ptype ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_string_ex ( ptype ) ;
2001-09-25 21:58:48 +00:00
type = cv_str2rep ( Z_STRVAL_PP ( ptype ) ) ;
2000-08-08 22:36:56 +00:00
r = cv_report ( sess , type ) ;
RETURN_STRING ( cv_stat2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_command(string session, string type, string argval)
2001-12-17 10:59:52 +00:00
Performs a command which is peculiar to a single protocol , and thus is not available in the general CCVS API */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_command ) /* cv_command() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
zval * * ptype ;
zval * * pargval ;
2000-08-08 22:36:56 +00:00
void * sess ;
int type ;
register int r ;
char * argval ;
if ( ( ZEND_NUM_ARGS ( ) ! = 3 ) | | ( zend_get_parameters_ex ( 3 , & psess , & ptype , & pargval ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_string_ex ( ptype ) ;
2001-09-25 21:58:48 +00:00
type = cv_str2cmd ( Z_STRVAL_PP ( ptype ) ) ;
2000-08-08 22:36:56 +00:00
convert_to_string_ex ( pargval ) ;
2001-09-25 21:58:48 +00:00
argval = Z_STRVAL_PP ( pargval ) ;
2000-08-08 22:36:56 +00:00
r = cv_command ( sess , type , argval ) ;
RETURN_STRING ( cv_stat2str ( r ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
2000-10-11 13:34:42 +00:00
/* {{{ proto string ccvs_textvalue(string session)
2001-12-17 10:59:52 +00:00
Get text return value for previous function call */
2000-08-10 20:23:33 +00:00
PHP_FUNCTION ( ccvs_textvalue ) /* cv_textvalue() */
2000-08-08 22:36:56 +00:00
{
2000-08-10 21:03:02 +00:00
zval * * psess ;
2000-08-08 22:36:56 +00:00
void * sess ;
if ( ( ZEND_NUM_ARGS ( ) ! = 1 ) | | ( zend_get_parameters_ex ( 1 , & psess ) ! = SUCCESS ) ) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
{
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( psess ) ;
2001-09-25 21:58:48 +00:00
sess = hks_ptr_stringtoptr ( Z_STRVAL_PP ( psess ) ) ;
2000-08-08 22:36:56 +00:00
RETURN_STRING ( cv_textvalue ( sess ) , 1 ) ;
}
2000-10-11 13:34:42 +00:00
/* }}} */
2000-08-08 22:36:56 +00:00
/*
2000-10-05 18:20:06 +00:00
* Our Info Function which reports info on this module out to PHP ' s phpinfo ( ) function
* Brendan W . McAdams < bmcadams @ php . net > on 2000.07 .26 @ 16 : 22. EST
2000-08-08 22:36:56 +00:00
*/
PHP_MINFO_FUNCTION ( ccvs )
{
php_info_print_table_start ( ) ;
php_info_print_table_header ( 2 , " RedHat CCVS support " , " enabled " ) ;
2001-10-06 20:13:39 +00:00
php_info_print_table_row ( 2 , " CCVS Support by " , " Brendan W. McAdams <bmcadams@php.net><br />& Doug DeJulio <ddj@redhat.com> " ) ;
2001-08-11 16:39:07 +00:00
php_info_print_table_row ( 2 , " Release ID " , cvsid ) ;
php_info_print_table_row ( 2 , " This Release Certified For CCVS Versions " , " 3.0 and greater " ) ;
2000-10-05 18:20:06 +00:00
php_info_print_table_end ( ) ;
2000-08-08 22:36:56 +00:00
/* DISPLAY_INI_ENTRIES(); */
2000-10-05 18:20:06 +00:00
2000-08-08 22:36:56 +00:00
/*
* In the future , we will probably have entries in php . ini for runtime config , in which case we will
* Uncomment the DISPLAY_INI_ENTRIES call . . .
*/
2000-10-05 18:20:06 +00:00
2000-08-09 01:18:28 +00:00
}
2001-06-06 13:06:12 +00:00
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* End :
2001-09-09 13:29:31 +00:00
* vim600 : sw = 4 ts = 4 fdm = marker
* vim < 600 : sw = 4 ts = 4
2001-06-06 13:06:12 +00:00
*/