cvs: php4 /ext/msession msession.c php_msession.h reqclient.h

From: Date: Mon, 08 Apr 2002 23:07:23 +0000
Subject: cvs: php4 /ext/msession msession.c php_msession.h reqclient.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10981@lists.php.net to get a copy of this message
mlwmohawk Mon Apr 8 19:07:23 2002 EDT Modified files: /php4/ext/msession msession.c php_msession.h reqclient.h Log: Added new features for msession beta 2 Index: php4/ext/msession/msession.c diff -u php4/ext/msession/msession.c:1.31 php4/ext/msession/msession.c:1.32 --- php4/ext/msession/msession.c:1.31 Sun Apr 7 00:20:15 2002 +++ php4/ext/msession/msession.c Mon Apr 8 19:07:20 2002 @@ -50,6 +50,7 @@ #define IFCONNECT_ENDVAL(V) } else { php_error(E_WARNING, s_szNoInit); return V; } #define IFCONNECT_END } else { php_error(E_WARNING, s_szNoInit); RETURN_FALSE; } +/* Test if session module contains custom sesson ID patch */ #ifdef PHP_SESSION_API #if (PHP_SESSION_API >= 20020330) #define HAVE_PHP_SESSION_CREATESID @@ -84,7 +85,6 @@ * Also, please to not reformat braces ;-) * -MLW */ - #if HAVE_MSESSION #ifdef HAVE_PHP_SESSION #ifdef HAVE_PHP_SESSION_CREATESID @@ -135,6 +135,7 @@ PHP_FE(msession_randstr,NULL) PHP_FE(msession_plugin,NULL) PHP_FE(msession_call,NULL) + PHP_FE(msession_ctl,NULL) {NULL, NULL, NULL} }; @@ -441,6 +442,78 @@ } /* }}} */ + +/* {{{ proto int msession_stat(string name) + Lock a session */ +PHP_FUNCTION(msession_ctl) +{ + static char *parray[] = + { "EXIST", + "TTL", + "AGE", + "TLA", + "CTIME", + "TOUCH", + "NOW", + NULL + }; + IFCONNECT_BEGIN + char *szsession; + zval **session; + zval **which; + int fn = REQ_STAT_EXIST; + + + int n = ZEND_NUM_ARGS(); + + if(n != 1 && n != 2) + { + WRONG_PARAM_COUNT; + } + + if(zend_get_parameters_ex(n,&session,&which) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(session); + szsession = Z_STRVAL_PP(session); + + if(n > 1) + { + char *szwhich; + int i; + convert_to_string_ex(which); + szwhich = Z_STRVAL_PP(which); + for(i=0; parray[i]; i++) + { + if(strcasecmp(parray[i], szwhich) == 0) + { + + fn = i; + break; + } + } + } + FormatRequest(&s_reqb, REQ_CTL, szsession, "","",fn); + DoRequest(s_conn,&s_reqb); + + if(s_reqb->req.stat==REQ_OK) + { +#ifdef ERR_DEBUG + char buffer[128]; + sprintf(buffer, "ret:%d", s_reqb->req.param); + ELOG(buffer); +#endif + RETURN_LONG(s_reqb->req.param); + } + else + { + ELOG("msession_ctl failed"); + RETURN_FALSE; + } + IFCONNECT_END +} /* {{{ proto int msession_unlock(string session, int key) Unlock a session */ Index: php4/ext/msession/php_msession.h diff -u php4/ext/msession/php_msession.h:1.7 php4/ext/msession/php_msession.h:1.8 --- php4/ext/msession/php_msession.h:1.7 Thu Feb 28 03:26:23 2002 +++ php4/ext/msession/php_msession.h Mon Apr 8 19:07:22 2002 @@ -44,6 +44,7 @@ PHP_FUNCTION(msession_disconnect); PHP_FUNCTION(msession_lock); PHP_FUNCTION(msession_unlock); +PHP_FUNCTION(msession_ctl); PHP_FUNCTION(msession_count); PHP_FUNCTION(msession_create); PHP_FUNCTION(msession_destroy); Index: php4/ext/msession/reqclient.h diff -u php4/ext/msession/reqclient.h:1.7 php4/ext/msession/reqclient.h:1.8 --- php4/ext/msession/reqclient.h:1.7 Fri Dec 21 21:10:42 2001 +++ php4/ext/msession/reqclient.h Mon Apr 8 19:07:22 2002 @@ -34,7 +34,7 @@ { REQ_ERR, REQ_OK, - REQ_STAT, + REQ_CTL, REQ_SETVAL, REQ_GETVAL, REQ_CREATE, @@ -55,9 +55,13 @@ REQ_RANDSTR, REQ_PLUGIN, REQ_CALL, + REQ_SERIALIZE, REQ_LAST, - REQ_POPEN=1024, - REQ_PCLOSE + REQ_INTERNAL_BEGIN=1023, + REQ_POPEN, + REQ_PCLOSE, + REQ_LOADDLL, + REQ_INTERNALLAST, }; enum REQ_ERRORS { @@ -102,6 +106,15 @@ #define REQB_STATIC 1 #define REQB_DYNAMIC 2 + +#define REQ_STAT_EXIST 0 +#define REQ_STAT_TTL 1 +#define REQ_STAT_AGE 2 +#define REQ_STAT_TLA 3 +#define REQ_STAT_CTIM 4 +#define REQ_STAT_TOUCH 5 +#define REQ_STAT_NOW 6 + #define STATIC_REQB( len ) \ char buffer [ len ]; \

« previous php.cvs (#10981) next »