Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

arch.h

00001 #ifndef CBM_ARCH_H
00002 #define CBM_ARCH_H
00003 
00004 #include <sys/types.h> /* for off_t */
00005 
00006 #define ARCH_EMPTY
00007 
00008 #ifdef WIN32
00009 # include "version.h"
00010 
00011 # define OPENCBM_VERSION CBM4WIN_VERSION_STRING
00012 # define ARCH_CBM_LINUX_WIN( _linux, _win) _win
00013 
00014 # include <stdio.h>
00015 # include <io.h>
00016 # include <fcntl.h>
00017 
00018 #else
00019 
00020 # define ARCH_CBM_LINUX_WIN( _linux, _win) _linux
00021 
00022 # include <unistd.h>
00023 # include <errno.h>
00024 # include <error.h>
00025 
00026 # define ULONG_PTR unsigned long
00027 
00028 #endif
00029 
00030 #include <string.h>
00031 
00032 #define arch_strcasecmp(_x,_y)     ARCH_CBM_LINUX_WIN(strcasecmp(_x,_y), _stricmp(_x,_y))
00033 #define arch_strncasecmp(_x,_y,_z) ARCH_CBM_LINUX_WIN(strncasecmp(_x,_y,_z), _strnicmp(_x,_y,_z))
00034 
00035 #define arch_sleep(_x)  ARCH_CBM_LINUX_WIN(sleep(_x), Sleep((_x) * 1000))
00036 #define arch_usleep(_x) ARCH_CBM_LINUX_WIN(usleep(_x), Sleep( ((_x) + 999) / 1000))
00037 
00038 #ifdef WIN32
00039  extern void arch_error(int AUnused, unsigned int ErrorCode, const char *format, ...);
00040  extern char *arch_strerror(unsigned int ErrorCode);
00041 #else
00042 # define arch_error error
00043 # define arch_strerror strerror
00044 #endif
00045 
00047 #define arch_set_errno(_x) ARCH_CBM_LINUX_WIN((errno = (_x)), SetLastError(_x))
00048 #define arch_get_errno()   ARCH_CBM_LINUX_WIN((errno), GetLastError())
00049 
00050 #define arch_atoc(_x) ((unsigned char) atoi(_x))
00051 
00052 /* dummys for compiling */
00053 
00054 #ifdef WIN32
00055 # include <stdlib.h> /* for getenv */
00056 
00057 /* Make sure that getenv() will not be defined with a prototype
00058    in arch/windows/getopt.c, which would result in a compiler error 
00059    "error C2373: 'getenv' : redefinition; different type modifiers".
00060 */
00061 # define getenv getenv
00062 #endif
00063 
00064 #define arch_unlink(_x) ARCH_CBM_LINUX_WIN(unlink(_x), _unlink(_x))
00065 
00066 int arch_filesize(const char *Filename, off_t *Filesize);
00067 
00068 #define arch_strdup(_x) ARCH_CBM_LINUX_WIN(strdup(_x), _strdup(_x))
00069 
00070 #define arch_fileno(_x) ARCH_CBM_LINUX_WIN(fileno(_x), _fileno(_x))
00071 
00072 #define arch_setbinmode(_x) ARCH_CBM_LINUX_WIN(ARCH_EMPTY/* already in bin mode */, _setmode(_x, _O_BINARY))
00073 
00074 #define arch_ftruncate(_x, _y) ARCH_CBM_LINUX_WIN(ftruncate(_x, _y), _chsize(_x, _y))
00075 
00076 #define arch_fdopen(_x, _y) ARCH_CBM_LINUX_WIN(fdopen(_x, _y), _fdopen(_x, _y))
00077 
00078 #define ARCH_MAINDECL   ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
00079 #define ARCH_SIGNALDECL ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
00080 
00081 #endif /* #ifndef CBM_ARCH_H */

Generated on Sun Apr 30 18:45:42 2006 for opencbm by  doxygen 1.4.2