Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

dcompat.h

00001 /*
00002 **  Copyright (C) 1993/1994, OFFIS, Oldenburg University and CERIUM
00003 **  
00004 **  This software and supporting documentation were
00005 **  developed by 
00006 **  
00007 **    Institut OFFIS
00008 **    Bereich Kommunikationssysteme
00009 **    Westerstr. 10-12
00010 **    26121 Oldenburg, Germany
00011 **    
00012 **    Fachbereich Informatik
00013 **    Abteilung Prozessinformatik
00014 **    Carl von Ossietzky Universitaet Oldenburg 
00015 **    Ammerlaender Heerstr. 114-118
00016 **    26111 Oldenburg, Germany
00017 **    
00018 **    CERIUM
00019 **    Laboratoire SIM
00020 **    Faculte de Medecine
00021 **    2 Avenue du Pr. Leon Bernard
00022 **    35043 Rennes Cedex, France
00023 **  
00024 **  for CEN/TC251/WG4 as a contribution to the Radiological 
00025 **  Society of North America (RSNA) 1993 Digital Imaging and 
00026 **  Communications in Medicine (DICOM) Demonstration.
00027 **  
00028 **  THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER OFFIS,
00029 **  OLDENBURG UNIVERSITY NOR CERIUM MAKE ANY WARRANTY REGARDING 
00030 **  THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 
00031 **  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER 
00032 **  DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION.  THE 
00033 **  ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE   
00034 **  IS WITH THE USER. 
00035 **  
00036 **  Copyright of the software and supporting documentation
00037 **  is, unless otherwise stated, jointly owned by OFFIS,
00038 **  Oldenburg University and CERIUM and free access is hereby
00039 **  granted as a license to use this software, copy this
00040 **  software and prepare derivative works based upon this
00041 **  software. However, any distribution of this software
00042 **  source code or supporting documentation or derivative
00043 **  works (source code and supporting documentation) must
00044 **  include the three paragraphs of this copyright notice. 
00045 ** 
00046 */
00047 /*
00048 ** 
00049 ** Author:Andrew Hewett     Created: 11-08-93 
00050 **     Oldenburg University
00051 **     Germany
00052 **
00053 ** Module: dcompat.h
00054 ** 
00055 ** Purpose:
00056 ** This is the place to declare compatability routines
00057 ** which can be missing on some systems.  
00058 **
00059 ** This include file is automatically included by dicom.h 
00060 **
00061 ** Module Prefix: none 
00062 ** 
00063 **
00064 ** Last Update:     $Author: meichel $
00065 ** Update Date:     $Date: 2003/12/17 16:33:26 $
00066 ** Source File:     $Source: /share/dicom/cvs-depot/dcmtk/dcmnet/include/dcompat.h,v $
00067 ** CVS/RCS Revision:    $Revision: 1.21 $
00068 ** Status:      $State: Exp $
00069 **
00070 ** CVS/RCS Log at end of file
00071 **
00072 */
00073 
00074 #ifndef DCOMPAT_H
00075 #define DCOMPAT_H
00076 
00077 #include "osconfig.h"    /* make sure OS specific configuration is included first */
00078 #include "ofbmanip.h"    /* for bzero workaround */
00079 
00080 #define INCLUDE_CSTDLIB
00081 #define INCLUDE_CTIME
00082 #define INCLUDE_CSTRING
00083 #define INCLUDE_CERRNO
00084 #include "ofstdinc.h"
00085 
00086 #ifdef HAVE_GUSI_H
00087 /* Use the Grand Unified Sockets Interface (GUSI) on Macintosh */
00088 #include <GUSI.h>   
00089 #endif
00090 
00091 #ifdef HAVE_WINDOWS_H
00092 #include <windows.h>  /* this includes either winsock.h or winsock2.h */
00093 #else
00094 #ifdef HAVE_WINSOCK_H
00095 #include <winsock.h>  /* include winsock.h directly i.e. on MacOS */
00096 #ifdef macintosh
00097 /*
00098 ** The WinSock header on Macintosh does not declare the WORD type nor the MAKEWORD
00099 ** macro need to initialize the WinSock library.
00100 */
00101 typedef u_short WORD;
00102 #define MAKEWORD(a,b) ((WORD) (((a)&0xff)<<8) | ((b)&0xff) )
00103 #endif
00104 #endif
00105 #endif
00106 
00107 BEGIN_EXTERN_C
00108 
00109 #ifdef HAVE_LIBC_H
00110 #include <libc.h>
00111 #endif
00112 #ifdef HAVE_UNISTD_H
00113 #include <unistd.h>
00114 #endif
00115 #ifdef HAVE_SYS_TIME_H
00116 #include <sys/time.h>
00117 #endif
00118 #ifdef HAVE_SYS_TYPES_H
00119 #include <sys/types.h>
00120 #endif
00121 #ifdef HAVE_SYS_SOCKET_H
00122 #ifndef DCOMPAT_SYS_SOCKET_H_
00123 #define DCOMPAT_SYS_SOCKET_H_
00124 /* some systems don't protect sys/socket.h (e.g. DEC Ultrix) */
00125 #include <sys/socket.h>
00126 #endif
00127 #endif
00128 #ifdef HAVE_NETINET_IN_H
00129 #include <netinet/in.h>
00130 #endif
00131 #ifdef HAVE_ARPA_INET_H
00132 #include <arpa/inet.h>
00133 #endif
00134 #ifdef HAVE_NETDB_H
00135 #include <netdb.h>
00136 #endif
00137 #ifdef HAVE_SYS_WAIT_H
00138 #include <sys/wait.h>
00139 #endif
00140 #ifdef HAVE_SYS_RESOURCE_H
00141 #include <sys/resource.h>
00142 #endif
00143 #ifdef HAVE_SYS_PARAM_H
00144 #include <sys/param.h>
00145 #endif
00146 #ifdef HAVE_SYS_SELECT_H
00147 #include <sys/select.h>
00148 #endif
00149 #ifdef HAVE_SYS_FILE_H
00150 #include <sys/file.h>
00151 #endif
00152 
00153 END_EXTERN_C
00154 
00155 #ifdef _WIN32
00156 #include <process.h>
00157 #include <io.h>
00158 #ifndef __CYGWIN__
00159 #include <sys/locking.h>
00160 #endif
00161 #endif
00162 
00163 #ifndef EINTR
00164 /* The WinSock header on Macintosh does not define an EINTR error code */
00165 #ifdef HAVE_WINSOCK_H
00166 #define EINTR WSAEINTR
00167 #endif
00168 #endif
00169 
00170 #ifdef HAVE_PROTOTYPE_FLOCK
00171 #define dcmtk_flock flock
00172 #define dcmtk_plockerr perror
00173 #endif
00174 
00175 #ifndef HAVE_PROTOTYPE_FLOCK
00176 #ifdef HAVE_FLOCK
00177 BEGIN_EXTERN_C
00178 int flock(int fd, int operation);
00179 END_EXTERN_C
00180 #define dcmtk_flock flock
00181 #define dcmtk_plockerr perror
00182 #else
00183 /*
00184  * Simulate the flock function calls 
00185  * using the facilities of fcntl(2)
00186  */
00187 
00188 #define   LOCK_SH   1    /* shared lock */
00189 #define   LOCK_EX   2    /* exclusive lock */
00190 #define   LOCK_NB   4    /* don't block when locking */
00191 #define   LOCK_UN   8    /* unlock */
00192 
00193 int dcmtk_flock(int fd, int operation);
00194 void dcmtk_plockerr(const char *s);
00195 
00196 #endif /* !HAVE_FLOCK */
00197 #endif
00198 
00199 #ifndef HAVE_BZERO
00200 #ifndef bzero
00201 #define bzero(p,len) memset((void*)(p), 0, (len));
00202 #endif
00203 #endif
00204 
00205 #ifndef HAVE_PROTOTYPE_GETHOSTNAME
00206 #ifdef HAVE_GETHOSTNAME
00207 /* gethostname is in the libraries but we have no prototype */
00208 BEGIN_EXTERN_C
00209 int gethostname(char* name, int namelen);
00210 END_EXTERN_C
00211 #else
00212 /* define gethostname ourselves */
00213 int gethostname(char* name, int namelen);
00214 #endif
00215 #endif
00216 
00217 #ifndef HAVE_PROTOTYPE_GETHOSTBYNAME
00218 #ifdef HAVE_GETHOSTBYNAME
00219 /* it is in the libraries but we have no prototype */
00220 BEGIN_EXTERN_C
00221 struct hostent *gethostbyname(const char* name);
00222 END_EXTERN_C
00223 #else
00224 /* don't know how to emulate */
00225 #endif
00226 #endif
00227 
00228 #ifndef HAVE_PROTOTYPE_GETSOCKOPT
00229 #ifdef HAVE_GETSOCKOPT
00230 /* it is in the libraries but we have no prototype */
00231 BEGIN_EXTERN_C
00232 int getsockopt(int s, int level, int optname, char *optval, int *optlen);
00233 END_EXTERN_C
00234 #else
00235 /* don't know how to emulate */
00236 #endif
00237 #endif
00238 
00239 #ifndef HAVE_PROTOTYPE_SETSOCKOPT
00240 #ifdef HAVE_SETSOCKOPT
00241 /* it is in the libraries but we have no prototype */
00242 BEGIN_EXTERN_C
00243 int setsockopt(int s, int level, int optname, const char *optval, int optlen);
00244 END_EXTERN_C
00245 #else
00246 /* don't know how to emulate */
00247 #endif
00248 #endif
00249 
00250 #ifndef HAVE_PROTOTYPE_LISTEN
00251 #ifdef HAVE_LISTEN
00252 /* it is in the libraries but we have no prototype */
00253 BEGIN_EXTERN_C
00254 int listen(int s, int backlog);
00255 END_EXTERN_C
00256 #else
00257 /* don't know how to emulate */
00258 #endif
00259 #endif
00260 
00261 #ifndef HAVE_PROTOTYPE_SOCKET
00262 #ifdef HAVE_SOCKET
00263 /* it is in the libraries but we have no prototype */
00264 BEGIN_EXTERN_C
00265 int socket(int domain, int type, int protocol);
00266 END_EXTERN_C
00267 #else
00268 /* don't know how to emulate */
00269 #endif
00270 #endif
00271 
00272 #ifndef HAVE_PROTOTYPE_CONNECT
00273 #ifdef HAVE_CONNECT
00274 /* it is in the libraries but we have no prototype */
00275 BEGIN_EXTERN_C
00276 int connect(int s, struct sockaddr *name, int namelen);
00277 END_EXTERN_C
00278 #else
00279 /* don't know how to emulate */
00280 #endif
00281 #endif
00282 
00283 #ifndef HAVE_PROTOTYPE_SELECT
00284 #ifdef HAVE_SELECT
00285 /* it is in the libraries but we have no prototype */
00286 BEGIN_EXTERN_C
00287 int select(int nfds, fd_set *readfds, fd_set *writefds,
00288        fd_set *exceptfds, struct timeval *timeout);
00289 END_EXTERN_C
00290 #else
00291 /* don't know how to emulate */
00292 #endif
00293 #endif
00294 
00295 #ifndef HAVE_PROTOTYPE_BIND
00296 #ifdef HAVE_BIND
00297 /* it is in the libraries but we have no prototype */
00298 BEGIN_EXTERN_C
00299 int bind(int s, const struct sockaddr *name, int namelen);
00300 END_EXTERN_C
00301 #else
00302 /* don't know how to emulate */
00303 #endif
00304 #endif
00305 
00306 #ifndef HAVE_PROTOTYPE_ACCEPT
00307 #ifdef HAVE_ACCEPT
00308 /* it is in the libraries but we have no prototype */
00309 BEGIN_EXTERN_C
00310 int accept(int s, struct sockaddr *addr, int *addrlen);
00311 END_EXTERN_C
00312 #else
00313 /* don't know how to emulate */
00314 #endif
00315 #endif
00316 
00317 #ifndef HAVE_PROTOTYPE_GETSOCKNAME
00318 #ifdef HAVE_GETSOCKNAME
00319 /* it is in the libraries but we have no prototype */
00320 BEGIN_EXTERN_C
00321 int getsockname(int s, struct sockaddr *name, int *namelen);
00322 END_EXTERN_C
00323 #else
00324 /* don't know how to emulate */
00325 #endif
00326 #endif
00327 
00328 #ifndef HAVE_PROTOTYPE_WAITPID
00329 #ifdef HAVE_WAITPID
00330 /* it is in the libraries but we have no prototype */
00331 BEGIN_EXTERN_C
00332 int waitpid(pid_t pid, int *statusp, int options);
00333 END_EXTERN_C
00334 #else
00335 /* don't know how to emulate */
00336 #endif
00337 #endif
00338 
00339 #ifndef HAVE_PROTOTYPE_WAIT3
00340 #ifdef HAVE_WAIT3
00341 /* it is in the libraries but we have no prototype */
00342 BEGIN_EXTERN_C
00343 int wait3(int *statusp, int options, struct rusage *rusage);
00344 END_EXTERN_C
00345 #else
00346 /* don't know how to emulate */
00347 #endif
00348 #endif
00349 
00350 #ifndef HAVE_GETPID
00351 #ifndef getpid
00352 #ifdef _WIN32
00353 #define getpid()    (_getpid())
00354 #else
00355 #define getpid()    ((int) 9000)
00356 #endif
00357 #endif
00358 #endif
00359 
00360 #ifndef HAVE_ACCESS
00361 
00362 #ifndef R_OK
00363 #define R_OK 0x01
00364 #define W_OK 0x02
00365 #define X_OK 0x04
00366 #define F_OK 0x08
00367 #endif
00368 
00369 int access(const char* path, int amode);
00370 #else /* HAVE_ACCESS */
00371 
00372 #ifdef _WIN32
00373 /* windows defines access but not the constants */
00374 #ifndef R_OK
00375 #define W_OK 02 /* Write permission */
00376 #define R_OK 04 /* Read permission */
00377 #define F_OK 00 /* Existance only */
00378 #define X_OK 00 /* execute permission has no meaning under windows, treat as existance */
00379 #endif /* R_OK */
00380 #endif /* _WIN32 */
00381 
00382 #endif /* HAVE_ACCESS */
00383 
00384 #ifndef HAVE_STRERROR
00385 char *strerror(int e);
00386 #endif
00387 
00388 #ifndef HAVE_TEMPNAM
00389 char *tempnam(char *dir, char *pfx);
00390 #endif
00391 
00392 #ifdef _WIN32
00393 #define NULL_DEVICE_NAME "nul"
00394 #else
00395 #define NULL_DEVICE_NAME "/dev/null"
00396 #endif
00397 
00398 
00399 #endif /* DCOMPAT_H */
00400 
00401 /*
00402 ** CVS Log
00403 ** $Log: dcompat.h,v $
00404 ** Revision 1.21  2003/12/17 16:33:26  meichel
00405 ** Removed unused macros
00406 **
00407 ** Revision 1.20  2003/06/06 09:44:56  meichel
00408 ** Added static sleep function in class OFStandard. This replaces the various
00409 **   calls to sleep(), Sleep() and usleep() throughout the toolkit.
00410 **
00411 ** Revision 1.19  2002/11/27 13:04:35  meichel
00412 ** Adapted module dcmnet to use of new header file ofstdinc.h
00413 **
00414 ** Revision 1.18  2000/11/10 16:25:01  meichel
00415 ** Fixed problem with DIMSE routines which attempted to delete /dev/null
00416 **   under certain circumstances, which could lead to disastrous results if
00417 **   tools were run with root permissions (what they shouldn't).
00418 **
00419 ** Revision 1.17  2000/02/23 15:12:24  meichel
00420 ** Corrected macro for Borland C++ Builder 4 workaround.
00421 **
00422 ** Revision 1.16  2000/02/01 10:24:06  meichel
00423 ** Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4,
00424 **   workaround for bug in compiler header files.
00425 **
00426 ** Revision 1.15  1999/11/12 16:51:02  meichel
00427 ** Corrected file locking code that did not work correctly under Win95/98.
00428 **
00429 ** Revision 1.14  1999/05/04 12:18:04  joergr
00430 ** Minor changes to support Cygwin B20.1 (check __CYGWIN__ to distinguish from
00431 ** MSVC which also defines _WIN32).
00432 **
00433 ** Revision 1.13  1999/04/30 16:36:32  meichel
00434 ** Renamed all flock calls to dcmtk_flock to avoid name clash between flock()
00435 ** emulation based on fcntl() and a constructor for struct flock.
00436 **
00437 ** Revision 1.12  1999/04/21 13:02:56  meichel
00438 ** Now always including <windows.h> instead of <winsock.h> on Win32 platforms.
00439 **   This makes sure that <winsock2.h> is used if available.
00440 **
00441 ** Revision 1.11  1999/04/19 08:42:35  meichel
00442 ** Added constants for access() on Win32.
00443 **
00444 ** Revision 1.10  1997/09/11 16:02:15  hewett
00445 ** Conditionally included more standard header files into the
00446 ** the dcmnet compatibility header file to allow appropriate
00447 ** declarations to be picked up.  For Signus GnuWin32.
00448 **
00449 ** Revision 1.9  1997/04/18 08:37:30  andreas
00450 ** - Removed double include of sys/select
00451 **
00452 ** Revision 1.8  1997/02/06 12:14:42  hewett
00453 ** Updated preliminary Apple Macintosh support for the Metrowerks CodeWarrior
00454 ** version 11 compiler and environment.
00455 **
00456 ** Revision 1.7  1996/09/27 14:03:03  hewett
00457 ** Added emulation of sleep() for Win32.
00458 **
00459 ** Revision 1.6  1996/09/27 08:27:59  hewett
00460 ** Move the defines for BEGIN_EXTERN_C/END_EXTERN_C to config/include/osconfig.h
00461 ** Added support for Win32 by conditionally including <WINSOCK.h>.
00462 **
00463 ** Revision 1.5  1996/09/24 16:22:36  hewett
00464 ** Added preliminary support for the Macintosh environment (GUSI library).
00465 **
00466 ** Revision 1.4  1996/06/20 07:31:09  hewett
00467 ** Corrected compilation problem when including <sys/socket.h> on
00468 ** DEC Alpha OSF/1.
00469 **
00470 ** Revision 1.3  1996/05/03 10:30:41  hewett
00471 ** Added some common include files.
00472 **
00473 ** Revision 1.2  1996/04/25 16:05:44  hewett
00474 ** Added prototypes for some network functions if not available on system.
00475 **
00476 ** Revision 1.1.1.1  1996/03/26 18:38:45  hewett
00477 ** Initial Release.
00478 **
00479 **
00480 */


Generated on 29 Apr 2005 for OFFIS DCMTK Version 3.5.3 by Doxygen 1.4.2