From: Mark L. Woodward Date: Mon, 8 Apr 2002 23:07:23 +0000 (+0000) Subject: Added new features for msession beta 2 X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~785 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e5bccccaa6a21bc2d9a524382dcfa4bf7f926fe;p=php Added new features for msession beta 2 --- diff --git a/ext/msession/msession.c b/ext/msession/msession.c index f1598fc442..9c20607a86 100644 --- a/ext/msession/msession.c +++ b/ext/msession/msession.c @@ -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 @@ function_entry msession_functions[] = { PHP_FE(msession_randstr,NULL) PHP_FE(msession_plugin,NULL) PHP_FE(msession_call,NULL) + PHP_FE(msession_ctl,NULL) {NULL, NULL, NULL} }; @@ -442,6 +443,78 @@ PHP_FUNCTION(msession_lock) } /* }}} */ +/* {{{ 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 */ PHP_FUNCTION(msession_unlock) diff --git a/ext/msession/php_msession.h b/ext/msession/php_msession.h index b5504c2a95..efae5b44f3 100644 --- a/ext/msession/php_msession.h +++ b/ext/msession/php_msession.h @@ -44,6 +44,7 @@ PHP_FUNCTION(msession_connect); 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); diff --git a/ext/msession/reqclient.h b/ext/msession/reqclient.h index e67c983dd7..fd6cf7ed92 100644 --- a/ext/msession/reqclient.h +++ b/ext/msession/reqclient.h @@ -34,7 +34,7 @@ enum REQ_TYPES { REQ_ERR, REQ_OK, - REQ_STAT, + REQ_CTL, REQ_SETVAL, REQ_GETVAL, REQ_CREATE, @@ -55,9 +55,13 @@ enum REQ_TYPES 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 { @@ -103,6 +107,15 @@ typedef struct _requestBuf #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 ]; \ REQB *preq = StaticRequestBuffer(buffer, len);