Changeset 209 for Evidence/Evidence.cc
- Timestamp:
- 05/19/10 09:08:40 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Evidence/Evidence.cc
r199 r209 38 38 // Initialize 39 39 Status = NULL; 40 StdOutText = NULL; 40 41 ExitRequest = false; 41 42 ThisServer = this; … … 60 61 61 62 Status = new DimService((ServerName+"/Status").c_str(), (char *) "C", InitMsg, strlen(InitMsg)+1); 63 StdOut = new DimService((ServerName+"/Textout").c_str(), (char *) ""); 62 64 63 65 start(Name); … … 74 76 } 75 77 delete ModifyInfo; 78 79 delete Status; 80 delete StdOut; 76 81 } 77 82 … … 126 131 // Terminate if message type is fatal 127 132 if (Severity == FATAL) exit(EXIT_FAILURE); 133 } 134 135 // Set text of StdOut service 136 void EvidenceServer::SetStdOut(char *Text) { 137 138 // Copy text to permanent buffer 139 char *Tmp = new char[strlen(Text)+1]; 140 strcpy(Tmp, Text); 141 StdOut->updateService(Tmp); 142 143 // Delete old buffer and save new buffer pointer 144 delete[] StdOutText; 145 StdOutText = Tmp; 128 146 } 129 147 … … 148 166 break; 149 167 } 150 168 151 169 // Make configuration request 152 DimRpcInfo Config((char *) "ConfigRequest", (char *) "");170 DimRpcInfo Config((char *) "ConfigRequest", NO_LINK); 153 171 Config.setData((char *) (ServerName + " " + Item).c_str()); 154 172 char *Result = Config.getString(); 155 173 156 174 // Terminate if not successful 175 if (!EvidenceServer::ServiceOK(&Config)) { 176 State(FATAL, "Configuration server unreachable, can't get '%s'", Item.c_str()); 177 } 178 157 179 if (strlen(Result) == 0) { 158 180 if (Default == NULL) State(FATAL, "Missing configuration data '%s'", Item.c_str()); … … 172 194 strcpy(ConfigList[ItemNo].Value, Result); 173 195 ConfigList[ItemNo].Time = ModifyInfo->LastModifyTime; 174 196 175 197 // Return address to configuration value 176 198 return ConfigList[ItemNo].Value; … … 314 336 return !((Item->getSize() == strlen(NO_LINK)+1) && 315 337 (memcmp(Item->getData(), NO_LINK, Item->getSize()) == 0)); 316 317 } 318 338 } 339 340 bool EvidenceServer::ServiceOK(DimRpcInfo *Item) { 341 342 return !((Item->getSize() == strlen(NO_LINK)+1) && 343 (memcmp(Item->getData(), NO_LINK, Item->getSize()) == 0)); 344 } 319 345 320 346 /////////////////////////// … … 333 359 334 360 // Constructor 335 EvidenceHistory::EvidenceHistory(std::string Name, int Delay): 336 Name(Name+".hist"), 337 Delay(Delay) { 361 EvidenceHistory::EvidenceHistory(std::string Name): Name(Name) { 338 362 339 363 Buffer = NULL; 340 LastUpdate = 0;341 364 } 342 365 … … 350 373 bool EvidenceHistory::GetHistory() { 351 374 352 // Check if last buffer update less than minimum delay in the past 353 if ((Buffer != NULL) && (time(NULL)-LastUpdate < Delay)) { 354 Offset = *(int *) Buffer; 355 return true; 356 } 357 LastUpdate = time(NULL); 358 359 // Check if service available 360 DimCurrentInfo Info(Name.c_str(), NO_LINK); 361 if (((Info.getSize() == strlen(NO_LINK)+1) && 362 (memcmp(Info.getData(), NO_LINK, Info.getSize()) == 0))) return false; 375 DimRpcInfo R((char *) "ServiceHistory", NO_LINK); 376 R.setData((char *) Name.c_str()); 377 if (!EvidenceServer::ServiceOK(&R)) return false; 363 378 364 379 delete[] Buffer; 365 BufferSize = Info.getSize();380 BufferSize = R.getSize(); 366 381 Buffer = new char [BufferSize]; 367 382 368 memcpy(Buffer, Info.getData(), BufferSize);383 memcpy(Buffer, R.getData(), BufferSize); 369 384 Offset = *(int *) Buffer; 370 385
Note:
See TracChangeset
for help on using the changeset viewer.