Recovered from cvs revision 2007-04-30 05:47:00
This commit is contained in:
@ -1,124 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="asecmn" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=asecmn - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "asecmn.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "asecmn.mak" CFG="asecmn - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "asecmn - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "asecmn - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "asecmn - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../release/lib"
|
||||
# PROP Intermediate_Dir "release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /Za /W3 /GX /O2 /I "../.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /FD /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "asecmn - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../debug/lib"
|
||||
# PROP Intermediate_Dir "debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "../.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "asecmn - Win32 Release"
|
||||
# Name "asecmn - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mem.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\str.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\str.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* $Id: conf_msw.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
/*
|
||||
Macro Meaning
|
||||
_WIN64 A 64-bit platform.
|
||||
_WIN32 A 32-bit platform. This value is also defined by the 64-bit
|
||||
compiler for backward compatibility.
|
||||
_WIN16 A 16-bit platform
|
||||
|
||||
The following macros are specific to the architecture.
|
||||
|
||||
Macro Meaning
|
||||
_M_IA64 Intel Itanium Processor Family
|
||||
_M_IX86 x86 platform
|
||||
_M_X64 x64 platform
|
||||
*/
|
||||
|
||||
#define ASE_ENDIAN_LITTLE
|
||||
|
||||
#define ASE_SIZEOF_CHAR 1
|
||||
#define ASE_SIZEOF_SHORT 2
|
||||
#define ASE_SIZEOF_INT 4
|
||||
|
||||
/*#ifdef _WIN64
|
||||
#define ASE_SIZEOF_LONG 8
|
||||
#else*/
|
||||
#define ASE_SIZEOF_LONG 4
|
||||
/*#endif*/
|
||||
|
||||
#ifdef __POCC__
|
||||
/* pelles c with no microsoft extension */
|
||||
#define ASE_SIZEOF_LONG_LONG 8
|
||||
|
||||
#define ASE_SIZEOF___INT8 0
|
||||
#define ASE_SIZEOF___INT16 0
|
||||
#define ASE_SIZEOF___INT32 0
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#define ASE_SIZEOF___INT96 0
|
||||
#define ASE_SIZEOF___INT128 0
|
||||
#else
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
|
||||
#define ASE_SIZEOF___INT8 1
|
||||
#define ASE_SIZEOF___INT16 2
|
||||
#define ASE_SIZEOF___INT32 4
|
||||
#define ASE_SIZEOF___INT64 8
|
||||
#define ASE_SIZEOF___INT96 0
|
||||
#define ASE_SIZEOF___INT128 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define ASE_SIZEOF_VOID_P 8
|
||||
#else
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF_FLOAT 4
|
||||
#define ASE_SIZEOF_DOUBLE 8
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 16
|
||||
#define ASE_SIZEOF_WCHAR_T 2
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* $Id: conf_unx.h.in,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
/* Big Endian */
|
||||
#undef ASE_ENDIAN_BIG
|
||||
|
||||
/* Little Endian */
|
||||
#undef ASE_ENDIAN_LITTLE
|
||||
|
||||
/* Unknown Endian */
|
||||
#undef ASE_ENDIAN_UNKNOWN
|
||||
|
||||
/* long long */
|
||||
#undef ASE_HAVE_LONG_LONG
|
||||
|
||||
/* long double */
|
||||
#undef ASE_HAVE_LONG_DOUBLE
|
||||
|
||||
/* data type size */
|
||||
#define ASE_SIZEOF_CHAR 0
|
||||
#define ASE_SIZEOF_SHORT 0
|
||||
#define ASE_SIZEOF_INT 0
|
||||
#define ASE_SIZEOF_LONG 0
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
#define ASE_SIZEOF___INT8 0
|
||||
#define ASE_SIZEOF___INT16 0
|
||||
#define ASE_SIZEOF___INT32 0
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#define ASE_SIZEOF___INT128 0
|
||||
#define ASE_SIZEOF_VOID_P 0
|
||||
#define ASE_SIZEOF_FLOAT 0
|
||||
#define ASE_SIZEOF_DOUBLE 0
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 0
|
||||
#define ASE_SIZEOF_WCHAR_T 0
|
||||
|
||||
/* char is wchar */
|
||||
#undef ASE_CHAR_IS_WCHAR
|
||||
|
||||
/* char is mchar */
|
||||
#undef ASE_CHAR_IS_MCHAR
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* $Id: conf_vms.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
/* all of vax, alpha, ia64 are in the little endian. */
|
||||
#define ASE_ENDIAN_LITTLE
|
||||
|
||||
/*
|
||||
* Refer to the chapter 3 of the following URL for the data sizes.
|
||||
* http://h71000.www7.hp.com/commercial/c/docs/6180profile.html
|
||||
*/
|
||||
|
||||
#define ASE_SIZEOF_CHAR 1
|
||||
#define ASE_SIZEOF_SHORT 2
|
||||
#define ASE_SIZEOF_INT 4
|
||||
#define ASE_SIZEOF_LONG 4
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF_LONG_LONG 8
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF_LONG_LONG 8
|
||||
#else
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF___INT8 1
|
||||
#define ASE_SIZEOF___INT16 2
|
||||
#define ASE_SIZEOF___INT32 4
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF___INT64 8
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF___INT64 8
|
||||
#else
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF___INT96 0
|
||||
#define ASE_SIZEOF___INT128 0
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#if __INITIAL_POINTER_SIZE==64
|
||||
#pragma pointer_size 64
|
||||
#define ASE_SIZEOF_VOID_P 8
|
||||
#elif __INITIAL_POINTER_SIZE==32
|
||||
#pragma pointer_size 32
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#elif __INITIAL_POINTER_SIZE==0
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#else
|
||||
#error "unsupported initial pointer size"
|
||||
#endif
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#if __INITIAL_POINTER_SIZE==64
|
||||
#pragma pointer_size 64
|
||||
#define ASE_SIZEOF_VOID_P 8
|
||||
#elif __INITIAL_POINTER_SIZE==32
|
||||
#pragma pointer_size 32
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#elif __INITIAL_POINTER_SIZE==0
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#else
|
||||
#error "unsupported initial pointer size"
|
||||
#endif
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF_FLOAT 4
|
||||
#define ASE_SIZEOF_DOUBLE 8
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 8
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 16
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 16
|
||||
#else
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF_WCHAR_T 4
|
@ -1,17 +0,0 @@
|
||||
#
|
||||
# OpenVMS MMS/MMK
|
||||
#
|
||||
|
||||
objects = mem.obj,str.obj,misc.obj
|
||||
|
||||
CFLAGS = /include="../.."
|
||||
#CFLAGS = /pointer_size=long /include="../.."
|
||||
LIBRFLAGS =
|
||||
|
||||
asecmn.olb : $(objects)
|
||||
$(LIBR)/create $(MMS$TARGET) $(objects)
|
||||
# $(LIBR)/replace $(LIBRFLAGS) $(MMS$TARGET),$(objects)
|
||||
|
||||
mem.obj depends_on mem.c
|
||||
str.obj depends_on str.c
|
||||
misc.obj depends_on misc.c
|
139
ase/cmn/macros.h
139
ase/cmn/macros.h
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* $Id: macros.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_MACROS_H_
|
||||
#define _ASE_MACROS_H_
|
||||
|
||||
#include <ase/cmn/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
/*#define ASE_NULL ((ase_uint_t)0)*/
|
||||
#define ASE_NULL (0)
|
||||
#else
|
||||
#define ASE_NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
#define ASE_CHAR_EOF ((ase_cint_t)-1)
|
||||
|
||||
#define ASE_SIZEOF(n) (sizeof(n))
|
||||
#define ASE_COUNTOF(n) (sizeof(n)/sizeof(n[0]))
|
||||
#define ASE_OFFSETOF(type,member) ((ase_size_t)&((type*)0)->member)
|
||||
|
||||
#define ASE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
|
||||
#define ASE_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
|
||||
|
||||
#define ASE_TYPE_SIGNED_MAX(type) \
|
||||
((type)~((type)1 << (ASE_SIZEOF(type) * 8 - 1)))
|
||||
#define ASE_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
|
||||
|
||||
#define ASE_TYPE_SIGNED_MIN(type) \
|
||||
((type)((type)1 << (ASE_SIZEOF(type) * 8 - 1)))
|
||||
#define ASE_TYPE_UNSIGNED_MIN(type) ((type)0)
|
||||
|
||||
#define ASE_TYPE_MAX(type) \
|
||||
((ASE_TYPE_IS_SIGNED(type)? ASE_TYPE_SIGNED_MAX(type): ASE_TYPE_UNSIGNED_MAX(type)))
|
||||
#define ASE_TYPE_MIN(type) \
|
||||
((ASE_TYPE_IS_SIGNED(type)? ASE_TYPE_SIGNED_MIN(type): ASE_TYPE_UNSIGNED_MIN(type)))
|
||||
|
||||
#define ASE_IS_POWOF2(x) (((x) & ((x) - 1)) == 0)
|
||||
|
||||
#define ASE_SWAP(x,y,original_type,casting_type) \
|
||||
do { \
|
||||
x = (original_type)((casting_type)(x) ^ (casting_type)(y)); \
|
||||
y = (original_type)((casting_type)(y) ^ (casting_type)(x)); \
|
||||
x = (original_type)((casting_type)(x) ^ (casting_type)(y)); \
|
||||
} while (0)
|
||||
|
||||
#define ASE_ABS(x) ((x) < 0? -(x): (x))
|
||||
|
||||
#define ASE_LOOP_CONTINUE(id) goto __loop_ ## id ## _begin__;
|
||||
#define ASE_LOOP_BREAK(id) goto __loop_ ## id ## _end__;
|
||||
#define ASE_LOOP_BEGIN(id) __loop_ ## id ## _begin__: {
|
||||
#define ASE_LOOP_END(id) ASE_LOOP_CONTINUE(id) } __loop_ ## id ## _end__:;
|
||||
|
||||
#define ASE_REPEAT(n,blk) \
|
||||
do { \
|
||||
ase_size_t __ase_repeat_x1__ = (ase_size_t)(n); \
|
||||
ase_size_t __ase_repeat_x2__ = __ase_repeat_x1__ >> 4; \
|
||||
__ase_repeat_x1__ &= 15; \
|
||||
while (__ase_repeat_x1__-- > 0) { blk; } \
|
||||
while (__ase_repeat_x2__-- > 0) { \
|
||||
blk; blk; blk; blk; blk; blk; blk; blk; \
|
||||
blk; blk; blk; blk; blk; blk; blk; blk; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define ASE_MQ_I(val) #val
|
||||
#define ASE_MQ(val) ASE_MQ_I(val)
|
||||
#define ASE_MC(ch) ((ase_mchar_t)ch)
|
||||
#define ASE_MS(str) ((const ase_mchar_t*)str)
|
||||
#define ASE_MT(txt) (txt)
|
||||
|
||||
#define ASE_WQ_I(val) (L ## #val)
|
||||
#define ASE_WQ(val) ASE_WQ_I(val)
|
||||
#define ASE_WC(ch) ((ase_wchar_t)L ## ch)
|
||||
#define ASE_WS(str) ((const ase_wchar_t*)L ## str)
|
||||
#define ASE_WT(txt) (L ## txt)
|
||||
|
||||
#if defined(ASE_CHAR_IS_MCHAR)
|
||||
#define ASE_C(ch) ASE_MC(ch)
|
||||
#define ASE_S(str) ASE_MS(str)
|
||||
#define ASE_T(txt) ASE_MT(txt)
|
||||
#else
|
||||
#define ASE_C(ch) ASE_WC(ch)
|
||||
#define ASE_S(str) ASE_WS(str)
|
||||
#define ASE_T(txt) ASE_WT(txt)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define ASE_BEGIN_PACKED_STRUCT(x) struct x {
|
||||
#define ASE_END_PACKED_STRUCT() } __attribute__((packed));
|
||||
#else
|
||||
#define ASE_BEGIN_PACKED_STRUCT(x) struct x {
|
||||
#define ASE_END_PACKED_STRUCT() };
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define ASE_ASSERT(expr) ((void)0)
|
||||
#define ASE_ASSERTX(expr,desc) ((void)0)
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void ase_assert_abort (void);
|
||||
void ase_assert_printf (const ase_char_t* fmt, ...);
|
||||
int ase_assert_failed (
|
||||
const ase_char_t* expr, const ase_char_t* desc,
|
||||
const ase_char_t* file, ase_size_t line);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ASE_ASSERT(expr) (void)((expr) || \
|
||||
(ase_assert_failed (ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
|
||||
#define ASE_ASSERTX(expr,desc) (void)((expr) || \
|
||||
(ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
||||
#endif
|
||||
|
||||
#define ASE_MALLOC(mmgr,size) (mmgr)->malloc((mmgr)->custom_data, size)
|
||||
#define ASE_REALLOC(mmgr,ptr,size) (mmgr)->realloc((mmgr)->custom_data, ptr, size)
|
||||
#define ASE_FREE(mmgr,ptr) (mmgr)->free((mmgr)->custom_data, ptr)
|
||||
|
||||
#define ASE_ISUPPER(ccls,c) (ccls)->is_upper((ccls)->custom_data,c)
|
||||
#define ASE_ISLOWER(ccls,c) (ccls)->is_lower((ccls)->custom_data,c)
|
||||
#define ASE_ISALPHA(ccls,c) (ccls)->is_alpha((ccls)->custom_data,c)
|
||||
#define ASE_ISDIGIT(ccls,c) (ccls)->is_digit((ccls)->custom_data,c)
|
||||
#define ASE_ISXDIGIT(ccls,c) (ccls)->is_xdigit((ccls)->custom_data,c)
|
||||
#define ASE_ISALNUM(ccls,c) (ccls)->is_alnum((ccls)->custom_data,c)
|
||||
#define ASE_ISSPACE(ccls,c) (ccls)->is_space((ccls)->custom_data,c)
|
||||
#define ASE_ISPRINT(ccls,c) (ccls)->is_print((ccls)->custom_data,c)
|
||||
#define ASE_ISGRAPH(ccls,c) (ccls)->is_graph((ccls)->custom_data,c)
|
||||
#define ASE_ISCNTRL(ccls,c) (ccls)->is_cntrl((ccls)->custom_data,c)
|
||||
#define ASE_ISPUNCT(ccls,c) (ccls)->is_punct((ccls)->custom_data,c)
|
||||
#define ASE_TOUPPER(ccls,c) (ccls)->to_upper((ccls)->custom_data,c)
|
||||
#define ASE_TOLOWER(ccls,c) (ccls)->to_lower((ccls)->custom_data,c)
|
||||
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
#
|
||||
# $Id: makefile.in,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
#
|
||||
|
||||
NAME = asecmn
|
||||
|
||||
CC = @CC@
|
||||
AR = ar
|
||||
MAKE = @MAKE@
|
||||
RANLIB = @RANLIB@
|
||||
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
MODE = @BUILDMODE@
|
||||
|
||||
OUT_DIR = ../$(MODE)/lib
|
||||
OUT_FILE = $(OUT_DIR)/lib$(NAME).a
|
||||
|
||||
TMP_DIR = $(MODE)
|
||||
|
||||
OBJ_FILES = \
|
||||
$(TMP_DIR)/mem.o \
|
||||
$(TMP_DIR)/str.o \
|
||||
$(TMP_DIR)/misc.o
|
||||
|
||||
lib: $(OUT_FILE)
|
||||
|
||||
$(OUT_FILE): $(OBJ_FILES) $(OUT_DIR)
|
||||
$(AR) cr $(OUT_FILE) $(OBJ_FILES)
|
||||
if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE); fi
|
||||
|
||||
$(TMP_DIR)/mem.o: $(TMP_DIR)
|
||||
$(CC) $(CFLAGS) -o $@ -c mem.c
|
||||
|
||||
$(TMP_DIR)/str.o: $(TMP_DIR)
|
||||
$(CC) $(CFLAGS) -o $@ -c str.c
|
||||
|
||||
$(TMP_DIR)/misc.o: $(TMP_DIR)
|
||||
$(CC) $(CFLAGS) -o $@ -c misc.c
|
||||
|
||||
$(OUT_DIR):
|
||||
mkdir -p $(OUT_DIR)
|
||||
|
||||
$(TMP_DIR):
|
||||
mkdir -p $(TMP_DIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(OUT_FILE) $(OBJ_FILES)
|
||||
|
@ -1,29 +0,0 @@
|
||||
OUT = asecmn
|
||||
|
||||
C_SRCS = mem.c str.c misc.c
|
||||
C_OBJS = $(C_SRCS:.c=.obj)
|
||||
|
||||
CC = bcc32
|
||||
LD = ilink32
|
||||
AR = tlib
|
||||
JAVAC = javac
|
||||
|
||||
CFLAGS = -O2 -WM -WU -RT- -w -q -I../.. -DNDEBUG
|
||||
LDFLAGS = -Tpd -ap -Gn -c -q
|
||||
STARTUP = c0d32w.obj
|
||||
LIBS = import32.lib cw32mt.lib
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(C_OBJS)
|
||||
$(AR) $(OUT).lib @&&!
|
||||
+-$(**: = &^
|
||||
+-)
|
||||
!
|
||||
|
||||
clean:
|
||||
-del $(OBJS) $(OUT).lib *.obj
|
||||
|
||||
.SUFFIXES: .c .obj
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c $<
|
@ -1,23 +0,0 @@
|
||||
OUT = asecmn
|
||||
|
||||
C_SRCS = mem.c str.c misc.c
|
||||
C_OBJS = $(C_SRCS:.c=.obj)
|
||||
|
||||
CC = cl
|
||||
LD = link
|
||||
|
||||
CFLAGS = /nologo /O2 /MT /W3 /GR- /Za -I../..
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(C_OBJS)
|
||||
$(LD) /lib @<<
|
||||
/nologo /out:$(OUT).lib $(C_OBJS)
|
||||
<<
|
||||
|
||||
clean:
|
||||
del $(OBJS) $(OUT).lib *.obj
|
||||
|
||||
.SUFFIXES: .c .obj
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) /c $<
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* $Id: mem.c,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include <ase/cmn/mem.h>
|
||||
|
||||
void* ase_memcpy (void* dst, const void* src, ase_size_t n)
|
||||
{
|
||||
void* p = dst;
|
||||
void* e = (ase_byte_t*)dst + n;
|
||||
|
||||
while (dst < e)
|
||||
{
|
||||
*(ase_byte_t*)dst = *(ase_byte_t*)src;
|
||||
dst = (ase_byte_t*)dst + 1;
|
||||
src = (ase_byte_t*)src + 1;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void* ase_memset (void* dst, int val, ase_size_t n)
|
||||
{
|
||||
void* p = dst;
|
||||
void* e = (ase_byte_t*)p + n;
|
||||
|
||||
while (p < e)
|
||||
{
|
||||
*(ase_byte_t*)p = (ase_byte_t)val;
|
||||
p = (ase_byte_t*)p + 1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
int ase_memcmp (const void* s1, const void* s2, ase_size_t n)
|
||||
{
|
||||
const void* e;
|
||||
|
||||
if (n == 0) return 0;
|
||||
|
||||
e = (const ase_byte_t*)s1 + n - 1;
|
||||
while (s1 < e && *(ase_byte_t*)s1 == *(ase_byte_t*)s2)
|
||||
{
|
||||
s1 = (ase_byte_t*)s1 + 1;
|
||||
s2 = (ase_byte_t*)s2 + 1;
|
||||
}
|
||||
|
||||
return *((ase_byte_t*)s1) - *((ase_byte_t*)s2);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* $Id: mem.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_MEM_H_
|
||||
#define _ASE_CMN_MEM_H_
|
||||
|
||||
#include <ase/cmn/types.h>
|
||||
#include <ase/cmn/macros.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* ase_memcpy (void* dst, const void* src, ase_size_t n);
|
||||
void* ase_memset (void* dst, int val, ase_size_t n);
|
||||
int ase_memcmp (const void* s1, const void* s2, ase_size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include <ase/cmn/types.h>
|
||||
#include <ase/cmn/macros.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
int ase_assert_failed (
|
||||
const ase_char_t* expr, const ase_char_t* desc,
|
||||
const ase_char_t* file, ase_size_t line)
|
||||
{
|
||||
if (desc == ASE_NULL)
|
||||
{
|
||||
ase_assert_printf (
|
||||
ASE_T("ASSERTION FAILURE AT FILE %s LINE %lu\n%s\n"),
|
||||
file, (unsigned long)line, expr);
|
||||
}
|
||||
else
|
||||
{
|
||||
ase_assert_printf (
|
||||
ASE_T("ASSERTION FAILURE AT FILE %s LINE %lu\n%s\n\nDESCRIPTION:\n%s\n"),
|
||||
file, (unsigned long)line, expr, desc);
|
||||
|
||||
}
|
||||
|
||||
ase_assert_abort ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* $Id: pack.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#elif defined(__HP_aCC) || defined(__HP_cc)
|
||||
#pragma PACK 1
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#pragma pack(push,1)
|
||||
#elif defined(__DECC)
|
||||
#pragma pack(push,1)
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#endif
|
385
ase/cmn/str.c
385
ase/cmn/str.c
@ -1,385 +0,0 @@
|
||||
/*
|
||||
* $Id: str.c,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include <ase/cmn/str.h>
|
||||
#include <ase/cmn/mem.h>
|
||||
|
||||
ase_size_t ase_strlen (const ase_char_t* str)
|
||||
{
|
||||
const ase_char_t* p = str;
|
||||
while (*p != ASE_T('\0')) p++;
|
||||
return p - str;
|
||||
}
|
||||
|
||||
ase_size_t ase_strcpy (ase_char_t* buf, const ase_char_t* str)
|
||||
{
|
||||
ase_char_t* org = buf;
|
||||
while ((*buf++ = *str++) != ASE_T('\0'));
|
||||
return buf - org - 1;
|
||||
}
|
||||
|
||||
ase_size_t ase_strxcpy (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str)
|
||||
{
|
||||
ase_char_t* p, * p2;
|
||||
|
||||
p = buf; p2 = buf + bsz - 1;
|
||||
|
||||
while (p < p2)
|
||||
{
|
||||
if (*str == ASE_T('\0')) break;
|
||||
*p++ = *str++;
|
||||
}
|
||||
|
||||
if (bsz > 0) *p = ASE_T('\0');
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
ase_size_t ase_strncpy (
|
||||
ase_char_t* buf, const ase_char_t* str, ase_size_t len)
|
||||
{
|
||||
const ase_char_t* end = str + len;
|
||||
while (str < end) *buf++ = *str++;
|
||||
*buf = ASE_T('\0');
|
||||
return len;
|
||||
}
|
||||
|
||||
ase_size_t ase_strxncpy (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len)
|
||||
{
|
||||
ase_size_t n;
|
||||
|
||||
if (bsz <= 0) return 0;
|
||||
if ((n = bsz - 1) > len) n = len;
|
||||
ase_memcpy (buf, str, n * ASE_SIZEOF(ase_char_t));
|
||||
buf[n] = ASE_T('\0');
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
ase_size_t ase_strxncat (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len)
|
||||
{
|
||||
ase_char_t* p, * p2;
|
||||
const ase_char_t* end;
|
||||
ase_size_t blen;
|
||||
|
||||
blen = ase_strlen(buf);
|
||||
if (blen >= bsz) return blen; /* something wrong */
|
||||
|
||||
p = buf + blen;
|
||||
p2 = buf + bsz - 1;
|
||||
|
||||
end = str + len;
|
||||
|
||||
while (p < p2)
|
||||
{
|
||||
if (str >= end) break;
|
||||
*p++ = *str++;
|
||||
}
|
||||
|
||||
if (bsz > 0) *p = ASE_T('\0');
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == ASE_C('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int ase_strxncmp (
|
||||
const ase_char_t* s1, ase_size_t len1,
|
||||
const ase_char_t* s2, ase_size_t len2)
|
||||
{
|
||||
ase_char_t c1, c2;
|
||||
const ase_char_t* end1 = s1 + len1;
|
||||
const ase_char_t* end2 = s2 + len2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = *s1;
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = *s2;
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
int ase_strcasecmp (
|
||||
const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls)
|
||||
{
|
||||
while (ASE_TOUPPER(ccls,*s1) == ASE_TOUPPER(ccls,*s2))
|
||||
{
|
||||
if (*s1 == ASE_C('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (ASE_TOUPPER(ccls,*s1) > ASE_TOUPPER(ccls,*s2))? 1: -1;
|
||||
}
|
||||
|
||||
int ase_strxncasecmp (
|
||||
const ase_char_t* s1, ase_size_t len1,
|
||||
const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls)
|
||||
{
|
||||
ase_char_t c1, c2;
|
||||
const ase_char_t* end1 = s1 + len1;
|
||||
const ase_char_t* end2 = s2 + len2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = ASE_TOUPPER (ccls, *s1);
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = ASE_TOUPPER (ccls, *s2);
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr)
|
||||
{
|
||||
ase_char_t* tmp;
|
||||
|
||||
tmp = (ase_char_t*) ASE_MALLOC (
|
||||
mmgr, (ase_strlen(str)+1)*ASE_SIZEOF(ase_char_t));
|
||||
if (tmp == ASE_NULL) return ASE_NULL;
|
||||
|
||||
ase_strcpy (tmp, str);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ase_char_t* ase_strxdup (
|
||||
const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr)
|
||||
{
|
||||
ase_char_t* tmp;
|
||||
|
||||
tmp = (ase_char_t*) ASE_MALLOC (
|
||||
mmgr, (len+1)*ASE_SIZEOF(ase_char_t));
|
||||
if (tmp == ASE_NULL) return ASE_NULL;
|
||||
|
||||
ase_strncpy (tmp, str, len);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ase_char_t* ase_strxdup2 (
|
||||
const ase_char_t* str1, ase_size_t len1,
|
||||
const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr)
|
||||
{
|
||||
ase_char_t* tmp;
|
||||
|
||||
tmp = (ase_char_t*) ASE_MALLOC (
|
||||
mmgr, (len1+len2+1) * ASE_SIZEOF(ase_char_t));
|
||||
if (tmp == ASE_NULL) return ASE_NULL;
|
||||
|
||||
ase_strncpy (tmp, str1, len1);
|
||||
ase_strncpy (tmp + len1, str2, len2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ase_char_t* ase_strxnstr (
|
||||
const ase_char_t* str, ase_size_t strsz,
|
||||
const ase_char_t* sub, ase_size_t subsz)
|
||||
{
|
||||
const ase_char_t* end, * subp;
|
||||
|
||||
if (subsz == 0) return (ase_char_t*)str;
|
||||
if (strsz < subsz) return ASE_NULL;
|
||||
|
||||
end = str + strsz - subsz;
|
||||
subp = sub + subsz;
|
||||
|
||||
while (str <= end)
|
||||
{
|
||||
const ase_char_t* x = str;
|
||||
const ase_char_t* y = sub;
|
||||
|
||||
while (ase_true)
|
||||
{
|
||||
if (y >= subp) return (ase_char_t*)str;
|
||||
if (*x != *y) break;
|
||||
x++; y++;
|
||||
}
|
||||
|
||||
str++;
|
||||
}
|
||||
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr)
|
||||
{
|
||||
if (str == ASE_NULL)
|
||||
{
|
||||
str = (ase_str_t*)
|
||||
ASE_MALLOC (mmgr, ASE_SIZEOF(ase_str_t));
|
||||
if (str == ASE_NULL) return ASE_NULL;
|
||||
str->__dynamic = ase_true;
|
||||
}
|
||||
else str->__dynamic = ase_false;
|
||||
|
||||
str->mmgr = mmgr;
|
||||
str->buf = (ase_char_t*) ASE_MALLOC (
|
||||
mmgr, ASE_SIZEOF(ase_char_t) * (capa + 1));
|
||||
if (str->buf == ASE_NULL)
|
||||
{
|
||||
if (str->__dynamic) ASE_FREE (mmgr, str);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
str->size = 0;
|
||||
str->capa = capa;
|
||||
str->buf[0] = ASE_T('\0');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void ase_str_close (ase_str_t* str)
|
||||
{
|
||||
ASE_FREE (str->mmgr, str->buf);
|
||||
if (str->__dynamic) ASE_FREE (str->mmgr, str);
|
||||
}
|
||||
|
||||
void ase_str_clear (ase_str_t* str)
|
||||
{
|
||||
str->size = 0;
|
||||
str->buf[0] = ASE_T('\0');
|
||||
}
|
||||
|
||||
void ase_str_forfeit (ase_str_t* str)
|
||||
{
|
||||
if (str->__dynamic) ASE_FREE (str->mmgr, str);
|
||||
}
|
||||
|
||||
void ase_str_swap (ase_str_t* str, ase_str_t* str1)
|
||||
{
|
||||
ase_str_t tmp;
|
||||
|
||||
tmp.buf = str->buf;
|
||||
tmp.size = str->size;
|
||||
tmp.capa = str->capa;
|
||||
tmp.mmgr = str->mmgr;
|
||||
|
||||
str->buf = str1->buf;
|
||||
str->size = str1->size;
|
||||
str->capa = str1->capa;
|
||||
str->mmgr = str1->mmgr;
|
||||
|
||||
str1->buf = tmp.buf;
|
||||
str1->size = tmp.size;
|
||||
str1->capa = tmp.capa;
|
||||
str1->mmgr = tmp.mmgr;
|
||||
}
|
||||
|
||||
ase_size_t ase_str_cpy (ase_str_t* str, const ase_char_t* s)
|
||||
{
|
||||
/* TODO: improve it */
|
||||
return ase_str_ncpy (str, s, ase_strlen(s));
|
||||
}
|
||||
|
||||
ase_size_t ase_str_ncpy (ase_str_t* str, const ase_char_t* s, ase_size_t len)
|
||||
{
|
||||
ase_char_t* buf;
|
||||
|
||||
if (len > str->capa)
|
||||
{
|
||||
buf = (ase_char_t*) ASE_MALLOC (
|
||||
str->mmgr, ASE_SIZEOF(ase_char_t) * (len + 1));
|
||||
if (buf == ASE_NULL) return (ase_size_t)-1;
|
||||
|
||||
ASE_FREE (str->mmgr, str->buf);
|
||||
str->capa = len;
|
||||
str->buf = buf;
|
||||
}
|
||||
|
||||
str->size = ase_strncpy (str->buf, s, len);
|
||||
str->buf[str->size] = ASE_T('\0');
|
||||
return str->size;
|
||||
}
|
||||
|
||||
ase_size_t ase_str_cat (ase_str_t* str, const ase_char_t* s)
|
||||
{
|
||||
/* TODO: improve it */
|
||||
return ase_str_ncat (str, s, ase_strlen(s));
|
||||
}
|
||||
|
||||
ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len)
|
||||
{
|
||||
if (len > str->capa - str->size)
|
||||
{
|
||||
ase_char_t* tmp;
|
||||
ase_size_t capa;
|
||||
|
||||
capa = str->size + len;
|
||||
|
||||
/* double the capa if necessary for concatenation */
|
||||
if (capa < str->capa * 2) capa = str->capa * 2;
|
||||
|
||||
if (str->mmgr->realloc != ASE_NULL)
|
||||
{
|
||||
tmp = (ase_char_t*) ASE_REALLOC (
|
||||
str->mmgr, str->buf,
|
||||
ASE_SIZEOF(ase_char_t) * (capa + 1));
|
||||
if (tmp == ASE_NULL) return (ase_size_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = (ase_char_t*) ASE_MALLOC (
|
||||
str->mmgr, ASE_SIZEOF(ase_char_t)*(capa+1));
|
||||
if (tmp == ASE_NULL) return (ase_size_t)-1;
|
||||
if (str->buf != ASE_NULL)
|
||||
{
|
||||
ase_memcpy (tmp, str->buf,
|
||||
ASE_SIZEOF(ase_char_t)*(str->capa+1));
|
||||
ASE_FREE (str->mmgr, str->buf);
|
||||
}
|
||||
}
|
||||
|
||||
str->capa = capa;
|
||||
str->buf = tmp;
|
||||
}
|
||||
|
||||
str->size += ase_strncpy (&str->buf[str->size], s, len);
|
||||
str->buf[str->size] = ASE_T('\0');
|
||||
return str->size;
|
||||
}
|
||||
|
||||
ase_size_t ase_str_ccat (ase_str_t* str, ase_char_t c)
|
||||
{
|
||||
return ase_str_ncat (str, &c, 1);
|
||||
}
|
||||
|
||||
ase_size_t ase_str_nccat (ase_str_t* str, ase_char_t c, ase_size_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
if (ase_str_ncat (str, &c, 1) == (ase_size_t)-1)
|
||||
{
|
||||
return (ase_size_t)-1;
|
||||
}
|
||||
|
||||
len--;
|
||||
}
|
||||
return str->size;
|
||||
}
|
||||
|
||||
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* $Id: str.h,v 1.1.1.1 2007/03/28 14:05:21 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_STR_H_
|
||||
#define _ASE_CMN_STR_H_
|
||||
|
||||
#include <ase/cmn/types.h>
|
||||
#include <ase/cmn/macros.h>
|
||||
|
||||
#define ASE_STR_LEN(x) ((x)->size)
|
||||
#define ASE_STR_SIZE(x) ((x)->size + 1)
|
||||
#define ASE_STR_CAPA(x) ((x)->capa)
|
||||
#define ASE_STR_BUF(x) ((x)->buf)
|
||||
#define ASE_STR_CHAR(x,idx) ((x)->buf[idx])
|
||||
|
||||
typedef struct ase_str_t ase_str_t;
|
||||
|
||||
struct ase_str_t
|
||||
{
|
||||
ase_char_t* buf;
|
||||
ase_size_t size;
|
||||
ase_size_t capa;
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_bool_t __dynamic;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_size_t ase_strlen (const ase_char_t* str);
|
||||
|
||||
ase_size_t ase_strcpy (
|
||||
ase_char_t* buf, const ase_char_t* str);
|
||||
ase_size_t ase_strxcpy (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str);
|
||||
ase_size_t ase_strncpy (
|
||||
ase_char_t* buf, const ase_char_t* str, ase_size_t len);
|
||||
ase_size_t ase_strxncpy (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len);
|
||||
|
||||
ase_size_t ase_strxncat (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len);
|
||||
|
||||
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2);
|
||||
int ase_strxncmp (
|
||||
const ase_char_t* s1, ase_size_t len1,
|
||||
const ase_char_t* s2, ase_size_t len2);
|
||||
int ase_strcasecmp (
|
||||
const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls);
|
||||
int ase_strxncasecmp (
|
||||
const ase_char_t* s1, ase_size_t len1,
|
||||
const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls);
|
||||
|
||||
ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr);
|
||||
ase_char_t* ase_strxdup (
|
||||
const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr);
|
||||
ase_char_t* ase_strxdup2 (
|
||||
const ase_char_t* str1, ase_size_t len1,
|
||||
const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr);
|
||||
|
||||
ase_char_t* ase_strxnstr (
|
||||
const ase_char_t* str, ase_size_t strsz,
|
||||
const ase_char_t* sub, ase_size_t subsz);
|
||||
|
||||
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr);
|
||||
void ase_str_close (ase_str_t* str);
|
||||
void ase_str_clear (ase_str_t* str);
|
||||
|
||||
void ase_str_forfeit (ase_str_t* str);
|
||||
void ase_str_swap (ase_str_t* str, ase_str_t* str2);
|
||||
|
||||
ase_size_t ase_str_cpy (ase_str_t* str, const ase_char_t* s);
|
||||
ase_size_t ase_str_ncpy (ase_str_t* str, const ase_char_t* s, ase_size_t len);
|
||||
|
||||
ase_size_t ase_str_cat (ase_str_t* str, const ase_char_t* s);
|
||||
ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len);
|
||||
ase_size_t ase_str_ccat (ase_str_t* str, ase_char_t c);
|
||||
ase_size_t ase_str_nccat (ase_str_t* str, ase_char_t c, ase_size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
276
ase/cmn/types.h
276
ase/cmn/types.h
@ -1,276 +0,0 @@
|
||||
/*
|
||||
* $Id: types.h,v 1.1.1.1 2007/03/28 14:05:22 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_TYPES_H_
|
||||
#define _ASE_TYPES_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <ase/cmn/conf_msw.h>
|
||||
#elif defined(vms) || defined(__vms)
|
||||
#include <ase/cmn/conf_vms.h>
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#if !defined(__unix__)
|
||||
#define __unix__
|
||||
#endif
|
||||
#if !defined(__unix)
|
||||
#define __unix
|
||||
#endif
|
||||
#include <ase/cmn/conf_unx.h>
|
||||
#else
|
||||
#error unsupported operating system
|
||||
#endif
|
||||
|
||||
/* boolean type */
|
||||
typedef int ase_bool_t;
|
||||
#define ase_true (0 == 0)
|
||||
#define ase_false (0 != 0)
|
||||
|
||||
/* tri-state type */
|
||||
typedef int ase_tri_t;
|
||||
#define ase_alive 1
|
||||
#define ase_zombie 0
|
||||
#define ase_dead -1
|
||||
|
||||
/* integer that can hold a pointer */
|
||||
#if ASE_SIZEOF_VOID_P == ASE_SIZEOF_INT
|
||||
typedef int ase_int_t;
|
||||
typedef unsigned int ase_uint_t;
|
||||
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG
|
||||
typedef long ase_int_t;
|
||||
typedef unsigned long ase_uint_t;
|
||||
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG_LONG
|
||||
typedef long long ase_int_t;
|
||||
typedef unsigned long long ase_uint_t;
|
||||
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF___INT32
|
||||
typedef __int32 ase_int_t;
|
||||
typedef unsigned __int32 ase_uint_t;
|
||||
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF___INT64
|
||||
typedef __int64 ase_int_t;
|
||||
typedef unsigned __int64 ase_uint_t;
|
||||
#else
|
||||
#error unsupported pointer size
|
||||
#endif
|
||||
|
||||
|
||||
/* the largest integer supported by the system */
|
||||
#if ASE_SIZEOF_LONG_LONG != 0
|
||||
typedef long long ase_long_t;
|
||||
typedef unsigned long long ase_ulong_t;
|
||||
#elif ASE_SIZEOF___INT64 != 0
|
||||
typedef __int64 ase_long_t;
|
||||
typedef unsigned __int64 ase_ulong_t;
|
||||
#else
|
||||
typedef long ase_long_t;
|
||||
typedef unsigned long ase_ulong_t;
|
||||
#endif
|
||||
|
||||
/* integers of specific size */
|
||||
#if ASE_SIZEOF_CHAR == 1
|
||||
typedef char ase_int8_t;
|
||||
typedef unsigned char ase_uint8_t;
|
||||
#elif ASE_SIZEOF___INT8 == 1
|
||||
typedef __int8 ase_int8_t;
|
||||
typedef unsigned __int8 ase_uint8_t;
|
||||
#endif
|
||||
|
||||
#if ASE_SIZEOF_SHORT == 2
|
||||
typedef short ase_int16_t;
|
||||
typedef unsigned short ase_uint16_t;
|
||||
#elif ASE_SIZEOF___INT16 == 2
|
||||
typedef __int16 ase_int16_t;
|
||||
typedef unsigned __int16 ase_uint16_t;
|
||||
#endif
|
||||
|
||||
#if ASE_SIZEOF_INT == 4
|
||||
typedef int ase_int32_t;
|
||||
typedef unsigned int ase_uint32_t;
|
||||
#elif ASE_SIZEOF_LONG == 4
|
||||
typedef long ase_int32_t;
|
||||
typedef unsigned long ase_uint32_t;
|
||||
#elif ASE_SIZEOF___INT32 == 4
|
||||
typedef __int32 ase_int32_t;
|
||||
typedef unsigned __int32 ase_uint32_t;
|
||||
#endif
|
||||
|
||||
#if ASE_SIZEOF_INT == 8
|
||||
#define ASE_HAVE_INT64_T
|
||||
#define ASE_HAVE_UINT64_T
|
||||
typedef int ase_int64_t;
|
||||
typedef unsigned int ase_uint64_t;
|
||||
#elif ASE_SIZEOF_LONG == 8
|
||||
#define ASE_HAVE_INT64_T
|
||||
#define ASE_HAVE_UINT64_T
|
||||
typedef long ase_int64_t;
|
||||
typedef unsigned long ase_uint64_t;
|
||||
#elif ASE_SIZEOF_LONG_LONG == 8
|
||||
#define ASE_HAVE_INT64_T
|
||||
#define ASE_HAVE_UINT64_T
|
||||
typedef long long ase_int64_t;
|
||||
typedef unsigned long long ase_uint64_t;
|
||||
#elif ASE_SIZEOF___INT64 == 8
|
||||
#define ASE_HAVE_INT64_T
|
||||
#define ASE_HAVE_UINT64_T
|
||||
typedef __int64 ase_int64_t;
|
||||
typedef unsigned __int64 ase_uint64_t;
|
||||
#endif
|
||||
|
||||
#if ASE_SIZEOF_INT == 16
|
||||
#define ASE_HAVE_INT128_T
|
||||
#define ASE_HAVE_UINT128_T
|
||||
typedef int ase_int128_t;
|
||||
typedef unsigned int ase_uint128_t;
|
||||
#elif ASE_SIZEOF_LONG == 16
|
||||
#define ASE_HAVE_INT128_T
|
||||
#define ASE_HAVE_UINT128_T
|
||||
typedef long ase_int128_t;
|
||||
typedef unsigned long ase_uint128_t;
|
||||
#elif ASE_SIZEOF_LONG_LONG == 16
|
||||
#define ASE_HAVE_INT128_T
|
||||
#define ASE_HAVE_UINT128_T
|
||||
typedef long long ase_int128_t;
|
||||
typedef unsigned long long ase_uint128_t;
|
||||
#elif ASE_SIZEOF___INT128 == 16
|
||||
#define ASE_HAVE_INT128_T
|
||||
#define ASE_HAVE_UINT128_T
|
||||
typedef __int128 ase_int128_t;
|
||||
typedef unsigned __int128 ase_uint128_t;
|
||||
#endif
|
||||
|
||||
/* miscellaneous integral types */
|
||||
typedef ase_uint8_t ase_byte_t;
|
||||
typedef ase_uint_t ase_size_t;
|
||||
typedef ase_int_t ase_ssize_t;
|
||||
typedef ase_uint_t ase_word_t;
|
||||
|
||||
/* floating-point number */
|
||||
#if defined(__FreeBSD__)
|
||||
/* TODO: check if the support for long double is complete.
|
||||
* if so, use long double for ase_real_t */
|
||||
#define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE
|
||||
typedef double ase_real_t;
|
||||
#elif ASE_SIZEOF_LONG_DOUBLE > ASE_SIZEOF_DOUBLE
|
||||
#define ASE_SIZEOF_REAL ASE_SIZEOF_LONG_DOUBLE
|
||||
typedef long double ase_real_t;
|
||||
#else
|
||||
#define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE
|
||||
typedef double ase_real_t;
|
||||
#endif
|
||||
|
||||
/* character types */
|
||||
typedef char ase_mchar_t;
|
||||
typedef int ase_mcint_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
/* C++ */
|
||||
typedef wchar_t ase_wchar_t;
|
||||
typedef wchar_t ase_wcint_t;
|
||||
|
||||
/* all the way down from here for C */
|
||||
#elif (ASE_SIZEOF_WCHAR_T == 2) || (ASE_SIZEOF_WCHAR_T == 0)
|
||||
typedef unsigned short ase_wchar_t;
|
||||
typedef unsigned short ase_wcint_t;
|
||||
#elif (ASE_SIZEOF_WCHAR_T == 4)
|
||||
#if defined(vms) || defined(__vms)
|
||||
typedef unsigned int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif (defined(sun) || defined(__sun)) && defined(_LP64)
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif defined(hpux) || defined(__hpux)
|
||||
typedef unsigned int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif ASE_SIZEOF_LONG == 4
|
||||
typedef long ase_wchar_t;
|
||||
typedef long ase_wcint_t;
|
||||
#else
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#endif
|
||||
#else
|
||||
#error unsupported size of wchar_t
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && (defined(UNICODE)||defined(_UNICODE))
|
||||
#define ASE_CHAR_IS_WCHAR
|
||||
typedef ase_wchar_t ase_char_t;
|
||||
typedef ase_wcint_t ase_cint_t;
|
||||
#else
|
||||
#if defined(ASE_CHAR_IS_MCHAR)
|
||||
typedef ase_mchar_t ase_char_t;
|
||||
typedef ase_mcint_t ase_cint_t;
|
||||
#elif defined(ASE_CHAR_IS_WCHAR)
|
||||
typedef ase_wchar_t ase_char_t;
|
||||
typedef ase_wcint_t ase_cint_t;
|
||||
#elif defined(_MBCS)
|
||||
#define ASE_CHAR_IS_MCHAR
|
||||
typedef ase_mchar_t ase_char_t;
|
||||
typedef ase_mcint_t ase_cint_t;
|
||||
#else
|
||||
#define ASE_CHAR_IS_WCHAR
|
||||
typedef ase_wchar_t ase_char_t;
|
||||
typedef ase_wcint_t ase_cint_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ASE_CHAR_IS_WCHAR) && defined(_WIN32)
|
||||
#ifndef UNICODE
|
||||
#define UNICODE
|
||||
#endif
|
||||
#ifndef _UNICODE
|
||||
#define _UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct ase_cstr_t ase_cstr_t;
|
||||
typedef struct ase_mmgr_t ase_mmgr_t;
|
||||
typedef struct ase_ccls_t ase_ccls_t;
|
||||
|
||||
typedef void* (*ase_malloc_t) (void* custom, ase_size_t n);
|
||||
typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n);
|
||||
typedef void (*ase_free_t) (void* custom, void* ptr);
|
||||
|
||||
typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c);
|
||||
typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c);
|
||||
|
||||
struct ase_cstr_t
|
||||
{
|
||||
const ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
};
|
||||
|
||||
struct ase_mmgr_t
|
||||
{
|
||||
ase_malloc_t malloc;
|
||||
ase_realloc_t realloc;
|
||||
ase_free_t free;
|
||||
void* custom_data;
|
||||
};
|
||||
|
||||
struct ase_ccls_t
|
||||
{
|
||||
ase_isccls_t is_upper;
|
||||
ase_isccls_t is_lower;
|
||||
ase_isccls_t is_alpha;
|
||||
ase_isccls_t is_digit;
|
||||
ase_isccls_t is_xdigit;
|
||||
ase_isccls_t is_alnum;
|
||||
ase_isccls_t is_space;
|
||||
ase_isccls_t is_print;
|
||||
ase_isccls_t is_graph;
|
||||
ase_isccls_t is_cntrl;
|
||||
ase_isccls_t is_punct;
|
||||
ase_toccls_t to_upper;
|
||||
ase_toccls_t to_lower;
|
||||
void* custom_data;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* $Id: unpack.h,v 1.1.1.1 2007/03/28 14:05:22 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#elif defined(__HP_aCC) || defined(__HP_cc)
|
||||
#pragma PACK
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#pragma pack(pop)
|
||||
#elif defined(__DECC)
|
||||
#pragma pack(pop)
|
||||
#else
|
||||
#pragma pack()
|
||||
#endif
|
Reference in New Issue
Block a user