From 81b48dc3a7480c3df87d4293722b5a3d5f0de2c2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Feb 2011 10:53:31 +0200 Subject: Pass profile paths to plugin; handle profile options --- odb/odb.cxx | 73 +++++++++---------------------------------------------------- 1 file changed, 10 insertions(+), 63 deletions(-) (limited to 'odb/odb.cxx') diff --git a/odb/odb.cxx b/odb/odb.cxx index d8576d2..d4d719d 100644 --- a/odb/odb.cxx +++ b/odb/odb.cxx @@ -25,7 +25,6 @@ # include // _O_TEXT #endif -#include #include #include #include // size_t @@ -38,6 +37,7 @@ #include #include +#include #ifdef HAVE_CONFIG_H # include @@ -115,25 +115,9 @@ encode_plugin_option (string const& k, string const& v); // profile_failure, process_failure and invalid_path exceptions. Name // is the program name (argv[0]) for diagnostics. // -struct profile_failure {}; - static paths profile_paths (strings const& args, char const* name); -// Search for the profile options file. -// -struct profile_data -{ - profile_data (paths const& p, char const* n): search_paths (p), name (n) {} - - paths const& search_paths; - set loaded; - char const* name; -}; - -static string -profile_search (char const* profile, void* arg); - static char const* const db_macro[] = { "-DODB_DATABASE_MYSQL", @@ -483,7 +467,15 @@ main (int argc, char* argv[]) args.push_back (encode_plugin_option (k, v)); } - // Reserve space for and remember the position of the --svc-file + // Pass profile search paths (svc-path option). + // + for (paths::const_iterator i (prof_paths.begin ()); + i != prof_paths.end (); ++i) + { + args.push_back (encode_plugin_option ("svc-path", i->string ())); + } + + // Reserve space for and remember the position of the svc-file // option. // size_t svc_file_pos (args.size ()); @@ -824,51 +816,6 @@ profile_paths (strings const& sargs, char const* name) return r; } -static string -profile_search (char const* prof, void* arg) -{ - profile_data* pd (static_cast (arg)); - paths const& ps (pd->search_paths); - - path p (prof), odb ("odb"), r; - p.normalize (); // Convert '/' to the canonical path separator form. - p += ".options"; - - struct stat info; - paths::const_iterator i (ps.begin ()), end (ps.end ()); - - for (; i != end; ++i) - { - // First check in the search directory itself and then try the odb/ - // subdirectory. - // - r = *i / p; - - // Just check that the file exist without checking for permissions, etc. - // - if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) - break; - - r = *i / odb / p; - - if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) - break; - } - - if (i == end) - { - cerr << pd->name << ": error: unable to locate options file for profile '" - << prof << "'" << endl; - throw profile_failure (); - } - - if (pd->loaded.find (r) != pd->loaded.end ()) - return string (); - - pd->loaded.insert (r); - return r.string (); -} - // // Path manipulation. // -- cgit v1.1