00001 /* 00002 * 00003 * Copyright (C) 1993-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmqrdb 00019 * 00020 * Author: Marco Eichelberg / Ralph Meyer 00021 * 00022 * Purpose: class DcmQueryRetrieveConfig 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:04:20 $ 00026 * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmqrdb/include/dcmtk/dcmqrdb/dcmqrcnf.h,v $ 00027 * CVS/RCS Revision: $Revision: 1.3 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 #ifndef DCMQRCNF_H 00035 #define DCMQRCNF_H 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 00039 #define INCLUDE_CSTDIO 00040 #include "dcmtk/ofstd/ofstdinc.h" 00041 #include "dcmtk/ofstd/ofcmdln.h" 00042 00045 struct DcmQueryRetrieveConfigQuota 00046 { 00048 int maxStudies; 00050 long maxBytesPerStudy; 00051 }; 00052 00055 struct DcmQueryRetrieveConfigPeer 00056 { 00058 const char *ApplicationTitle; 00059 00061 const char *HostName; 00062 00064 int PortNumber; 00065 }; 00066 00069 struct DcmQueryRetrieveConfigAEEntry 00070 { 00072 const char *ApplicationTitle; 00073 00075 const char *StorageArea; 00076 00078 const char *Access; 00079 00081 DcmQueryRetrieveConfigQuota *StorageQuota; 00082 00084 int noOfPeers; 00085 00087 DcmQueryRetrieveConfigPeer *Peers; 00088 }; 00089 00092 struct DcmQueryRetrieveConfigConfiguration 00093 { 00095 int noOfAEEntries; 00096 00098 DcmQueryRetrieveConfigAEEntry *AEEntries; 00099 }; 00100 00103 struct DcmQueryRetrieveConfigHostEntry 00104 { 00106 const char *SymbolicName; 00107 00109 int noOfPeers; 00110 00112 DcmQueryRetrieveConfigPeer *Peers; 00113 }; 00114 00117 struct DcmQueryRetrieveConfigHostTable 00118 { 00120 int noOfHostEntries; 00121 00123 DcmQueryRetrieveConfigHostEntry *HostEntries; 00124 }; 00125 00128 class DcmQueryRetrieveConfig 00129 { 00130 00131 public: 00132 00133 /* 00134 * read configuration file and initialize the 00135 * intern configuration structure 00136 * Input : configuration file name 00137 * Return : 1 - ok 00138 * 0 - error 00139 */ 00140 int init(const char *ConfigurationFile); 00141 00142 /* 00143 * search for peer with AETitle 00144 * Input : AETitle 00145 * Ouput : Host Name, Port Number 00146 * Return : 1 - found in AETable 00147 * 2 - found in HostTable 00148 * 0 - not found 00149 */ 00150 int peerForAETitle(const char *AETitle, const char **HostName, int *PortNumber) const; 00151 00152 /* 00153 * check if given AETitles exist in same 00154 * Vendor Group 00155 * Input : two AETitles 00156 * Return : 1 - same group 00157 * 0 - else 00158 */ 00159 int checkForSameVendor(const char *AETitle1, const char *AETitle2) const; 00160 00161 /* 00162 * get Storage Area for AETitle 00163 * Input : AETitle 00164 * Return : Storage Area 00165 */ 00166 const char *getStorageArea(const char *AETitle) const; 00167 00168 /* 00169 * get Number of Maximal Studies 00170 * Input : AETitle 00171 * Return : Number of Maximal Studies 00172 */ 00173 int getMaxStudies(const char *AETitle) const; 00174 00175 /* 00176 * get Number of maximal Bytes per Study 00177 * Input : AETitle 00178 * Return : Number of maximal Bytes per Study 00179 */ 00180 long getMaxBytesPerStudy(const char *AETitle) const; 00181 00182 /* 00183 * get Max Associations 00184 * Input : 00185 * Return : Max Associations 00186 */ 00187 int getMaxAssociations() const; 00188 00189 /* 00190 * get Network TCP Port 00191 * Input : 00192 * Return : Network TCP Port 00193 */ 00194 int getNetworkTCPPort() const; 00195 00196 /* 00197 * get Max PDU Size 00198 * Input : 00199 * Return : Max PDU Size 00200 */ 00201 OFCmdUnsignedInt getMaxPDUSize() const; 00202 00203 /* 00204 * check if there is an peer with calling AETitle 00205 * on HostName 00206 * Input : called AETitle, calling AETitle, Host Name 00207 * Return : 1 -- yes 00208 * 0 -- no 00209 */ 00210 int peerInAETitle(const char *calledAETitle, const char *callingAETitle, const char *HostName) const; 00211 00212 /* 00213 * get Access mode 00214 * Input : AETitle 00215 * Return : Access mode 00216 */ 00217 const char *getAccess(const char *AETitle) const; 00218 00219 /* 00220 * check if given storage area is read/write 00221 * Input : AETitle 00222 * Return : true if storage area is writable 00223 */ 00224 OFBool writableStorageArea(const char *aeTitle) const; 00225 00226 // methods only used by TI 00227 00228 /* 00229 * searches in the host table for all AE titles 00230 * known for peer hostName. Creates an array of string pointers 00231 * containing the known AE titles. The AE titles contained 00232 * in the array are privately owned by the config facility (you 00233 * may not free them). You may free the array when no longer needed. 00234 * 00235 * Input Parameter: peer host name 00236 * Output Parameter: malloc'ed array of private string pointers. 00237 * Returns : number of entries in the malloced array. 00238 * 0 if no entries found. 00239 */ 00240 00241 int aeTitlesForPeer(const char *hostName, const char *** aeTitleList) const; 00242 00243 /* 00244 * Creates an array of string pointers 00245 * containing the known AE titles for CTN storage areas. 00246 * The AE titles contained in the array are privately owned 00247 * by the config facility (you may not free them). You may 00248 * free the array when no longer needed. 00249 * 00250 * Output Parameter: malloc'ed array of private string pointers. 00251 * Returns : number of entries in the malloced array. 00252 * 0 if no entries exist. 00253 */ 00254 00255 int ctnTitles(const char *** ctnTitleList) const; 00256 00257 /* 00258 * Creates an array of string pointers 00259 * containing the kown Host Names for given Vendor Name. 00260 * The Host Names contained in the array are privately owned 00261 * by the config facility (you may not free them). You may 00262 * free the array when no longer needed. 00263 * Input : Vendor Name 00264 * Ouput : array of string pointers 00265 * Return : number of entries in array 00266 * 0 if no entries exist 00267 */ 00268 int HostNamesForVendor(const char *Vendor, const char ***HostNameArray) const; 00269 00270 /* 00271 * searches in the host table for all AE titles 00272 * known for a symbolic name. Creates an array of string pointers 00273 * containing the known AE titles. The AE titles contained 00274 * in the array are privately owned by the config facility (you 00275 * may not free them). You may free the array when no longer needed. 00276 * 00277 * Input Parameter: symbolic name 00278 * Output Parameter: malloc'ed array of private string pointers. 00279 * Returns : number of entries in the malloced array. 00280 * 0 if no entries found. 00281 */ 00282 int aeTitlesForSymbolicName(const char *symbolicName, const char ***aeTitleList) const; 00283 00284 /* 00285 * printf contents of configuration stucture 00286 * to stdout 00287 */ 00288 void printConfig(); 00289 00290 /* 00291 * get User Name 00292 * Input : 00293 * Return : User Name 00294 */ 00295 const char *getUserName() const; 00296 00297 /* 00298 * get Group Name 00299 * Input : 00300 * Return : Group Name 00301 */ 00302 const char *getGroupName() const; 00303 00304 private: 00305 00306 /* 00307 * get Application Title 00308 * Input : 00309 * Return : Application Title 00310 */ 00311 const char *getApplicationTitle() const; 00312 00313 /* 00314 * get Application Context 00315 * Input : 00316 * Return : Application Context 00317 */ 00318 const char *getApplicationContext() const; 00319 00320 /* 00321 * get Implementation Class 00322 * Input : 00323 * Return : Implementation Class 00324 */ 00325 const char *getImplementationClass() const; 00326 00327 /* 00328 * get Implementation Version 00329 * Input : 00330 * Return : Implementation Version 00331 */ 00332 const char *getImplementationVersion() const; 00333 00334 /* 00335 * get Network Type 00336 * Input : 00337 * Return : Network Type 00338 */ 00339 const char *getNetworkType() const; 00340 00341 const char* vendorForPeerAETitle(const char *peerAETitle) const; 00342 00343 int countCtnTitles() const; 00344 00345 00346 /* 00347 * initialize configuration storage structure 00348 */ 00349 void initConfigStruct(); 00350 00351 /* 00352 * read configuration file line by line 00353 * Input : configuration file pointer 00354 * Return : 1 - ok 00355 * 0 - error 00356 */ 00357 int readConfigLines(FILE *cnffp); 00358 00359 /* 00360 * read HostTable in configuration file 00361 * Input : configuration file pointer, line number 00362 * Output : line number 00363 * Return : 1 - ok 00364 * 0 - error 00365 */ 00366 int readHostTable(FILE *cnffp, int *lineno); 00367 00368 /* 00369 * read VendorTable in configuration file 00370 * Input : configuration file pointer, line number 00371 * Output : line number 00372 * Return : 1 - ok 00373 * 0 - error 00374 */ 00375 int readVendorTable(FILE *cnffp, int *lineno); 00376 00377 /* 00378 * read AETable in configuration file 00379 * Input : configuration file pointer, line number 00380 * Output : line number 00381 * Return : 1 - ok 00382 * 0 - error 00383 */ 00384 int readAETable(FILE *cnffp, int *lineno); 00385 00386 /* 00387 * separate the peer list from value list 00388 * Input : pointer to value list 00389 * Output : number of peers 00390 * Return : pointer to peer list 00391 */ 00392 DcmQueryRetrieveConfigPeer *parsePeers(char **valuehandle, int *peers); 00393 00394 /* 00395 * extract peers from peer list 00396 * Input : pointer to value list 00397 * Output : number of peers 00398 * Return : pointer to peer list 00399 */ 00400 DcmQueryRetrieveConfigPeer *readPeerList(char **valuehandle, int *peers); 00401 00402 /* 00403 * separate a quota from value list 00404 * Input : pointer to value list 00405 * Return : pointer to quota structure 00406 */ 00407 static DcmQueryRetrieveConfigQuota *parseQuota(char **valuehandle); 00408 00409 /* 00410 * check if character is white space or separator 00411 * Input : character 00412 * Return : 1 - yes 00413 * 0 - no 00414 */ 00415 static int isgap (char gap); 00416 00417 /* 00418 * check if character is quote 00419 * Input : character 00420 * Return : 1 - yes 00421 * 0 - no 00422 */ 00423 static int isquote (char quote); 00424 00425 /* 00426 * print a panic message to stderr 00427 * Input : variable 00428 */ 00429 static void panic(const char *fmt, ...); 00430 00431 /* 00432 * convert string to long 00433 * Input : parameter string value 00434 * Return : parameter as long 00435 * -1 on error 00436 */ 00437 static long quota (const char *value); 00438 00439 /* 00440 * skip mnemonic and first gap in rc line 00441 * Input : rc line 00442 * Return : pointer to value list 00443 */ 00444 static char *skipmnemonic (char *rcline); 00445 00446 /* 00447 * separate on value from value list 00448 * Input : pointer to value list 00449 * Return : pointer to next value 00450 */ 00451 static char *parsevalues (char **valuehandle); 00452 00453 /* Configuration Parameters */ 00454 OFString applicationTitle_; 00455 OFString applicationContext_; 00456 OFString implementationClass_; 00457 OFString implementationVersion_; 00458 OFString networkType_; 00459 OFString UserName_; 00460 OFString GroupName_; 00461 int networkTCPPort_; 00462 Uint32 maxPDUSize_; 00463 int maxAssociations_; 00464 DcmQueryRetrieveConfigConfiguration CNF_Config; /* configuration file contents */ 00465 DcmQueryRetrieveConfigHostTable CNF_HETable; /* HostEntries Table */ 00466 DcmQueryRetrieveConfigHostTable CNF_VendorTable; /* Vendor Table */ 00467 00468 }; 00469 00470 00471 #endif 00472 00473 /* 00474 * CVS Log 00475 * $Log: dcmqrcnf.h,v $ 00476 * Revision 1.3 2005/12/08 16:04:20 meichel 00477 * Changed include path schema for all DCMTK header files 00478 * 00479 * Revision 1.2 2005/04/04 13:15:13 meichel 00480 * Added username/groupname configuration option that allows to start the 00481 * image database as root and let it call setuid/setgid to execute under an 00482 * unprivileged account once the listen socket has been opened. 00483 * 00484 * Revision 1.1 2005/03/30 13:34:50 meichel 00485 * Initial release of module dcmqrdb that will replace module imagectn. 00486 * It provides a clear interface between the Q/R DICOM front-end and the 00487 * database back-end. The imagectn code has been re-factored into a minimal 00488 * class structure. 00489 * 00490 * 00491 */