00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #ifndef DCOMPAT_H
00075 #define DCOMPAT_H
00076
00077 #include "dcmtk/config/osconfig.h"
00078 #include "dcmtk/ofstd/ofbmanip.h"
00079
00080 #define INCLUDE_CSTDLIB
00081 #define INCLUDE_CTIME
00082 #define INCLUDE_CSTRING
00083 #define INCLUDE_CERRNO
00084 #define INCLUDE_LIBC
00085 #define INCLUDE_UNISTD
00086 #include "dcmtk/ofstd/ofstdinc.h"
00087
00088 #ifdef HAVE_GUSI_H
00089
00090 #include <GUSI.h>
00091 #endif
00092
00093 #ifdef HAVE_WINDOWS_H
00094 #include <windows.h>
00095 #else
00096 #ifdef HAVE_WINSOCK_H
00097 #include <winsock.h>
00098 #ifdef macintosh
00099
00100
00101
00102
00103 typedef u_short WORD;
00104 #define MAKEWORD(a,b) ((WORD) (((a)&0xff)<<8) | ((b)&0xff) )
00105 #endif
00106 #endif
00107 #endif
00108
00109 BEGIN_EXTERN_C
00110 #ifdef HAVE_SYS_TIME_H
00111 #include <sys/time.h>
00112 #endif
00113 #ifdef HAVE_SYS_TYPES_H
00114 #include <sys/types.h>
00115 #endif
00116 #ifdef HAVE_SYS_SOCKET_H
00117 #ifndef DCOMPAT_SYS_SOCKET_H_
00118 #define DCOMPAT_SYS_SOCKET_H_
00119
00120 #include <sys/socket.h>
00121 #endif
00122 #endif
00123 #ifdef HAVE_NETINET_IN_H
00124 #include <netinet/in.h>
00125 #endif
00126 #ifdef HAVE_ARPA_INET_H
00127 #include <arpa/inet.h>
00128 #endif
00129 #ifdef HAVE_NETDB_H
00130 #include <netdb.h>
00131 #endif
00132 #ifdef HAVE_SYS_WAIT_H
00133 #include <sys/wait.h>
00134 #endif
00135 #ifdef HAVE_SYS_RESOURCE_H
00136 #include <sys/resource.h>
00137 #endif
00138 #ifdef HAVE_SYS_PARAM_H
00139 #include <sys/param.h>
00140 #endif
00141 #ifdef HAVE_SYS_SELECT_H
00142 #include <sys/select.h>
00143 #endif
00144 #ifdef HAVE_SYS_FILE_H
00145 #include <sys/file.h>
00146 #endif
00147 END_EXTERN_C
00148
00149 #ifdef _WIN32
00150 #include <process.h>
00151 #include <io.h>
00152 #ifndef __CYGWIN__
00153 #include <sys/locking.h>
00154 #endif
00155 #endif
00156
00157 #ifndef EINTR
00158
00159 #ifdef HAVE_WINSOCK_H
00160 #define EINTR WSAEINTR
00161 #endif
00162 #endif
00163
00164 #ifdef HAVE_PROTOTYPE_FLOCK
00165 #define dcmtk_flock flock
00166 #define dcmtk_plockerr perror
00167 #endif
00168
00169 #ifndef HAVE_PROTOTYPE_FLOCK
00170 #ifdef HAVE_FLOCK
00171 BEGIN_EXTERN_C
00172 int flock(int fd, int operation);
00173 END_EXTERN_C
00174 #define dcmtk_flock flock
00175 #define dcmtk_plockerr perror
00176 #else
00177
00178
00179
00180
00181
00182 #define LOCK_SH 1
00183 #define LOCK_EX 2
00184 #define LOCK_NB 4
00185 #define LOCK_UN 8
00186
00187 int dcmtk_flock(int fd, int operation);
00188 void dcmtk_plockerr(const char *s);
00189
00190 #endif
00191 #endif
00192
00193 #ifndef HAVE_BZERO
00194 #ifndef bzero
00195 #define bzero(p,len) memset((void*)(p), 0, (len));
00196 #endif
00197 #endif
00198
00199 #ifndef HAVE_PROTOTYPE_GETHOSTNAME
00200 #ifdef HAVE_GETHOSTNAME
00201
00202 BEGIN_EXTERN_C
00203 int gethostname(char* name, int namelen);
00204 END_EXTERN_C
00205 #else
00206
00207 int gethostname(char* name, int namelen);
00208 #endif
00209 #endif
00210
00211 #ifndef HAVE_PROTOTYPE_GETHOSTBYNAME
00212 #ifdef HAVE_GETHOSTBYNAME
00213
00214 BEGIN_EXTERN_C
00215 struct hostent *gethostbyname(const char* name);
00216 END_EXTERN_C
00217 #else
00218
00219 #endif
00220 #endif
00221
00222 #ifndef HAVE_PROTOTYPE_GETSOCKOPT
00223 #ifdef HAVE_GETSOCKOPT
00224
00225 BEGIN_EXTERN_C
00226 int getsockopt(int s, int level, int optname, char *optval, int *optlen);
00227 END_EXTERN_C
00228 #else
00229
00230 #endif
00231 #endif
00232
00233 #ifndef HAVE_PROTOTYPE_SETSOCKOPT
00234 #ifdef HAVE_SETSOCKOPT
00235
00236 BEGIN_EXTERN_C
00237 int setsockopt(int s, int level, int optname, const char *optval, int optlen);
00238 END_EXTERN_C
00239 #else
00240
00241 #endif
00242 #endif
00243
00244 #ifndef HAVE_PROTOTYPE_LISTEN
00245 #ifdef HAVE_LISTEN
00246
00247 BEGIN_EXTERN_C
00248 int listen(int s, int backlog);
00249 END_EXTERN_C
00250 #else
00251
00252 #endif
00253 #endif
00254
00255 #ifndef HAVE_PROTOTYPE_SOCKET
00256 #ifdef HAVE_SOCKET
00257
00258 BEGIN_EXTERN_C
00259 int socket(int domain, int type, int protocol);
00260 END_EXTERN_C
00261 #else
00262
00263 #endif
00264 #endif
00265
00266 #ifndef HAVE_PROTOTYPE_CONNECT
00267 #ifdef HAVE_CONNECT
00268
00269 BEGIN_EXTERN_C
00270 int connect(int s, struct sockaddr *name, int namelen);
00271 END_EXTERN_C
00272 #else
00273
00274 #endif
00275 #endif
00276
00277 #ifndef HAVE_PROTOTYPE_SELECT
00278 #ifdef HAVE_SELECT
00279
00280 BEGIN_EXTERN_C
00281 int select(int nfds, fd_set *readfds, fd_set *writefds,
00282 fd_set *exceptfds, struct timeval *timeout);
00283 END_EXTERN_C
00284 #else
00285
00286 #endif
00287 #endif
00288
00289 #ifndef HAVE_PROTOTYPE_BIND
00290 #ifdef HAVE_BIND
00291
00292 BEGIN_EXTERN_C
00293 int bind(int s, const struct sockaddr *name, int namelen);
00294 END_EXTERN_C
00295 #else
00296
00297 #endif
00298 #endif
00299
00300 #ifndef HAVE_PROTOTYPE_ACCEPT
00301 #ifdef HAVE_ACCEPT
00302
00303 BEGIN_EXTERN_C
00304 int accept(int s, struct sockaddr *addr, int *addrlen);
00305 END_EXTERN_C
00306 #else
00307
00308 #endif
00309 #endif
00310
00311 #ifndef HAVE_PROTOTYPE_GETSOCKNAME
00312 #ifdef HAVE_GETSOCKNAME
00313
00314 BEGIN_EXTERN_C
00315 int getsockname(int s, struct sockaddr *name, int *namelen);
00316 END_EXTERN_C
00317 #else
00318
00319 #endif
00320 #endif
00321
00322 #ifndef HAVE_PROTOTYPE_WAITPID
00323 #ifdef HAVE_WAITPID
00324
00325 BEGIN_EXTERN_C
00326 int waitpid(pid_t pid, int *statusp, int options);
00327 END_EXTERN_C
00328 #else
00329
00330 #endif
00331 #endif
00332
00333 #ifndef HAVE_PROTOTYPE_WAIT3
00334 #ifdef HAVE_WAIT3
00335
00336 BEGIN_EXTERN_C
00337 int wait3(int *statusp, int options, struct rusage *rusage);
00338 END_EXTERN_C
00339 #else
00340
00341 #endif
00342 #endif
00343
00344 #ifndef HAVE_GETPID
00345 #ifndef getpid
00346 #ifdef _WIN32
00347 #define getpid() (_getpid())
00348 #else
00349 #define getpid() ((int) 9000)
00350 #endif
00351 #endif
00352 #endif
00353
00354 #ifndef HAVE_ACCESS
00355
00356 #ifndef R_OK
00357 #define R_OK 0x01
00358 #define W_OK 0x02
00359 #define X_OK 0x04
00360 #define F_OK 0x08
00361 #endif
00362
00363 int access(const char* path, int amode);
00364 #else
00365
00366 #ifdef _WIN32
00367
00368 #ifndef R_OK
00369 #define W_OK 02
00370 #define R_OK 04
00371 #define F_OK 00
00372 #define X_OK 00
00373 #endif
00374 #endif
00375
00376 #endif
00377
00378 #ifndef HAVE_STRERROR
00379 char *strerror(int e);
00380 #endif
00381
00382 #ifndef HAVE_TEMPNAM
00383 char *tempnam(char *dir, char *pfx);
00384 #endif
00385
00386 #ifdef _WIN32
00387 #define NULL_DEVICE_NAME "nul"
00388 #else
00389 #define NULL_DEVICE_NAME "/dev/null"
00390 #endif
00391
00392
00393 #endif
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480