Mercurial > hg > orthanc
comparison OrthancServer/OrthancInitialization.cpp @ 394:9784f19f7e1b lua-scripting
path relative to configuration path, list of lua scripts
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 May 2013 11:02:15 +0200 |
parents | fe180eae201d |
children | 2d269089078f |
comparison
equal
deleted
inserted
replaced
392:7035f4a5b07b | 394:9784f19f7e1b |
---|---|
45 { | 45 { |
46 static const char* CONFIGURATION_FILE = "Configuration.json"; | 46 static const char* CONFIGURATION_FILE = "Configuration.json"; |
47 | 47 |
48 static boost::mutex globalMutex_; | 48 static boost::mutex globalMutex_; |
49 static std::auto_ptr<Json::Value> configuration_; | 49 static std::auto_ptr<Json::Value> configuration_; |
50 static boost::filesystem::path defaultDirectory_; | |
50 | 51 |
51 | 52 |
52 static void ReadGlobalConfiguration(const char* configurationFile) | 53 static void ReadGlobalConfiguration(const char* configurationFile) |
53 { | 54 { |
54 configuration_.reset(new Json::Value); | 55 configuration_.reset(new Json::Value); |
56 std::string content; | 57 std::string content; |
57 | 58 |
58 if (configurationFile) | 59 if (configurationFile) |
59 { | 60 { |
60 Toolbox::ReadFile(content, configurationFile); | 61 Toolbox::ReadFile(content, configurationFile); |
62 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path(); | |
61 LOG(INFO) << "Using the configuration from: " << configurationFile; | 63 LOG(INFO) << "Using the configuration from: " << configurationFile; |
62 } | 64 } |
63 else | 65 else |
64 { | 66 { |
65 #if 0 && ORTHANC_STANDALONE == 1 && defined(__linux) | 67 #if 0 && ORTHANC_STANDALONE == 1 && defined(__linux) |
117 | 119 |
118 | 120 |
119 void OrthancInitialize(const char* configurationFile) | 121 void OrthancInitialize(const char* configurationFile) |
120 { | 122 { |
121 boost::mutex::scoped_lock lock(globalMutex_); | 123 boost::mutex::scoped_lock lock(globalMutex_); |
124 defaultDirectory_ = boost::filesystem::current_path(); | |
122 ReadGlobalConfiguration(configurationFile); | 125 ReadGlobalConfiguration(configurationFile); |
123 curl_global_init(CURL_GLOBAL_ALL); | 126 curl_global_init(CURL_GLOBAL_ALL); |
124 } | 127 } |
125 | 128 |
126 | 129 |
273 const std::string& username = usernames[i]; | 276 const std::string& username = usernames[i]; |
274 std::string password = users[username].asString(); | 277 std::string password = users[username].asString(); |
275 httpServer.RegisterUser(username.c_str(), password.c_str()); | 278 httpServer.RegisterUser(username.c_str(), password.c_str()); |
276 } | 279 } |
277 } | 280 } |
281 | |
282 | |
283 std::string InterpretStringParameterAsPath(const std::string& parameter) | |
284 { | |
285 boost::mutex::scoped_lock lock(globalMutex_); | |
286 return (defaultDirectory_ / parameter).string(); | |
287 } | |
288 | |
289 | |
290 void GetGlobalListOfStringsParameter(std::list<std::string>& target, | |
291 const std::string& key) | |
292 { | |
293 boost::mutex::scoped_lock lock(globalMutex_); | |
294 | |
295 target.clear(); | |
296 | |
297 if (!configuration_->isMember(key)) | |
298 { | |
299 return; | |
300 } | |
301 | |
302 const Json::Value& lst = (*configuration_) [key]; | |
303 | |
304 if (lst.type() != Json::arrayValue) | |
305 { | |
306 throw OrthancException("Badly formatted list of strings"); | |
307 } | |
308 | |
309 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++) | |
310 { | |
311 target.push_back(lst[i].asString()); | |
312 } | |
313 } | |
278 } | 314 } |