UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2013 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef CONF_H 30 #define CONF_H 31 32 #include <inttypes.h> 33 34 #include "../util/object.h" 35 36 #include "../config/objconf.h" 37 #include "../config/initconf.h" 38 #include "../config/mimeconf.h" 39 #include "../config/acl.h" 40 #include "../config/keyfile.h" 41 #include "../config/serverconfig.h" 42 43 #include "acldata.h" 44 #include "keyfile_auth.h" 45 #include "log.h" 46 #include "vfs.h" 47 48 #include "../webdav/webdav.h" 49 50 #include <cx/linked_list.h> 51 #include <cx/hash_map.h> 52 #include <cx/mempool.h> 53 #include <cx/string.h> 54 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 typedef struct mime_map MimeMap; 60 61 typedef struct WebdavRepository WebdavRepository; 62 typedef struct WebdavBackendInitData WebdavBackendInitData; 63 64 typedef struct CfgManager { 65 ServerConfig *serverconf; 66 ServerConfiguration *cfg; 67 } CfgManager; 68 69 struct ServerConfiguration { 70 pool_handle_t *pool; 71 CxAllocator *a; 72 73 ServerConfiguration *next; 74 75 CxMap *host_vs; // map of all vservers. key is the host name 76 CxList *listeners; // list of all listeners - TODO: remove 77 78 CxMap *listeners2; 79 80 CxList *logfiles; 81 AccessLog *default_log; 82 CxMap *authdbs; 83 MimeMap *mimetypes; 84 CxMap *resources; 85 CxMap *dav; 86 cxmutstr tmp; 87 cxmutstr user; 88 uint32_t ref; // reference counter 89 }; 90 91 struct WebdavRepository { 92 VfsType *vfs; 93 void *vfsInitData; 94 CxList *davBackends; // list of WebdavBackendInitData* 95 cxmutstr object; 96 }; 97 98 struct WebdavBackendInitData { 99 WebdavType *davType; 100 void *davInitData; 101 }; 102 103 struct mime_map { 104 CxMap *map; 105 }; 106 107 pool_handle_t* cfg_get_init_pool(void); 108 109 char* cfg_config_file_path(const char *file); 110 111 InitConfig* load_init_conf(const char *file); 112 int apply_init_conf(InitConfig *cfg); 113 void free_init_conf(InitConfig *cfg); 114 115 void init_server_config_parser(); 116 117 int cfg_handle_runtime(ServerConfiguration *cfg, ConfigNode *obj); 118 119 int cfg_handle_logfile(ServerConfiguration *cfg, ConfigNode *obj); 120 121 int cfg_handle_threadpool(ServerConfiguration *cfg, ConfigNode *obj); 122 123 int cfg_handle_eventhandler(ServerConfiguration *cfg, ConfigNode *obj); 124 125 int cfg_handle_resourcepool(ServerConfiguration *cfg, ConfigNode *obj); 126 127 int cfg_handle_accesslog(ServerConfiguration *cfg, ConfigNode *obj); 128 129 int cfg_handle_authdb(ServerConfiguration *cfg, ConfigNode *obj); 130 131 int cfg_handle_listener(ServerConfiguration *cfg, ConfigNode *obj); 132 133 int cfg_handle_vs(ServerConfiguration *cfg, ConfigNode *obj); 134 135 int cfg_handle_dav(ServerConfiguration *cfg, ConfigNode *obj); 136 137 ServerConfiguration* load_server_conf(CfgManager *mgr, char *file); 138 ServerConfiguration* apply_server_conf(CfgManager *mgr); 139 int migrate_server_conf(ServerConfiguration *old_cfg, ServerConfiguration *new_cfg); 140 141 void cfg_ref(ServerConfiguration *cfg); 142 void cfg_unref(ServerConfiguration *cfg); 143 144 HTTPObjectConfig* objconf_load(ServerConfiguration *scfg, cxmutstr file); 145 int mime_conf_load(ServerConfiguration *cfg, cxmutstr file); 146 147 ACLData* acl_conf_load(ServerConfiguration *cfg, const char *file); 148 ACLList* acl_config_convert(ServerConfiguration *cfg, ACLConfig *acl); 149 AuthDB* keyfile_load(ServerConfiguration *cfg, cxstring file); 150 151 pblock* config_obj2pblock(pool_handle_t *pool, ConfigNode *obj); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif /* CONF_H */ 158 159