1 /*
2 *
3 * Copyright (C) 1998-2018, OFFIS e.V.
4 * All rights reserved. See COPYRIGHT file for details.
5 *
6 * This software and supporting documentation were developed by
7 *
8 * OFFIS e.V.
9 * R&D Division Health
10 * Escherweg 2
11 * D-26121 Oldenburg, Germany
12 *
13 *
14 * Module: dcmpstat
15 *
16 * Author: Joerg Riesmeier, Marco Eichelberg
17 *
18 * Purpose: DVConfiguration
19 *
20 */
21
22
23 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
24 #include "dcmtk/dcmpstat/dvpscf.h" /* for DVConfiguration */
25 #include "dcmtk/ofstd/ofconfig.h" /* for class OFConfigFile */
26 #include "dcmtk/dcmpstat/dvpsdef.h" /* for constants */
27 #include "dcmtk/ofstd/ofstd.h" /* for class OFStandard */
28
29 #define INCLUDE_CSTDIO
30 #define INCLUDE_CSTRING
31 #define INCLUDE_CCTYPE
32 #include "dcmtk/ofstd/ofstdinc.h"
33
34 #ifndef HAVE_WINDOWS_H
35 /* some Unix operating systems do not define a prototype for strncasecmp
36 * although the function is known.
37 */
38 #ifndef HAVE_PROTOTYPE_STRNCASECMP
39 extern "C" int strncasecmp(const char *s1, const char *s2, size_t n);
40 #endif
41 #endif
42
43 /* keywords for configuration file */
44
45 #define L0_AETITLE "AETITLE"
46 #define L0_ALWAYSDELETETERMINATEJOBS "ALWAYSDELETETERMINATEJOBS"
47 #define L0_ANNOTATION "ANNOTATION"
48 #define L0_AUTOCREATECONFIGFILE "AUTOCREATECONFIGFILE"
49 #define L0_BINARYLOG "BINARYLOG"
50 #define L0_BITPRESERVINGMODE "BITPRESERVINGMODE"
51 #define L0_BORDERDENSITY "BORDERDENSITY"
52 #define L0_CACERTIFICATEDIRECTORY "CACERTIFICATEDIRECTORY"
53 #define L0_CENTER "CENTER"
54 #define L0_CERTIFICATE "CERTIFICATE"
55 #define L0_CHARACTERISTICS "CHARACTERISTICS"
56 #define L0_CHECK "CHECK"
57 #define L0_CODE "CODE"
58 #define L0_CORRECTUIDPADDING "CORRECTUIDPADDING"
59 #define L0_DEFAULTILLUMINATION "DEFAULTILLUMINATION"
60 #define L0_DEFAULTREFLECTION "DEFAULTREFLECTION"
61 #define L0_DELETEPRINTJOBS "DELETEPRINTJOBS"
62 #define L0_DESCRIPTION "DESCRIPTION"
63 #define L0_DETAILEDLOG "DETAILEDLOG"
64 #define L0_DICOMNAME "DICOMNAME"
65 #define L0_DIFFIEHELLMANPARAMETERS "DIFFIEHELLMANPARAMETERS"
66 #define L0_DIRECTORY "DIRECTORY"
67 #define L0_DISABLENEWVRS "DISABLENEWVRS"
68 #define L0_DISPLAYFORMAT "DISPLAYFORMAT"
69 #define L0_DUMP "DUMP"
70 #define L0_EMPTYIMAGEDENSITY "EMPTYIMAGEDENSITY"
71 #define L0_FILENAME "FILENAME"
72 #define L0_FILMDESTINATION "FILMDESTINATION"
73 #define L0_FILMSIZEID "FILMSIZEID"
74 #define L0_HOSTNAME "HOSTNAME"
75 #define L0_IMPLICITONLY "IMPLICITONLY"
76 #define L0_KEEPMESSAGEPORTOPEN "KEEPMESSAGEPORTOPEN"
77 #define L0_LOGDIRECTORY "LOGDIRECTORY"
78 #define L0_LOGFILE "LOGFILE"
79 #define L0_LOGIN "LOGIN"
80 #define L0_LOGLEVEL "LOGLEVEL"
81 #define L0_MAGNIFICATIONTYPE "MAGNIFICATIONTYPE"
82 #define L0_MAXASSOCIATIONS "MAXASSOCIATIONS"
83 #define L0_MAXCOLUMNS "MAXCOLUMNS"
84 #define L0_MAXDENSITY "MAXDENSITY"
85 #define L0_MAXPDU "MAXPDU"
86 #define L0_MAXPRINTRESOLUTION "MAXPRINTRESOLUTION"
87 #define L0_MAXROWS "MAXROWS"
88 #define L0_MEDIUMTYPE "MEDIUMTYPE"
89 #define L0_MESSAGEPORT "MESSAGEPORT"
90 #define L0_MINDENSITY "MINDENSITY"
91 #define L0_MINPRINTRESOLUTION "MINPRINTRESOLUTION"
92 #define L0_MODALITY "MODALITY"
93 #define L0_NAME "NAME"
94 #define L0_OMITSOPCLASSUIDFROMCREATERESPONSE "OMITSOPCLASSUIDFROMCREATERESPONSE"
95 #define L0_ORGANIZATION "ORGANIZATION"
96 #define L0_PEERAUTHENTICATION "PEERAUTHENTICATION"
97 #define L0_PORT "PORT"
98 #define L0_PRESENTATIONLUTINFILMSESSION "PRESENTATIONLUTINFILMSESSION"
99 #define L0_PRESENTATIONLUTMATCHREQUIRED "PRESENTATIONLUTMATCHREQUIRED"
100 #define L0_PRESENTATIONLUTPREFERSCPRENDERING "PRESENTATIONLUTPREFERSCPRENDERING"
101 #define L0_PREVIEW "PREVIEWSIZE"
102 #define L0_PRIVATEKEY "PRIVATEKEY"
103 #define L0_PRIVATEKEYPASSWORD "PRIVATEKEYPASSWORD"
104 #define L0_RANDOMSEED "RANDOMSEED"
105 #define L0_RECEIVER "RECEIVER"
106 #define L0_RESOLUTION "RESOLUTION"
107 #define L0_RESOLUTIONID "RESOLUTIONID"
108 #define L0_SCREENSIZE "SCREENSIZE"
109 #define L0_SENDER "SENDER"
110 #define L0_SERVER "SERVER"
111 #define L0_SESSIONLABELANNOTATION "SESSIONLABELANNOTATION"
112 #define L0_SLEEP "SLEEP"
113 #define L0_SMOOTHINGTYPE "SMOOTHINGTYPE"
114 #define L0_SPOOLER "SPOOLER"
115 #define L0_SUPPORTS12BIT "SUPPORTS12BIT"
116 #define L0_SUPPORTSDECIMATECROP "SUPPORTSDECIMATECROP"
117 #define L0_SUPPORTSIMAGESIZE "SUPPORTSIMAGESIZE"
118 #define L0_SUPPORTSPRESENTATIONLUT "SUPPORTSPRESENTATIONLUT"
119 #define L0_SUPPORTSTRIM "SUPPORTSTRIM"
120 #define L0_TIMEOUT "TIMEOUT"
121 #define L0_TLSDIRECTORY "TLSDIRECTORY"
122 #define L0_TLSPROFILE "TLSPROFILE"
123 #define L0_TYPE "TYPE"
124 #define L0_USEPEMFORMAT "USEPEMFORMAT"
125 #define L0_USERKEYDIRECTORY "USERKEYDIRECTORY"
126 #define L0_USETLS "USETLS"
127 #define L0_WIDTH "WIDTH"
128 #define L1_APPLICATION "APPLICATION"
129 #define L1_DATABASE "DATABASE"
130 #define L1_GUI "GUI"
131 #define L1_LUT "LUT"
132 #define L1_REPORT "REPORT"
133 #define L1_MONITOR "MONITOR"
134 #define L1_NETWORK "NETWORK"
135 #define L1_PRINT "PRINT"
136 #define L1_QUERY_RETRIEVE "QUERY_RETRIEVE"
137 #define L1_TLS "TLS"
138 #define L2_COMMUNICATION "COMMUNICATION"
139 #define L2_GENERAL "GENERAL"
140 // L2_HIGHRESOLUTIONGRAPHICS is defined in dvpsdef.h
141 #define L2_LUT "LUT"
142 #define L2_USERS "USERS"
143 #define L2_VOI "VOI"
144 #define L2_REPORT "REPORT"
145
146
147
148 /* --------------- static helper functions --------------- */
149
getConfigTargetType(const char * val)150 static DVPSPeerType getConfigTargetType(const char *val)
151 {
152 DVPSPeerType result = DVPSE_storage; /* default */
153
154 if (val==NULL) return result;
155 OFString pstring(val);
156 OFString ostring;
157 size_t len = pstring.length();
158 unsigned char c;
159 for (size_t i=0; i<len; i++)
160 {
161 c = pstring[i];
162 if ((c>='a') && (c <= 'z')) ostring += (char)(toupper(c));
163 else if ((c>='A') && (c <= 'Z')) ostring += c;
164 else if ((c>='0') && (c <= '9')) ostring += c;
165 else if (c=='_') ostring += c;
166 }
167 if (ostring=="PRINTER") result=DVPSE_printRemote; else
168 if (ostring=="LOCALPRINTER") result=DVPSE_printLocal; else
169 if (ostring=="STORAGE") result=DVPSE_storage; else
170 if (ostring=="RECEIVER") result=DVPSE_receiver; else
171 {
172 DCMPSTAT_WARN("unsupported peer type in config file: '" << val << "', ignoring.");
173 }
174 return result;
175 }
176
countValues(const char * str)177 static Uint32 countValues(const char *str)
178 {
179 if (str)
180 {
181 Uint32 result = 0;
182 if (*str) result++;
183 char c;
184 while ((c = *str++)) if (c == '\\') result++;
185 return result;
186 }
187 return 0;
188 }
189
copyValue(const char * str,Uint32 idx,OFString & target)190 static void copyValue(const char *str, Uint32 idx, OFString& target)
191 {
192 target.clear();
193 if (str)
194 {
195 char c = '\\';
196 while (idx)
197 {
198 c = *str++;
199 if (c == 0) idx=0; else if (c == '\\') idx--;
200 }
201 if (c=='\\')
202 {
203 const char *endstr = str;
204 while ((*endstr) && (*endstr != '\\')) endstr++;
205 target.assign(str,(endstr-str));
206 }
207 }
208 return;
209 }
210
strCompare(const char * str1,const char * str2,size_t len)211 static int strCompare(const char *str1, const char *str2, size_t len)
212 {
213 #ifdef HAVE_WINDOWS_H
214 return _strnicmp(str1, str2, len);
215 #else
216 return strncasecmp(str1, str2, len);
217 #endif
218 }
219
220
DVConfiguration(const char * config_file)221 DVConfiguration::DVConfiguration(const char *config_file)
222 : pConfig(NULL)
223 {
224 if (config_file)
225 {
226 FILE *cfgfile = fopen(config_file, "rb");
227 if (cfgfile)
228 {
229 pConfig = new OFConfigFile(cfgfile);
230 fclose(cfgfile);
231 }
232 }
233 }
234
235
~DVConfiguration()236 DVConfiguration::~DVConfiguration()
237 {
238 if (pConfig) delete pConfig;
239 }
240
241
getNumberOfTargets(DVPSPeerType peerType)242 Uint32 DVConfiguration::getNumberOfTargets(DVPSPeerType peerType)
243 {
244 Uint32 result = 0;
245 DVPSPeerType currentType;
246
247 if (pConfig)
248 {
249 pConfig->set_section(2, L2_COMMUNICATION);
250 if (pConfig->section_valid(2))
251 {
252 pConfig->first_section(1);
253 while (pConfig->section_valid(1))
254 {
255 currentType = getConfigTargetType(pConfig->get_entry(L0_TYPE));
256 switch (peerType)
257 {
258 case DVPSE_storage:
259 if (currentType==DVPSE_storage) result++;
260 break;
261 case DVPSE_receiver:
262 if (currentType==DVPSE_receiver) result++;
263 break;
264 case DVPSE_printRemote:
265 if (currentType==DVPSE_printRemote) result++;
266 break;
267 case DVPSE_printLocal:
268 if (currentType==DVPSE_printLocal) result++;
269 break;
270 case DVPSE_printAny:
271 if (currentType==DVPSE_printRemote) result++;
272 else if (currentType==DVPSE_printLocal) result++;
273 break;
274 case DVPSE_any:
275 result++;
276 break;
277 }
278 pConfig->next_section(1);
279 }
280 }
281 }
282 return result;
283 }
284
285
getTargetID(Uint32 idx,DVPSPeerType peerType)286 const char *DVConfiguration::getTargetID(Uint32 idx, DVPSPeerType peerType)
287 {
288 const char *result=NULL;
289 DVPSPeerType currentType;
290 OFBool found = OFFalse;
291
292 if (pConfig)
293 {
294 pConfig->set_section(2, L2_COMMUNICATION);
295 if (pConfig->section_valid(2))
296 {
297 pConfig->first_section(1);
298 while ((! found)&&(pConfig->section_valid(1)))
299 {
300 currentType = getConfigTargetType(pConfig->get_entry(L0_TYPE));
301 switch (peerType)
302 {
303 case DVPSE_storage:
304 if (currentType==DVPSE_storage)
305 {
306 if (idx==0) found=OFTrue; else idx--;
307 }
308 break;
309 case DVPSE_receiver:
310 if (currentType==DVPSE_receiver)
311 {
312 if (idx==0) found=OFTrue; else idx--;
313 }
314 break;
315 case DVPSE_printRemote:
316 if (currentType==DVPSE_printRemote)
317 {
318 if (idx==0) found=OFTrue; else idx--;
319 }
320 break;
321 case DVPSE_printLocal:
322 if (currentType==DVPSE_printLocal)
323 {
324 if (idx==0) found=OFTrue; else idx--;
325 }
326 break;
327 case DVPSE_printAny:
328 if ((currentType==DVPSE_printRemote)||(currentType==DVPSE_printLocal))
329 {
330 if (idx==0) found=OFTrue; else idx--;
331 }
332 break;
333 case DVPSE_any:
334 if (idx==0) found=OFTrue; else idx--;
335 break;
336 }
337 if (!found) pConfig->next_section(1);
338 }
339 if (pConfig->section_valid(1)) result = pConfig->get_keyword(1);
340 }
341 }
342 return result;
343 }
344
345
getConfigEntry(const char * l2_key,const char * l1_key,const char * l0_key)346 const char *DVConfiguration::getConfigEntry(const char *l2_key, const char *l1_key, const char *l0_key)
347 {
348 const char *result=NULL;
349 if (l2_key && l1_key && l0_key && pConfig)
350 {
351 pConfig->select_section(l1_key, l2_key);
352 if (pConfig->section_valid(1)) result = pConfig->get_entry(l0_key);
353 }
354 return result;
355 }
356
getConfigBoolEntry(const char * l2_key,const char * l1_key,const char * l0_key,OFBool deflt)357 OFBool DVConfiguration::getConfigBoolEntry(const char *l2_key, const char *l1_key, const char *l0_key, OFBool deflt)
358 {
359 OFBool result=deflt;
360 if (l2_key && l1_key && l0_key && pConfig)
361 {
362 pConfig->select_section(l1_key, l2_key);
363 if (pConfig->section_valid(1))
364 {
365 pConfig->set_section(0,l0_key);
366 result = pConfig->get_bool_value(deflt);
367 }
368 }
369 return result;
370 }
371
getTargetDescription(const char * targetID)372 const char *DVConfiguration::getTargetDescription(const char *targetID)
373 {
374 return getConfigEntry(L2_COMMUNICATION, targetID, L0_DESCRIPTION);
375 }
376
getTargetHostname(const char * targetID)377 const char *DVConfiguration::getTargetHostname(const char *targetID)
378 {
379 return getConfigEntry(L2_COMMUNICATION, targetID, L0_HOSTNAME);
380 }
381
getTargetPort(const char * targetID)382 unsigned short DVConfiguration::getTargetPort(const char *targetID)
383 {
384 const char *c = getConfigEntry(L2_COMMUNICATION, targetID, L0_PORT);
385 unsigned short result = 0;
386 if (c)
387 {
388 if (1 != sscanf(c, "%hu", &result)) result=0;
389 }
390 return result;
391 }
392
getTargetAETitle(const char * targetID)393 const char *DVConfiguration::getTargetAETitle(const char *targetID)
394 {
395 return getConfigEntry(L2_COMMUNICATION, targetID, L0_AETITLE);
396 }
397
getTargetMaxPDU(const char * targetID)398 unsigned long DVConfiguration::getTargetMaxPDU(const char *targetID)
399 {
400 const char *c = getConfigEntry(L2_COMMUNICATION, targetID, L0_MAXPDU);
401 unsigned long result = 0;
402 if (c)
403 {
404 if (1 != sscanf(c, "%lu", &result)) result=0;
405 }
406 return result;
407 }
408
getTargetTimeout(const char * targetID)409 Sint32 DVConfiguration::getTargetTimeout(const char *targetID)
410 {
411 const char *c = getConfigEntry(L2_COMMUNICATION, targetID, L0_TIMEOUT);
412 signed long result = -1; // default is -1
413 if (c)
414 {
415 if (1 != sscanf(c, "%ld", &result)) result=0;
416 }
417 return (Sint32) result;
418 }
419
getTargetImplicitOnly(const char * targetID)420 OFBool DVConfiguration::getTargetImplicitOnly(const char *targetID)
421 {
422 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_IMPLICITONLY, OFFalse);
423 }
424
getTargetDisableNewVRs(const char * targetID)425 OFBool DVConfiguration::getTargetDisableNewVRs(const char *targetID)
426 {
427 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_DISABLENEWVRS, OFFalse);
428 }
429
getTargetType(const char * targetID)430 DVPSPeerType DVConfiguration::getTargetType(const char *targetID)
431 {
432 return getConfigTargetType(getConfigEntry(L2_COMMUNICATION, targetID, L0_TYPE));
433 }
434
getLogFolder()435 const char *DVConfiguration::getLogFolder()
436 {
437 return getConfigEntry(L2_GENERAL, L1_APPLICATION, L0_LOGDIRECTORY);
438 }
439
getLogFile()440 const char *DVConfiguration::getLogFile()
441 {
442 return getConfigEntry(L2_GENERAL, L1_APPLICATION, L0_LOGFILE);
443 }
444
getLogLevel()445 OFLogger::LogLevel DVConfiguration::getLogLevel()
446 {
447 OFLogger::LogLevel result = OFLogger::FATAL_LOG_LEVEL;
448 const char *c = getConfigEntry(L2_GENERAL, L1_APPLICATION, L0_LOGLEVEL);
449 if (c != NULL)
450 {
451 if (strCompare(c, "ERROR", 5) == 0)
452 result = OFLogger::ERROR_LOG_LEVEL;
453 else if (strCompare(c, "WARN", 4) == 0)
454 result = OFLogger::WARN_LOG_LEVEL;
455 else if (strCompare(c, "INFO", 4) == 0)
456 result = OFLogger::INFO_LOG_LEVEL;
457 else if (strCompare(c, "DEBUG", 5) == 0)
458 result = OFLogger::DEBUG_LOG_LEVEL;
459 }
460 return result;
461 }
462
getMessagePort()463 unsigned short DVConfiguration::getMessagePort()
464 {
465 const char *c = getConfigEntry(L2_GENERAL, L1_APPLICATION, L0_MESSAGEPORT);
466 unsigned short result = 0;
467 if (c)
468 {
469 if (1 != sscanf(c, "%hu", &result)) result=0;
470 }
471 return result;
472 }
473
getMessagePortKeepOpen()474 OFBool DVConfiguration::getMessagePortKeepOpen()
475 {
476 return getConfigBoolEntry(L2_GENERAL, L1_APPLICATION, L0_KEEPMESSAGEPORTOPEN, OFFalse);
477 }
478
getNetworkAETitle()479 const char *DVConfiguration::getNetworkAETitle()
480 {
481 const char *result = getConfigEntry(L2_GENERAL, L1_NETWORK, L0_AETITLE);
482 if (result==NULL) result = PSTAT_AETITLE;
483 return result;
484 }
485
getQueryRetrieveAutoCreateConfigFile()486 OFBool DVConfiguration::getQueryRetrieveAutoCreateConfigFile()
487 {
488 return getConfigBoolEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_AUTOCREATECONFIGFILE, OFTrue);
489 }
490
getQueryRetrieveAETitle()491 const char *DVConfiguration::getQueryRetrieveAETitle()
492 {
493 const char *result = getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_AETITLE);
494 if (result==NULL) result = PSTAT_AETITLE;
495 return result;
496 }
497
getQueryRetrievePort()498 unsigned short DVConfiguration::getQueryRetrievePort()
499 {
500 const char *c = getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_PORT);
501 unsigned short result = 0;
502 if (c)
503 {
504 if (1 != sscanf(c, "%hu", &result)) result=0;
505 }
506 return result;
507 }
508
getQueryRetrieveMaxPDU()509 unsigned long DVConfiguration::getQueryRetrieveMaxPDU()
510 {
511 const char *c = getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_MAXPDU);
512 unsigned long result = 0;
513 if (c)
514 {
515 if (1 != sscanf(c, "%lu", &result)) result=0;
516 }
517 return result;
518 }
519
getQueryRetrieveTimeout()520 Sint32 DVConfiguration::getQueryRetrieveTimeout()
521 {
522 const char *c = getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_TIMEOUT);
523 signed long result = -1; // default is -1
524 if (c)
525 {
526 if (1 != sscanf(c, "%ld", &result)) result=0;
527 }
528 return (Sint32) result;
529 }
530
getQueryRetrieveMaxAssociations()531 unsigned long DVConfiguration::getQueryRetrieveMaxAssociations()
532 {
533 const char *c = getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_MAXASSOCIATIONS);
534 unsigned long result = 0;
535 if (c)
536 {
537 if (1 != sscanf(c, "%lu", &result)) result=0;
538 }
539 return result;
540 }
541
getDatabaseFolder()542 const char *DVConfiguration::getDatabaseFolder()
543 {
544 const char *result = getConfigEntry(L2_GENERAL, L1_DATABASE, L0_DIRECTORY);
545 if (result==NULL) result = PSTAT_DBFOLDER;
546 return result;
547 }
548
getSpoolFolder()549 const char *DVConfiguration::getSpoolFolder()
550 {
551 const char *result = getConfigEntry(L2_GENERAL, L1_PRINT, L0_DIRECTORY);
552 if (result==NULL) result = PSTAT_SPOOLFOLDER;
553 return result;
554 }
555
getDetailedLog()556 OFBool DVConfiguration::getDetailedLog()
557 {
558 return getConfigBoolEntry(L2_GENERAL, L1_PRINT, L0_DETAILEDLOG, OFFalse);
559 }
560
getBinaryLog()561 OFBool DVConfiguration::getBinaryLog()
562 {
563 return getConfigBoolEntry(L2_GENERAL, L1_PRINT, L0_BINARYLOG, OFFalse);
564 }
565
getSpoolerSleep()566 unsigned long DVConfiguration::getSpoolerSleep()
567 {
568 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_SLEEP);
569 unsigned long result = 0;
570 if (c)
571 {
572 if (1 != sscanf(c, "%lu", &result)) result=0;
573 }
574 return result;
575 }
576
getSpoolerDeletePrintJobs()577 OFBool DVConfiguration::getSpoolerDeletePrintJobs()
578 {
579 return getConfigBoolEntry(L2_GENERAL, L1_PRINT, L0_DELETEPRINTJOBS, OFFalse);
580 }
581
getSpoolerAlwaysDeleteTerminateJobs()582 OFBool DVConfiguration::getSpoolerAlwaysDeleteTerminateJobs()
583 {
584 return getConfigBoolEntry(L2_GENERAL, L1_PRINT, L0_ALWAYSDELETETERMINATEJOBS, OFFalse);
585 }
586
getLUTFolder()587 const char *DVConfiguration::getLUTFolder()
588 {
589 const char *result = getConfigEntry(L2_GENERAL, L1_LUT, L0_DIRECTORY);
590 if (result==NULL) result = PSTAT_LUTFOLDER;
591 return result;
592 }
593
getReportFolder()594 const char *DVConfiguration::getReportFolder()
595 {
596 const char *result = getConfigEntry(L2_GENERAL, L1_REPORT, L0_DIRECTORY);
597 if (result==NULL) result = PSTAT_REPORTFOLDER;
598 return result;
599 }
600
getSenderName()601 const char *DVConfiguration::getSenderName()
602 {
603 return getConfigEntry(L2_GENERAL, L1_NETWORK, L0_SENDER);
604 }
605
getReceiverName()606 const char *DVConfiguration::getReceiverName()
607 {
608 return getConfigEntry(L2_GENERAL, L1_NETWORK, L0_RECEIVER);
609 }
610
getQueryRetrieveServerName()611 const char *DVConfiguration::getQueryRetrieveServerName()
612 {
613 return getConfigEntry(L2_GENERAL, L1_QUERY_RETRIEVE, L0_SERVER);
614 }
615
getSpoolerName()616 const char *DVConfiguration::getSpoolerName()
617 {
618 return getConfigEntry(L2_GENERAL, L1_PRINT, L0_SPOOLER);
619 }
620
getPrintServerName()621 const char *DVConfiguration::getPrintServerName()
622 {
623 return getConfigEntry(L2_GENERAL, L1_PRINT, L0_SERVER);
624 }
625
getDumpToolName()626 const char *DVConfiguration::getDumpToolName()
627 {
628 return getConfigEntry(L2_GENERAL, L1_DATABASE, L0_DUMP);
629 }
630
getCheckToolName()631 const char *DVConfiguration::getCheckToolName()
632 {
633 return getConfigEntry(L2_GENERAL, L1_DATABASE, L0_CHECK);
634 }
635
getMonitorCharacteristicsFile()636 const char *DVConfiguration::getMonitorCharacteristicsFile()
637 {
638 return getConfigEntry(L2_GENERAL, L1_MONITOR, L0_CHARACTERISTICS);
639 }
640
getMonitorPixelWidth()641 double DVConfiguration::getMonitorPixelWidth()
642 {
643 const char *resolution = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_RESOLUTION);
644 const char *screensize = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_SCREENSIZE);
645
646 if (resolution && screensize)
647 {
648 double rX=0.0, rY=0.0, sX=0.0, sY=0.0;
649 OFString s(resolution);
650 OFBool success = OFFalse;
651
652 rX = OFStandard::atof(s.c_str(), &success);
653 if (success)
654 {
655 s.erase(0, s.find('\\')+1);
656 if (!s.empty())
657 {
658 rY = OFStandard::atof(s.c_str(), &success);
659 } else success = OFFalse;
660 }
661
662 if (success)
663 {
664 s = screensize;
665 sX = OFStandard::atof(s.c_str(), &success);
666 if (success)
667 {
668 s.erase(0, s.find('\\')+1);
669 if (!s.empty())
670 {
671 sY = OFStandard::atof(s.c_str(), &success);
672 } else success = OFFalse;
673 }
674 }
675
676 if (success && (rX > 0) && (rY > 0) && (sX > 0) && (sY > 0))
677 {
678 // everything OK, return pixel width
679 return sX/rX;
680 }
681 }
682 return 0.0;
683 }
684
getMonitorPixelHeight()685 double DVConfiguration::getMonitorPixelHeight()
686 {
687 const char *resolution = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_RESOLUTION);
688 const char *screensize = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_SCREENSIZE);
689
690 if (resolution && screensize)
691 {
692 double rX=0.0, rY=0.0, sX=0.0, sY=0.0;
693 OFString s(resolution);
694 OFBool success = OFFalse;
695
696 rX = OFStandard::atof(s.c_str(), &success);
697 if (success)
698 {
699 s.erase(0, s.find('\\')+1);
700 if (!s.empty())
701 {
702 rY = OFStandard::atof(s.c_str(), &success);
703 } else success = OFFalse;
704 }
705
706 if (success)
707 {
708 s = screensize;
709 sX = OFStandard::atof(s.c_str(), &success);
710 if (success)
711 {
712 s.erase(0, s.find('\\')+1);
713 if (!s.empty())
714 {
715 sY = OFStandard::atof(s.c_str(), &success);
716 } else success = OFFalse;
717 }
718 }
719
720 if (success && (rX > 0) && (rY > 0) && (sX > 0) && (sY > 0))
721 {
722 // everything OK, return pixel height
723 return sY/rY;
724 }
725 }
726 return 0.0;
727 }
728
getMaxPreviewResolutionX()729 Uint32 DVConfiguration::getMaxPreviewResolutionX()
730 {
731 const char *c = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_PREVIEW);
732 if (c)
733 {
734 unsigned long result = 0;
735 unsigned long dummy = 0;
736 if (2 == sscanf(c, "%lu\\%lu", &result, &dummy)) return (Uint32) result;
737 }
738 return 0;
739 }
740
getMaxPreviewResolutionY()741 Uint32 DVConfiguration::getMaxPreviewResolutionY()
742 {
743 const char *c = getConfigEntry(L2_GENERAL, L1_MONITOR, L0_PREVIEW);
744 if (c)
745 {
746 unsigned long result = 0;
747 unsigned long dummy = 0;
748 if (2 == sscanf(c, "%lu\\%lu", &dummy, &result)) return (Uint32) result;
749 }
750 return 0;
751 }
752
getGUIConfigEntry(const char * key)753 const char *DVConfiguration::getGUIConfigEntry(const char *key)
754 {
755 return getConfigEntry(L2_GENERAL, L1_GUI, key);
756 }
757
getGUIConfigEntryBool(const char * key,OFBool dfl)758 OFBool DVConfiguration::getGUIConfigEntryBool(const char *key, OFBool dfl)
759 {
760 return getConfigBoolEntry(L2_GENERAL, L1_GUI, key, dfl);
761 }
762
getTargetPrinterSupportsPresentationLUT(const char * targetID)763 OFBool DVConfiguration::getTargetPrinterSupportsPresentationLUT(const char *targetID)
764 {
765 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SUPPORTSPRESENTATIONLUT, OFFalse);
766 }
767
getTargetPrinterPresentationLUTMatchRequired(const char * targetID)768 OFBool DVConfiguration::getTargetPrinterPresentationLUTMatchRequired(const char *targetID)
769 {
770 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_PRESENTATIONLUTMATCHREQUIRED, OFTrue);
771 }
772
getTargetPrinterPresentationLUTPreferSCPRendering(const char * targetID)773 OFBool DVConfiguration::getTargetPrinterPresentationLUTPreferSCPRendering(const char *targetID)
774 {
775 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_PRESENTATIONLUTPREFERSCPRENDERING, OFFalse);
776 }
777
getTargetPrinterPresentationLUTinFilmSession(const char * targetID)778 OFBool DVConfiguration::getTargetPrinterPresentationLUTinFilmSession(const char *targetID)
779 {
780 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_PRESENTATIONLUTINFILMSESSION, OFFalse);
781 }
782
getTargetPrinterSupports12BitTransmission(const char * targetID)783 OFBool DVConfiguration::getTargetPrinterSupports12BitTransmission(const char *targetID)
784 {
785 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SUPPORTS12BIT, OFTrue);
786 }
787
getTargetPrintSCPOmitSOPClassUIDFromCreateResponse(const char * targetID)788 OFBool DVConfiguration::getTargetPrintSCPOmitSOPClassUIDFromCreateResponse(const char *targetID)
789 {
790 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_OMITSOPCLASSUIDFROMCREATERESPONSE, OFFalse);
791 }
792
getTargetPrinterSupportsRequestedImageSize(const char * targetID)793 OFBool DVConfiguration::getTargetPrinterSupportsRequestedImageSize(const char *targetID)
794 {
795 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SUPPORTSIMAGESIZE, OFFalse);
796 }
797
getTargetPrinterSupportsDecimateCrop(const char * targetID)798 OFBool DVConfiguration::getTargetPrinterSupportsDecimateCrop(const char *targetID)
799 {
800 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SUPPORTSDECIMATECROP, OFFalse);
801 }
802
getTargetPrinterSupportsTrim(const char * targetID)803 OFBool DVConfiguration::getTargetPrinterSupportsTrim(const char *targetID)
804 {
805 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SUPPORTSTRIM, OFFalse);
806 }
807
getTargetPrinterNumberOfFilmSizeIDs(const char * targetID)808 Uint32 DVConfiguration::getTargetPrinterNumberOfFilmSizeIDs(const char *targetID)
809 {
810 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_FILMSIZEID));
811 }
812
getTargetPrinterFilmSizeID(const char * targetID,Uint32 idx,OFString & value)813 const char *DVConfiguration::getTargetPrinterFilmSizeID(const char *targetID, Uint32 idx, OFString& value)
814 {
815 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_FILMSIZEID), idx, value);
816 if (value.length()) return value.c_str(); else return NULL;
817 }
818
getTargetPrinterNumberOfMediumTypes(const char * targetID)819 Uint32 DVConfiguration::getTargetPrinterNumberOfMediumTypes(const char *targetID)
820 {
821 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_MEDIUMTYPE));
822 }
823
getTargetPrinterMediumType(const char * targetID,Uint32 idx,OFString & value)824 const char *DVConfiguration::getTargetPrinterMediumType(const char *targetID, Uint32 idx, OFString& value)
825 {
826 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_MEDIUMTYPE), idx, value);
827 if (value.length()) return value.c_str(); else return NULL;
828 }
829
getTargetPrinterNumberOfFilmDestinations(const char * targetID)830 Uint32 DVConfiguration::getTargetPrinterNumberOfFilmDestinations(const char *targetID)
831 {
832 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_FILMDESTINATION));
833 }
834
getTargetPrinterFilmDestination(const char * targetID,Uint32 idx,OFString & value)835 const char *DVConfiguration::getTargetPrinterFilmDestination(const char *targetID, Uint32 idx, OFString& value)
836 {
837 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_FILMDESTINATION), idx, value);
838 if (value.length()) return value.c_str(); else return NULL;
839 }
840
getTargetPrinterNumberOfPrinterResolutionIDs(const char * targetID)841 Uint32 DVConfiguration::getTargetPrinterNumberOfPrinterResolutionIDs(const char *targetID)
842 {
843 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_RESOLUTIONID));
844 }
845
getTargetPrinterResolutionID(const char * targetID,Uint32 idx,OFString & value)846 const char *DVConfiguration::getTargetPrinterResolutionID(const char *targetID, Uint32 idx, OFString& value)
847 {
848 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_RESOLUTIONID), idx, value);
849 if (value.length()) return value.c_str(); else return NULL;
850 }
851
getTargetPrinterNumberOfMagnificationTypes(const char * targetID)852 Uint32 DVConfiguration::getTargetPrinterNumberOfMagnificationTypes(const char *targetID)
853 {
854 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_MAGNIFICATIONTYPE));
855 }
856
getTargetPrinterMagnificationType(const char * targetID,Uint32 idx,OFString & value)857 const char *DVConfiguration::getTargetPrinterMagnificationType(const char *targetID, Uint32 idx, OFString& value)
858 {
859 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_MAGNIFICATIONTYPE), idx, value);
860 if (value.length()) return value.c_str(); else return NULL;
861 }
862
getTargetPrinterNumberOfSmoothingTypes(const char * targetID)863 Uint32 DVConfiguration::getTargetPrinterNumberOfSmoothingTypes(const char *targetID)
864 {
865 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_SMOOTHINGTYPE));
866 }
867
getTargetPrinterSmoothingType(const char * targetID,Uint32 idx,OFString & value)868 const char *DVConfiguration::getTargetPrinterSmoothingType(const char *targetID, Uint32 idx, OFString& value)
869 {
870 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_SMOOTHINGTYPE), idx, value);
871 if (value.length()) return value.c_str(); else return NULL;
872 }
873
874
getTargetPrinterNumberOfConfigurationSettings(const char * targetID)875 Uint32 DVConfiguration::getTargetPrinterNumberOfConfigurationSettings(const char *targetID)
876 {
877 Uint32 result = 0;
878
879 if (pConfig)
880 {
881
882 pConfig->select_section(targetID, L2_COMMUNICATION);
883 if (pConfig->section_valid(1))
884 {
885 int counter = 1;
886 char l0_key[80];
887 do
888 {
889 sprintf(l0_key, "CONFIGURATION_%d", counter++);
890 } while (NULL != pConfig->get_entry(l0_key));
891 result = counter - 2;
892 }
893 }
894 return result;
895 }
896
getTargetPrinterConfigurationSetting(const char * targetID,Uint32 idx)897 const char *DVConfiguration::getTargetPrinterConfigurationSetting(const char *targetID, Uint32 idx)
898 {
899 char l0_key[80];
900 sprintf(l0_key, "CONFIGURATION_%d", (int)idx+1);
901 return getConfigEntry(L2_COMMUNICATION, targetID, l0_key);
902 }
903
getNumberOfLUTs()904 Uint32 DVConfiguration::getNumberOfLUTs()
905 {
906 Uint32 result = 0;
907 if (pConfig)
908 {
909 pConfig->set_section(2, L2_LUT);
910 if (pConfig->section_valid(2))
911 {
912 pConfig->first_section(1);
913 while (pConfig->section_valid(1))
914 {
915 result++;
916 pConfig->next_section(1);
917 }
918 }
919 }
920 return result;
921 }
922
getLUTID(Uint32 idx)923 const char *DVConfiguration::getLUTID(Uint32 idx)
924 {
925 OFBool found = OFFalse;
926 const char *result=NULL;
927 if (pConfig)
928 {
929 pConfig->set_section(2, L2_LUT);
930 if (pConfig->section_valid(2))
931 {
932 pConfig->first_section(1);
933 while ((! found)&&(pConfig->section_valid(1)))
934 {
935 if (idx==0) found=OFTrue;
936 else
937 {
938 idx--;
939 pConfig->next_section(1);
940 }
941 }
942 if (pConfig->section_valid(1)) result = pConfig->get_keyword(1);
943 }
944 }
945 return result;
946 }
947
getLUTDescription(const char * lutID)948 const char *DVConfiguration::getLUTDescription(const char *lutID)
949 {
950 return getConfigEntry(L2_LUT, lutID, L0_DESCRIPTION);
951 }
952
getLUTFilename(const char * lutID)953 const char *DVConfiguration::getLUTFilename(const char *lutID)
954 {
955 return getConfigEntry(L2_LUT, lutID, L0_FILENAME);
956 }
957
getNumberOfReports()958 Uint32 DVConfiguration::getNumberOfReports()
959 {
960 Uint32 result = 0;
961 if (pConfig)
962 {
963 pConfig->set_section(2, L2_REPORT);
964 if (pConfig->section_valid(2))
965 {
966 pConfig->first_section(1);
967 while (pConfig->section_valid(1))
968 {
969 result++;
970 pConfig->next_section(1);
971 }
972 }
973 }
974 return result;
975 }
976
getReportID(Uint32 idx)977 const char *DVConfiguration::getReportID(Uint32 idx)
978 {
979 OFBool found = OFFalse;
980 const char *result=NULL;
981 if (pConfig)
982 {
983 pConfig->set_section(2, L2_REPORT);
984 if (pConfig->section_valid(2))
985 {
986 pConfig->first_section(1);
987 while ((! found)&&(pConfig->section_valid(1)))
988 {
989 if (idx==0) found=OFTrue;
990 else
991 {
992 idx--;
993 pConfig->next_section(1);
994 }
995 }
996 if (pConfig->section_valid(1)) result = pConfig->get_keyword(1);
997 }
998 }
999 return result;
1000 }
1001
getReportDescription(const char * reportID)1002 const char *DVConfiguration::getReportDescription(const char *reportID)
1003 {
1004 return getConfigEntry(L2_REPORT, reportID, L0_DESCRIPTION);
1005 }
1006
getReportFilename(const char * reportID)1007 const char *DVConfiguration::getReportFilename(const char *reportID)
1008 {
1009 return getConfigEntry(L2_REPORT, reportID, L0_FILENAME);
1010 }
1011
getTargetPrinterNumberOfBorderDensities(const char * targetID)1012 Uint32 DVConfiguration::getTargetPrinterNumberOfBorderDensities(const char *targetID)
1013 {
1014 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_BORDERDENSITY));
1015 }
1016
getTargetPrinterBorderDensity(const char * targetID,Uint32 idx,OFString & value)1017 const char *DVConfiguration::getTargetPrinterBorderDensity(const char *targetID, Uint32 idx, OFString& value)
1018 {
1019 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_BORDERDENSITY), idx, value);
1020 if (value.length()) return value.c_str(); else return NULL;
1021 }
1022
getTargetPrinterNumberOfMaxDensities(const char * targetID)1023 Uint32 DVConfiguration::getTargetPrinterNumberOfMaxDensities(const char *targetID)
1024 {
1025 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_MAXDENSITY));
1026 }
1027
getTargetPrinterMaxDensity(const char * targetID,Uint32 idx,OFString & value)1028 const char *DVConfiguration::getTargetPrinterMaxDensity(const char *targetID, Uint32 idx, OFString& value)
1029 {
1030 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_MAXDENSITY), idx, value);
1031 if (value.length()) return value.c_str(); else return NULL;
1032 }
1033
getTargetPrinterNumberOfMinDensities(const char * targetID)1034 Uint32 DVConfiguration::getTargetPrinterNumberOfMinDensities(const char *targetID)
1035 {
1036 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_MINDENSITY));
1037 }
1038
getTargetPrinterMinDensity(const char * targetID,Uint32 idx,OFString & value)1039 const char *DVConfiguration::getTargetPrinterMinDensity(const char *targetID, Uint32 idx, OFString& value)
1040 {
1041 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_MINDENSITY), idx, value);
1042 if (value.length()) return value.c_str(); else return NULL;
1043 }
1044
getTargetPrinterNumberOfEmptyImageDensities(const char * targetID)1045 Uint32 DVConfiguration::getTargetPrinterNumberOfEmptyImageDensities(const char *targetID)
1046 {
1047 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_EMPTYIMAGEDENSITY));
1048 }
1049
getTargetPrinterEmptyImageDensity(const char * targetID,Uint32 idx,OFString & value)1050 const char *DVConfiguration::getTargetPrinterEmptyImageDensity(const char *targetID, Uint32 idx, OFString& value)
1051 {
1052 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_EMPTYIMAGEDENSITY), idx, value);
1053 if (value.length()) return value.c_str(); else return NULL;
1054 }
1055
getMinPrintResolutionX()1056 Uint32 DVConfiguration::getMinPrintResolutionX()
1057 {
1058 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_MINPRINTRESOLUTION);
1059 if (c)
1060 {
1061 unsigned long result = 0;
1062 unsigned long dummy = 0;
1063 if (2 == sscanf(c, "%lu\\%lu", &result, &dummy)) return (Uint32) result;
1064 }
1065 return 0;
1066 }
1067
getMinPrintResolutionY()1068 Uint32 DVConfiguration::getMinPrintResolutionY()
1069 {
1070 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_MINPRINTRESOLUTION);
1071 if (c)
1072 {
1073 unsigned long result = 0;
1074 unsigned long dummy = 0;
1075 if (2 == sscanf(c, "%lu\\%lu", &dummy, &result)) return (Uint32) result;
1076 }
1077 return 0;
1078 }
1079
getMaxPrintResolutionX()1080 Uint32 DVConfiguration::getMaxPrintResolutionX()
1081 {
1082 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_MAXPRINTRESOLUTION);
1083 if (c)
1084 {
1085 unsigned long result = 0;
1086 unsigned long dummy = 0;
1087 if (2 == sscanf(c, "%lu\\%lu", &result, &dummy)) return (Uint32) result;
1088 }
1089 return 0;
1090 }
1091
getMaxPrintResolutionY()1092 Uint32 DVConfiguration::getMaxPrintResolutionY()
1093 {
1094 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_MAXPRINTRESOLUTION);
1095 if (c)
1096 {
1097 unsigned long result = 0;
1098 unsigned long dummy = 0;
1099 if (2 == sscanf(c, "%lu\\%lu", &dummy, &result)) return (Uint32) result;
1100 }
1101 return 0;
1102 }
1103
getDefaultPrintIllumination()1104 Uint16 DVConfiguration::getDefaultPrintIllumination()
1105 {
1106 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_DEFAULTILLUMINATION);
1107 if (c)
1108 {
1109 Uint16 result = 0;
1110 if (1 == sscanf(c, "%hu", &result)) return result;
1111 }
1112 return DEFAULT_illumination;
1113 }
1114
getDefaultPrintReflection()1115 Uint16 DVConfiguration::getDefaultPrintReflection()
1116 {
1117 const char *c = getConfigEntry(L2_GENERAL, L1_PRINT, L0_DEFAULTREFLECTION);
1118 if (c)
1119 {
1120 Uint16 result = 0;
1121 if (1 == sscanf(c, "%hu", &result)) return result;
1122 }
1123 return DEFAULT_reflectedAmbientLight;
1124 }
1125
getNumberOfVOIPresets(const char * modality)1126 Uint32 DVConfiguration::getNumberOfVOIPresets(const char *modality)
1127 {
1128 Uint32 result = 0;
1129 if (modality && pConfig)
1130 {
1131 OFString aModality = modality;
1132 const char *currentModality = NULL;
1133 pConfig->set_section(2, L2_VOI);
1134 if (pConfig->section_valid(2))
1135 {
1136 pConfig->first_section(1);
1137 while (pConfig->section_valid(1))
1138 {
1139 currentModality = pConfig->get_entry(L0_MODALITY);
1140 if (currentModality && (aModality == currentModality)) result++;
1141 pConfig->next_section(1);
1142 }
1143 }
1144 }
1145 return result;
1146 }
1147
getVOIPresetDescription(const char * modality,Uint32 idx)1148 const char *DVConfiguration::getVOIPresetDescription(const char *modality, Uint32 idx)
1149 {
1150 if (modality && pConfig)
1151 {
1152 OFString aModality = modality;
1153 const char *currentModality = NULL;
1154 pConfig->set_section(2, L2_VOI);
1155 if (pConfig->section_valid(2))
1156 {
1157 pConfig->first_section(1);
1158 while (pConfig->section_valid(1))
1159 {
1160 currentModality = pConfig->get_entry(L0_MODALITY);
1161 if (currentModality && (aModality == currentModality))
1162 {
1163 if (idx==0)
1164 {
1165 // found entry
1166 return pConfig->get_entry(L0_DESCRIPTION);
1167 } else idx--;
1168 }
1169 pConfig->next_section(1);
1170 }
1171 }
1172 }
1173 return NULL;
1174 }
1175
getVOIPresetWindowCenter(const char * modality,Uint32 idx)1176 double DVConfiguration::getVOIPresetWindowCenter(const char *modality, Uint32 idx)
1177 {
1178 double result = 0.0;
1179 if (modality && pConfig)
1180 {
1181 OFString aModality = modality;
1182 const char *currentModality = NULL;
1183 pConfig->set_section(2, L2_VOI);
1184 if (pConfig->section_valid(2))
1185 {
1186 pConfig->first_section(1);
1187 while (pConfig->section_valid(1))
1188 {
1189 currentModality = pConfig->get_entry(L0_MODALITY);
1190 if (currentModality && (aModality == currentModality))
1191 {
1192 if (idx==0)
1193 {
1194 // found entry
1195 const char *window = pConfig->get_entry(L0_CENTER);
1196 if (window) return OFStandard::atof(window); else return 0.0;
1197 } else idx--;
1198 }
1199 pConfig->next_section(1);
1200 }
1201 }
1202 }
1203 return result;
1204 }
1205
getVOIPresetWindowWidth(const char * modality,Uint32 idx)1206 double DVConfiguration::getVOIPresetWindowWidth(const char *modality, Uint32 idx)
1207 {
1208 double result = 1.0;
1209 if (modality && pConfig)
1210 {
1211 OFString aModality = modality;
1212 const char *currentModality = NULL;
1213 pConfig->set_section(2, L2_VOI);
1214 if (pConfig->section_valid(2))
1215 {
1216 pConfig->first_section(1);
1217 while (pConfig->section_valid(1))
1218 {
1219 currentModality = pConfig->get_entry(L0_MODALITY);
1220 if (currentModality && (aModality == currentModality))
1221 {
1222 if (idx==0)
1223 {
1224 // found entry
1225 const char *window = pConfig->get_entry(L0_WIDTH);
1226 if (window) return OFStandard::atof(window); else return 1.0;
1227 } else idx--;
1228 }
1229 pConfig->next_section(1);
1230 }
1231 }
1232 }
1233 return result;
1234 }
1235
getTargetPrinterNumberOfPortraitDisplayFormats(const char * targetID)1236 Uint32 DVConfiguration::getTargetPrinterNumberOfPortraitDisplayFormats(const char *targetID)
1237 {
1238 return countValues(getConfigEntry(L2_COMMUNICATION, targetID, L0_DISPLAYFORMAT));
1239 }
1240
getTargetPrinterPortraitDisplayFormatRows(const char * targetID,Uint32 idx)1241 Uint32 DVConfiguration::getTargetPrinterPortraitDisplayFormatRows(const char *targetID, Uint32 idx)
1242 {
1243 OFString value;
1244 unsigned long rows=0;
1245 unsigned long columns=0;
1246 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_DISPLAYFORMAT), idx, value);
1247 if (2==sscanf(value.c_str(), "%lu,%lu", &columns, &rows)) return rows;
1248 return 0;
1249 }
1250
getTargetPrinterPortraitDisplayFormatColumns(const char * targetID,Uint32 idx)1251 Uint32 DVConfiguration::getTargetPrinterPortraitDisplayFormatColumns(const char *targetID, Uint32 idx)
1252 {
1253 OFString value;
1254 unsigned long rows=0;
1255 unsigned long columns=0;
1256 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_DISPLAYFORMAT), idx, value);
1257 if (2==sscanf(value.c_str(), "%lu,%lu", &columns, &rows)) return columns;
1258 return 0;
1259 }
1260
getTargetPrinterSupportsAnnotation(const char * targetID)1261 OFBool DVConfiguration::getTargetPrinterSupportsAnnotation(const char *targetID)
1262 {
1263 if (NULL==getConfigEntry(L2_COMMUNICATION, targetID, L0_ANNOTATION)) return getTargetPrinterSessionLabelAnnotation(targetID);
1264 return OFTrue;
1265 }
1266
getTargetPrinterSupportsAnnotationBoxSOPClass(const char * targetID)1267 OFBool DVConfiguration::getTargetPrinterSupportsAnnotationBoxSOPClass(const char *targetID)
1268 {
1269 if (NULL==getConfigEntry(L2_COMMUNICATION, targetID, L0_ANNOTATION)) return OFFalse;
1270 return OFTrue;
1271 }
1272
getTargetPrinterSessionLabelAnnotation(const char * targetID)1273 OFBool DVConfiguration::getTargetPrinterSessionLabelAnnotation(const char *targetID)
1274 {
1275 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_SESSIONLABELANNOTATION, OFFalse);
1276 }
1277
getTargetPrinterAnnotationDisplayFormatID(const char * targetID,OFString & value)1278 const char *DVConfiguration::getTargetPrinterAnnotationDisplayFormatID(const char *targetID, OFString& value)
1279 {
1280 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_ANNOTATION), 1, value);
1281 if (value.length()) return value.c_str(); else return NULL;
1282 }
1283
getTargetPrinterAnnotationPosition(const char * targetID)1284 Uint16 DVConfiguration::getTargetPrinterAnnotationPosition(const char *targetID)
1285 {
1286 OFString value;
1287 copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_ANNOTATION), 0, value);
1288 if (value.length())
1289 {
1290 Uint16 result = 0;
1291 if (1 == sscanf(value.c_str(), "%hu", &result)) return result;
1292 }
1293 return 0;
1294 }
1295
getTLSFolder()1296 const char *DVConfiguration::getTLSFolder()
1297 {
1298 return getConfigEntry(L2_GENERAL, L1_TLS, L0_TLSDIRECTORY);
1299 }
1300
getTLSCACertificateFolder()1301 const char *DVConfiguration::getTLSCACertificateFolder()
1302 {
1303 return getConfigEntry(L2_GENERAL, L1_TLS, L0_CACERTIFICATEDIRECTORY);
1304 }
1305
getTLSPEMFormat()1306 OFBool DVConfiguration::getTLSPEMFormat()
1307 {
1308 return getConfigBoolEntry(L2_GENERAL, L1_TLS, L0_USEPEMFORMAT, OFTrue);
1309 }
1310
getTargetBitPreservingMode(const char * targetID)1311 OFBool DVConfiguration::getTargetBitPreservingMode(const char *targetID)
1312 {
1313 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_BITPRESERVINGMODE, OFFalse);
1314 }
1315
getTargetCorrectUIDPadding(const char * targetID)1316 OFBool DVConfiguration::getTargetCorrectUIDPadding(const char *targetID)
1317 {
1318 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_CORRECTUIDPADDING, OFFalse);
1319 }
1320
getTargetUseTLS(const char * targetID)1321 OFBool DVConfiguration::getTargetUseTLS(const char *targetID)
1322 {
1323 return getConfigBoolEntry(L2_COMMUNICATION, targetID, L0_USETLS, OFFalse);
1324 }
1325
getTargetCertificate(const char * targetID)1326 const char *DVConfiguration::getTargetCertificate(const char *targetID)
1327 {
1328 return getConfigEntry(L2_COMMUNICATION, targetID, L0_CERTIFICATE);
1329 }
1330
getTargetPrivateKey(const char * targetID)1331 const char *DVConfiguration::getTargetPrivateKey(const char *targetID)
1332 {
1333 return getConfigEntry(L2_COMMUNICATION, targetID, L0_PRIVATEKEY);
1334 }
1335
getTargetPrivateKeyPassword(const char * targetID)1336 const char *DVConfiguration::getTargetPrivateKeyPassword(const char *targetID)
1337 {
1338 return getConfigEntry(L2_COMMUNICATION, targetID, L0_PRIVATEKEYPASSWORD);
1339 }
1340
getTargetTLSProfile(const char * targetID)1341 const char *DVConfiguration::getTargetTLSProfile(const char *targetID)
1342 {
1343 return getConfigEntry(L2_COMMUNICATION, targetID, L0_TLSPROFILE);
1344 }
1345
getTargetPeerAuthentication(const char * targetID)1346 DVPSCertificateVerificationType DVConfiguration::getTargetPeerAuthentication(const char *targetID)
1347 {
1348 DVPSCertificateVerificationType result = DVPSQ_require;
1349 const char *c = getConfigEntry(L2_COMMUNICATION, targetID, L0_PEERAUTHENTICATION);
1350 if (c != NULL)
1351 {
1352 if (strCompare(c, "REQUIRE", 7) == 0)
1353 result = DVPSQ_require;
1354 else if (strCompare(c, "VERIFY", 6) == 0)
1355 result = DVPSQ_verify;
1356 else if (strCompare(c, "IGNORE", 6) == 0)
1357 result = DVPSQ_ignore;
1358 }
1359 return result;
1360 }
1361
getTargetDiffieHellmanParameters(const char * targetID)1362 const char *DVConfiguration::getTargetDiffieHellmanParameters(const char *targetID)
1363 {
1364 return getConfigEntry(L2_COMMUNICATION, targetID, L0_DIFFIEHELLMANPARAMETERS);
1365 }
1366
getTargetRandomSeed(const char * targetID)1367 const char *DVConfiguration::getTargetRandomSeed(const char *targetID)
1368 {
1369 return getConfigEntry(L2_COMMUNICATION, targetID, L0_RANDOMSEED);
1370 }
1371
getUserCertificateFolder()1372 const char *DVConfiguration::getUserCertificateFolder()
1373 {
1374 return getConfigEntry(L2_GENERAL, L1_TLS, L0_USERKEYDIRECTORY);
1375 }
1376
getNumberOfUsers()1377 Uint32 DVConfiguration::getNumberOfUsers()
1378 {
1379 Uint32 result = 0;
1380 if (pConfig)
1381 {
1382 pConfig->set_section(2, L2_USERS);
1383 if (pConfig->section_valid(2))
1384 {
1385 pConfig->first_section(1);
1386 while (pConfig->section_valid(1))
1387 {
1388 result++;
1389 pConfig->next_section(1);
1390 }
1391 }
1392 }
1393 return result;
1394 }
1395
getUserID(Uint32 idx)1396 const char *DVConfiguration::getUserID(Uint32 idx)
1397 {
1398 OFBool found = OFFalse;
1399 const char *result=NULL;
1400 if (pConfig)
1401 {
1402 pConfig->set_section(2, L2_USERS);
1403 if (pConfig->section_valid(2))
1404 {
1405 pConfig->first_section(1);
1406 while ((! found)&&(pConfig->section_valid(1)))
1407 {
1408 if (idx==0) found=OFTrue;
1409 else
1410 {
1411 idx--;
1412 pConfig->next_section(1);
1413 }
1414 }
1415 if (pConfig->section_valid(1)) result = pConfig->get_keyword(1);
1416 }
1417 }
1418 return result;
1419 }
1420
getUserLogin(const char * userID)1421 const char *DVConfiguration::getUserLogin(const char *userID)
1422 {
1423 return getConfigEntry(L2_USERS, userID, L0_LOGIN);
1424 }
1425
getUserName(const char * userID)1426 const char *DVConfiguration::getUserName(const char *userID)
1427 {
1428 return getConfigEntry(L2_USERS, userID, L0_NAME);
1429 }
1430
getUserDICOMName(const char * userID)1431 const char *DVConfiguration::getUserDICOMName(const char *userID)
1432 {
1433 return getConfigEntry(L2_USERS, userID, L0_DICOMNAME);
1434 }
1435
getUserCertificate(const char * userID)1436 const char *DVConfiguration::getUserCertificate(const char *userID)
1437 {
1438 return getConfigEntry(L2_USERS, userID, L0_CERTIFICATE);
1439 }
1440
getUserPrivateKey(const char * userID)1441 const char *DVConfiguration::getUserPrivateKey(const char *userID)
1442 {
1443 return getConfigEntry(L2_USERS, userID, L0_PRIVATEKEY);
1444 }
1445
getUserOrganization(const char * userID)1446 const char *DVConfiguration::getUserOrganization(const char *userID)
1447 {
1448 return getConfigEntry(L2_USERS, userID, L0_ORGANIZATION);
1449 }
1450
getUserCodingSchemeDesignator(const char * userID,OFString & value)1451 const char *DVConfiguration::getUserCodingSchemeDesignator(const char *userID, OFString& value)
1452 {
1453 copyValue(getConfigEntry(L2_USERS, userID, L0_CODE), 0, value);
1454 if (value.length()) return value.c_str(); else return NULL;
1455 }
1456
getUserCodingSchemeVersion(const char * userID,OFString & value)1457 const char *DVConfiguration::getUserCodingSchemeVersion(const char *userID, OFString& value)
1458 {
1459 copyValue(getConfigEntry(L2_USERS, userID, L0_CODE), 1, value);
1460 if (value.length()) return value.c_str(); else return NULL;
1461 }
1462
getUserCodeValue(const char * userID,OFString & value)1463 const char *DVConfiguration::getUserCodeValue(const char *userID, OFString& value)
1464 {
1465 copyValue(getConfigEntry(L2_USERS, userID, L0_CODE), 2, value);
1466 if (value.length()) return value.c_str(); else return NULL;
1467 }
1468
getUserCodeMeaning(const char * userID,OFString & value)1469 const char *DVConfiguration::getUserCodeMeaning(const char *userID, OFString& value)
1470 {
1471 copyValue(getConfigEntry(L2_USERS, userID, L0_CODE), 3, value);
1472 if (value.length()) return value.c_str(); else return NULL;
1473 }
1474