void MaHost::setDocumentRoot(char *dir) { MaAlias *ap; char pathBuf[MPR_MAX_FNAME]; int len; makePath(pathBuf, sizeof(pathBuf) - 1, dir, 1); documentRoot = mprStrdup(pathBuf); // // Create a catch-all alias. We want this directory to have a trailing // "/" just like all aliases should. // len = strlen(pathBuf); if (pathBuf[len - 1] != '/') { pathBuf[len] = '/'; pathBuf[len + 1] = '\0'; } ap = new MaAlias("", pathBuf); insertAlias(ap); }
/* * AddAlias - add an alias to an alias list * - if an alias already exists for this identifier replace it */ void AddAlias( AliasHdl hdl, char *text, unsigned long id ) { AnAlias *cur; size_t len; cur = findAlias( hdl, id ); if( cur == NULL ) { cur = MemAlloc( sizeof( AnAlias ) ); cur->id = id; insertAlias( hdl, cur ); if( hdl->updatefn != NULL ) { hdl->updatefn( id, text, NULL, hdl->userdata ); } } else { if( hdl->updatefn != NULL ) { hdl->updatefn( id, text, cur->name, hdl->userdata ); } MemFree( cur->name ); } len = strlen( text ) + 1; cur->name = MemAlloc( len ); strcpy( cur->name, text ); } /* AddAlias */
void MaHost::inheritHost(MaHost *host) { MaHandler *hp; MaHandlerService *hs; MaLocation *lp; MaDir *dp; MaAlias *ap; // // Inherit key settings // httpVersion = host->httpVersion; #if BLD_FEATURE_KEEP_ALIVE keepAlive = host->keepAlive; keepAliveTimeout = host->keepAliveTimeout; maxKeepAlive = host->maxKeepAlive; #endif timeout = host->timeout; #if BLD_FEATURE_SESSION sessionTimeout = host->sessionTimeout; #endif #if BLD_FEATURE_ACCESS_LOG logHost = host->logHost; #endif setMimeTypes(host->mimeTypes); // // Inherit Aliases // ap = (MaAlias*) host->aliases.getFirst(); while (ap) { insertAlias(new MaAlias(ap)); ap = (MaAlias*) host->aliases.getNext(ap); } // // Inherit Directories // dp = (MaDir*) host->dirs.getFirst(); while (dp) { insertDir(new MaDir(this, dp)); dp = (MaDir*) host->dirs.getNext(dp); } // // Inherit Handlers // hp = (MaHandler*) host->handlers.getFirst(); while (hp) { hs = server->http->lookupHandlerService(hp->getName()); insertHandler(hs->newHandler(host->getServer(), this, hp->getExtensions())); hp = (MaHandler*) host->handlers.getNext(hp); } // // Inherit Locations // lp = (MaLocation*) host->locations.getFirst(); while (lp) { insertLocation(new MaLocation(lp)); lp = (MaLocation*) host->locations.getNext(lp); } }