22 #include <sys/types.h>
27 #define OPENCBM_VERSION OPENCBM_VERSION_STRING
30 # define ARCH_CBM_LINUX_WIN( _linux, _win) _win
36 #if (_MSC_VER <= 1200) // MSVC 6 or older
37 typedef unsigned long ULONG_PTR;
42 # define ARCH_CBM_LINUX_WIN( _linux, _win) _linux
49 typedef unsigned long UINT_PTR;
51 typedef unsigned int UINT_PTR;
59 typedef unsigned long ULONG_PTR;
74 #define arch_strcasecmp(_x,_y) ARCH_CBM_LINUX_WIN(strcasecmp(_x,_y), _stricmp(_x,_y))
75 #define arch_strncasecmp(_x,_y,_z) ARCH_CBM_LINUX_WIN(strncasecmp(_x,_y,_z), _strnicmp(_x,_y,_z))
77 #define arch_sleep(_x) ARCH_CBM_LINUX_WIN(sleep(_x), Sleep((_x) * 1000))
78 #define arch_usleep(_x) ARCH_CBM_LINUX_WIN(usleep(_x), Sleep( ((_x) + 999) / 1000))
81 extern void arch_error(
int AUnused,
unsigned int ErrorCode,
const char *format, ...);
82 extern char *arch_strerror(
unsigned int ErrorCode);
84 #if defined(__APPLE__) || defined(__FreeBSD__)
85 extern void arch_error(
int AUnused,
unsigned int ErrorCode,
const char *format, ...);
87 # define arch_error error
89 # define arch_strerror strerror
93 #define arch_set_errno(_x) ARCH_CBM_LINUX_WIN((errno = (_x)), SetLastError(_x))
94 #define arch_get_errno() ARCH_CBM_LINUX_WIN((errno), GetLastError())
96 #define arch_atoc(_x) ((unsigned char) atoi(_x))
107 # define getenv getenv
110 #define arch_unlink(_x) ARCH_CBM_LINUX_WIN(unlink(_x), _unlink(_x))
114 #define arch_strdup(_x) ARCH_CBM_LINUX_WIN(strdup(_x), _strdup(_x))
116 #define arch_fileno(_x) ARCH_CBM_LINUX_WIN(fileno(_x), _fileno(_x))
118 #define arch_setbinmode(_x) ARCH_CBM_LINUX_WIN(ARCH_EMPTY, _setmode(_x, _O_BINARY))
120 #define arch_ftruncate(_x, _y) ARCH_CBM_LINUX_WIN(ftruncate(_x, _y), _chsize(_x, _y))
122 #define arch_fdopen(_x, _y) ARCH_CBM_LINUX_WIN(fdopen(_x, _y), _fdopen(_x, _y))
124 #define arch_snprintf ARCH_CBM_LINUX_WIN(snprintf, _snprintf)
126 #define ARCH_MAINDECL ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
127 #define ARCH_SIGNALDECL ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
129 typedef void (ARCH_SIGNALDECL *ARCH_CTRLBREAK_HANDLER)(
int dummy);
void arch_set_ctrlbreak_handler(ARCH_CTRLBREAK_HANDLER Handler)
Set the Ctrl+C / Ctrl+Break handler.
int arch_filesize(const char *Filename, off_t *Filesize)
Obtain the size of a given file.
Defining OpenCBM version.