OFFIS DCMTK  Version 3.6.0
dcmqrcnf.h
1 /*
2  *
3  * Copyright (C) 1993-2010, 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: dcmqrdb
15  *
16  * Author: Marco Eichelberg / Ralph Meyer
17  *
18  * Purpose: class DcmQueryRetrieveConfig
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:41 $
22  * CVS/RCS Revision: $Revision: 1.7 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCMQRCNF_H
30 #define DCMQRCNF_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 
34 #define INCLUDE_CSTDIO
35 #include "dcmtk/ofstd/ofstdinc.h"
36 #include "dcmtk/ofstd/ofcmdln.h"
37 #include "dcmtk/oflog/oflog.h"
38 
39 OFLogger DCM_dcmqrdbGetLogger();
40 
41 #define DCMQRDB_TRACE(msg) OFLOG_TRACE(DCM_dcmqrdbGetLogger(), msg)
42 #define DCMQRDB_DEBUG(msg) OFLOG_DEBUG(DCM_dcmqrdbGetLogger(), msg)
43 #define DCMQRDB_INFO(msg) OFLOG_INFO(DCM_dcmqrdbGetLogger(), msg)
44 #define DCMQRDB_WARN(msg) OFLOG_WARN(DCM_dcmqrdbGetLogger(), msg)
45 #define DCMQRDB_ERROR(msg) OFLOG_ERROR(DCM_dcmqrdbGetLogger(), msg)
46 #define DCMQRDB_FATAL(msg) OFLOG_FATAL(DCM_dcmqrdbGetLogger(), msg)
47 
51 {
56 };
57 
61 {
63  const char *ApplicationTitle;
64 
66  const char *HostName;
67 
70 };
71 
75 {
77  const char *ApplicationTitle;
78 
80  const char *StorageArea;
81 
83  const char *Access;
84 
87 
89  int noOfPeers;
90 
93 };
94 
98 {
101 
104 };
105 
109 {
111  const char *SymbolicName;
112 
115 
118 };
119 
123 {
126 
129 };
130 
134 {
135 
136 public:
137 
138  /*
139  * read configuration file and initialize the
140  * intern configuration structure
141  * Input : configuration file name
142  * Return : 1 - ok
143  * 0 - error
144  */
145  int init(const char *ConfigurationFile);
146 
147  /*
148  * search for peer with AETitle
149  * Input : AETitle
150  * Ouput : Host Name, Port Number
151  * Return : 1 - found in AETable
152  * 2 - found in HostTable
153  * 0 - not found
154  */
155  int peerForAETitle(const char *AETitle, const char **HostName, int *PortNumber) const;
156 
157  /*
158  * check if given AETitles exist in same
159  * Vendor Group
160  * Input : two AETitles
161  * Return : 1 - same group
162  * 0 - else
163  */
164  int checkForSameVendor(const char *AETitle1, const char *AETitle2) const;
165 
166  /*
167  * get Storage Area for AETitle
168  * Input : AETitle
169  * Return : Storage Area
170  */
171  const char *getStorageArea(const char *AETitle) const;
172 
173  /*
174  * get Number of Maximal Studies
175  * Input : AETitle
176  * Return : Number of Maximal Studies
177  */
178  int getMaxStudies(const char *AETitle) const;
179 
180  /*
181  * get Number of maximal Bytes per Study
182  * Input : AETitle
183  * Return : Number of maximal Bytes per Study
184  */
185  long getMaxBytesPerStudy(const char *AETitle) const;
186 
187  /*
188  * get Max Associations
189  * Input :
190  * Return : Max Associations
191  */
192  int getMaxAssociations() const;
193 
194  /*
195  * get Network TCP Port
196  * Input :
197  * Return : Network TCP Port
198  */
199  int getNetworkTCPPort() const;
200 
201  /*
202  * get Max PDU Size
203  * Input :
204  * Return : Max PDU Size
205  */
206  OFCmdUnsignedInt getMaxPDUSize() const;
207 
208  /*
209  * check if there is an peer with calling AETitle
210  * on HostName
211  * Input : called AETitle, calling AETitle, Host Name
212  * Return : 1 -- yes
213  * 0 -- no
214  */
215  int peerInAETitle(const char *calledAETitle, const char *callingAETitle, const char *HostName) const;
216 
217  /*
218  * get Access mode
219  * Input : AETitle
220  * Return : Access mode
221  */
222  const char *getAccess(const char *AETitle) const;
223 
224  /*
225  * check if given storage area is read/write
226  * Input : AETitle
227  * Return : true if storage area is writable
228  */
229  OFBool writableStorageArea(const char *aeTitle) const;
230 
231  // methods only used by TI
232 
233  /*
234  * searches in the host table for all AE titles
235  * known for peer hostName. Creates an array of string pointers
236  * containing the known AE titles. The AE titles contained
237  * in the array are privately owned by the config facility (you
238  * may not free them). You may free the array when no longer needed.
239  *
240  * Input Parameter: peer host name
241  * Output Parameter: malloc'ed array of private string pointers.
242  * Returns : number of entries in the malloced array.
243  * 0 if no entries found.
244  */
245 
246  int aeTitlesForPeer(const char *hostName, const char *** aeTitleList) const;
247 
248  /*
249  * Creates an array of string pointers
250  * containing the known AE titles for CTN storage areas.
251  * The AE titles contained in the array are privately owned
252  * by the config facility (you may not free them). You may
253  * free the array when no longer needed.
254  *
255  * Output Parameter: malloc'ed array of private string pointers.
256  * Returns : number of entries in the malloced array.
257  * 0 if no entries exist.
258  */
259 
260  int ctnTitles(const char *** ctnTitleList) const;
261 
262  /*
263  * Creates an array of string pointers
264  * containing the kown Host Names for given Vendor Name.
265  * The Host Names contained in the array are privately owned
266  * by the config facility (you may not free them). You may
267  * free the array when no longer needed.
268  * Input : Vendor Name
269  * Ouput : array of string pointers
270  * Return : number of entries in array
271  * 0 if no entries exist
272  */
273  int HostNamesForVendor(const char *Vendor, const char ***HostNameArray) const;
274 
275  /*
276  * searches in the host table for all AE titles
277  * known for a symbolic name. Creates an array of string pointers
278  * containing the known AE titles. The AE titles contained
279  * in the array are privately owned by the config facility (you
280  * may not free them). You may free the array when no longer needed.
281  *
282  * Input Parameter: symbolic name
283  * Output Parameter: malloc'ed array of private string pointers.
284  * Returns : number of entries in the malloced array.
285  * 0 if no entries found.
286  */
287  int aeTitlesForSymbolicName(const char *symbolicName, const char ***aeTitleList) const;
288 
289  /*
290  * printf contents of configuration stucture
291  * to stdout
292  */
293  void printConfig();
294 
295  /*
296  * get User Name
297  * Input :
298  * Return : User Name
299  */
300  const char *getUserName() const;
301 
302  /*
303  * get Group Name
304  * Input :
305  * Return : Group Name
306  */
307  const char *getGroupName() const;
308 
309 private:
310 
311  const char* vendorForPeerAETitle(const char *peerAETitle) const;
312 
313  int countCtnTitles() const;
314 
315 
316  /*
317  * initialize configuration storage structure
318  */
319  void initConfigStruct();
320 
321  /*
322  * read configuration file line by line
323  * Input : configuration file pointer
324  * Return : 1 - ok
325  * 0 - error
326  */
327  int readConfigLines(FILE *cnffp);
328 
329  /*
330  * read HostTable in configuration file
331  * Input : configuration file pointer, line number
332  * Output : line number
333  * Return : 1 - ok
334  * 0 - error
335  */
336  int readHostTable(FILE *cnffp, int *lineno);
337 
338  /*
339  * read VendorTable in configuration file
340  * Input : configuration file pointer, line number
341  * Output : line number
342  * Return : 1 - ok
343  * 0 - error
344  */
345  int readVendorTable(FILE *cnffp, int *lineno);
346 
347  /*
348  * read AETable in configuration file
349  * Input : configuration file pointer, line number
350  * Output : line number
351  * Return : 1 - ok
352  * 0 - error
353  */
354  int readAETable(FILE *cnffp, int *lineno);
355 
356  /*
357  * separate the peer list from value list
358  * Input : pointer to value list
359  * Output : number of peers
360  * Return : pointer to peer list
361  */
362  DcmQueryRetrieveConfigPeer *parsePeers(char **valuehandle, int *peers);
363 
364  /*
365  * extract peers from peer list
366  * Input : pointer to value list
367  * Output : number of peers
368  * Return : pointer to peer list
369  */
370  DcmQueryRetrieveConfigPeer *readPeerList(char **valuehandle, int *peers);
371 
372  /*
373  * separate a quota from value list
374  * Input : pointer to value list
375  * Return : pointer to quota structure
376  */
377  static DcmQueryRetrieveConfigQuota *parseQuota(char **valuehandle);
378 
379  /*
380  * check if character is white space or separator
381  * Input : character
382  * Return : 1 - yes
383  * 0 - no
384  */
385  static int isgap (char gap);
386 
387  /*
388  * check if character is quote
389  * Input : character
390  * Return : 1 - yes
391  * 0 - no
392  */
393  static int isquote (char quote);
394 
395  /*
396  * print a panic message to stderr
397  * Input : variable
398  */
399  static void panic(const char *fmt, ...);
400 
401  /*
402  * convert string to long
403  * Input : parameter string value
404  * Return : parameter as long
405  * -1 on error
406  */
407  static long quota (const char *value);
408 
409  /*
410  * skip mnemonic and first gap in rc line
411  * Input : rc line
412  * Return : pointer to value list
413  */
414  static char *skipmnemonic (char *rcline);
415 
416  /*
417  * separate on value from value list
418  * Input : pointer to value list
419  * Return : pointer to next value
420  */
421  static char *parsevalues (char **valuehandle);
422 
423  /* Configuration Parameters */
424  OFString UserName_;
425  OFString GroupName_;
426  int networkTCPPort_;
427  Uint32 maxPDUSize_;
428  int maxAssociations_;
429  DcmQueryRetrieveConfigConfiguration CNF_Config; /* configuration file contents */
430  DcmQueryRetrieveConfigHostTable CNF_HETable; /* HostEntries Table */
431  DcmQueryRetrieveConfigHostTable CNF_VendorTable; /* Vendor Table */
432 
433 };
434 
435 
436 #endif
437 
438 /*
439  * CVS Log
440  * $Log: dcmqrcnf.h,v $
441  * Revision 1.7 2010-10-14 13:16:41 joergr
442  * Updated copyright header. Added reference to COPYRIGHT file.
443  *
444  * Revision 1.6 2010-09-09 17:20:33 joergr
445  * Removed unused (or never used?) configuration entries.
446  *
447  * Revision 1.5 2009-11-24 10:10:42 uli
448  * Switched to logging mechanism provided by the "new" oflog module.
449  *
450  * Revision 1.4 2009-08-21 09:50:07 joergr
451  * Replaced tabs by spaces and updated copyright date.
452  *
453  * Revision 1.3 2005/12/08 16:04:20 meichel
454  * Changed include path schema for all DCMTK header files
455  *
456  * Revision 1.2 2005/04/04 13:15:13 meichel
457  * Added username/groupname configuration option that allows to start the
458  * image database as root and let it call setuid/setgid to execute under an
459  * unprivileged account once the listen socket has been opened.
460  *
461  * Revision 1.1 2005/03/30 13:34:50 meichel
462  * Initial release of module dcmqrdb that will replace module imagectn.
463  * It provides a clear interface between the Q/R DICOM front-end and the
464  * database back-end. The imagectn code has been re-factored into a minimal
465  * class structure.
466  *
467  *
468  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2