summaryrefslogtreecommitdiffabout
path: root/include/sitecing/configuration.h
Unidiff
Diffstat (limited to 'include/sitecing/configuration.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/sitecing/configuration.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/include/sitecing/configuration.h b/include/sitecing/configuration.h
index 330a5a6..a2bf612 100644
--- a/include/sitecing/configuration.h
+++ b/include/sitecing/configuration.h
@@ -83,377 +83,394 @@ namespace sitecing {
83 * The files to be built are specified in the context. 83 * The files to be built are specified in the context.
84 * @see auto_build_files 84 * @see auto_build_files
85 */ 85 */
86 flag_auto_build_files = 0x0400 86 flag_auto_build_files = 0x0400
87 }; 87 };
88 /** 88 /**
89 * The flags specifying what parts of configuration have been 89 * The flags specifying what parts of configuration have been
90 * specified for the context. 90 * specified for the context.
91 */ 91 */
92 int flags; 92 int flags;
93 93
94 /** 94 /**
95 * The skeleton for building components. 95 * The skeleton for building components.
96 */ 96 */
97 string skeleton; 97 string skeleton;
98 /** 98 /**
99 * The flags to pass to compiler. 99 * The flags to pass to compiler.
100 */ 100 */
101 list<string> cpp_flags; 101 list<string> cpp_flags;
102 /** 102 /**
103 * The flags to pass to linker. 103 * The flags to pass to linker.
104 */ 104 */
105 list<string> ld_flags; 105 list<string> ld_flags;
106 /** 106 /**
107 * Whether to build inexstent and outdated components. 107 * Whether to build inexstent and outdated components.
108 */ 108 */
109 bool build; 109 bool build;
110 /** 110 /**
111 * Whether to track cpp dependencies. 111 * Whether to track cpp dependencies.
112 */ 112 */
113 bool cpp_deps; 113 bool cpp_deps;
114 /** 114 /**
115 * The component handling caught exceptions. 115 * The component handling caught exceptions.
116 */ 116 */
117 string exception_handler; 117 string exception_handler;
118 /** 118 /**
119 * Enforced intermediate dependencies. 119 * Enforced intermediate dependencies.
120 */ 120 */
121 list<string> intermediate_deps; 121 list<string> intermediate_deps;
122 /** 122 /**
123 * Enforced depencies for .so objects. 123 * Enforced depencies for .so objects.
124 */ 124 */
125 list<string> so_deps; 125 list<string> so_deps;
126 /** 126 /**
127 * The action handler type. 127 * The action handler type.
128 */ 128 */
129 struct action_handler_t { 129 struct action_handler_t {
130 /** 130 /**
131 * The regexp to check request against. 131 * The regexp to check request against.
132 */ 132 */
133 string s_regex; 133 string s_regex;
134 /** 134 /**
135 * Precompiled regex. 135 * Precompiled regex.
136 */ 136 */
137 pcrepp::Pcre regex; 137 pcrepp::Pcre regex;
138 /** 138 /**
139 * The action handler component. 139 * The action handler component.
140 */ 140 */
141 string action; 141 string action;
142 /** 142 /**
143 * Arguments for the action hander coponent. 143 * Arguments for the action hander coponent.
144 */ 144 */
145 list<string> args; 145 list<string> args;
146 146
147 /**
148 * @param s regex pattern
149 * @param a action handler
150 */
147 action_handler_t(const string& s,const string& a) 151 action_handler_t(const string& s,const string& a)
148 : s_regex(s), regex(s), action(a) { } 152 : s_regex(s), regex(s), action(a) { }
153 /**
154 * Copy constructor
155 *
156 * @param s source object
157 */
149 action_handler_t(const action_handler_t& s) 158 action_handler_t(const action_handler_t& s)
150 : s_regex(s.s_regex), regex(s.regex), action (s.action), args(s.args) { } 159 : s_regex(s.s_regex), regex(s.regex), action (s.action), args(s.args) { }
151 }; 160 };
152 /** 161 /**
153 * Type for the list of action handlers. 162 * Type for the list of action handlers.
154 */ 163 */
155 typedef list<action_handler_t> action_handlers_t; 164 typedef list<action_handler_t> action_handlers_t;
156 /** 165 /**
157 * The list of action handlers. 166 * The list of action handlers.
158 */ 167 */
159 action_handlers_t action_handlers; 168 action_handlers_t action_handlers;
160 /** 169 /**
161 * Type for the map of HTTP status handler components. 170 * Type for the map of HTTP status handler components.
162 */ 171 */
163 typedef map<string,string> http_status_handlers_t; 172 typedef map<string,string> http_status_handlers_t;
164 /** 173 /**
165 * The map of HTTP status handler components. 174 * The map of HTTP status handler components.
166 */ 175 */
167 http_status_handlers_t http_status_handlers; 176 http_status_handlers_t http_status_handlers;
168 /** 177 /**
169 * Files to be built automatically. 178 * Files to be built automatically.
170 */ 179 */
171 list<string> auto_build_files; 180 list<string> auto_build_files;
172 181
173 config_options() 182 config_options()
174 : flags(0) { } 183 : flags(0) { }
175 184
176 /** 185 /**
177 * Look up if there is an action handler for the target defined. 186 * Look up if there is an action handler for the target defined.
178 * @param target the target component. 187 * @param target the target component.
179 * @return the pointer to handler or zero. 188 * @return the pointer to handler or zero.
180 */ 189 */
181 action_handler_t *lookup_action_handler(const string& target); 190 action_handler_t *lookup_action_handler(const string& target);
182 /** 191 /**
183 * Look up if there is a handler defined for the HTTP status. 192 * Look up if there is a handler defined for the HTTP status.
184 * @param status HTTP status 193 * @param status HTTP status
185 * @return the handler component. 194 * @return the handler component.
186 */ 195 */
187 string lookup_http_status_handler(const string& status); 196 string lookup_http_status_handler(const string& status);
188 /** 197 /**
189 * Check whether the file should be build automatically. 198 * Check whether the file should be build automatically.
190 * @param fn file name. 199 * @param fn file name.
191 * @param rv reference to the boolean where the answer should go. 200 * @param rv reference to the boolean where the answer should go.
192 * @return true if we know the answer. 201 * @return true if we know the answer.
193 */ 202 */
194 bool match_autobuild_files(const char *fn,bool &rv); 203 bool match_autobuild_files(const char *fn,bool &rv);
195 }; 204 };
196 205
197 /** 206 /**
198 * Configuration data container for the configuration loaded from disk file. 207 * Configuration data container for the configuration loaded from disk file.
199 */ 208 */
200 class loaded_options : public config_options { 209 class loaded_options : public config_options {
201 public: 210 public:
202 /** 211 /**
203 * The file where configuration originates from. 212 * The file where configuration originates from.
204 */ 213 */
205 string source_file; 214 string source_file;
206 /** 215 /**
207 * The stat structure for the source file as it was when we have 216 * The stat structure for the source file as it was when we have
208 * loaded it. 217 * loaded it.
209 */ 218 */
210 struct stat st; 219 struct stat st;
211 220
212 /** 221 /**
213 * See if the data is still valid. 222 * See if the data is still valid.
214 * @return true if yes. 223 * @return true if yes.
215 */ 224 */
216 bool is_valid(); 225 bool is_valid();
217 226
218 /** 227 /**
219 * Load the configuration file. 228 * Load the configuration file.
220 * @param config the main configuration container. 229 * @param config the main configuration container.
221 * @param the configuration file. 230 * @param cfile the configuration file.
222 */ 231 */
223 void parse(configuration *config,const string& cfile); 232 void parse(configuration *config,const string& cfile);
224 }; 233 };
225 234
226 /** 235 /**
227 * The main configuration container. 236 * The main configuration container.
228 */ 237 */
229 class configuration { 238 class configuration {
230 public: 239 public:
231 /** 240 /**
232 * @todo TODO:: document me. 241 * @todo TODO:: document me.
233 */ 242 */
234 bool autobuild; 243 bool autobuild;
235 /** 244 /**
236 * The flags enumeration. 245 * The flags enumeration.
237 */ 246 */
238 enum _flags { 247 enum _flags {
239 /** 248 /**
240 * Was the source root specified? 249 * Was the source root specified?
241 * @see root_source 250 * @see root_source
242 */ 251 */
243 flag_root_source = 0x00000001, 252 flag_root_source = 0x00000001,
244 /** 253 /**
245 * Was the root for intermediate files specified? 254 * Was the root for intermediate files specified?
246 * @see root_intermediate 255 * @see root_intermediate
247 */ 256 */
248 flag_root_intermediate = 0x00000002, 257 flag_root_intermediate = 0x00000002,
249 /** 258 /**
250 * Was the root for the resulting .so files specified? 259 * Was the root for the resulting .so files specified?
251 * @see root_so 260 * @see root_so
252 */ 261 */
253 flag_root_so = 0x00000004, 262 flag_root_so = 0x00000004,
254 /** 263 /**
255 * Was the socket to listen to specified? 264 * Was the socket to listen to specified?
256 * @see listen_socket 265 * @see listen_socket
257 */ 266 */
258 flag_listen_socket = 0x00000008, 267 flag_listen_socket = 0x00000008,
259 /** 268 /**
260 * Was the per-dir config file name specified. 269 * Was the per-dir config file name specified.
261 * @see rc_file_name 270 * @see rc_file_name
262 */ 271 */
263 flag_rc_file_name = 0x00000010, 272 flag_rc_file_name = 0x00000010,
264 /** 273 /**
265 * Was the minimum number of child processes specified? 274 * Was the minimum number of child processes specified?
266 * @see min_children 275 * @see min_children
267 */ 276 */
268 flag_min_children = 0x00000020, 277 flag_min_children = 0x00000020,
269 /** 278 /**
270 * Was the maximum number of child processes specified? 279 * Was the maximum number of child processes specified?
271 * @see max_children 280 * @see max_children
272 */ 281 */
273 flag_max_children = 0x00000040, 282 flag_max_children = 0x00000040,
274 /** 283 /**
275 * Was the minimum number of spare child processes specified? 284 * Was the minimum number of spare child processes specified?
276 * @see min_spare_children 285 * @see min_spare_children
277 */ 286 */
278 flag_min_spare_children = 0x00000080, 287 flag_min_spare_children = 0x00000080,
279 /** 288 /**
280 * Was he maximum number of spare child processes specified? 289 * Was he maximum number of spare child processes specified?
281 * @see max_spare_children 290 * @see max_spare_children
282 */ 291 */
283 flag_max_spare_children = 0x00000100, 292 flag_max_spare_children = 0x00000100,
284 /** 293 /**
285 * Was the number of requests to handle per child process 294 * Was the number of requests to handle per child process
286 * specified? 295 * specified?
287 * @see requests_per_child 296 * @see requests_per_child
288 */ 297 */
289 flag_requests_per_child = 0x00000200, 298 flag_requests_per_child = 0x00000200,
290 /** 299 /**
291 * Was the multiprocess node (or it's absences) specified? 300 * Was the multiprocess node (or it's absences) specified?
292 * @see multi_process 301 * @see multi_process
293 */ 302 */
294 flag_multi_process = 0x00000400, 303 flag_multi_process = 0x00000400,
295 /** 304 /**
296 * Was the user specified? 305 * Was the user specified?
297 * @see user 306 * @see user
298 */ 307 */
299 flag_user = 0x00000800, 308 flag_user = 0x00000800,
300 /** 309 /**
301 * @Was the group specified? 310 * Was the group specified?
302 * @see group 311 * @see group
303 */ 312 */
304 flag_group = 0x00001000, 313 flag_group = 0x00001000,
305 /** 314 /**
306 * Was the root to change to specified? 315 * Was the root to change to specified?
307 * @see chroot 316 * @see chroot
308 */ 317 */
309 flag_chroot = 0x00002000, 318 flag_chroot = 0x00002000,
310 /** 319 /**
311 * Was the file for storing PID specified? 320 * Was the file for storing PID specified?
312 * @see pidfile 321 * @see pidfile
313 */ 322 */
314 flag_pid_file = 0x00004000, 323 flag_pid_file = 0x00004000,
315 /** 324 /**
316 * Was it specified wether we should daemonize the process? 325 * Was it specified wether we should daemonize the process?
317 * @see daemonize 326 * @see daemonize
318 */ 327 */
319 flag_daemonize = 0x00008000 328 flag_daemonize = 0x00008000
320 }; 329 };
321 /** 330 /**
322 * The flags specifying what parts of the configuration has been 331 * The flags specifying what parts of the configuration has been
323 * loaded into the object. 332 * loaded into the object.
324 */ 333 */
325 long flags; 334 long flags;
326 335
327 /** 336 /**
328 * The root for the components source code. 337 * The root for the components source code.
329 */ 338 */
330 string root_source; 339 string root_source;
331 /** 340 /**
332 * The root for intermediate files. 341 * The root for intermediate files.
333 */ 342 */
334 string root_intermediate; 343 string root_intermediate;
335 /** 344 /**
336 * The root for .so files. 345 * The root for .so files.
337 */ 346 */
338 string root_so; 347 string root_so;
339 /** 348 /**
340 * Socket to bind to 349 * Socket to bind to
341 */ 350 */
342 string listen_socket; 351 string listen_socket;
343 /** 352 /**
344 * per-dir config file name. 353 * per-dir config file name.
345 */ 354 */
346 string rc_file_name; 355 string rc_file_name;
347 /** 356 /**
348 * The minimum number of child processes in multiprocess mode. 357 * The minimum number of child processes in multiprocess mode.
349 */ 358 */
350 int min_children; 359 int min_children;
351 /** 360 /**
352 * The maxium number of child processes in multiprocess mode. 361 * The maxium number of child processes in multiprocess mode.
353 */ 362 */
354 int max_children; 363 int max_children;
355 /** 364 /**
356 * The minimum number of spare chidren in multiprocess mode. 365 * The minimum number of spare chidren in multiprocess mode.
357 */ 366 */
358 int min_spare_children; 367 int min_spare_children;
359 /** 368 /**
360 * The maximum number of spare children in multiprocess mode. 369 * The maximum number of spare children in multiprocess mode.
361 */ 370 */
362 int max_spare_children; 371 int max_spare_children;
363 /** 372 /**
364 * The number of requests the child process should handle before 373 * The number of requests the child process should handle before
365 * exiting. 374 * exiting.
366 */ 375 */
367 int requests_per_child; 376 int requests_per_child;
368 /** 377 /**
369 * Whether we should run in multiprocess mode or not. 378 * Whether we should run in multiprocess mode or not.
370 */ 379 */
371 bool multi_process; 380 bool multi_process;
372 /** 381 /**
373 * User to change to. 382 * User to change to.
374 */ 383 */
375 string user; 384 string user;
376 /** 385 /**
377 * Group to set to. 386 * Group to set to.
378 */ 387 */
379 string group; 388 string group;
380 /** 389 /**
381 * Directory to change root to. 390 * Directory to change root to.
382 */ 391 */
383 string chroot; 392 string chroot;
384 /** 393 /**
385 * The file to store PID into. 394 * The file to store PID into.
386 */ 395 */
387 string pid_file; 396 string pid_file;
388 /** 397 /**
389 * Whether we should fork into background. 398 * Whether we should fork into background.
390 */ 399 */
391 bool daemonize; 400 bool daemonize;
392 401
402 /**
403 * Type for the config options map
404 * @see specs
405 */
393 typedef map<string,config_options> specs_t; 406 typedef map<string,config_options> specs_t;
394 /** 407 /**
395 * The local config options map. 408 * The local config options map.
396 */ 409 */
397 specs_t specs; 410 specs_t specs;
411 /**
412 * Type for the loaded per-dir config map
413 * @see loaded_specs
414 */
398 typedef map<string,loaded_options> loaded_specs_t; 415 typedef map<string,loaded_options> loaded_specs_t;
399 /** 416 /**
400 * The local config options as specified in per-dir config files 417 * The local config options as specified in per-dir config files
401 * map. 418 * map.
402 */ 419 */
403 loaded_specs_t loaded_specs; 420 loaded_specs_t loaded_specs;
404 421
405 configuration(); 422 configuration();
406 /** 423 /**
407 * @param cfile the configuration file. 424 * @param cfile the configuration file.
408 * @param ab @todo TODO:: document me 425 * @param ab document me @todo TODO:: document me
409 */ 426 */
410 configuration(const string& cfile,bool ab=false); 427 configuration(const string& cfile,bool ab=false);
411 428
412 /** 429 /**
413 * Parse the configuration file. 430 * Parse the configuration file.
414 * @param cfile the configuration file. 431 * @param cfile the configuration file.
415 */ 432 */
416 void parse(const string& cfile); 433 void parse(const string& cfile);
417 434
418 /** 435 /**
419 * Fetch the reference to options for the very root. 436 * Fetch the reference to options for the very root.
420 */ 437 */
421 config_options& root_options() { return specs[""]; } 438 config_options& root_options() { return specs[""]; }
422 /** 439 /**
423 * Lookup where the certain config option for the target lies in. 440 * Lookup where the certain config option for the target lies in.
424 * @param target the target component. 441 * @param target the target component.
425 * @param flag the flag specifying the option we're looking for. 442 * @param flag the flag specifying the option we're looking for.
426 * @return the destination options continer or zero. 443 * @return the destination options continer or zero.
427 */ 444 */
428 config_options* lookup_config(const string& target,int flag); 445 config_options* lookup_config(const string& target,int flag);
429 /** 446 /**
430 * Lookup the action handler for the target. 447 * Lookup the action handler for the target.
431 * @param target the target request. 448 * @param target the target request.
432 * @return the action handler or zero. 449 * @return the action handler or zero.
433 */ 450 */
434 config_options::action_handler_t *lookup_action_handler(const string& target); 451 config_options::action_handler_t *lookup_action_handler(const string& target);
435 /** 452 /**
436 * Lookup the HTPP status handler for the target. 453 * Lookup the HTPP status handler for the target.
437 * @param target the target. 454 * @param target the target.
438 * @param status the HTTP status. 455 * @param status the HTTP status.
439 * @return the handler component. 456 * @return the handler component.
440 */ 457 */
441 string lookup_http_status_handler(const string& target,const string& status); 458 string lookup_http_status_handler(const string& target,const string& status);
442 /** 459 /**
443 * Lookup the options loaded from per-dir config for the target 460 * Lookup the options loaded from per-dir config for the target
444 * @param target the target. 461 * @param target the target.
445 * @return options container or zero. 462 * @return options container or zero.
446 */ 463 */
447 loaded_options* lookup_loaded_options(const string& target); 464 loaded_options* lookup_loaded_options(const string& target);
448 /** 465 /**
449 * Check whether the components for the target should be prebuilt. 466 * Check whether the components for the target should be prebuilt.
450 * @param target the target. 467 * @param target the target.
451 * @param fn file name. 468 * @param fn file name.
452 * @return true if yes. 469 * @return true if yes.
453 */ 470 */
454 bool match_autobuild_files(const string& target,const char *fn); 471 bool match_autobuild_files(const string& target,const char *fn);
455 }; 472 };
456 473
457} 474}
458 475
459#endif /* __SITECING_CONFIGURATION_H */ 476#endif /* __SITECING_CONFIGURATION_H */