Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1280:d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 10:25:56 +0100 |
parents | 2ffe07abd9d8 |
children | 7bccdd221e2b |
comparison
equal
deleted
inserted
replaced
1279:7f3a65e84d4b | 1280:d6a65dc6d0ac |
---|---|
190 boost::mutex callbackMutex_; | 190 boost::mutex callbackMutex_; |
191 SharedMessageQueue pendingChanges_; | 191 SharedMessageQueue pendingChanges_; |
192 boost::thread changeThread_; | 192 boost::thread changeThread_; |
193 bool done_; | 193 bool done_; |
194 Properties properties_; | 194 Properties properties_; |
195 int argc_; | |
196 char** argv_; | |
195 | 197 |
196 PImpl(ServerContext& context) : | 198 PImpl(ServerContext& context) : |
197 context_(context), | 199 context_(context), |
198 restApi_(NULL), | 200 restApi_(NULL), |
199 hasStorageArea_(false), | 201 hasStorageArea_(false), |
200 done_(false) | 202 done_(false), |
203 argc_(1), | |
204 argv_(NULL) | |
201 { | 205 { |
202 memset(&storageArea_, 0, sizeof(storageArea_)); | 206 memset(&storageArea_, 0, sizeof(storageArea_)); |
203 } | 207 } |
204 | 208 |
205 | 209 |
1056 std::string result = pimpl_->context_.GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); | 1060 std::string result = pimpl_->context_.GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); |
1057 *(p.result) = CopyString(result); | 1061 *(p.result) = CopyString(result); |
1058 return true; | 1062 return true; |
1059 } | 1063 } |
1060 | 1064 |
1065 case _OrthancPluginService_GetCommandLineArgumentsCount: | |
1066 { | |
1067 const _OrthancPluginReturnSingleValue& p = | |
1068 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters); | |
1069 *(p.resultUint32) = pimpl_->argc_ - 1; | |
1070 return true; | |
1071 } | |
1072 | |
1073 case _OrthancPluginService_GetCommandLineArgument: | |
1074 { | |
1075 const _OrthancPluginGlobalProperty& p = | |
1076 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters); | |
1077 | |
1078 if (p.property + 1 > pimpl_->argc_) | |
1079 { | |
1080 return false; | |
1081 } | |
1082 else | |
1083 { | |
1084 std::string arg = std::string(pimpl_->argv_[p.property + 1]); | |
1085 *(p.result) = CopyString(arg); | |
1086 return true; | |
1087 } | |
1088 } | |
1089 | |
1061 default: | 1090 default: |
1062 return false; | 1091 return false; |
1063 } | 1092 } |
1064 } | 1093 } |
1065 | 1094 |
1189 else | 1218 else |
1190 { | 1219 { |
1191 return it->second.c_str(); | 1220 return it->second.c_str(); |
1192 } | 1221 } |
1193 } | 1222 } |
1223 | |
1224 | |
1225 void OrthancPlugins::SetCommandLineArguments(int argc, char* argv[]) | |
1226 { | |
1227 if (argc < 1 || argv == NULL) | |
1228 { | |
1229 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1230 } | |
1231 | |
1232 pimpl_->argc_ = argc; | |
1233 pimpl_->argv_ = argv; | |
1234 } | |
1194 } | 1235 } |