in src/mod_rivet_ng/mod_rivet_common.c [233:330]
void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
rivet_thread_private* private,
server_rec *s,
apr_pool_t *p)
{
rivet_interp_globals* globals = NULL;
Tcl_Obj* auto_path = NULL;
Tcl_Obj* rivet_tcl = NULL;
Tcl_Interp* interp = interp_obj->interp;
ap_assert (interp != (Tcl_Interp *)NULL);
Tcl_Preserve (interp);
/* Set up interpreter associated data */
globals = ckalloc(sizeof(rivet_interp_globals));
/*
* we assign a default server_rec value into the globals
* even though some mpm bridge may override it
*/
globals->server = s;
/*
* we store in the globals some information relevant to
* the embedded interpreter work
*/
/* the ::rivet namespace is created */
globals->rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,NULL,
(Tcl_NamespaceDeleteProc *)NULL);
/* this is interp specific global data */
Tcl_SetAssocData (interp,"rivet",NULL,globals);
/* We put in front the auto_path list the path to the directory where
* init.tcl is located (provides package Rivet, previously RivetTcl)
*/
auto_path = Tcl_GetVar2Ex(interp,"auto_path",NULL,TCL_GLOBAL_ONLY);
rivet_tcl = Tcl_NewStringObj(RIVET_DIR,-1);
Tcl_IncrRefCount(rivet_tcl);
if (Tcl_IsShared(auto_path)) {
auto_path = Tcl_DuplicateObj(auto_path);
}
if (Tcl_ListObjReplace(interp,auto_path,0,0,1,&rivet_tcl) == TCL_ERROR)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": error setting auto_path: %s",
Tcl_GetStringFromObj(auto_path,NULL));
} else {
Tcl_SetVar2Ex(interp,"auto_path",NULL,auto_path,TCL_GLOBAL_ONLY);
}
Tcl_DecrRefCount(rivet_tcl);
/* If the thread has private data we stuff the server conf
* pointer in the 'running_conf' field.
* Commands running ouside a request processing must figure out
* themselves how get a pointer to the configuration from the
* context (e.g. ::rivet::inspect)
*/
if (private != NULL) private->running_conf = RIVET_SERVER_CONF (s->module_config);
/* Initialize the interpreter with Rivet's Tcl commands. */
Rivet_InitCore(interp,private);
/* Create a global array with information about the server. */
Rivet_InitServerVariables(interp,p);
/* Eval Rivet's init.tcl file to load in the Tcl-level commands. */
/* Watch out! Calling Tcl_PkgRequire with a version number binds this module to
* the Rivet package revision number in rivet/init.tcl
*
* RIVET_TCL_PACKAGE_VERSION is defined by configure.ac as the combination
* "MAJOR_VERSION.MINOR_VERSION". We don't expect to change rivet/init.tcl
* across patchlevel releases
*/
if (Tcl_PkgRequire(interp, "Rivet", RIVET_INIT_VERSION, 1) == NULL)
{
ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": init.tcl must be installed correctly for Apache Rivet to function: %s (%s)",
Tcl_GetStringResult(interp), RIVET_DIR );
exit(1);
}
Tcl_Release(interp);
interp_obj->flags |= RIVET_INTERP_INITIALIZED;
}