1
0
mirror of https://github.com/upx/upx.git synced 2025-08-11 22:52:30 +08:00

New ACC version.

committer: mfx <mfx> 1066732570 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2003-10-21 10:36:10 +00:00
parent e4f6378dfe
commit bcb5e7d852
23 changed files with 623 additions and 140 deletions

View File

@ -23,9 +23,9 @@
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED
#define __ACC_H_INCLUDED 1
#define ACC_VERSION 20030913L
#define ACC_VERSION 20031020L
#if !defined(ACC_CONFIG_INCLUDE)
# define ACC_CONFIG_INCLUDE(file) file

View File

@ -40,7 +40,7 @@
#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
# define ACC_ARCH_IA16 1
# define ACC_INFO_ARCH "ia16"
#elif defined(__amd64__) || defined(__x86_64__)
#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
# define ACC_ARCH_AMD64 1
# define ACC_INFO_ARCH "amd64"
#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
@ -57,7 +57,7 @@
#elif (ACC_OS_WIN32)
# error "missing define for CPU architecture"
#elif (ACC_OS_WIN64)
# error "missing define for CPU architecture"
/* # error "missing define for CPU architecture" */
#elif (ACC_OS_TOS) || defined(__m68000__)
# define ACC_ARCH_M68K 1
# define ACC_INFO_ARCH "m68k"
@ -76,7 +76,7 @@
#endif
#if (ACC_ARCH_IA16 || ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA16 || ACC_ARCH_IA32)
# define ACC_ENDIAN_LITTLE_ENDIAN 1
# define ACC_INFO_ENDIAN "little-endian"
#elif (ACC_ARCH_M68K)

View File

@ -80,7 +80,6 @@
# define HAVE_ALLOCA_H 1
# endif
#elif (ACC_OS_CYGWIN)
# define HAVE_ALLOCA_H 1
# define HAVE_IO_H 1
#elif (ACC_OS_EMX)
# define HAVE_ALLOCA_H 1
@ -136,7 +135,7 @@
# undef HAVE_DIRENT_H /* not working */
# undef HAVE_UNISTD_H /* not working */
# define HAVE_SYS_DIRENT_H 1
#elif defined(__DJGPP__)
#elif defined(__DJGPP__) && defined(__GNUC__)
#elif (ACC_CC_IBMC && ACC_OS_OS2)
# undef HAVE_DOS_H
# undef HAVE_DIRENT_H
@ -154,7 +153,7 @@
# undef HAVE_DIRENT_H
# undef HAVE_DOS_H
# undef HAVE_SYS_TIME_H
#elif defined(__MINGW32__)
#elif defined(__MINGW32__) && defined(__GNUC__)
# undef HAVE_UTIME_H
# define HAVE_SYS_UTIME_H 1
#elif (ACC_CC_PACIFICC)
@ -170,6 +169,7 @@
# undef HAVE_SYS_STAT_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
#elif defined(__PW32__) && defined(__GNUC__)
#elif (ACC_CC_SYMANTECC)
# undef HAVE_DIRENT_H /* opendir() not implemented in libc */
# undef HAVE_UNISTD_H /* not working */
@ -265,7 +265,10 @@
#define HAVE_UTIME 1
#define HAVE_VSNPRINTF 1
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_POSIX)
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_POSIX || ACC_OS_QNX)
# define HAVE_STRCASECMP 1
# define HAVE_STRNCASECMP 1
#elif (ACC_OS_WIN32 && defined(__PW32__) && defined(__GNUC__))
# define HAVE_STRCASECMP 1
# define HAVE_STRNCASECMP 1
#else
@ -279,6 +282,10 @@
# undef HAVE_ALLOCA
# endif
#elif (ACC_OS_CYGWIN)
# if (ACC_CC_GNUC < 0x025f00ul)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# endif
#elif (ACC_OS_EMX)
# undef HAVE_CHOWN
# undef HAVE_LSTAT
@ -333,7 +340,7 @@
#elif (ACC_CC_DMC)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#elif defined(__DJGPP__)
#elif defined(__DJGPP__) && defined(__GNUC__)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_IBMC)
@ -358,9 +365,14 @@
# if ((_MSC_VER < 800) && ACC_OS_WIN16)
# undef HAVE_ALLOCA
# endif
#elif defined(__MINGW32__)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#elif defined(__MINGW32__) && defined(__GNUC__)
# if (ACC_CC_GNUC < 0x025f00ul)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# else
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
#elif (ACC_CC_PACIFICC)
# undef HAVE_ACCESS
# undef HAVE_ALLOCA
@ -373,6 +385,9 @@
# undef HAVE_STRFTIME
# undef HAVE_UTIME
# undef HAVE_VSNPRINTF
#elif defined(__PW32__) && defined(__GNUC__)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_SYMANTECC)
# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE))
# undef HAVE_ALLOCA

View File

