--- sbbs/src/xpdev/genwrap.h 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/xpdev/genwrap.h 2018/04/24 16:45:42 1.1.1.2 @@ -2,13 +2,13 @@ /* General cross-platform development wrappers */ -/* $Id: genwrap.h,v 1.1.1.1 2018/04/24 16:41:24 root Exp $ */ +/* $Id: genwrap.h,v 1.1.1.2 2018/04/24 16:45:42 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -39,6 +39,8 @@ #define _GENWRAP_H #include /* sprintf */ +#include /* strerror() */ +#include /* clock_t */ #include "gen_defs.h" /* ulong */ #include "wrapdll.h" /* DLLEXPORT and DLLCALL */ @@ -58,6 +60,7 @@ #endif #elif defined(_WIN32) #include /* getpid() */ + typedef DWORD pid_t; #endif #if !defined(_WIN32) @@ -155,13 +158,44 @@ extern "C" { #error "Need to describe target platform" #endif +#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__amd64__) + #define ARCHITECTURE_DESC "x64" +#elif defined(__i386__) || _M_IX86 == 300 + #define ARCHITECTURE_DESC "i386" +#elif defined(__i486__) || _M_IX86 == 400 + #define ARCHITECTURE_DESC "i486" +#elif defined(__i586__) || _M_IX86 == 500 + #define ARCHITECTURE_DESC "i586" +#elif defined(__i686__) || _M_IX86 == 600 + #define ARCHITECTURE_DESC "i686" +#elif defined(__i786__) || _M_IX86 == 700 + #define ARCHITECTURE_DESC "i786" +#elif defined(_X86_) || defined(__x86__) || defined(_M_IX86) + #define ARCHITECTURE_DESC "x86" +#elif defined(__mips__) + #define ARCHITECTURE_DESC "mips" +#elif defined(__arm__) + #define ARCHITECTURE_DESC "arm" +#elif defined(_M_PPC) || defined(__ppc__) + #define ARCHITECTURE_DESC "ppc" +#elif defined(_M_IA64) || defined(__ia64__) + #define ARCHITECTURE_DESC "ia64" +#else + #error "Need to describe target architecture" +#endif + /*********************/ /* String Functionss */ /*********************/ -#define snprintf safe_snprintf +#ifndef USE_SNPRINTF + #define snprintf safe_snprintf +#endif #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__DMC__) +#if !defined(snprintf) + #define snprintf _snprintf +#endif #define vsnprintf _vsnprintf #endif @@ -183,6 +217,8 @@ extern "C" { #endif #endif +/* Skip white-space chars at beginning of string */ +DLLEXPORT char* DLLCALL skipsp(char* str); /* Truncate white-space chars off end of string */ DLLEXPORT char* DLLCALL truncsp(char* str); /* Truncate white-space chars off end of every \n-terminated line in string */ @@ -281,29 +317,14 @@ DLLEXPORT int DLLCALL get_errno(void); #endif /* Win32 implementations of recursive (thread-safe) std C time functions on Unix */ - #if !defined(__unix__) - #include /* time_t, etc. */ - - DLLEXPORT struct tm* DLLCALL gmtime_r(const time_t* t, struct tm* tm); - DLLEXPORT struct tm* DLLCALL localtime_r(const time_t* t, struct tm* tm); - DLLEXPORT char* DLLCALL ctime_r(const time_t *t, char *buf); - DLLEXPORT char* DLLCALL asctime_r(const struct tm *tm, char *buf); DLLEXPORT char* DLLCALL strtok_r(char *str, const char *delim, char **last); - -#endif - -#if defined(__solaris__) - #define CTIME_R(x,y) ctime_r(x,y) - /* #define CTIME_R(x,y) ctime_r(x,y,sizeof y) */ -#else - #define CTIME_R(x,y) ctime_r(x,y) #endif /* Mimic the Borland randomize() and random() CRTL functions */ -DLLEXPORT unsigned DLLCALL xp_randomize(void); -DLLEXPORT int DLLCALL xp_random(int); +DLLEXPORT void DLLCALL xp_randomize(void); +DLLEXPORT long DLLCALL xp_random(int); DLLEXPORT long double DLLCALL xp_timer(void); DLLEXPORT char* DLLCALL os_version(char *str); @@ -328,6 +349,9 @@ typedef clock_t msclock_t; msclock_t msclock(void); #endif +DLLEXPORT BOOL DLLCALL check_pid(pid_t); +DLLEXPORT BOOL DLLCALL terminate_pid(pid_t); + #if defined(__cplusplus) } #endif