dcmqrdb/include/dcmtk/dcmqrdb/dcmqrcnf.h

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


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1