@ -335,6 +335,7 @@
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
ACCCHK_ASSERT(sizeof(void*) == 2)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 2)
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
ACCCHK_ASSERT(sizeof(void*) == 4)
#endif
@ -345,6 +346,29 @@
#endif
/*************************************************************************
// check ACC_ARCH and ACC_OS
**************************************************************************/
#if (ACC_ARCH_IA16)
ACCCHK_ASSERT(sizeof(size_t) == 2)
#elif (ACC_ARCH_IA32)
ACCCHK_ASSERT(sizeof(size_t) == 4)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4)
#elif (ACC_ARCH_AMD64 || ACC_ARCH_IA64)
ACCCHK_ASSERT(sizeof(size_t) == 8)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 8)
#endif
#if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32)
ACCCHK_ASSERT(sizeof(size_t) == 4)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4)
#elif (ACC_OS_WIN64)
ACCCHK_ASSERT(sizeof(size_t) == 8)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 8)
#endif
/*************************************************************************
// check promotion rules
**************************************************************************/

View File

@ -14,7 +14,7 @@
#ifndef __ACC_CXX_H_INCLUDED
#define __ACC_CXX_H_INCLUDED
#define __ACC_CXX_H_INCLUDED 1
#if defined(__cplusplus)
@ -23,7 +23,7 @@
// ACC_CXX_NOTHROW
**************************************************************************/
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x028000ul))
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul))
# define ACC_CXX_NOTHROW
#elif (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450))
# define ACC_CXX_NOTHROW
@ -40,6 +40,27 @@
#endif
/*************************************************************************
// disable dynamic allocation of an object - private helpers
// __ACC_CXX_DO_NEW
// __ACC_CXX_DO_DELETE
**************************************************************************/
#if defined(__ACC_CXX_DO_NEW)
#else
# define __ACC_CXX_DO_NEW ;
#endif
/* need an implementation in case a class has virtual members */
#if defined(__ACC_CXX_DO_DELETE)
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# define __ACC_CXX_DO_DELETE { }
#else
# define __ACC_CXX_DO_DELETE ACC_CXX_NOTHROW { }
#endif
/*************************************************************************
// disable dynamic allocation of an object
// ACC_CXX_DISABLE_NEW_DELETE
@ -51,8 +72,6 @@
#undef __ACC_CXX_HAVE_PLACEMENT_DELETE
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450))
#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x029000ul))
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif (ACC_CC_MSC && ACC_MM_HUGE)
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif (ACC_CC_MSC && (_MSC_VER < 1100))
@ -80,11 +99,11 @@
#if !defined(__ACC_CXX_PLACEMENT_NEW) && (__ACC_CXX_HAVE_PLACEMENT_NEW)
# define __ACC_CXX_PLACEMENT_NEW \
static void* operator new(size_t, void*);
static void* operator new(size_t, void*) __ACC_CXX_DO_NEW
#endif
#if !defined(__ACC_CXX_PLACEMENT_DELETE) && (__ACC_CXX_HAVE_PLACEMENT_DELETE)
# define __ACC_CXX_PLACEMENT_DELETE \
static void operator delete(void*, void*) ACC_CXX_NOTHROW { }
static void operator delete(void*, void*) __ACC_CXX_DO_DELETE
#endif
#if !defined(__ACC_CXX_PLACEMENT_NEW)
# define __ACC_CXX_PLACEMENT_NEW
@ -101,27 +120,27 @@
#if !defined(ACC_CXX_DISABLE_NEW_DELETE) && !(__ACC_CXX_HAVE_ARRAY_NEW)
/* for old compilers use `protected' instead of `private' */
# define ACC_CXX_DISABLE_NEW_DELETE \
protected: static void operator delete(void*) ACC_CXX_NOTHROW { } \
protected: static void* operator new(size_t); \
protected: static void operator delete(void*) __ACC_CXX_DO_DELETE \
protected: static void* operator new(size_t) __ACC_CXX_DO_NEW \
private:
#endif
#if !defined(ACC_CXX_DISABLE_NEW_DELETE)
# define ACC_CXX_DISABLE_NEW_DELETE \
protected: \
static void operator delete(void*) ACC_CXX_NOTHROW { } \
static void operator delete[](void*) ACC_CXX_NOTHROW { } \
static void operator delete(void*) __ACC_CXX_DO_DELETE \
static void operator delete[](void*) __ACC_CXX_DO_DELETE \
private: \
static void* operator new(size_t); \
static void* operator new[](size_t);
static void* operator new(size_t) __ACC_CXX_DO_NEW \
static void* operator new[](size_t) __ACC_CXX_DO_NEW
# define ACC_CXX_DISABLE_NEW_DELETE_STRICT \
protected: \
static void operator delete(void*) ACC_CXX_NOTHROW { } \
static void operator delete[](void*) ACC_CXX_NOTHROW { } \
static void operator delete(void*) __ACC_CXX_DO_DELETE \
static void operator delete[](void*) __ACC_CXX_DO_DELETE \
__ACC_CXX_PLACEMENT_DELETE \
private: \
static void* operator new(size_t); \
static void* operator new[](size_t); \
static void* operator new(size_t) __ACC_CXX_DO_NEW \
static void* operator new[](size_t) __ACC_CXX_DO_NEW \
__ACC_CXX_PLACEMENT_NEW
#endif

