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/serverconf.h" 39 #include "../config/mimeconf.h" 40 #include "../config/acl.h" 41 #include "../config/keyfile.h" 42 43 #include "acldata.h" 44 #include "keyfile_auth.h" 45 #include "log.h" 46 47 #include <ucx/list.h> 48 #include <ucx/map.h> 49 #include <ucx/mempool.h> 50 #include <ucx/string.h> 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 typedef struct mime_map MimeMap; 57 58 typedef struct _server_configuration { 59 pool_handle_t *pool; 60 UcxMap *host_vs; // map of all vservers. key is the host name 61 UcxList *listeners; // list of all listeners 62 UcxList *logfiles; 63 AccessLog *default_log; 64 UcxMap *authdbs; 65 MimeMap *mimetypes; 66 sstr_t tmp; 67 sstr_t user; 68 uint32_t ref; // reference counter 69 } ServerConfiguration; 70 71 72 typedef struct ConfigFile ConfigFile; 73 74 typedef int(*cfg_reload_f)(ConfigFile*,ServerConfiguration*); 75 76 struct ConfigFile { 77 sstr_t file; 78 time_t last_modified; 79 cfg_reload_f reload; 80 void *data; 81 }; 82 83 struct mime_map { 84 UcxMap *map; 85 uint32_t ref; 86 }; 87 88 int load_init_conf(char *file); 89 90 void init_server_config_parser(); 91 92 int cfg_handle_runtime(ServerConfiguration *cfg, ServerConfigObject *obj); 93 94 int cfg_handle_logfile(ServerConfiguration *cfg, ServerConfigObject *obj); 95 96 int cfg_handle_threadpool(ServerConfiguration *cfg, ServerConfigObject *obj); 97 98 int cfg_handle_eventhandler(ServerConfiguration *cfg, ServerConfigObject *obj); 99 100 int cfg_handle_accesslog(ServerConfiguration *cfg, ServerConfigObject *obj); 101 102 int cfg_handle_authdb(ServerConfiguration *cfg, ServerConfigObject *obj); 103 104 int cfg_handle_listener(ServerConfiguration *cfg, ServerConfigObject *obj); 105 106 int cfg_handle_vs(ServerConfiguration *cfg, ServerConfigObject *obj); 107 108 ServerConfiguration* load_server_conf(ServerConfiguration *old, char *file); 109 void cfg_ref(ServerConfiguration *cfg); 110 void cfg_unref(ServerConfiguration *cfg); 111 112 113 int object_conf_reload(ConfigFile *file, ServerConfiguration *cfg); 114 void object_conf_ref(HTTPObjectConfig *conf); 115 void object_conf_unref(HTTPObjectConfig *conf); 116 HTTPObjectConfig* load_obj_conf(char *file); 117 int mime_conf_reload(ConfigFile *file, ServerConfiguration *cfg); 118 void mime_conf_ref(MimeMap *conf); 119 void mime_conf_unref(MimeMap *conf); 120 int acl_conf_reload(ConfigFile *file, ServerConfiguration *cfg); 121 ACLList* acl_config_convert(ServerConfiguration *cfg, ACLConfig *acl); 122 int keyfile_reload(ConfigFile *file, ServerConfiguration *cfg); 123 124 sstr_t cfg_load_file(sstr_t file); 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif /* CONF_H */ 131 132