]> granicus.if.org Git - php/commitdiff
Added new features for msession beta 2
authorMark L. Woodward <mlwmohawk@php.net>
Mon, 8 Apr 2002 23:07:23 +0000 (23:07 +0000)
committerMark L. Woodward <mlwmohawk@php.net>
Mon, 8 Apr 2002 23:07:23 +0000 (23:07 +0000)
ext/msession/msession.c
ext/msession/php_msession.h
ext/msession/reqclient.h

index f1598fc442650394fc62dc7a35d247988a9ccd0a..9c20607a86abf8336f80e322c2008955d8ef7956 100644 (file)
@@ -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)
index b5504c2a95d28d3ab0029feddbb9c82d6804d919..efae5b44f3331d862795bb8d9198730ce12a48a8 100644 (file)
@@ -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);
index e67c983dd7acf06615443de3bee00d5f2360d1bb..fd6cf7ed92f75def1a833123ee55a01ecc93f641 100644 (file)
@@ -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);