View File

@ -22,7 +22,7 @@
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_GCC)
# elif (ACC_CC_GNUC)
# define ACC_UNUSED(var) ((void) var)
# else
# define ACC_UNUSED(var) ((void) &var)

View File

@ -14,7 +14,7 @@
#ifndef __ACC_INCD_H_INCLUDED
#define __ACC_INCD_H_INCLUDED
#define __ACC_INCD_H_INCLUDED 1
/* default system includes */
/* see Autoconf:

View File

@ -14,7 +14,7 @@
#ifndef __ACC_INCE_H_INCLUDED
#define __ACC_INCE_H_INCLUDED
#define __ACC_INCE_H_INCLUDED 1
/* extra system includes */

View File

@ -14,7 +14,7 @@
#ifndef __ACC_INCI_H_INCLUDED
#define __ACC_INCI_H_INCLUDED
#define __ACC_INCI_H_INCLUDED 1
/*************************************************************************
@ -24,7 +24,11 @@
#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# include <tos.h>
#elif (ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN || (ACC_OS_EMX && defined(__RSXNT__)))
# if (ACC_CC_WATCOMC && __WATCOMC__ < 1000)
# if (ACC_CC_WATCOMC && (__WATCOMC__ < 1000))
# elif defined(__PW32__) && defined(__GNUC__)
/* ancient pw32 version */
# elif ((ACC_OS_CYGWIN || defined(__MINGW32__)) && (ACC_CC_GNUC < 0x025f00ul))
/* ancient cygwin/mingw version */
# else
# if 1 && !defined(WIN32_LEAN_AND_MEAN)
# define WIN32_LEAN_AND_MEAN 1

View File

