cvs: php4 /ext/session mod_mm.c modules.c php_session.h session.c
| From: | Sascha Schumann | Date: | Thu, 03 May 2001 15:48:49 +0000 |
| Subject: | cvs: php4 /ext/session mod_mm.c modules.c php_session.h session.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5508@lists.php.net to get a copy of this message | ||
sas Thu May 3 08:48:49 2001 EDT
Removed files:
/php4/ext/session modules.c
Modified files:
/php4/ext/session mod_mm.c php_session.h session.c
Log:
add an interface for registering storage modules at run-time.
Index: php4/ext/session/mod_mm.c
diff -u php4/ext/session/mod_mm.c:1.14 php4/ext/session/mod_mm.c:1.15
--- php4/ext/session/mod_mm.c:1.14 Sun Feb 25 22:07:15 2001
+++ php4/ext/session/mod_mm.c Thu May 3 08:48:49 2001
@@ -211,6 +211,7 @@
ps_mm_instance = NULL;
return FAILURE;
}
+ php_session_register_module(&ps_mod_mm);
return SUCCESS;
}
Index: php4/ext/session/php_session.h
diff -u php4/ext/session/php_session.h:1.39 php4/ext/session/php_session.h:1.40
--- php4/ext/session/php_session.h:1.39 Tue May 1 10:01:48 2001
+++ php4/ext/session/php_session.h Thu May 3 08:48:49 2001
@@ -169,6 +169,8 @@
void php_set_session_var(char *name, size_t namelen, zval *state_val PSLS_DC);
int php_get_session_var(char *name, size_t namelen, zval ***state_var PLS_DC PSLS_DC ELS_DC);
+int php_session_register_module(ps_module *);
+
int php_session_register_serializer(const char *name,
int (*encode)(PS_SERIALIZER_ENCODE_ARGS),
int (*decode)(PS_SERIALIZER_DECODE_ARGS));
Index: php4/ext/session/session.c
diff -u php4/ext/session/session.c:1.200 php4/ext/session/session.c:1.201
--- php4/ext/session/session.c:1.200 Tue May 1 10:01:48 2001
+++ php4/ext/session/session.c Thu May 3 08:48:49 2001
@@ -40,10 +40,11 @@
#include "ext/standard/php_rand.h" /* for RAND_MAX */
#include "ext/standard/info.h"
-#include "modules.c"
-
#include "ext/standard/php_smart_str.h"
+#include "mod_files.h"
+#include "mod_user.h"
+
function_entry session_functions[] = {
PHP_FE(session_name, NULL)
PHP_FE(session_module_name, NULL)
@@ -131,6 +132,13 @@
PS_SERIALIZER_ENTRY(php_binary)
};
+#define MAX_MODULES 10
+
+static ps_module *ps_modules[MAX_MODULES + 1] = {
+ ps_files_ptr,
+ ps_user_ptr
+};
+
int php_session_register_serializer(const char *name,
int (*encode)(PS_SERIALIZER_ENCODE_ARGS),
int (*decode)(PS_SERIALIZER_DECODE_ARGS))
@@ -152,7 +160,22 @@
return ret;
}
+int php_session_register_module(ps_module *ptr)
+{
+ int ret = -1;
+ int i;
+ for (i = 0; i < MAX_MODULES; i++) {
+ if (!ps_modules[i]) {
+ ps_modules[i] = ptr;
+ ret = 0;
+ break;
+ }
+ }
+
+ return ret;
+}
+
PHP_MINIT_FUNCTION(session);
PHP_RINIT_FUNCTION(session);
PHP_MSHUTDOWN_FUNCTION(session);
@@ -713,9 +736,9 @@
{
ps_module *ret = NULL;
ps_module **mod;
- ps_module **end = ps_modules + (sizeof(ps_modules)/sizeof(ps_module*));
+ int i;
- for (mod = ps_modules; mod < end; mod++)
+ for (i = 0, mod = ps_modules; i < MAX_MODULES; i++, mod++)
if (*mod && !strcasecmp(name, (*mod)->name)) {
ret = *mod;
break;