diff -r d07810b02147 -r de4bc3cd2d36 src/server/daemon/config.c --- a/src/server/daemon/config.c Sat Dec 29 18:08:23 2012 +0100 +++ b/src/server/daemon/config.c Sun Dec 30 15:49:44 2012 +0100 @@ -246,7 +246,30 @@ cfg->tmp = sstrdup(cfg_directivelist_get_str( obj->directives, sstr("Temp"))); - + + // mime file + sstr_t mf = cfg_directivelist_get_str(obj->directives, sstr("MimeFile")); + + sstr_t base = sstr("config/"); + sstr_t file; + file.length = base.length + mf.length + 1; + file.ptr = alloca(file.length); + file.ptr[file.length] = 0; + file = sstrncat(2, file, base, mf); + + ConfigFile *f = cfgmgr_get_file(file); + if(f == NULL) { + f = malloc(sizeof(ConfigFile)); + f->file = sstrdup(file); + f->reload = mime_conf_reload; + + // load the file content + f->reload(f, cfg); + cfgmgr_attach_file(f); + } + + cfg->mimetypes = f->data; // TODO: ref + return 0; } @@ -453,7 +476,7 @@ sstr_t objfile = cfg_directivelist_get_str( obj->directives, sstr("ObjectFile")); - sstr_t base = sstr("conf/"); + sstr_t base = sstr("config/"); sstr_t file; file.length = base.length + objfile.length + 1; file.ptr = alloca(file.length); @@ -572,3 +595,23 @@ return conf; } + +int mime_conf_reload(ConfigFile *file, ServerConfiguration *cfg) { + MimeConfig *mimecfg = load_mime_config(file->file.ptr); + + UcxMap *mimemap = ucx_map_new((mimecfg->ntypes * 3) / 2); + + // add ext type pairs + UCX_FOREACH(UcxList*, mimecfg->directives, md) { + MimeDirective *d = md->data; + // add the type for each extension to the map + UCX_FOREACH(UcxList*, d->exts, xl) { + sstr_t ext = sstr(xl->data); + sstr_t value = sstrdup(d->type); + ucx_map_sstr_put(mimemap, ext, value.ptr); + } + } + + file->data = mimemap; + return 0; +}