@ -14,7 +14,7 @@
#ifndef __ACC_LIB_H_INCLUDED
#define __ACC_LIB_H_INCLUDED
#define __ACC_LIB_H_INCLUDED 1
#if !defined(__ACCLIB_FUNCNAME)
@ -49,6 +49,30 @@
#endif
/*************************************************************************
// wrap <ctype.h>
**************************************************************************/
#if 0
ACCLIB_EXTERN(int, acc_ascii_digit) (int);
ACCLIB_EXTERN(int, acc_ascii_islower) (int);
ACCLIB_EXTERN(int, acc_ascii_isupper) (int);
ACCLIB_EXTERN(int, acc_ascii_tolower) (int);
ACCLIB_EXTERN(int, acc_ascii_toupper) (int);
ACCLIB_EXTERN(int, acc_ascii_utolower) (int);
ACCLIB_EXTERN(int, acc_ascii_utoupper) (int);
#endif
#define acc_ascii_isdigit(c) (((unsigned)(c) - 48) < 10)
#define acc_ascii_islower(c) (((unsigned)(c) - 97) < 26)
#define acc_ascii_isupper(c) (((unsigned)(c) - 65) < 26)
#define acc_ascii_tolower(c) ((int)(c) + (acc_ascii_isupper(c) << 5))
#define acc_ascii_toupper(c) ((int)(c) - (acc_ascii_islower(c) << 5))
#define acc_ascii_utolower(c) acc_ascii_tolower((unsigned char)(c))
#define acc_ascii_utoupper(c) acc_ascii_toupper((unsigned char)(c))
/*************************************************************************
// huge pointer layer
**************************************************************************/
@ -90,12 +114,31 @@ ACCLIB_EXTERN(acc_hvoid_p, acc_hmemset) (acc_hvoid_p, int, acc_hsize_t);
/* string */
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlen) (const acc_hchar_p);
ACCLIB_EXTERN(int, acc_hstrcmp) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(int, acc_hstrncmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_ascii_hstricmp) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(int, acc_ascii_hstrnicmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_ascii_hmemicmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrstr) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrcpy) (acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrcat) (acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_hstrscpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_hstrscat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrccpy) (acc_hchar_p, const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p, const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrchr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemchr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrrspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrcspn) (const acc_hchar_p, const acc_hchar_p);
@ -104,6 +147,10 @@ ACCLIB_EXTERN(acc_hchar_p, acc_hstrpbrk) (const acc_hchar_p, const acc_hchar_p)
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrsep) (acc_hchar_pp, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p, acc_hsize_t);
/* stdio */
ACCLIB_EXTERN(acc_hsize_t, acc_hfread) (ACC_FILE_P, acc_hvoid_p, acc_hsize_t);
@ -147,6 +194,14 @@ ACCLIB_EXTERN(long, acc_hwrite) (int, const acc_hvoid_p, long);
#endif
#define ACC_FNMATCH_NOESCAPE 1
#define ACC_FNMATCH_PATHNAME 2
#define ACC_FNMATCH_PATHSTAR 4
#define ACC_FNMATCH_PERIOD 8
#define ACC_FNMATCH_ASCII_CASEFOLD 16
ACCLIB_EXTERN(int, acc_fnmatch) (const acc_hchar_p, const acc_hchar_p, int);
/*************************************************************************
// wrap <dirent.h>
**************************************************************************/
@ -235,7 +290,7 @@ ACCLIB_EXTERN(acc_uint32l_t, acc_umuldiv32) (acc_uint32l_t, acc_uint32l_t, acc_u
typedef struct { /* all private */
acclib_handle_t h;
int mode;
#if (ACC_H_WINDOWS_H) && defined(acc_uint64l_t)
#if (ACC_H_WINDOWS_H) && defined(acc_int64l_t)
double qpf;
#endif
} acc_uclock_handle_t;
@ -269,7 +324,7 @@ ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uc
/*************************************************************************
// bele (Big Endian / Little Endian)
// Big Endian / Little Endian
**************************************************************************/
ACCLIB_EXTERN(unsigned, acc_get_be16) (const acc_hvoid_p);
@ -292,19 +347,57 @@ ACCLIB_EXTERN(void, acc_set_le64) (acc_hvoid_p, acc_uint64l_t);
#endif
/* inline versions */
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
# define ACC_GET_LE16(p) (* (const unsigned short *) (p))
# define ACC_GET_LE32(p) (* (const acc_uint32e_t *) (p))
# define ACC_SET_LE16(p,v) (* (unsigned short *) (p) = (unsigned short) (v))
# define ACC_SET_LE32(p,v) (* (acc_uint32e_t *) (p) = (acc_uint32e_t) (v))
#endif
#if (ACC_ARCH_AMD64)
# define ACC_GET_LE64(p) (* (const acc_uint64l_t *) (p))
# define ACC_SET_LE64(p,v) (* (acc_uint64l_t *) (p) = (acc_uint64l_t) (v))
#endif
/*************************************************************************
// getopt
**************************************************************************/
typedef struct {
const char* name;
int has_arg;
int* flag;
int val;
} acc_getopt_longopt_t;
#ifndef acc_getopt_longopt_p
#define acc_getopt_longopt_p acc_getopt_longopt_t *
#endif
typedef struct {
int go_argc;
char** go_argv;
const char* go_shortopts;
const acc_getopt_longopt_p longopts;
#if (ACC_CC_AZTECC || ACC_CC_TURBOC)
int __acc_cdecl_va (*go_error)(const char *, ...);
#else
int (__acc_cdecl_va *go_error)(const char *, ...);
#endif
} acc_getopt_t;
#ifndef acc_getopt_p
#define acc_getopt_p acc_getopt_t *
#endif
ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p);
ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p);
ACCLIB_EXTERN(void, acc_getopt_close)(acc_getopt_p);
/*************************************************************************
// rand
**************************************************************************/
typedef struct {
typedef struct { /* all private */
acc_uint32l_t seed;
} acc_rand31_t;
#ifndef acc_rand31_p
@ -314,7 +407,7 @@ ACCLIB_EXTERN(void, acc_srand31) (acc_rand31_p, acc_uint32l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand31) (acc_rand31_p);
#if defined(acc_uint64l_t)
typedef struct {
typedef struct { /* all private */
acc_uint64l_t seed;
} acc_rand48_t;
#ifndef acc_rand48_p
@ -326,7 +419,7 @@ ACCLIB_EXTERN(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p);
#endif
#if defined(acc_uint64l_t)
typedef struct {
typedef struct { /* all private */
acc_uint64l_t seed;
} acc_rand64_t;
#ifndef acc_rand64_p
@ -337,7 +430,7 @@ ACCLIB_EXTERN(acc_uint32l_t, acc_rand64) (acc_rand64_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p);
#endif
typedef struct {
typedef struct { /* all private */
unsigned n;
acc_uint32l_t s[624];
} acc_randmt_t;

View File

@ -43,6 +43,9 @@
#elif defined(__EMX__) && defined(__GNUC__)
# define ACC_OS_EMX 1
# define ACC_INFO_OS "emx"
#elif defined(__BEOS__)
# define ACC_OS_BEOS 1
# define ACC_INFO_OS "beos"
#elif defined(__QNX__)
# define ACC_OS_QNX 1
# define ACC_INFO_OS "qnx"

View File

@ -0,0 +1,2 @@
getopt.ch
fnmatch.ch

View File

@ -13,13 +13,14 @@
*/
#define __ACCLIB_BELE_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
//
// be16 / be24 / be32
**************************************************************************/
ACCLIB_PUBLIC(unsigned, acc_get_be16) (const acc_hvoid_p p)
@ -70,7 +71,7 @@ ACCLIB_PUBLIC(void, acc_set_be32) (acc_hvoid_p p, acc_uint32l_t v)
ACCLIB_PUBLIC(unsigned, acc_get_le16) (const acc_hvoid_p p)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return (* (const unsigned short *) (p));
#else
const acc_hbyte_p b = (const acc_hbyte_p) p;
@ -86,7 +87,7 @@ ACCLIB_PUBLIC(acc_uint32l_t, acc_get_le24) (const acc_hvoid_p p)
ACCLIB_PUBLIC(acc_uint32l_t, acc_get_le32) (const acc_hvoid_p p)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return (* (const acc_uint32e_t *) (p));
#else
const acc_hbyte_p b = (const acc_hbyte_p) p;
@ -95,10 +96,13 @@ ACCLIB_PUBLIC(acc_uint32l_t, acc_get_le32) (const acc_hvoid_p p)
}
/*************************************************************************
// le16 / le24 / le32
**************************************************************************/
ACCLIB_PUBLIC(void, acc_set_le16) (acc_hvoid_p p, unsigned v)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
(* (unsigned short *) (p) = (unsigned short) (v));
#else
acc_hbyte_p b = (acc_hbyte_p) p;
@ -117,7 +121,7 @@ ACCLIB_PUBLIC(void, acc_set_le24) (acc_hvoid_p p, acc_uint32l_t v)
ACCLIB_PUBLIC(void, acc_set_le32) (acc_hvoid_p p, acc_uint32l_t v)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
(* (acc_uint32e_t *) (p) = (acc_uint32e_t) (v));
#else
acc_hbyte_p b = (acc_hbyte_p) p;
@ -129,6 +133,9 @@ ACCLIB_PUBLIC(void, acc_set_le32) (acc_hvoid_p p, acc_uint32l_t v)
}
/*************************************************************************
// be64
**************************************************************************/
#if defined(acc_uint64l_t)
@ -173,11 +180,20 @@ ACCLIB_PUBLIC(void, acc_set_be64) (acc_hvoid_p p, acc_uint64l_t v)
#endif
}
#endif /* acc_uint64l_t */
/*************************************************************************
// le64
**************************************************************************/
#if defined(acc_uint64l_t)
ACCLIB_PUBLIC(acc_uint64l_t, acc_get_le64) (const acc_hvoid_p p)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64)
return (* (const acc_uint64l_t *) (p));
#elif (ACC_ARCH_IA32)
const acc_uint32e_t* b = (const acc_uint32e_t*) p;
return ((acc_uint64l_t)b[0]) | ((acc_uint64l_t)b[1] << 32);
#elif (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
@ -195,7 +211,9 @@ ACCLIB_PUBLIC(acc_uint64l_t, acc_get_le64) (const acc_hvoid_p p)
ACCLIB_PUBLIC(void, acc_set_le64) (acc_hvoid_p p, acc_uint64l_t v)
{
#if (ACC_ARCH_IA32)
#if (ACC_ARCH_AMD64)
(* (acc_uint64l_t *) (p)) = v;
#elif (ACC_ARCH_IA32)
(((acc_uint32e_t *)(p))[0] = (acc_uint32e_t) (v >> 0));
(((acc_uint32e_t *)(p))[1] = (acc_uint32e_t) (v >> 32));
#elif (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
@ -224,7 +242,6 @@ ACCLIB_PUBLIC(void, acc_set_le64) (acc_hvoid_p p, acc_uint64l_t v)
#endif
}
#endif /* acc_uint64l_t */

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_DOSALLOC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -37,7 +38,6 @@ ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
return p;
ri.x.ax = 0x4800;
ri.x.bx = (unsigned short) size;
ro.x.cflag = 1;
int86(0x21, &ri, &ro);
if ((ro.x.cflag & 1) == 0) /* if carry flag not set */
p = (void __far*) ACC_MK_FP(ro.x.ax, 0);
@ -57,7 +57,6 @@ ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
segread(&rs);
ri.x.ax = 0x4900;
rs.es = ACC_FP_SEG(p);
ro.x.cflag = 1;
int86x(0x21, &ri, &ro, &rs);
if (ro.x.cflag & 1) /* if carry flag set */
return -1;

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_HALLOC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_HFREAD_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -25,7 +26,21 @@
ACCLIB_PUBLIC(acc_hsize_t, acc_hfread) (ACC_FILE_P fp, acc_hvoid_p buf, acc_hsize_t size)
{
#if (ACC_HAVE_MM_HUGE_PTR)
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
n = fread(tmp, 1, n, fp);
if (n == 0)
break;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
acc_hbyte_p b = (acc_hbyte_p) buf;
acc_hsize_t l = 0;
@ -42,19 +57,7 @@ ACCLIB_PUBLIC(acc_hsize_t, acc_hfread) (ACC_FILE_P fp, acc_hvoid_p buf, acc_hsiz
}
return l;
#else
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
n = fread(tmp, 1, n, fp);
if (n == 0)
break;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
# error "unknown memory model"
#endif
#else
return fread(buf, 1, size, fp);
@ -65,7 +68,21 @@ ACCLIB_PUBLIC(acc_hsize_t, acc_hfread) (ACC_FILE_P fp, acc_hvoid_p buf, acc_hsiz
ACCLIB_PUBLIC(acc_hsize_t, acc_hfwrite) (ACC_FILE_P fp, const acc_hvoid_p buf, acc_hsize_t size)
{
#if (ACC_HAVE_MM_HUGE_PTR)
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = fwrite(tmp, 1, n, fp);
if (n == 0)
break;
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
const acc_hbyte_p b = (const acc_hbyte_p) buf;
acc_hsize_t l = 0;
@ -82,19 +99,7 @@ ACCLIB_PUBLIC(acc_hsize_t, acc_hfwrite) (ACC_FILE_P fp, const acc_hvoid_p buf, a
}
return l;
#else
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = fwrite(tmp, 1, n, fp);
if (n == 0)
break;
l += n;
}
return l;
# error "unknown memory model"
#endif
#else
return fwrite(buf, 1, size, fp);

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_HMEMCPY_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_HREAD_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -26,7 +27,23 @@
ACCLIB_PUBLIC(long, acc_hread) (int fd, acc_hvoid_p buf, long size)
{
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
n = read(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
acc_hbyte_p b = (acc_hbyte_p) buf;
long l = 0;
@ -45,28 +62,30 @@ ACCLIB_PUBLIC(long, acc_hread) (int fd, acc_hvoid_p buf, long size)
}
return l;
#else
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
n = read(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
# error "unknown memory model"
#endif
}
ACCLIB_PUBLIC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size)
{
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = write(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
const acc_hbyte_p b = (const acc_hbyte_p) buf;
long l = 0;
@ -85,25 +104,11 @@ ACCLIB_PUBLIC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size)
}
return l;
#else
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = write(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
l += n;
}
return l;
# error "unknown memory model"
#endif
}
#endif
#endif /* #if (ACC_HAVE_MM_HUGE_PTR) */
/*

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_HSTRING_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -26,16 +27,150 @@ ACCLIB_PUBLIC(acc_hsize_t, acc_hstrlen) (const acc_hchar_p s)
{
/* TODO: which one is the fastest generic version? */
#if 1
const acc_hchar_p start = s; while (*s) ++s;
return (acc_hsize_t) (s - start);
#elif 1
acc_hsize_t n = 0; while (*s) ++s, ++n; return n;
#elif 1
acc_hsize_t n = 0; while (s[n]) ++n; return n;
#else
const acc_hchar_p start = s; while (*s) ++s;
return (acc_hsize_t) (s - start);
#endif
}
/***********************************************************************
// strcmp, strncmp, ascii_stricmp, ascii_strnicmp, ascii_memicmp
************************************************************************/
ACCLIB_PUBLIC(int, acc_hstrcmp) (const acc_hchar_p p, const acc_hchar_p s)
{
for ( ; *p; ++p, ++s) {
if (*p != *s)
break;
}
return (unsigned char)*p - (unsigned char)*s;
}
ACCLIB_PUBLIC(int, acc_hstrncmp) (const acc_hchar_p p, const acc_hchar_p s, acc_hsize_t n)
{
for ( ; *p && n > 0; ++p, ++s, --n) {
if (*p != *s)
break;
}
return (unsigned char)*p - (unsigned char)*s;
}
ACCLIB_PUBLIC(int, acc_ascii_hstricmp) (const acc_hchar_p p, const acc_hchar_p s)
{
for ( ; *p; ++p, ++s) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
ACCLIB_PUBLIC(int, acc_ascii_hstrnicmp) (const acc_hchar_p p, const acc_hchar_p s, acc_hsize_t n)
{
for ( ; *p && n > 0; ++p, ++s, --n) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
ACCLIB_PUBLIC(int, acc_ascii_hmemicmp) (const acc_hvoid_p pp, const acc_hvoid_p ss, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) pp;
const acc_hbyte_p s = (const acc_hbyte_p) ss;
for ( ; n > 0; ++p, ++s, --n) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
/***********************************************************************
// strstr, ascii_stristr, memmem, ascii_memimem
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrstr) (const acc_hchar_p p, const acc_hchar_p s)
{
acc_hsize_t pn = __ACCLIB_FUNCNAME(acc_hstrlen)(p);
acc_hsize_t sn = __ACCLIB_FUNCNAME(acc_hstrlen)(s);
return (acc_hchar_p) __ACCLIB_FUNCNAME(acc_hmemmem)(p, pn, s, sn);
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p p, const acc_hchar_p s)
{
acc_hsize_t pn = __ACCLIB_FUNCNAME(acc_hstrlen)(p);
acc_hsize_t sn = __ACCLIB_FUNCNAME(acc_hstrlen)(s);
return (acc_hchar_p) __ACCLIB_FUNCNAME(acc_ascii_hmemimem)(p, pn, s, sn);
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p p, acc_hsize_t pn, const acc_hvoid_p s, acc_hsize_t sn)
{
if (sn == 0) __ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
for ( ; pn >= sn; --pn) {
if (__ACCLIB_FUNCNAME(acc_hmemcmp)(p, s, sn) == 0)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
p = (const acc_hbyte_p)p + 1;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p p, acc_hsize_t pn, const acc_hvoid_p s, acc_hsize_t sn)
{
if (sn == 0) __ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
for ( ; pn >= sn; --pn) {
if (__ACCLIB_FUNCNAME(acc_ascii_hmemicmp)(p, s, sn) == 0)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
p = (const acc_hbyte_p)p + 1;
}
return (acc_hvoid_p) 0;
}
/***********************************************************************
// strcpy, strcat
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcpy) (acc_hchar_p d, const acc_hchar_p s)
{
acc_hchar_p dest = d;
for (;;) {
if ((*d = *s) == 0) return dest;
++d; ++s;
}
}
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcat) (acc_hchar_p d, const acc_hchar_p s)
{
acc_hchar_p dest = d;
while (*d) ++d;
for (;;) {
if ((*d = *s) == 0) return dest;
++d; ++s;
}
}
/***********************************************************************
// strlcpy, strlcat
************************************************************************/
@ -72,8 +207,8 @@ ACCLIB_PUBLIC(acc_hsize_t, acc_hstrlcat) (acc_hchar_p d, const acc_hchar_p s, ac
/***********************************************************************
// strscpy, strscat - same as strlcpy/strlcat, but just return -1
// in case of failure
// strscpy, strscat
// (same as strlcpy/strlcat, but just return -1 in case of failure)
************************************************************************/
ACCLIB_PUBLIC(int, acc_hstrscpy) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_t size)
@ -106,7 +241,35 @@ ACCLIB_PUBLIC(int, acc_hstrscat) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_
/***********************************************************************
// strchr, strrchr
// strccpy, memccpy
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrccpy) (acc_hchar_p d, const acc_hchar_p s, int c)
{
for (;;) {
if ((*d = *s) == 0) break;
if (*d++ == (char) c) return d;
++s;
}
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p d, const acc_hvoid_p s, int c, acc_hsize_t n)
{
acc_hbyte_p a = (acc_hbyte_p) d;
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
while (p != e) {
if ((*a++ = *p++) == (unsigned char) c)
return a;
}
return (acc_hvoid_p) 0;
}
/***********************************************************************
// strchr, strrchr, ascii_strichr, ascii_strrichr
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrchr) (const acc_hchar_p s, int c)
@ -116,7 +279,7 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrchr) (const acc_hchar_p s, int c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
if ((char) c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
return (acc_hchar_p)0;
return (acc_hchar_p) 0;
}
@ -130,7 +293,92 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p s, int c)
if (*s == (char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
return (acc_hchar_p)0;
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p s, int c)
{
c = acc_ascii_utolower(c);
for ( ; *s; ++s) {
if (acc_ascii_utolower(*s) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
if (c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p s, int c)
{
const acc_hchar_p start = s;
c = acc_ascii_utolower(c);
while (*s) ++s;
if (c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
for (;;) {
if (s == start) break; --s;
if (acc_ascii_utolower(*s) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
return (acc_hchar_p) 0;
}
/***********************************************************************
// memchr, memrchr, ascii_memichr, ascii_memrichr
************************************************************************/
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemchr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
while (p != e) {
if (*p == (unsigned char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
++p;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s + n;
const acc_hbyte_p e = (const acc_hbyte_p) s;
while (p != e) {
--p;
if (*p == (unsigned char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
c = acc_ascii_utolower(c);
while (p != e) {
if (acc_ascii_utolower(*p) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
++p;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s + n;
const acc_hbyte_p e = (const acc_hbyte_p) s;
c = acc_ascii_utolower(c);
while (p != e) {
--p;
if (acc_ascii_utolower(*p) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
}
return (acc_hvoid_p) 0;
}
@ -219,7 +467,7 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrpbrk) (const acc_hchar_p s, const acc_hchar_p
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
}
return (acc_hchar_p)0;
return (acc_hchar_p) 0;
}
@ -235,7 +483,7 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p s, const acc_hchar_
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
}
return (acc_hchar_p)0;
return (acc_hchar_p) 0;
}
@ -264,12 +512,54 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp ss, const acc_hchar_p del
*p++ = 0;
return p;
}
*ss = (acc_hchar_p)0;
*ss = (acc_hchar_p) 0;
}
return s;
}
/***********************************************************************
// ascii_strlwr, ascii_strupr, ascii_memlwr, ascii_memupr
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p s)
{
acc_hbyte_p p = (acc_hbyte_p) s;
for ( ; *p; ++p)
*p = (unsigned char) acc_ascii_utolower(*p);
return s;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p s)
{
acc_hbyte_p p = (acc_hbyte_p) s;
for ( ; *p; ++p)
*p = (unsigned char) acc_ascii_utoupper(*p);
return s;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p s, acc_hsize_t n)
{
acc_hbyte_p p = (acc_hbyte_p) s;
acc_hbyte_p e = (acc_hbyte_p) s + n;
for ( ; p != e; ++p)
*p = (unsigned char) acc_ascii_utolower(*p);
return s;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p s, acc_hsize_t n)
{
acc_hbyte_p p = (acc_hbyte_p) s;
acc_hbyte_p e = (acc_hbyte_p) s + n;
for ( ; p != e; ++p)
*p = (unsigned char) acc_ascii_utoupper(*p);
return s;
}
/*
vi:ts=4:et
*/

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_MISC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -29,8 +30,9 @@ ACCLIB_PUBLIC(acclib_handle_t, acc_get_osfhandle) (int fd)
#if (ACC_OS_CYGWIN)
return get_osfhandle(fd);
#elif (ACC_OS_EMX && defined(__RSXNT__))
/* FIXME */
return -1;
return -1; /* FIXME */
#elif (ACC_OS_WIN32 && defined(__PW32__) && defined(__GNUC__))
return -1; /* FIXME */
#elif (ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_WATCOMC && (__WATCOMC__ < 1100))
/* FIXME */
@ -75,21 +77,23 @@ ACCLIB_PUBLIC(int, acc_set_binmode) (int fd, int binary)
if (r == -1)
return -1;
return (r & O_TEXT) ? 0 : 1;
#elif (ACC_OS_WIN32 && defined(__PW32__) && defined(__GNUC__))
if (fd < 0) return -1;
ACC_UNUSED(binary);
return 1;
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN || ACC_OS_EMX)
int r;
#if !defined(ACC_CC_ZORTECHC)
ACC_COMPILE_TIME_ASSERT(O_BINARY > 0)
#endif
ACC_COMPILE_TIME_ASSERT(O_TEXT > 0)
if (fd < 0)
return -1;
if (fd < 0) return -1;
r = setmode(fd, binary ? O_BINARY : O_TEXT);
if (r == -1)
return -1;
return (r & O_TEXT) ? 0 : 1;
#else
if (fd < 0)
return -1;
if (fd < 0) return -1;
ACC_UNUSED(binary);
return 1;
#endif
@ -106,7 +110,6 @@ ACCLIB_PUBLIC(int, acc_isatty) (int fd)
{
union REGS ri, ro;
ri.x.ax = 0x4400; ri.x.bx = fd;
ro.x.ax = 0xffff; ro.x.cflag = 1;
int86(0x21, &ri, &ro);
if ((ro.x.cflag & 1) == 0) /* if carry flag not set */
if ((ro.x.ax & 0x83) != 0x83)
@ -116,7 +119,6 @@ ACCLIB_PUBLIC(int, acc_isatty) (int fd)
{
union REGS ri, ro;
ri.w.ax = 0x4400; ri.w.bx = (unsigned short) fd;
ro.w.ax = 0xffff; ro.w.cflag = 1;
int386(0x21, &ri, &ro);
if ((ro.w.cflag & 1) == 0) /* if carry flag not set */
if ((ro.w.ax & 0x83) != 0x83)
@ -144,6 +146,8 @@ ACCLIB_PUBLIC(int, acc_mkdir) (const char* name, unsigned mode)
return Dcreate(name);
#elif (ACC_OS_DOS32 && defined(__DJGPP__))
return mkdir(name, mode);
#elif (ACC_OS_WIN32 && defined(__PW32__) && defined(__GNUC__))
return mkdir(name, mode);
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
ACC_UNUSED(mode);
return mkdir(name);

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_OPENDIR_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_RAND_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -57,7 +58,7 @@ ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p r)
return (acc_uint32l_t) (r->seed >> 16);
}
#endif /* defined(acc_uint64l_t) */
#endif /* acc_uint64l_t */
#if defined(acc_uint64l_t)
@ -81,7 +82,7 @@ ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p r)
return (acc_uint32l_t) (r->seed >> 32);
}
#endif /* defined(acc_uint64l_t) */
#endif /* acc_uint64l_t */
/*************************************************************************

View File

@ -13,6 +13,7 @@
*/
#define __ACCLIB_UCLOCK_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
@ -26,8 +27,6 @@
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
#elif (ACC_OS_DOS32 && defined(__DJGPP__))
#elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS)
# define __ACCLIB_UCLOCK_USE_CLOCK 1
#elif (ACC_H_WINDOWS_H) && (ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_DMC || ACC_CC_LCC)
/* winmm.lib is missing */
@ -43,6 +42,8 @@
# pragma comment(lib,"winmm")
# endif
# endif
#elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN32 || ACC_OS_WIN64)
# define __ACCLIB_UCLOCK_USE_CLOCK 1
#endif
#if (__ACCLIB_UCLOCK_USE_CLOCK) && !defined(CLOCKS_PER_SEC)
@ -163,10 +164,8 @@ ACCLIB_PUBLIC(double, acc_uclock_get_elapsed) (acc_uclock_handle_p h, const acc_
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
h->mode = 2;
if (stop->ticks.t32 < start->ticks.t32) /* midnight passed */
d = 86400.0 - (start->ticks.t32 - stop->ticks.t32) / 100.0;
else
d = (stop->ticks.t32 - start->ticks.t32) / 100.0;
d = (double) (stop->ticks.t32 - start->ticks.t32) / 100.0;
if (d < 0.0) d += 86400.0; /* midnight passed */
#elif (ACC_OS_DOS32 && defined(__DJGPP__))
h->mode = 3;
d = (double) (stop->ticks.t64 - start->ticks.t64) / (UCLOCKS_PER_SEC);