author | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
commit | 981b219f5297ad2ccc1fc1d0e24e41ec009c35a3 (patch) (unidiff) | |
tree | 9fa81d7fe70883ad26d946c902ba06edcebd4516 /lib/configuration.cc | |
parent | 54e344b7e3623e807b893b7febad3adfc6c1648f (diff) | |
download | sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.zip sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.gz sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.bz2 |
moved a few utility functions to konforka and bumped konforka version requirement accordingly
-rw-r--r-- | lib/configuration.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/configuration.cc b/lib/configuration.cc index 4ee1526..6b21690 100644 --- a/lib/configuration.cc +++ b/lib/configuration.cc | |||
@@ -1,16 +1,17 @@ | |||
1 | #ifdef USE_PCH | 1 | #ifdef USE_PCH |
2 | #include "pch.h" | 2 | #include "pch.h" |
3 | #else | 3 | #else |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fnmatch.h> | 5 | #include <fnmatch.h> |
6 | #include <cassert> | 6 | #include <cassert> |
7 | #include <stdexcept> | 7 | #include <stdexcept> |
8 | using namespace std; | 8 | using namespace std; |
9 | #include <konforka/util.h> | ||
9 | #include <dotconf.h> | 10 | #include <dotconf.h> |
10 | #include "sitecing/configuration.h" | 11 | #include "sitecing/configuration.h" |
11 | #include "sitecing/sitecing_util.h" | 12 | #include "sitecing/sitecing_util.h" |
12 | #include "sitecing/scoreboard.h" | 13 | #include "sitecing/scoreboard.h" |
13 | #endif | 14 | #endif |
14 | 15 | ||
15 | namespace sitecing { | 16 | namespace sitecing { |
16 | 17 | ||
@@ -299,17 +300,17 @@ namespace sitecing { | |||
299 | string rv; | 300 | string rv; |
300 | if(i!=http_status_handlers.end()) | 301 | if(i!=http_status_handlers.end()) |
301 | rv = i->second; | 302 | rv = i->second; |
302 | return rv; | 303 | return rv; |
303 | } | 304 | } |
304 | 305 | ||
305 | string configuration::lookup_http_status_handler(const string& target,const string& status) { | 306 | string configuration::lookup_http_status_handler(const string& target,const string& status) { |
306 | string t = "/"; | 307 | string t = "/"; |
307 | t += normalize_path(target,strip_leading_slash); | 308 | t += konforka::normalize_path(target,konforka::strip_leading_slash); |
308 | string rv; | 309 | string rv; |
309 | for(;;) { | 310 | for(;;) { |
310 | if(t[t.length()-1]=='/') { | 311 | if(t[t.length()-1]=='/') { |
311 | loaded_options* lo = lookup_loaded_options(t); | 312 | loaded_options* lo = lookup_loaded_options(t); |
312 | if( lo && (lo->flags&config_options::flag_http_status_handlers) ) { | 313 | if( lo && (lo->flags&config_options::flag_http_status_handlers) ) { |
313 | rv = lo->lookup_http_status_handler(status); | 314 | rv = lo->lookup_http_status_handler(status); |
314 | if(!rv.empty()) | 315 | if(!rv.empty()) |
315 | return rv; | 316 | return rv; |
@@ -332,17 +333,17 @@ namespace sitecing { | |||
332 | else | 333 | else |
333 | t.erase(sl+1); | 334 | t.erase(sl+1); |
334 | } | 335 | } |
335 | } | 336 | } |
336 | } | 337 | } |
337 | 338 | ||
338 | config_options::action_handler_t *configuration::lookup_action_handler(const string& target) { | 339 | config_options::action_handler_t *configuration::lookup_action_handler(const string& target) { |
339 | string t = "/"; | 340 | string t = "/"; |
340 | t += normalize_path(target,strip_leading_slash); | 341 | t += konforka::normalize_path(target,konforka::strip_leading_slash); |
341 | for(;;) { | 342 | for(;;) { |
342 | if(t[t.length()-1]=='/') { | 343 | if(t[t.length()-1]=='/') { |
343 | loaded_options* lo = lookup_loaded_options(t); | 344 | loaded_options* lo = lookup_loaded_options(t); |
344 | if( lo && (lo->flags&config_options::flag_action_handlers) ) { | 345 | if( lo && (lo->flags&config_options::flag_action_handlers) ) { |
345 | config_options::action_handler_t *rv = lo->lookup_action_handler(target); | 346 | config_options::action_handler_t *rv = lo->lookup_action_handler(target); |
346 | if(rv) | 347 | if(rv) |
347 | return rv; | 348 | return rv; |
348 | } | 349 | } |
@@ -364,17 +365,17 @@ namespace sitecing { | |||
364 | else | 365 | else |
365 | t.erase(sl+1); | 366 | t.erase(sl+1); |
366 | } | 367 | } |
367 | } | 368 | } |
368 | } | 369 | } |
369 | 370 | ||
370 | config_options* configuration::lookup_config(const string& target,int flag) { | 371 | config_options* configuration::lookup_config(const string& target,int flag) { |
371 | string t = "/"; // always assume leading slash | 372 | string t = "/"; // always assume leading slash |
372 | t += normalize_path(target,strip_leading_slash); | 373 | t += konforka::normalize_path(target,konforka::strip_leading_slash); |
373 | // XXX: reconsider precedence | 374 | // XXX: reconsider precedence |
374 | for(;;) { | 375 | for(;;) { |
375 | if(t[t.length()-1]=='/') { | 376 | if(t[t.length()-1]=='/') { |
376 | loaded_options* lo = lookup_loaded_options(t); | 377 | loaded_options* lo = lookup_loaded_options(t); |
377 | if( lo && (lo->flags&flag)==flag ) | 378 | if( lo && (lo->flags&flag)==flag ) |
378 | return lo; | 379 | return lo; |
379 | } | 380 | } |
380 | specs_t::iterator i = specs.find(t); | 381 | specs_t::iterator i = specs.find(t); |
@@ -409,17 +410,17 @@ namespace sitecing { | |||
409 | return true; | 410 | return true; |
410 | } | 411 | } |
411 | } | 412 | } |
412 | return false; | 413 | return false; |
413 | } | 414 | } |
414 | 415 | ||
415 | bool configuration::match_autobuild_files(const string& target,const char *fn) { | 416 | bool configuration::match_autobuild_files(const string& target,const char *fn) { |
416 | string t = "/"; | 417 | string t = "/"; |
417 | t += normalize_path(target,strip_leading_slash|strip_trailing_slash); | 418 | t += konforka::normalize_path(target,konforka::strip_leading_slash|konforka::strip_trailing_slash); |
418 | t += "/"; | 419 | t += "/"; |
419 | bool rv = false; | 420 | bool rv = false; |
420 | for(;;) { | 421 | for(;;) { |
421 | if(t[t.length()-1]=='/') { | 422 | if(t[t.length()-1]=='/') { |
422 | loaded_options* lo = lookup_loaded_options(t); | 423 | loaded_options* lo = lookup_loaded_options(t); |
423 | if(lo && (lo->flags&config_options::flag_auto_build_files) && lo->match_autobuild_files(fn,rv) ) | 424 | if(lo && (lo->flags&config_options::flag_auto_build_files) && lo->match_autobuild_files(fn,rv) ) |
424 | return rv; | 425 | return rv; |
425 | } | 426 | } |