From: Gonzalo A. <ga...@us...> - 2006-09-08 15:01:42
|
Update of /cvsroot/mod-c/mod_c/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28783/src Modified Files: mod_c.c Makefile.am Log Message: Session handling shifted to EHTML. Index: Makefile.am =================================================================== RCS file: /cvsroot/mod-c/mod_c/src/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Makefile.am 22 Aug 2006 20:31:57 -0000 1.13 --- Makefile.am 8 Sep 2006 15:01:38 -0000 1.14 *************** *** 10,25 **** noinst_LIBRARIES = libmod_c.a noinst_PROGRAMS = mod_c - bin_PROGRAMS = mod_c_dss - - mod_c_dss_SOURCES = def_session_server.cpp - mod_c_dss_LDADD = -lpthread - mod_c_dss_CXXFLAGS = $(INCLUDE_DIRS) ! libmod_c_a_SOURCES = session_drivers.cpp lib_cache.cpp def_session_driver.cpp mod_c_LDADD = libmod_c.a mod_c$(EXEEXT): mod_c.c libmod_c.a ! $(APXS) $(INCLUDE_DIRS) -Wc,"$(CFLAGS)" -L$(srcdir) -c mod_c.c -lmod_c -ldl -lstdc++ rm -f mod_c.so ln -s .libs/mod_c.so mod_c.so --- 10,20 ---- noinst_LIBRARIES = libmod_c.a noinst_PROGRAMS = mod_c ! libmod_c_a_SOURCES = lib_cache.cpp mod_c_LDADD = libmod_c.a mod_c$(EXEEXT): mod_c.c libmod_c.a ! $(APXS) $(INCLUDE_DIRS) -Wc,"$(CFLAGS)" -L$(srcdir) -c mod_c.c -lmod_c -ldl -lstdc++ -lehtml rm -f mod_c.so ln -s .libs/mod_c.so mod_c.so *************** *** 27,29 **** install-exec-hook: $(APXS) -i -a mod_c.so ! SUBDIRS = dss_tool --- 22,24 ---- install-exec-hook: $(APXS) -i -a mod_c.so ! Index: mod_c.c =================================================================== RCS file: /cvsroot/mod-c/mod_c/src/mod_c.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mod_c.c 25 Aug 2006 13:27:41 -0000 1.18 --- mod_c.c 8 Sep 2006 15:01:38 -0000 1.19 *************** *** 21,31 **** #include "mod_c.h" #include "lib_cache.h" ! #include "session_drivers.h" ! #include "def_session_driver.h" ! #include "def_session_server.h" #include <dlfcn.h> #include <ehtml.h> ! #include <mod_c_sessions.h> #include <http_log.h> --- 21,29 ---- #include "mod_c.h" #include "lib_cache.h" ! #include "Session.h" #include <dlfcn.h> #include <ehtml.h> ! //#include <mod_c_sessions.h> #include <http_log.h> *************** *** 131,135 **** dir_config->sessions = 0; // Set the default duration of a session ! dir_config->session_duration = DEF_SESSION_DURATION; // Set the default session management type dir_config->session_funcs = 0; --- 129,133 ---- dir_config->sessions = 0; // Set the default duration of a session ! dir_config->session_duration = 10080 /* DEF_SESSION_DURATION*/; // Set the default session management type dir_config->session_funcs = 0; *************** *** 137,141 **** dir_config->cookieless = 0; // Set the default key size setting ! dir_config->key_size = DEF_ID_SIZE; return dir_config; --- 135,139 ---- dir_config->cookieless = 0; // Set the default key size setting ! dir_config->key_size = 64 /*DEF_ID_SIZE*/; return dir_config; *************** *** 160,174 **** // Initialize the caches (both for session drivers and ehtml files) config->ehtml_cache = CreateEHTMLCache(); ! config->session_drivers = InitSessionDrivers(); ! config->enable_remote_sessions = 0; ! config->session_server_port = -1; ! config->disable_session_server = 0; config->allow_on_demand = 0; config->allow_auto_refresh = 0; // Add the default session driver to the driver list ! const char* retVal = PutSessionDriverEx( config->session_drivers, DefaultSessionIdFunc ); ! if ( retVal ) ! SDEBUG(LOG_ERR, s, "The default driver could not have been imported. " ! "Error message: '%s'", retVal ); return config; --- 158,172 ---- // Initialize the caches (both for session drivers and ehtml files) config->ehtml_cache = CreateEHTMLCache(); ! //config->session_drivers = InitSessionDrivers(); ! //config->enable_remote_sessions = 0; ! //config->session_server_port = -1; ! //config->disable_session_server = 0; config->allow_on_demand = 0; config->allow_auto_refresh = 0; // Add the default session driver to the driver list ! //const char* retVal = PutSessionDriverEx( config->session_drivers, DefaultSessionIdFunc ); ! //if ( retVal ) ! // SDEBUG(LOG_ERR, s, "The default driver could not have been imported. " ! // "Error message: '%s'", retVal ); return config; *************** *** 255,270 **** * Loads and registers a session driver. */ ! static char* LoadEHTMLSessionDriver( cmd_parms* parms, void *mconfig, const char * path ) { ! mod_c_config * config = ( mod_c_config * ) ap_get_module_config( parms->server->module_config, &c_module ); ! const char * retVal = PutSessionDriver( config->session_drivers, path ); ! if ( retVal ) ! { char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "LoadEHTMLSessionDriver: Could not load the session driver '%s'. Error message: %s", path, retVal ); return errorMsg; ! } ! else ! return 0; } --- 253,277 ---- * Loads and registers a session driver. */ ! static char* LoadEHTMLSessionDriver( cmd_parms* parms, void *mconfig, const char* name, const char* path) { ! if (registerSessionDriver(name, path) < 0) { char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "LoadEHTMLSessionDriver: Could not load the session driver '%s' in '%s'. Error message: %s / %s", name, path, dlerror(), strerror(errno)); return errorMsg; ! } ! return NULL; ! } ! ! /** ! * Loads and registers a session id generation driver. ! */ ! static char* LoadEHTMLSessionIDDriver( cmd_parms* parms, void *mconfig, const char* name, const char* path) ! { ! if (registerSessionIDDriver(name, path) < 0) { ! char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "LoadEHTMLSessionIDDriver: Could not load the session id driver '%s' in '%s'. Error message: %s / %s", name, path, dlerror(), strerror(errno)); ! return errorMsg; ! } ! return NULL; } *************** *** 304,352 **** static char * EHTMLSessionTypeDirective( cmd_parms* parms, void *mconfig, const char * type, const char * arguments ) { ! mod_c_config * config = c_sconfig(parms->server); ! mod_c_dir_config* dir_config = c_pconfig(parms); ! // Search for the session driver that supports the desired type of session management ! ses_dr_info_t* dr_info = GetSessionDriver( config->session_drivers, type ); ! if ( dr_info ) ! { ! // Create a new session api object ! ses_api_t* ses_api = (ses_api_t*) apr_palloc( parms->pool, sizeof( ses_api_t ) ); ! memcpy( ses_api, &dr_info->api, sizeof( ses_api_t ) ); ! // We have found a session driver ! // Does it need any arguments? ! switch( dr_info->needs_args ) ! { ! case MUST_HAVE_ARGS: ! if ( arguments ) ! { ! const char * retVal = dr_info->ParseArgs( arguments, parms->pool, &ses_api->arguments ); ! if ( retVal ) // Was there an error? ! { ! char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "EHTMLSessionType: The session driver failed to parse these arguments: '%s'. The driver returned this error: '%s'", arguments, retVal ); ! return errorMsg; ! } ! // There was no error. We assume that the parsed arguments are correctly stored in the ses_api object ! } ! else ! { ! char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "EHTMLSessionType: The session driver that handles sessions of type '%s' needs additional arguments.", type ); ! return errorMsg; ! } ! break; ! default: ! break; ! } ! // Store the session api into the per-directory configuration object ! dir_config->session_funcs = ses_api; ! return 0; ! } ! else ! { ! char * errorMsg = ( char * ) apr_palloc( parms->temp_pool, 512 ); ! snprintf( errorMsg, 512, "EHTMLSessionType: Could not find a session driver that could handle sessions of type '%s'.", type ); ! return errorMsg; ! } } --- 311,343 ---- static char * EHTMLSessionTypeDirective( cmd_parms* parms, void *mconfig, const char * type, const char * arguments ) { ! // mod_c_config * config = c_sconfig(parms->server); ! // mod_c_dir_config* dir_config = c_pconfig(parms); ! // Search for the session driver that supports the desired type of session ! // management ! if (useSessionDriver(type, arguments) < 0) { ! char* errorMsg = (char*)apr_palloc(parms->temp_pool, 512); ! snprintf(errorMsg, 512, "EHTMLSessionType: unknown session type %s, " ! "or invalid argument \"%s\" (%s)", type, arguments, strerror(errno)); ! return errorMsg; ! } ! return NULL; ! } ! ! /** ! * Selects the proper driver for the specified session id generation type. ! */ ! static char * EHTMLSessionIDTypeDirective( cmd_parms* parms, void *mconfig, const char * type, const char * arguments ) ! { ! // mod_c_config * config = c_sconfig(parms->server); ! // mod_c_dir_config* dir_config = c_pconfig(parms); ! // Search for the session driver that supports the desired type of session ! // management ! if (useSessionIDDriver(type, arguments) < 0) { ! char* errorMsg = (char*)apr_palloc(parms->temp_pool, 512); ! snprintf(errorMsg, 512, "EHTMLSessionIDType: unknown session id type %s, " ! "or invalid argument \"%s\" (%s)", type, arguments, strerror(errno)); ! return errorMsg; ! } ! return NULL; } *************** *** 400,406 **** // Session directives ! AP_INIT_TAKE1("LoadEHTMLSessionDriver", (void*)LoadEHTMLSessionDriver, NULL, RSRC_CONF, ! "Arguments: a valid absolute path to a session driver file." ), AP_INIT_FLAG("EHTMLSessions", (void*)EHTMLSessionsDirective, NULL, --- 391,401 ---- // Session directives ! AP_INIT_TAKE2("LoadEHTMLSessionDriver", (void*)LoadEHTMLSessionDriver, NULL, RSRC_CONF, ! "Driver name and a valid absolute path to a session driver file." ), ! ! AP_INIT_TAKE2("LoadEHTMLSessionIDDriver", (void*)LoadEHTMLSessionIDDriver, ! NULL, RSRC_CONF, ! "Driver name and a valid absolute path to a session driver file." ), AP_INIT_FLAG("EHTMLSessions", (void*)EHTMLSessionsDirective, NULL, *************** *** 417,420 **** --- 412,421 ---- "type of session management needs it." ), + AP_INIT_TAKE12("EHTMLSessionIDType", (void*)EHTMLSessionIDTypeDirective, + NULL, + OR_LIMIT, "< type > [ arguments ] - the first parameter is " + "mandatory, while the second one is needed only if the selected " + "type of session management needs it." ), + AP_INIT_FLAG("EHTMLCookieless", (void*)EHTMLCookielessDirective, NULL, OR_LIMIT, "< on | off > - 'on' disables cookies while 'off' " |