OFFIS DCMTK
Version 3.6.0
Main Page
Related Pages
Classes
Files
File List
File Members
dcmnet
include
dcmtk
dcmnet
dcompat.h
1
/*
2
*
3
* Copyright (C) 1994-2010, OFFIS e.V.
4
* All rights reserved. See COPYRIGHT file for details.
5
*
6
* This software and supporting documentation were partly developed by
7
*
8
* OFFIS e.V.
9
* R&D Division Health
10
* Escherweg 2
11
* D-26121 Oldenburg, Germany
12
*
13
* For further copyrights, see the following paragraphs.
14
*
15
*/
16
17
/*
18
** Copyright (C) 1993/1994, OFFIS, Oldenburg University and CERIUM
19
**
20
** This software and supporting documentation were
21
** developed by
22
**
23
** Institut OFFIS
24
** Bereich Kommunikationssysteme
25
** Westerstr. 10-12
26
** 26121 Oldenburg, Germany
27
**
28
** Fachbereich Informatik
29
** Abteilung Prozessinformatik
30
** Carl von Ossietzky Universitaet Oldenburg
31
** Ammerlaender Heerstr. 114-118
32
** 26111 Oldenburg, Germany
33
**
34
** CERIUM
35
** Laboratoire SIM
36
** Faculte de Medecine
37
** 2 Avenue du Pr. Leon Bernard
38
** 35043 Rennes Cedex, France
39
**
40
** for CEN/TC251/WG4 as a contribution to the Radiological
41
** Society of North America (RSNA) 1993 Digital Imaging and
42
** Communications in Medicine (DICOM) Demonstration.
43
**
44
** THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER OFFIS,
45
** OLDENBURG UNIVERSITY NOR CERIUM MAKE ANY WARRANTY REGARDING
46
** THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR
47
** FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER
48
** DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION. THE
49
** ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE
50
** IS WITH THE USER.
51
**
52
** Copyright of the software and supporting documentation
53
** is, unless otherwise stated, jointly owned by OFFIS,
54
** Oldenburg University and CERIUM and free access is hereby
55
** granted as a license to use this software, copy this
56
** software and prepare derivative works based upon this
57
** software. However, any distribution of this software
58
** source code or supporting documentation or derivative
59
** works (source code and supporting documentation) must
60
** include the three paragraphs of this copyright notice.
61
**
62
*/
63
/*
64
**
65
** Author: Andrew Hewett Created: 11-08-93
66
**
67
** Module: dcompat.h
68
**
69
** Purpose:
70
** This is the place to declare compatability routines
71
** which can be missing on some systems.
72
**
73
** This include file is automatically included by dicom.h
74
**
75
** Module Prefix: none
76
**
77
** Last Update: $Author: joergr $
78
** Update Date: $Date: 2010-12-01 08:26:10 $
79
** CVS/RCS Revision: $Revision: 1.26 $
80
** Status: $State: Exp $
81
**
82
** CVS/RCS Log at end of file
83
**
84
*/
85
86
#ifndef DCOMPAT_H
87
#define DCOMPAT_H
88
89
#include "dcmtk/config/osconfig.h"
/* make sure OS specific configuration is included first */
90
#include "dcmtk/ofstd/ofbmanip.h"
/* for bzero workaround */
91
92
#define INCLUDE_CSTDLIB
93
#define INCLUDE_CTIME
94
#define INCLUDE_CSTRING
95
#define INCLUDE_CERRNO
96
#define INCLUDE_LIBC
97
#define INCLUDE_UNISTD
98
#include "dcmtk/ofstd/ofstdinc.h"
99
100
#ifdef HAVE_GUSI_H
101
/* Use the Grand Unified Sockets Interface (GUSI) on Macintosh */
102
#include <GUSI.h>
103
#endif
104
105
#ifdef HAVE_WINDOWS_H
106
#include <windows.h>
/* this includes either winsock.h or winsock2.h */
107
#else
108
#ifdef HAVE_WINSOCK_H
109
#include <winsock.h>
/* include winsock.h directly i.e. on MacOS */
110
#ifdef macintosh
111
/*
112
** The WinSock header on Macintosh does not declare the WORD type nor the MAKEWORD
113
** macro need to initialize the WinSock library.
114
*/
115
typedef
u_short WORD;
116
#define MAKEWORD(a,b) ((WORD) (((a)&0xff)<<8) | ((b)&0xff) )
117
#endif
118
#endif
119
#endif
120
121
BEGIN_EXTERN_C
122
#ifdef HAVE_SYS_TIME_H
123
#include <sys/time.h>
124
#endif
125
#ifdef HAVE_SYS_TYPES_H
126
#include <sys/types.h>
127
#endif
128
#ifdef HAVE_SYS_SOCKET_H
129
#ifndef DCOMPAT_SYS_SOCKET_H_
130
#define DCOMPAT_SYS_SOCKET_H_
131
/* some systems don't protect sys/socket.h (e.g. DEC Ultrix) */
132
#include <sys/socket.h>
133
#endif
134
#endif
135
#ifdef HAVE_NETINET_IN_H
136
#include <netinet/in.h>
137
#endif
138
#ifdef HAVE_ARPA_INET_H
139
#include <arpa/inet.h>
140
#endif
141
#ifdef HAVE_NETDB_H
142
#include <netdb.h>
143
#endif
144
#ifdef HAVE_SYS_WAIT_H
145
#include <sys/wait.h>
146
#endif
147
#ifdef HAVE_SYS_RESOURCE_H
148
#include <sys/resource.h>
149
#endif
150
#ifdef HAVE_SYS_PARAM_H
151
#include <sys/param.h>
152
#endif
153
#ifdef HAVE_SYS_SELECT_H
154
#include <sys/select.h>
155
#endif
156
#ifdef HAVE_SYS_FILE_H
157
#include <sys/file.h>
158
#endif
159
END_EXTERN_C
160
161
#ifdef _WIN32
162
#include <process.h>
163
#include <io.h>
164
#ifndef __CYGWIN__
165
#include <sys/locking.h>
166
#endif
167
#endif
168
169
#ifndef EINTR
170
/* The WinSock header on Macintosh does not define an EINTR error code */
171
#ifdef HAVE_WINSOCK_H
172
#define EINTR WSAEINTR
173
#endif
174
#endif
175
176
#ifdef HAVE_PROTOTYPE_FLOCK
177
#define dcmtk_flock flock
178
#define dcmtk_plockerr perror
179
#endif
180
181
#ifndef HAVE_PROTOTYPE_FLOCK
182
#ifdef HAVE_FLOCK
183
BEGIN_EXTERN_C
184
int
flock(
int
fd,
int
operation);
185
END_EXTERN_C
186
#define dcmtk_flock flock
187
#define dcmtk_plockerr perror
188
#else
189
/*
190
* Simulate the flock function calls
191
* using the facilities of fcntl(2)
192
*/
193
194
#define LOCK_SH 1
/* shared lock */
195
#define LOCK_EX 2
/* exclusive lock */
196
#define LOCK_NB 4
/* don't block when locking */
197
#define LOCK_UN 8
/* unlock */
198
199
int
dcmtk_flock(
int
fd,
int
operation);
200
void
dcmtk_plockerr(
const
char
*s);
201
202
#endif
/* !HAVE_FLOCK */
203
#endif
204
205
#ifndef HAVE_BZERO
206
#ifndef bzero
207
#define bzero(p,len) memset((void*)(p), 0, (len));
208
#endif
209
#endif
210
211
#ifndef HAVE_PROTOTYPE_GETHOSTNAME
212
#ifdef HAVE_GETHOSTNAME
213
/* gethostname is in the libraries but we have no prototype */
214
BEGIN_EXTERN_C
215
int
gethostname(
char
* name,
int
namelen);
216
END_EXTERN_C
217
#else
218
/* define gethostname ourselves */
219
int
gethostname(
char
* name,
int
namelen);
220
#endif
221
#endif
222
223
#ifndef HAVE_PROTOTYPE_GETHOSTBYNAME
224
#ifdef HAVE_GETHOSTBYNAME
225
/* it is in the libraries but we have no prototype */
226
BEGIN_EXTERN_C
227
struct
hostent *gethostbyname(
const
char
* name);
228
END_EXTERN_C
229
#else
230
/* don't know how to emulate */
231
#endif
232
#endif
233
234
#ifndef HAVE_PROTOTYPE_GETSOCKOPT
235
#ifdef HAVE_GETSOCKOPT
236
/* it is in the libraries but we have no prototype */
237
BEGIN_EXTERN_C
238
int
getsockopt(
int
s,
int
level,
int
optname,
char
*optval,
int
*optlen);
239
END_EXTERN_C
240
#else
241
/* don't know how to emulate */
242
#endif
243
#endif
244
245
#ifndef HAVE_PROTOTYPE_SETSOCKOPT
246
#ifdef HAVE_SETSOCKOPT
247
/* it is in the libraries but we have no prototype */
248
BEGIN_EXTERN_C
249
int
setsockopt(
int
s,
int
level,
int
optname,
const
char
*optval,
int
optlen);
250
END_EXTERN_C
251
#else
252
/* don't know how to emulate */
253
#endif
254
#endif
255
256
#ifndef HAVE_PROTOTYPE_LISTEN
257
#ifdef HAVE_LISTEN
258
/* it is in the libraries but we have no prototype */
259
BEGIN_EXTERN_C
260
int
listen(
int
s,
int
backlog);
261
END_EXTERN_C
262
#else
263
/* don't know how to emulate */
264
#endif
265
#endif
266
267
#ifndef HAVE_PROTOTYPE_SOCKET
268
#ifdef HAVE_SOCKET
269
/* it is in the libraries but we have no prototype */
270
BEGIN_EXTERN_C
271
int
socket(
int
domain,
int
type,
int
protocol);
272
END_EXTERN_C
273
#else
274
/* don't know how to emulate */
275
#endif
276
#endif
277
278
#ifndef HAVE_PROTOTYPE_CONNECT
279
#ifdef HAVE_CONNECT
280
/* it is in the libraries but we have no prototype */
281
BEGIN_EXTERN_C
282
int
connect(
int
s,
struct
sockaddr *name,
int
namelen);
283
END_EXTERN_C
284
#else
285
/* don't know how to emulate */
286
#endif
287
#endif
288
289
#ifndef HAVE_PROTOTYPE_SELECT
290
#ifdef HAVE_SELECT
291
/* it is in the libraries but we have no prototype */
292
BEGIN_EXTERN_C
293
int
select(
int
nfds, fd_set *readfds, fd_set *writefds,
294
fd_set *exceptfds,
struct
timeval *timeout);
295
END_EXTERN_C
296
#else
297
/* don't know how to emulate */
298
#endif
299
#endif
300
301
#ifndef HAVE_PROTOTYPE_BIND
302
#ifdef HAVE_BIND
303
/* it is in the libraries but we have no prototype */
304
BEGIN_EXTERN_C
305
int
bind(
int
s,
const
struct
sockaddr *name,
int
namelen);
306
END_EXTERN_C
307
#else
308
/* don't know how to emulate */
309
#endif
310
#endif
311
312
#ifndef HAVE_PROTOTYPE_ACCEPT
313
#ifdef HAVE_ACCEPT
314
/* it is in the libraries but we have no prototype */
315
BEGIN_EXTERN_C
316
int
accept(
int
s,
struct
sockaddr *addr,
int
*addrlen);
317
END_EXTERN_C
318
#else
319
/* don't know how to emulate */
320
#endif
321
#endif
322
323
#ifndef HAVE_PROTOTYPE_GETSOCKNAME
324
#ifdef HAVE_GETSOCKNAME
325
/* it is in the libraries but we have no prototype */
326
BEGIN_EXTERN_C
327
int
getsockname(
int
s,
struct
sockaddr *name,
int
*namelen);
328
END_EXTERN_C
329
#else
330
/* don't know how to emulate */
331
#endif
332
#endif
333
334
#ifndef HAVE_PROTOTYPE_WAITPID
335
#ifdef HAVE_WAITPID
336
/* it is in the libraries but we have no prototype */
337
BEGIN_EXTERN_C
338
int
waitpid(pid_t pid,
int
*statusp,
int
options);
339
END_EXTERN_C
340
#else
341
/* don't know how to emulate */
342
#endif
343
#endif
344
345
#ifndef HAVE_PROTOTYPE_WAIT3
346
#ifdef HAVE_WAIT3
347
/* it is in the libraries but we have no prototype */
348
BEGIN_EXTERN_C
349
int
wait3(
int
*statusp,
int
options,
struct
rusage *rusage);
350
END_EXTERN_C
351
#else
352
/* don't know how to emulate */
353
#endif
354
#endif
355
356
#ifndef HAVE_ACCESS
357
358
#ifndef R_OK
359
#define R_OK 0x01
360
#define W_OK 0x02
361
#define X_OK 0x04
362
#define F_OK 0x08
363
#endif
364
365
int
access(
const
char
* path,
int
amode);
366
#else
/* HAVE_ACCESS */
367
368
#ifdef _WIN32
369
/* windows defines access but not the constants */
370
#ifndef R_OK
371
#define W_OK 02
/* Write permission */
372
#define R_OK 04
/* Read permission */
373
#define F_OK 00
/* Existance only */
374
#define X_OK 00
/* execute permission has no meaning under windows, treat as existance */
375
#endif
/* R_OK */
376
#endif
/* _WIN32 */
377
378
#endif
/* HAVE_ACCESS */
379
380
#ifndef HAVE_STRERROR
381
char
*strerror(
int
e);
382
#endif
383
384
#ifndef HAVE_TEMPNAM
385
char
*tempnam(
char
*dir,
char
*pfx);
386
#endif
387
388
#ifdef _WIN32
389
#define NULL_DEVICE_NAME "nul"
390
#else
391
#define NULL_DEVICE_NAME "/dev/null"
392
#endif
393
394
395
#endif
/* DCOMPAT_H */
396
397
/*
398
** CVS Log
399
** $Log: dcompat.h,v $
400
** Revision 1.26 2010-12-01 08:26:10 joergr
401
** Added OFFIS copyright header (beginning with the year 1994).
402
**
403
** Revision 1.25 2010-10-14 13:17:22 joergr
404
** Updated copyright header. Added reference to COPYRIGHT file.
405
**
406
** Revision 1.24 2010-01-20 13:49:47 uli
407
** Added OFStandard::getProcessID().
408
**
409
** Revision 1.23 2005-12-08 16:02:19 meichel
410
** Changed include path schema for all DCMTK header files
411
**
412
** Revision 1.22 2004/08/03 11:42:43 meichel
413
** Headers libc.h and unistd.h are now included via ofstdinc.h
414
**
415
** Revision 1.21 2003/12/17 16:33:26 meichel
416
** Removed unused macros
417
**
418
** Revision 1.20 2003/06/06 09:44:56 meichel
419
** Added static sleep function in class OFStandard. This replaces the various
420
** calls to sleep(), Sleep() and usleep() throughout the toolkit.
421
**
422
** Revision 1.19 2002/11/27 13:04:35 meichel
423
** Adapted module dcmnet to use of new header file ofstdinc.h
424
**
425
** Revision 1.18 2000/11/10 16:25:01 meichel
426
** Fixed problem with DIMSE routines which attempted to delete /dev/null
427
** under certain circumstances, which could lead to disastrous results if
428
** tools were run with root permissions (what they shouldn't).
429
**
430
** Revision 1.17 2000/02/23 15:12:24 meichel
431
** Corrected macro for Borland C++ Builder 4 workaround.
432
**
433
** Revision 1.16 2000/02/01 10:24:06 meichel
434
** Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4,
435
** workaround for bug in compiler header files.
436
**
437
** Revision 1.15 1999/11/12 16:51:02 meichel
438
** Corrected file locking code that did not work correctly under Win95/98.
439
**
440
** Revision 1.14 1999/05/04 12:18:04 joergr
441
** Minor changes to support Cygwin B20.1 (check __CYGWIN__ to distinguish from
442
** MSVC which also defines _WIN32).
443
**
444
** Revision 1.13 1999/04/30 16:36:32 meichel
445
** Renamed all flock calls to dcmtk_flock to avoid name clash between flock()
446
** emulation based on fcntl() and a constructor for struct flock.
447
**
448
** Revision 1.12 1999/04/21 13:02:56 meichel
449
** Now always including <windows.h> instead of <winsock.h> on Win32 platforms.
450
** This makes sure that <winsock2.h> is used if available.
451
**
452
** Revision 1.11 1999/04/19 08:42:35 meichel
453
** Added constants for access() on Win32.
454
**
455
** Revision 1.10 1997/09/11 16:02:15 hewett
456
** Conditionally included more standard header files into the
457
** the dcmnet compatibility header file to allow appropriate
458
** declarations to be picked up. For Signus GnuWin32.
459
**
460
** Revision 1.9 1997/04/18 08:37:30 andreas
461
** - Removed double include of sys/select
462
**
463
** Revision 1.8 1997/02/06 12:14:42 hewett
464
** Updated preliminary Apple Macintosh support for the Metrowerks CodeWarrior
465
** version 11 compiler and environment.
466
**
467
** Revision 1.7 1996/09/27 14:03:03 hewett
468
** Added emulation of sleep() for Win32.
469
**
470
** Revision 1.6 1996/09/27 08:27:59 hewett
471
** Move the defines for BEGIN_EXTERN_C/END_EXTERN_C to config/include/osconfig.h
472
** Added support for Win32 by conditionally including <WINSOCK.h>.
473
**
474
** Revision 1.5 1996/09/24 16:22:36 hewett
475
** Added preliminary support for the Macintosh environment (GUSI library).
476
**
477
** Revision 1.4 1996/06/20 07:31:09 hewett
478
** Corrected compilation problem when including <sys/socket.h> on
479
** DEC Alpha OSF/1.
480
**
481
** Revision 1.3 1996/05/03 10:30:41 hewett
482
** Added some common include files.
483
**
484
** Revision 1.2 1996/04/25 16:05:44 hewett
485
** Added prototypes for some network functions if not available on system.
486
**
487
** Revision 1.1.1.1 1996/03/26 18:38:45 hewett
488
** Initial Release.
489
**
490
**
491
*/
Generated on Thu Dec 20 2012 for
OFFIS DCMTK
Version 3.6.0 by
Doxygen
1.8.2