initial import
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* $Id: ctype.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_CHR_H_
|
||||
#define _ASE_CMN_CHR_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/* gets a pointer to the default memory manager */
|
||||
#define ASE_CCLS_GETDFL() (ase_ccls)
|
||||
|
||||
/* sets a pointer to the default memory manager */
|
||||
#define ASE_CCLS_SETDFL(m) ((ase_ccls)=(m))
|
||||
|
||||
#define ASE_CCLS_IS(ccls,c,type) ((ccls)->is((ccls)->data,c,type))
|
||||
#define ASE_CCLS_TO(ccls,c,type) ((ccls)->to((ccls)->data,c,type))
|
||||
|
||||
#define ASE_CCLS_ISUPPER(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_UPPER)
|
||||
#define ASE_CCLS_ISLOWER(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_LOWER)
|
||||
#define ASE_CCLS_ISALPHA(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_ALPHA)
|
||||
#define ASE_CCLS_ISDIGIT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_DIGIT)
|
||||
#define ASE_CCLS_ISXDIGIT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_XDIGIT)
|
||||
#define ASE_CCLS_ISALNUM(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_ALNUM)
|
||||
#define ASE_CCLS_ISSPACE(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_SPACE)
|
||||
#define ASE_CCLS_ISPRINT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_PRINT)
|
||||
#define ASE_CCLS_ISGRAPH(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_GRAPH)
|
||||
#define ASE_CCLS_ISCNTRL(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_CNTRL)
|
||||
#define ASE_CCLS_ISPUNCT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_PUNCT)
|
||||
#define ASE_CCLS_TOUPPER(ccls,c) ASE_CCLS_TO(ccls,c,ASE_CCLS_UPPER)
|
||||
#define ASE_CCLS_TOLOWER(ccls,c) ASE_CCLS_TO(ccls,c,ASE_CCLS_LOWER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ase_ccls_t* ase_ccls;
|
||||
|
||||
ase_bool_t ase_ccls_is (
|
||||
ase_cint_t c,
|
||||
ase_ccls_type_t type
|
||||
);
|
||||
|
||||
ase_cint_t ase_ccls_to (
|
||||
ase_cint_t c,
|
||||
ase_ccls_type_t type
|
||||
);
|
||||
|
||||
|
||||
|
||||
ase_size_t ase_mblen (
|
||||
const ase_mchar_t* mb,
|
||||
ase_size_t mblen
|
||||
);
|
||||
|
||||
/****f* ase.cmn.chr/ase_mbtowc
|
||||
* NAME
|
||||
* ase_mbtowc - convert a multibyte sequence to a wide character.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_mbtowc() function returns 0 if an invalid multibyte sequence is
|
||||
* detected, mblen + 1 if the sequence is incomplete. It returns the number
|
||||
* of bytes processed to form a wide character.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_mbtowc (
|
||||
const ase_mchar_t* mb,
|
||||
ase_size_t mblen,
|
||||
ase_wchar_t* wc
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.chr/ase_wctomb
|
||||
* NAME
|
||||
* ase_wctomb - convert a wide character to a multibyte sequence
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wctomb() functions returns 0 if the wide character is illegal,
|
||||
* mblen + 1 if mblen is not large enough to hold the multibyte sequence.
|
||||
* On successful conversion, it returns the number of bytes in the sequence.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_wctomb (
|
||||
ase_wchar_t wc,
|
||||
ase_mchar_t* mb,
|
||||
ase_size_t mblen
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,260 +0,0 @@
|
||||
/*
|
||||
* $Id: map.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_DLL_H_
|
||||
#define _ASE_CMN_DLL_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/*
|
||||
* Doubly Linked List
|
||||
*/
|
||||
typedef struct ase_dll_t ase_dll_t;
|
||||
typedef struct ase_dll_node_t ase_dll_node_t;
|
||||
|
||||
/* data copier */
|
||||
typedef void* (*ase_dll_copier_t) (ase_dll_t* dll, void* dptr, ase_size_t dlen);
|
||||
|
||||
/* data freeer */
|
||||
typedef void (*ase_dll_freeer_t) (ase_dll_t* dll, void* dptr, ase_size_t dlen);
|
||||
|
||||
/* node visitor */
|
||||
typedef int (*ase_dll_walker_t) (
|
||||
ase_dll_t* dll, ase_dll_node_t* node, void* arg);
|
||||
|
||||
struct ase_dll_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
|
||||
ase_dll_copier_t copier;
|
||||
ase_dll_freeer_t freeer;
|
||||
|
||||
ase_size_t size;
|
||||
ase_dll_node_t* head;
|
||||
ase_dll_node_t* tail;
|
||||
};
|
||||
|
||||
struct ase_dll_node_t
|
||||
{
|
||||
void* dptr; /* pointer to the beginning of data */
|
||||
ase_size_t dlen; /* length of data in bytes */
|
||||
ase_dll_node_t* next; /* pointer to the next node */
|
||||
ase_dll_node_t* prev; /* pointer to the prev node */
|
||||
};
|
||||
|
||||
|
||||
enum ase_dll_walk_t
|
||||
{
|
||||
ASE_DLL_WALK_STOP = 0,
|
||||
ASE_DLL_WALK_FORWARD = 1
|
||||
};
|
||||
|
||||
#define ASE_DLL_COPIER_INLINE ase_dll_copyinline
|
||||
|
||||
#define ASE_DLL_HEAD(dll) ((dll)->head)
|
||||
#define ASE_DLL_TAIL(dll) ((dll)->tail)
|
||||
#define ASE_DLL_SIZE(dll) ((dll)->size)
|
||||
|
||||
#define ASE_DLL_DPTR(n) ((n)->dptr)
|
||||
#define ASE_DLL_DLEN(n) ((n)->dlen)
|
||||
#define ASE_DLL_NEXT(n) ((n)->next)
|
||||
#define ASE_DLL_PREV(n) ((n)->prev)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NAME: creates a doubly linked list with extension area
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_dll_open() function creates an empty doubly linked list.
|
||||
* If the memory manager mmgr is ASE_NULL, the function gets the default
|
||||
* memory manager with ASE_MMGR_GETMMGR() and uses it if it is not ASE_NULL.
|
||||
* The extension area is allocated when the positive extension size extension
|
||||
* is specified. It calls the extension initialization function initializer
|
||||
* after initializing the main area. The extension initializer is passed
|
||||
* the pointer to the doubly linked list created.
|
||||
*
|
||||
* RETURNS:
|
||||
* the pointer to a newly created doubly linked list on success.
|
||||
* ASE_NULL on failure.
|
||||
*
|
||||
* WARNING:
|
||||
* In the debug build, it fails the assertion if ASE_MMGR_SETMMGR() returns
|
||||
* ASE_NULL when ASE_NULL is passed as the first parameter. In the release
|
||||
* build, it returns ASE_NULL if such a thing happens.
|
||||
*/
|
||||
|
||||
ase_dll_t* ase_dll_open (
|
||||
ase_mmgr_t* mmgr /* memory manager */ ,
|
||||
ase_size_t ext /* size of extension area in bytes */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME destroys a singly linked list
|
||||
*/
|
||||
void ase_dll_close (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME deletes all elements of a singly linked list
|
||||
*/
|
||||
void ase_dll_clear (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier ASE_DLL_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*/
|
||||
void ase_dll_setcopier (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
ase_dll_copier_t copier /* a element copier */
|
||||
);
|
||||
|
||||
ase_dll_copier_t ase_dll_getcopier (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*/
|
||||
void ase_dll_setfreeer (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
ase_dll_freeer_t freeer /* a element freeer */
|
||||
);
|
||||
|
||||
ase_dll_freeer_t ase_dll_getfreeer (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the pointer to the extension area
|
||||
* RETURN the pointer to the extension area
|
||||
*/
|
||||
void* ase_dll_getxtn (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get the pointer to the memory manager in use
|
||||
*/
|
||||
ase_mmgr_t* ase_dll_getmmgr (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
void ase_dll_setmmgr (ase_dll_t* dll, ase_mmgr_t* mmgr);
|
||||
|
||||
/*
|
||||
* NAME Gets the number of elements held in a singly linked list
|
||||
* RETURN the number of elements the list holds
|
||||
*/
|
||||
ase_size_t ase_dll_getsize (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the head(first) node
|
||||
* RETURN the tail node of a singly linked list
|
||||
*/
|
||||
ase_dll_node_t* ase_dll_gethead (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the tail(last) node
|
||||
* RETURN the tail node of a singly linked list
|
||||
*/
|
||||
ase_dll_node_t* ase_dll_gettail (
|
||||
ase_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Inserts data before a positional node given
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Inserts data.
|
||||
*/
|
||||
ase_dll_node_t* ase_dll_insert (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
ase_dll_node_t* pos /* a node before which a new node is inserted */,
|
||||
void* dptr /* the pointer to the data */ ,
|
||||
ase_size_t dlen /* the length of the data in bytes */
|
||||
);
|
||||
|
||||
ase_dll_node_t* ase_dll_pushhead (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_dll_node_t* ase_dll_pushtail (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
void ase_dll_delete (
|
||||
ase_dll_t* dll,
|
||||
ase_dll_node_t* pos
|
||||
);
|
||||
|
||||
void ase_dll_pophead (
|
||||
ase_dll_t* dll
|
||||
);
|
||||
|
||||
void ase_dll_poptail (
|
||||
ase_dll_t* dll
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Traverses s singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A singly linked list allows uni-directional in-order traversal.
|
||||
* The ase_dll_walk() function traverses a singly linkked list from its
|
||||
* head node down to its tail node as long as the walker function returns
|
||||
* ASE_DLL_WALK_FORWARD. A walker can return ASE_DLL_WALK_STOP to cause
|
||||
* immediate stop of traversal.
|
||||
* For each node, the walker function is called and it is passed three
|
||||
* parameters: the singly linked list, the visiting node, and the
|
||||
* user-defined data passed as the third parameter in a call to the
|
||||
* ase_dll_walk() function.
|
||||
*/
|
||||
void ase_dll_walk (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
ase_dll_walker_t walker /* a user-defined walker function */,
|
||||
void* arg /* pointer to user-defined data */
|
||||
);
|
||||
|
||||
/*
|
||||
* Causes a singly linked list to copy in data to a node.
|
||||
* Use ASE_DLL_COPIER_INLINE instead.
|
||||
*/
|
||||
void* ase_dll_copyinline (
|
||||
ase_dll_t* dll /* a singly linked list */,
|
||||
void* data /* pointer to data to copy */ ,
|
||||
ase_size_t len /* length of data in bytes */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_FIO_H_
|
||||
#define _ASE_CMN_FIO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
enum ase_fio_open_flag_t
|
||||
{
|
||||
/* treat the file name pointer as a handle pointer */
|
||||
ASE_FIO_HANDLE = (1 << 0),
|
||||
|
||||
ASE_FIO_READ = (1 << 1),
|
||||
ASE_FIO_WRITE = (1 << 2),
|
||||
ASE_FIO_APPEND = (1 << 3),
|
||||
|
||||
ASE_FIO_CREATE = (1 << 4),
|
||||
ASE_FIO_TRUNCATE = (1 << 5),
|
||||
ASE_FIO_EXCLUSIVE = (1 << 6),
|
||||
ASE_FIO_SYNC = (1 << 7),
|
||||
|
||||
/* for ms windows only */
|
||||
ASE_FIO_NOSHRD = (1 << 16),
|
||||
ASE_FIO_NOSHWR = (1 << 17)
|
||||
};
|
||||
|
||||
/* seek origin */
|
||||
enum ase_fio_seek_origin_t
|
||||
{
|
||||
ASE_FIO_BEGIN = 0,
|
||||
ASE_FIO_CURRENT = 1,
|
||||
ASE_FIO_END = 2
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
/* <winnt.h> typedef PVOID HANDLE; */
|
||||
typedef void* ase_fio_hnd_t;
|
||||
#else
|
||||
typedef int ase_fio_hnd_t;
|
||||
#endif
|
||||
|
||||
/* file offset */
|
||||
typedef ase_int64_t ase_fio_off_t;
|
||||
typedef enum ase_fio_seek_origin_t ase_fio_ori_t;
|
||||
|
||||
typedef struct ase_fio_t ase_fio_t;
|
||||
|
||||
struct ase_fio_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_fio_hnd_t handle;
|
||||
};
|
||||
|
||||
#define ASE_FIO_MMGR(fio) ((fio)->mmgr)
|
||||
#define ASE_FIO_HANDLE(fio) ((fio)->handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.fio/ase_fio_open
|
||||
* NAME
|
||||
* ase_fio_open - open a file
|
||||
*
|
||||
* DESCRIPTION
|
||||
* To open a file, you should set the flags with at least one of
|
||||
* ASE_FIO_READ, ASE_FIO_WRITE, ASE_FIO_APPEND.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_fio_t* ase_fio_open (
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t ext,
|
||||
const ase_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.fio/ase_fio_close
|
||||
* NAME
|
||||
* ase_fio_close - close a file
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_fio_close (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_fio_t* ase_fio_init (
|
||||
ase_fio_t* fio,
|
||||
ase_mmgr_t* mmgr,
|
||||
const ase_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
|
||||
void ase_fio_fini (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
|
||||
ase_fio_hnd_t ase_fio_gethandle (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
|
||||
/****f* ase.cmn.fio/ase_fio_sethandle
|
||||
* SYNOPSIS
|
||||
* ase_fio_sethandle - set the file handle
|
||||
* WARNING
|
||||
* Avoid using this function if you don't know what you are doing.
|
||||
* You may have to retrieve the previous handle using ase_fio_gethandle()
|
||||
* to take relevant actions before resetting it with ase_fio_sethandle().
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_fio_sethandle (
|
||||
ase_fio_t* fio,
|
||||
ase_fio_hnd_t handle
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_fio_off_t ase_fio_seek (
|
||||
ase_fio_t* fio,
|
||||
ase_fio_off_t offset,
|
||||
ase_fio_ori_t origin
|
||||
);
|
||||
|
||||
int ase_fio_truncate (
|
||||
ase_fio_t* fio,
|
||||
ase_fio_off_t size
|
||||
);
|
||||
|
||||
ase_ssize_t ase_fio_read (
|
||||
ase_fio_t* fio,
|
||||
void* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
ase_ssize_t ase_fio_write (
|
||||
ase_fio_t* fio,
|
||||
const void* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* $Id: sysapi.h,v 1.56 2006/03/21 16:15:16 bacon Ease $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_IO_H_
|
||||
#define _ASE_CMN_IO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/* flags for ase_open */
|
||||
enum
|
||||
{
|
||||
ASE_OPEN_READ = (1 << 0),
|
||||
ASE_OPEN_WRITE = (1 << 1),
|
||||
ASE_OPEN_CREATE = (1 << 2),
|
||||
ASE_OPEN_TRUNCATE = (1 << 3),
|
||||
ASE_OPEN_EXCLUSIVE = (1 << 4),
|
||||
ASE_OPEN_APPEND = (1 << 5),
|
||||
ASE_OPEN_NONBLOCK = (1 << 6)
|
||||
};
|
||||
|
||||
/* origin for ase_seek */
|
||||
enum
|
||||
{
|
||||
ASE_SEEK_BEGIN = 0,
|
||||
ASE_SEEK_CURRENT = 1,
|
||||
ASE_SEEK_END = 2
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_hnd_t ase_open (
|
||||
const ase_char_t* path,
|
||||
int flag,
|
||||
...
|
||||
);
|
||||
|
||||
int ase_close (
|
||||
ase_hnd_t handle
|
||||
);
|
||||
|
||||
ase_ssize_t ase_read (
|
||||
ase_hnd_t handle,
|
||||
void* buf,
|
||||
ase_size_t sz
|
||||
);
|
||||
|
||||
ase_ssize_t ase_write (
|
||||
ase_hnd_t handle,
|
||||
const void* data,
|
||||
ase_size_t sz
|
||||
);
|
||||
|
||||
ase_off_t ase_seek (
|
||||
ase_hnd_t handle,
|
||||
ase_off_t offset,
|
||||
int origin
|
||||
);
|
||||
|
||||
/*
|
||||
int ase_hstat (ase_hnd_t handle, ase_stat_t* buf);
|
||||
int ase_hchmod (ase_hnd_t handle, ase_mode_t mode);
|
||||
*/
|
||||
int ase_htruncate (ase_hnd_t handle, ase_off_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,477 +0,0 @@
|
||||
/*
|
||||
* $Id: lda.h 363 2008-09-04 10:58:08Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_LDA_H_
|
||||
#define _ASE_CMN_LDA_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****o* ase.cmn.lda/linear dynamic array
|
||||
* DESCRIPTION
|
||||
* <ase/cmn/lda.h> provides a linear dynamic array. It grows as more items
|
||||
* are added. T
|
||||
*
|
||||
* #include <ase/cmn/lda.h>
|
||||
******
|
||||
*/
|
||||
|
||||
enum ase_lda_walk_t
|
||||
{
|
||||
ASE_LDA_WALK_STOP = 0,
|
||||
ASE_LDA_WALK_FORWARD = 1,
|
||||
ASE_LDA_WALK_BACKWARD = 2
|
||||
};
|
||||
|
||||
typedef struct ase_lda_t ase_lda_t;
|
||||
typedef struct ase_lda_node_t ase_lda_node_t;
|
||||
typedef enum ase_lda_walk_t ase_lda_walk_t;
|
||||
|
||||
#define ASE_LDA_COPIER_SIMPLE ((ase_lda_copier_t)1)
|
||||
#define ASE_LDA_COPIER_INLINE ((ase_lda_copier_t)2)
|
||||
|
||||
#define ASE_LDA_INVALID ((ase_size_t)-1)
|
||||
|
||||
#define ASE_LDA_SIZE(lda) ((lda)->size)
|
||||
#define ASE_LDA_CAPA(lda) ((lda)->capa)
|
||||
|
||||
#define ASE_LDA_NODE(lda,index) ((lda)->node[index])
|
||||
#define ASE_LDA_DPTR(lda,index) ((lda)->node[index]->dptr)
|
||||
#define ASE_LDA_DLEN(lda,index) ((lda)->node[index]->dlen)
|
||||
|
||||
#define ASE_LDA_MMGR(lda) ((lda)->mmgr)
|
||||
#define ASE_LDA_XTN(lda) ((void*)(((ase_lda_t*)lda) + 1))
|
||||
|
||||
#define ASE_LDA_COPIER(lda) ((lda)->copier)
|
||||
#define ASE_LDA_FREEER(lda) ((lda)->freeer)
|
||||
#define ASE_LDA_COMPER(lda) ((lda)->comper)
|
||||
#define ASE_LDA_KEEPER(lda) ((lda)->keeper)
|
||||
#define ASE_LDA_SIZER(lda) ((lda)->sizer)
|
||||
|
||||
|
||||
|
||||
/****b* ase.cmn.lda/ase_lda_copier_t
|
||||
* NAME
|
||||
* ase_lda_copier_t - define a node contruction callback
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_copier_t defines a callback function for node construction.
|
||||
* A node is contructed when a user adds data to a list. The user can
|
||||
* define how the data to add can be maintained in the list. A singly
|
||||
* linked list not specified with any copiers stores the data pointer and
|
||||
* the data length into a node. A special copier ASE_LDA_COPIER_INLINE copies
|
||||
* the contents of the data a user provided into the node. You can use the
|
||||
* ase_lda_setcopier() function to change the copier.
|
||||
*
|
||||
* A copier should return the pointer to the copied data. If it fails to copy
|
||||
* data, it may return ASE_NULL. You need to set a proper freeer to free up
|
||||
* memory allocated for copy.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ase_lda_setcopier, ase_lda_getcopier, ASE_LDA_COPIER
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*ase_lda_copier_t) (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
void* dptr /* the pointer to data to copy */,
|
||||
ase_size_t dlen /* the length of data to copy */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* ase.cmn.lda/ase_lda_freeer_t
|
||||
* NAME
|
||||
* ase_lda_freeer_t - define a node destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*ase_lda_freeer_t) (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
void* dptr /* the pointer to data to free */,
|
||||
ase_size_t dlen /* the length of data to free */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.lda/ase_lda_comper_t
|
||||
* NAME
|
||||
* ase_lda_comper_t - define a data comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_comper_t type defines a key comparator that is called when
|
||||
* the list needs to compare data. A linear dynamic array is created with a
|
||||
* default comparator that performs bitwise comparison.
|
||||
*
|
||||
* The comparator should return 0 if the data are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*ase_lda_comper_t) (
|
||||
ase_lda_t* lda /* a linear dynamic array */,
|
||||
const void* dptr1 /* a data pointer */,
|
||||
ase_size_t dlen1 /* a data length */,
|
||||
const void* dptr2 /* a data pointer */,
|
||||
ase_size_t dlen2 /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.lda/ase_lda_keeper_t
|
||||
* NAME
|
||||
* ase_lda_keeper_t - define a value keeper
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_keeper_t type defines a value keeper that is called when
|
||||
* a value is retained in the context that it should be destroyed because
|
||||
* it is identical to a new value. Two values are identical if their beginning
|
||||
* pointers and their lengths are equal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*ase_lda_keeper_t) (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.lda/ase_lda_sizer_t
|
||||
* NAME
|
||||
* ase_lda_sizer_t - define an array size calculator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_sizer_t type defines an array size claculator that is called
|
||||
* when the array needs to be resized.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef ase_size_t (*ase_lda_sizer_t) (
|
||||
ase_lda_t* lda, /* a linear dynamic array */
|
||||
ase_size_t hint /* a sizing hint */
|
||||
);
|
||||
/******/
|
||||
|
||||
typedef ase_lda_walk_t (*ase_lda_walker_t) (
|
||||
ase_lda_t* lda /* a linear dynamic array */,
|
||||
ase_size_t index /* the index to the visited node */,
|
||||
void* arg /* user-defined data */
|
||||
);
|
||||
|
||||
/****s* ase.cmn.lda/ase_lda_t
|
||||
* NAME
|
||||
* ase_lda_t - define a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_lda_t
|
||||
{
|
||||
ase_mmgr_t* mmgr; /* memory manager */
|
||||
|
||||
ase_lda_copier_t copier; /* data copier */
|
||||
ase_lda_freeer_t freeer; /* data freeer */
|
||||
ase_lda_comper_t comper; /* data comparator */
|
||||
ase_lda_keeper_t keeper; /* data keeper */
|
||||
ase_lda_sizer_t sizer; /* size calculator */
|
||||
ase_byte_t scale; /* scale factor */
|
||||
ase_size_t size; /* the number of items */
|
||||
ase_size_t capa; /* capacity */
|
||||
ase_lda_node_t** node;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****s*
|
||||
* NAME
|
||||
* ase_lda_node_t - define a linear dynamic array node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_lda_node_t
|
||||
{
|
||||
void* dptr;
|
||||
ase_size_t dlen;
|
||||
};
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_open
|
||||
* NAME
|
||||
* ase_lda_open - create a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_lda_t* ase_lda_open (
|
||||
ase_mmgr_t* lda,
|
||||
ase_size_t ext,
|
||||
ase_size_t capa
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_close
|
||||
* NAME
|
||||
* ase_lda_close - destroy a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_close (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_init
|
||||
* NAME
|
||||
* ase_lda_init - initialize a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_lda_t* ase_lda_init (
|
||||
ase_lda_t* lda,
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t capa
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_fini
|
||||
* NAME
|
||||
* ase_lda_fini - deinitialize a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_fini (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_getxtn
|
||||
* NAME
|
||||
* ase_lda_getxtn - get the pointer to the extension
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_getxtn() function returns the pointer to the extension.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void* ase_lda_getxtn (
|
||||
ase_lda_t* lda /* a linear dynamic array */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_getmmgr
|
||||
* NAME
|
||||
* ase_lda_getmmgr - get the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_mmgr_t* ase_lda_getmmgr (
|
||||
ase_lda_t* lda /* a linear dynamic array */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_setmmgr
|
||||
* NAME
|
||||
* ase_lda_setmmgr - set the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_setmmgr (
|
||||
ase_lda_t* lda /* a linear dynamic array */,
|
||||
ase_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
int ase_lda_getscale (
|
||||
ase_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_setscale
|
||||
* NAME
|
||||
* ase_lda_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_setscale() function sets the scale factor of the length
|
||||
* of a key and a value. A scale factor determines the actual length of
|
||||
* a key and a value in bytes. A lda is created with a scale factor of 1.
|
||||
* The scale factor should be larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a lda is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_setscale (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_lda_copier_t ase_lda_getcopier (
|
||||
ase_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_setcopier
|
||||
* NAME
|
||||
* ase_lda_setcopier - specify how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier ASE_LDA_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_setcopier (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
ase_lda_copier_t copier /* an element copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_lda_freeer_t ase_lda_getfreeer (
|
||||
ase_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_setfreeer
|
||||
* NAME
|
||||
* ase_lda_setfreeer - specify how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_lda_setfreeer (
|
||||
ase_lda_t* lda /* a lda */,
|
||||
ase_lda_freeer_t freeer /* an element freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_lda_keeper_t ase_lda_getkeeper (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
|
||||
void ase_lda_setkeeper (
|
||||
ase_lda_t* lda,
|
||||
ase_lda_keeper_t keeper
|
||||
);
|
||||
|
||||
ase_lda_sizer_t ase_lda_getsizer (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
|
||||
void ase_lda_setsizer (
|
||||
ase_lda_t* lda,
|
||||
ase_lda_sizer_t sizer
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_getsize (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_getcapa (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
|
||||
ase_lda_t* ase_lda_setcapa (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t capa
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_search (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t pos,
|
||||
const void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_rsearch (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t pos,
|
||||
const void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_upsert (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t index,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_insert (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t index,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_size_t ase_lda_update (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t pos,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_delete
|
||||
* NAME
|
||||
* ase_lda_delete - delete data
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_delete() function deletes the as many data as the count
|
||||
* from the index.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_lda_delete() function returns the number of data deleted.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_lda_delete (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t index,
|
||||
ase_size_t count
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.lda/ase_lda_uplete
|
||||
* NAME
|
||||
* ase_lda_uplete - delete data node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_lda_uplete() function deletes data node without compaction.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_lda_uplete() function returns the number of data affected.
|
||||
*
|
||||
*/
|
||||
ase_size_t ase_lda_uplete (
|
||||
ase_lda_t* lda,
|
||||
ase_size_t index,
|
||||
ase_size_t count
|
||||
);
|
||||
/******/
|
||||
|
||||
void ase_lda_clear (
|
||||
ase_lda_t* lda
|
||||
);
|
||||
|
||||
void ase_lda_walk (
|
||||
ase_lda_t* lda,
|
||||
ase_lda_walker_t walker,
|
||||
void* arg
|
||||
);
|
||||
|
||||
void ase_lda_rwalk (
|
||||
ase_lda_t* lda,
|
||||
ase_lda_walker_t walker,
|
||||
void* arg
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,566 +0,0 @@
|
||||
/*
|
||||
* $Id: map.h 496 2008-12-15 09:56:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_MAP_H_
|
||||
#define _ASE_CMN_MAP_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****o* ase.cmn.map/hash map
|
||||
* DESCRIPTION
|
||||
* A hash map maintains buckets for key/value pairs with the same key hash
|
||||
* chained under the same bucket.
|
||||
*
|
||||
* #include <ase/cmn/map.h>
|
||||
*
|
||||
* EXAMPLES
|
||||
* void f (void)
|
||||
* {
|
||||
* }
|
||||
******
|
||||
*/
|
||||
|
||||
/* values that can be returned by ase_map_walker_t */
|
||||
enum ase_map_walk_t
|
||||
{
|
||||
ASE_MAP_WALK_STOP = 0,
|
||||
ASE_MAP_WALK_FORWARD = 1
|
||||
};
|
||||
|
||||
enum ase_map_id_t
|
||||
{
|
||||
ASE_MAP_KEY = 0,
|
||||
ASE_MAP_VAL = 1
|
||||
};
|
||||
|
||||
typedef struct ase_map_t ase_map_t;
|
||||
typedef struct ase_map_pair_t ase_map_pair_t;
|
||||
typedef enum ase_map_walk_t ase_map_walk_t;
|
||||
typedef enum ase_map_id_t ase_map_id_t;
|
||||
|
||||
/****b* ase.cmn.map/ase_map_copier_t
|
||||
* NAME
|
||||
* ase_map_copier_t - define a pair contruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*ase_map_copier_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
void* dptr /* the pointer to a key or a value */,
|
||||
ase_size_t dlen /* the length of a key or a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* ase.cmn.map/ase_map_freeer_t
|
||||
* NAME
|
||||
* ase_map_freeer_t - define a key/value destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*ase_map_freeer_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
void* dptr /* the pointer to a key or a value */,
|
||||
ase_size_t dlen /* the length of a key or a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/* key hasher */
|
||||
typedef ase_size_t (*ase_map_hasher_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the length of a key in bytes */
|
||||
);
|
||||
|
||||
/****t* ase.cmn.map/ase_map_comper_t
|
||||
* NAME
|
||||
* ase_map_comper_t - define a key comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_comper_t type defines a key comparator that is called when
|
||||
* the map needs to compare keys. A map is created with a default comparator
|
||||
* which performs bitwise comparison between two keys.
|
||||
*
|
||||
* The comparator should return 0 if the keys are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*ase_map_comper_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
const void* kptr1 /* the pointer to a key */,
|
||||
ase_size_t klen1 /* the length of a key */,
|
||||
const void* kptr2 /* the pointer to a key */,
|
||||
ase_size_t klen2 /* the length of a key */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.map/ase_map_keeper_t
|
||||
* NAME
|
||||
* ase_map_keeper_t - define a value keeper
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_keeper_t type defines a value keeper that is called when
|
||||
* a value is retained in the context that it should be destroyed because
|
||||
* it is identical to a new value. Two values are identical if their beginning
|
||||
* pointers and their lengths are equal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*ase_map_keeper_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.map/ase_map_sizer_t
|
||||
* NAME
|
||||
* ase_map_sizer_t - define a bucket size calculator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_sizer_T type defines a bucket size claculator that is called
|
||||
* when a map should resize the bucket. The current bucket size +1 is passed
|
||||
* as the hint.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef ase_size_t (*ase_map_sizer_t) (
|
||||
ase_map_t* map, /* a map */
|
||||
ase_size_t hint /* a sizing hint */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.map/ase_map_walker_t
|
||||
* NAME
|
||||
* ase_map_walker_t - define a pair visitor
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef ase_map_walk_t (*ase_map_walker_t) (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_pair_t* pair /* the pointer to a key/value pair */,
|
||||
void* arg /* the pointer to user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****s* ase.cmn.map/ase_map_pair_t
|
||||
* NAME
|
||||
* ase_map_pair_t - define a pair
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A pair is composed of a key and a value. It maintains pointers to the
|
||||
* beginning of a key and a value plus their length. The length is scaled
|
||||
* down with the scale factor specified in an owning map. Use macros defined
|
||||
* in the SEE ALSO section below to access individual fields.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ASE_MAP_KPTR, ASE_MAP_KLEN, ASE_MAP_VPTR, ASE_MAP_VLEN
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_map_pair_t
|
||||
{
|
||||
void* kptr; /* the pointer to a key */
|
||||
ase_size_t klen; /* the length of a key */
|
||||
void* vptr; /* the pointer to a value */
|
||||
ase_size_t vlen; /* the length of a value */
|
||||
ase_map_pair_t* next; /* the next pair under the same slot */
|
||||
};
|
||||
/*****/
|
||||
|
||||
/****s* ase.cmn.map/ase_map_t
|
||||
* NAME
|
||||
* ase_map_t - define a hash map
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_map_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_map_copier_t copier[2];
|
||||
ase_map_freeer_t freeer[2];
|
||||
ase_map_hasher_t hasher; /* key hasher */
|
||||
ase_map_comper_t comper; /* key comparator */
|
||||
ase_map_keeper_t keeper; /* value keeper */
|
||||
ase_map_sizer_t sizer; /* bucket capacity recalculator */
|
||||
ase_byte_t scale[2]; /* length scale */
|
||||
ase_byte_t factor; /* load factor */
|
||||
ase_byte_t filler0;
|
||||
ase_size_t size;
|
||||
ase_size_t capa;
|
||||
ase_size_t threshold;
|
||||
ase_map_pair_t** bucket;
|
||||
};
|
||||
/******/
|
||||
|
||||
#define ASE_MAP_COPIER_SIMPLE ((ase_map_copier_t)1)
|
||||
#define ASE_MAP_COPIER_INLINE ((ase_map_copier_t)2)
|
||||
|
||||
/****d* ase.cmn.map/ASE_MAP_SIZE
|
||||
* NAME
|
||||
* ASE_MAP_SIZE - get the number of pairs
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ASE_MAP_SIZE() macro returns the number of pairs in a map.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
#define ASE_MAP_SIZE(m) ((m)->size)
|
||||
/*****/
|
||||
|
||||
/****d* ase.cmn.map/ASE_MAP_CAPA
|
||||
* NAME
|
||||
* ASE_MAP_CAPA - get the capacity of a map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ASE_MAP_CAPA() macro returns the maximum number of pairs a map can hold.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
#define ASE_MAP_CAPA(m) ((m)->capa)
|
||||
/*****/
|
||||
|
||||
#define ASE_MAP_MMGR(m) ((m)->mmgr)
|
||||
#define ASE_MAP_XTN(m) ((void*)(((ase_map_t*)m) + 1))
|
||||
|
||||
#define ASE_MAP_KCOPIER(m) ((m)->copier[ASE_MAP_KEY])
|
||||
#define ASE_MAP_VCOPIER(m) ((m)->copier[ASE_MAP_VAL])
|
||||
#define ASE_MAP_KFREEER(m) ((m)->freeer[ASE_MAP_KEY])
|
||||
#define ASE_MAP_VFREEER(m) ((m)->freeer[ASE_MAP_VAL])
|
||||
#define ASE_MAP_HASHER(m) ((m)->hasher)
|
||||
#define ASE_MAP_COMPER(m) ((m)->comper)
|
||||
#define ASE_MAP_KEEPER(m) ((m)->keeper)
|
||||
#define ASE_MAP_SIZER(m) ((m)->sizer)
|
||||
|
||||
#define ASE_MAP_FACTOR(m) ((m)->factor)
|
||||
#define ASE_MAP_KSCALE(m) ((m)->scale[ASE_MAP_KEY])
|
||||
#define ASE_MAP_VSCALE(m) ((m)->scale[ASE_MAP_VAL])
|
||||
|
||||
#define ASE_MAP_KPTR(p) ((p)->kptr)
|
||||
#define ASE_MAP_KLEN(p) ((p)->klen)
|
||||
#define ASE_MAP_VPTR(p) ((p)->vptr)
|
||||
#define ASE_MAP_VLEN(p) ((p)->vlen)
|
||||
#define ASE_MAP_NEXT(p) ((p)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.cmn.map/ase_map_open
|
||||
* NAME
|
||||
* ase_map_open - creates a hash map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_open() function creates a hash map with a dynamic array
|
||||
* bucket and a list of values chained. The initial capacity should be larger
|
||||
* than 0. The load factor should be between 0 and 100 inclusive and the load
|
||||
* factor of 0 disables bucket resizing. If you need extra space associated
|
||||
* with a map, you may pass a non-zero value as the second parameter.
|
||||
* The ASE_MAP_XTN() macro and the ase_map_getxtn() function
|
||||
* return the pointer to the beginning of the extension.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_map_open() function returns an ase_map_t pointer on success and
|
||||
* ASE_NULL on failure.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ASE_MAP_XTN, ase_map_getxtn
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_t* ase_map_open (
|
||||
ase_mmgr_t* mmgr /* a memory manager */,
|
||||
ase_size_t ext /* extension size in bytes */,
|
||||
ase_size_t capa /* initial capacity */,
|
||||
int factor /* load factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* ase.cmn.map/ase_map_close
|
||||
* NAME
|
||||
* ase_map_close - destroy a hash map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_close() function destroys a hash map.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_close (
|
||||
ase_map_t* map /* a map */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_map_t* ase_map_init (
|
||||
ase_map_t* map,
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t capa,
|
||||
int factor
|
||||
);
|
||||
|
||||
void ase_map_fini (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
void* ase_map_getxtn (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
ase_mmgr_t* ase_map_getmmgr (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
void ase_map_setmmgr (
|
||||
ase_map_t* map,
|
||||
ase_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/* get the number of key/value pairs in a map */
|
||||
ase_size_t ase_map_getsize (
|
||||
ase_map_t* map /* a map */
|
||||
);
|
||||
|
||||
ase_size_t ase_map_getcapa (
|
||||
ase_map_t* map /* a map */
|
||||
);
|
||||
|
||||
int ase_map_getscale (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setscale
|
||||
* NAME
|
||||
* ase_map_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_setscale() function sets the scale factor of the length
|
||||
* of a key and a value. A scale factor determines the actual length of
|
||||
* a key and a value in bytes. A map is created with a scale factor of 1.
|
||||
* The scale factor should be larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a map is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_setscale (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_map_copier_t ase_map_getcopier (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setcopier
|
||||
* NAME
|
||||
* ase_map_setcopier - specify how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier ASE_MAP_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_setcopier (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_copier_t copier /* an element copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_map_freeer_t ase_map_getfreeer (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setfreeer
|
||||
* NAME
|
||||
* ase_map_setfreeer - specify how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_setfreeer (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_id_t id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_freeer_t freeer /* an element freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
ase_map_hasher_t ase_map_gethasher (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
void ase_map_sethasher (
|
||||
ase_map_t* map,
|
||||
ase_map_hasher_t hasher
|
||||
);
|
||||
|
||||
ase_map_comper_t ase_map_getcomper (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
void ase_map_setcomper (
|
||||
ase_map_t* map,
|
||||
ase_map_comper_t comper
|
||||
);
|
||||
|
||||
ase_map_keeper_t ase_map_getkeeper (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
void ase_map_setkeeper (
|
||||
ase_map_t* map,
|
||||
ase_map_keeper_t keeper
|
||||
);
|
||||
|
||||
ase_map_sizer_t ase_map_getsizer (
|
||||
ase_map_t* map
|
||||
);
|
||||
|
||||
/* the sizer function is passed a map object and map->capa + 1 */
|
||||
void ase_map_setsizer (
|
||||
ase_map_t* map,
|
||||
ase_map_sizer_t sizer
|
||||
);
|
||||
|
||||
int ase_map_put (
|
||||
ase_map_t* map,
|
||||
void* kptr,
|
||||
ase_size_t klen,
|
||||
void* vptr,
|
||||
ase_size_t vlen,
|
||||
ase_map_pair_t** px
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_search
|
||||
* NAME
|
||||
* ase_map_search - find a pair with a matching key
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_search() function searches a map to find a pair with a
|
||||
* matching key. It returns the pointer to the pair found. If it fails
|
||||
* to find one, it returns ASE_NULL.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_map_search() function returns the pointer to the pair with a
|
||||
* maching key, and ASE_NULL if no match is found.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_search (
|
||||
ase_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the size of the key in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.map/ase_map_upsert
|
||||
* NAME
|
||||
* ase_map_upsert - update an existing pair or inesrt a new pair
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_upsert() function searches a map for the pair with a matching
|
||||
* key. If one is found, it updates the pair. Otherwise, it inserts a new
|
||||
* pair with a key and a value. It returns the pointer to the pair updated
|
||||
* or inserted.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_map_upsert() function returns a pointer to the updated or inserted
|
||||
* pair on success, and ASE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_upsert (
|
||||
ase_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.map/ase_map_insert
|
||||
* NAME
|
||||
* ase_map_insert - insert a new pair with a key and a value
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_insert() function inserts a new pair with the key and the value
|
||||
* given. If there exists a pair with the key given, the function returns
|
||||
* ASE_NULL without channging the value.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_map_insert() function returns a pointer to the pair created on
|
||||
* success, and ASE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_insert (
|
||||
ase_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/* update the value of a existing pair with a matching key */
|
||||
ase_map_pair_t* ase_map_update (
|
||||
ase_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
|
||||
/* delete a pair with a matching key */
|
||||
int ase_map_delete (
|
||||
ase_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the size of the key in bytes */
|
||||
);
|
||||
|
||||
/* clear a map */
|
||||
void ase_map_clear (
|
||||
ase_map_t* map /* a map */
|
||||
);
|
||||
|
||||
/* traverse a map */
|
||||
void ase_map_walk (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_walker_t walker /* the pointer to the function for each pair */,
|
||||
void* arg /* a pointer to user-specific data */
|
||||
);
|
||||
|
||||
/* get the pointer to the first pair in the map. */
|
||||
ase_map_pair_t* ase_map_getfirstpair (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_size_t* buckno
|
||||
);
|
||||
|
||||
/* get the pointer to the next pair in the map. */
|
||||
ase_map_pair_t* ase_map_getnextpair (
|
||||
ase_map_t* map /* a map */,
|
||||
ase_map_pair_t* pair,
|
||||
ase_size_t* buckno
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* $Id: getopt.h 290 2008-07-27 06:16:54Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_OPT_H_
|
||||
#define _ASE_CMN_OPT_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
typedef struct ase_opt_t ase_opt_t;
|
||||
typedef struct ase_opt_lng_t ase_opt_lng_t;
|
||||
|
||||
struct ase_opt_lng_t
|
||||
{
|
||||
const ase_char_t* str;
|
||||
ase_cint_t val;
|
||||
};
|
||||
|
||||
struct ase_opt_t
|
||||
{
|
||||
/* input */
|
||||
const ase_char_t* str; /* option string */
|
||||
ase_opt_lng_t* lng; /* long options */
|
||||
|
||||
/* output */
|
||||
ase_cint_t opt; /* character checked for validity */
|
||||
ase_char_t* arg; /* argument associated with an option */
|
||||
|
||||
/* output */
|
||||
const ase_char_t* lngopt;
|
||||
|
||||
/* input + output */
|
||||
int ind; /* index into parent argv vector */
|
||||
|
||||
/* input + output - internal*/
|
||||
ase_char_t* cur;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.cmn.opt/ase_getopt
|
||||
* NAME
|
||||
* ase_getopt - parse command line options
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_cint_t ase_getopt (
|
||||
int argc /* argument count */,
|
||||
ase_char_t* const* argv /* argument array */,
|
||||
ase_opt_t* opt /* option configuration */
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* $Id: rex.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_REX_H_
|
||||
#define _ASE_CMN_REX_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/*
|
||||
* Regular Esseression Syntax
|
||||
* A regular expression is zero or more branches, separated by '|'.
|
||||
* ......
|
||||
* ......
|
||||
*
|
||||
* Compiled form of a regular expression:
|
||||
*
|
||||
* | expression |
|
||||
* | header | branch | branch | branch |
|
||||
* | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd |
|
||||
*
|
||||
* nb: the number of branches
|
||||
* el: the length of a expression including the length of nb and el
|
||||
* na: the number of atoms
|
||||
* bl: the length of a branch including the length of na and bl
|
||||
* cmd: The command and repetition info encoded together.
|
||||
* Some commands require an argument to follow them but some other don't.
|
||||
* It is encoded as follows:
|
||||
*
|
||||
* Subexpressions can be nested by having the command "GROUP"
|
||||
* and a subexpression as its argument.
|
||||
*
|
||||
* Examples:
|
||||
* a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c|
|
||||
* ab|xy -> |2|10|4|ORD_CHAR(no bound)|a|ORD_CHAR(no bound)|b|4|ORD_CHAR(no bound)|x|ORD_CHAR(no bound)|y|
|
||||
*/
|
||||
|
||||
#define ASE_REX_NA(code) (*(ase_size_t*)(code))
|
||||
|
||||
#define ASE_REX_LEN(code) \
|
||||
(*(ase_size_t*)((ase_byte_t*)(code)+ASE_SIZEOF(ase_size_t)))
|
||||
|
||||
enum ase_rex_option_t
|
||||
{
|
||||
ASE_REX_IGNORECASE = (1 << 0)
|
||||
};
|
||||
|
||||
enum ase_rex_errnum_t
|
||||
{
|
||||
ASE_REX_ENOERR = 0,
|
||||
ASE_REX_ENOMEM,
|
||||
ASE_REX_ERECUR, /* recursion too deep */
|
||||
ASE_REX_ERPAREN, /* a right parenthesis is expected */
|
||||
ASE_REX_ERBRACKET, /* a right bracket is expected */
|
||||
ASE_REX_ERBRACE, /* a right brace is expected */
|
||||
ASE_REX_EUNBALPAR, /* unbalanced parenthesis */
|
||||
ASE_REX_ECOLON, /* a colon is expected */
|
||||
ASE_REX_ECRANGE, /* invalid character range */
|
||||
ASE_REX_ECCLASS, /* invalid character class */
|
||||
ASE_REX_EBRANGE, /* invalid boundary range */
|
||||
ASE_REX_EEND, /* unexpected end of the pattern */
|
||||
ASE_REX_EGARBAGE /* garbage after the pattern */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* ase_buildrex (
|
||||
ase_mmgr_t* mmgr, ase_size_t depth,
|
||||
const ase_char_t* ptn, ase_size_t len, int* errnum);
|
||||
|
||||
int ase_matchrex (
|
||||
ase_mmgr_t* mmgr, ase_ccls_t* ccls, ase_size_t depth,
|
||||
void* code, int option,
|
||||
const ase_char_t* str, ase_size_t len,
|
||||
const ase_char_t** match_ptr, ase_size_t* match_len, int* errnum);
|
||||
|
||||
void ase_freerex (ase_mmgr_t* mmgr, void* code);
|
||||
|
||||
ase_bool_t ase_isemptyrex (void* code);
|
||||
|
||||
#if 0
|
||||
void ase_dprintrex (ase_rex_t* rex, void* rex);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* $Id: sio.h,v 1.29 2005/12/26 05:38:24 bacon Ease $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_SIO_H_
|
||||
#define _ASE_CMN_SIO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
#include <ase/cmn/fio.h>
|
||||
#include <ase/cmn/tio.h>
|
||||
|
||||
enum ase_sio_open_flag_t
|
||||
{
|
||||
ASE_SIO_HANDLE = ASE_FIO_HANDLE,
|
||||
|
||||
ASE_SIO_READ = ASE_FIO_READ,
|
||||
ASE_SIO_WRITE = ASE_FIO_WRITE,
|
||||
ASE_SIO_APPEND = ASE_FIO_APPEND,
|
||||
|
||||
ASE_SIO_CREATE = ASE_FIO_CREATE,
|
||||
ASE_SIO_TRUNCATE = ASE_FIO_TRUNCATE,
|
||||
ASE_SIO_EXCLUSIVE = ASE_FIO_EXCLUSIVE,
|
||||
ASE_SIO_SYNC = ASE_FIO_SYNC,
|
||||
|
||||
ASE_SIO_NOSHRD = ASE_FIO_NOSHRD,
|
||||
ASE_SIO_NOSHWR = ASE_FIO_NOSHWR
|
||||
};
|
||||
|
||||
typedef ase_fio_off_t ase_sio_off_t;
|
||||
typedef ase_fio_hnd_t ase_sio_hnd_t;
|
||||
|
||||
typedef struct ase_sio_t ase_sio_t;
|
||||
|
||||
struct ase_sio_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_fio_t fio;
|
||||
ase_tio_t tio;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ase_sio_t* ase_sio_in;
|
||||
extern ase_sio_t* ase_sio_out;
|
||||
extern ase_sio_t* ase_sio_err;
|
||||
|
||||
ase_sio_t* ase_sio_open (
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t ext,
|
||||
const ase_char_t* file,
|
||||
int flags
|
||||
);
|
||||
|
||||
void ase_sio_close (
|
||||
ase_sio_t* sio
|
||||
);
|
||||
|
||||
ase_sio_t* ase_sio_init (
|
||||
ase_sio_t* sio,
|
||||
ase_mmgr_t* mmgr,
|
||||
const ase_char_t* file,
|
||||
int flags
|
||||
);
|
||||
|
||||
void ase_sio_fini (
|
||||
ase_sio_t* sio
|
||||
);
|
||||
|
||||
ase_fio_hnd_t ase_sio_gethandle (
|
||||
ase_sio_t* sio
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_flush (
|
||||
ase_sio_t* sio
|
||||
);
|
||||
|
||||
void ase_sio_purge (
|
||||
ase_sio_t* sio
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_getc (
|
||||
ase_sio_t* sio,
|
||||
ase_char_t* c
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_gets (
|
||||
ase_sio_t* sio,
|
||||
ase_char_t* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_getsx (
|
||||
ase_sio_t* sio,
|
||||
ase_char_t* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_getstr (
|
||||
ase_sio_t* sio,
|
||||
ase_str_t* buf
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_putc (
|
||||
ase_sio_t* sio,
|
||||
ase_char_t c
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_puts (
|
||||
ase_sio_t* sio,
|
||||
const ase_char_t* str
|
||||
);
|
||||
|
||||
ase_ssize_t ase_sio_putsx (
|
||||
ase_sio_t* sio,
|
||||
const ase_char_t* str,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
#if 0
|
||||
ase_ssize_t ase_sio_putsn (ase_sio_t* sio, ...);
|
||||
ase_ssize_t ase_sio_putsxn (ase_sio_t* sio, ...);
|
||||
ase_ssize_t ase_sio_putsv (ase_sio_t* sio, ase_va_list ap);
|
||||
ase_ssize_t ase_sio_putsxv (ase_sio_t* sio, ase_va_list ap);
|
||||
|
||||
/* WARNING:
|
||||
* getpos may not return the desired postion because of the buffering
|
||||
*/
|
||||
int ase_sio_getpos (ase_sio_t* sio, ase_sio_off_t* pos);
|
||||
int ase_sio_setpos (ase_sio_t* sio, ase_sio_off_t pos);
|
||||
int ase_sio_rewind (ase_sio_t* sio);
|
||||
int ase_sio_movetoend (ase_sio_t* sio);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,582 +0,0 @@
|
||||
/*
|
||||
* $Id: sll.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_SLL_H_
|
||||
#define _ASE_CMN_SLL_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****t* ase.cmn.sll/ase_sll_walk_t
|
||||
* NAME
|
||||
* ase_sll_walk_t - define return values for ase_sll_walker_t
|
||||
*
|
||||
* SEE ALSO
|
||||
* ase_sll_walk, ase_sll_walker_t
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum ase_sll_walk_t
|
||||
{
|
||||
ASE_SLL_WALK_STOP = 0,
|
||||
ASE_SLL_WALK_FORWARD = 1
|
||||
};
|
||||
/******/
|
||||
|
||||
typedef struct ase_sll_t ase_sll_t;
|
||||
typedef struct ase_sll_node_t ase_sll_node_t;
|
||||
typedef enum ase_sll_walk_t ase_sll_walk_t;
|
||||
|
||||
/****b* ase.cmn.sll/ase_sll_copier_t
|
||||
* NAME
|
||||
* ase_sll_copier_t - define a node contruction callback
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_copier_t defines a callback function for node construction.
|
||||
* A node is contructed when a user adds data to a list. The user can
|
||||
* define how the data to add can be maintained in the list. A singly
|
||||
* linked list not specified with any copiers stores the data pointer and
|
||||
* the data length into a node. A special copier ASE_SLL_COPIER_INLINE copies
|
||||
* the contents of the data a user provided into the node. You can use the
|
||||
* ase_sll_setcopier() function to change the copier.
|
||||
*
|
||||
* A copier should return the pointer to the copied data. If it fails to copy
|
||||
* data, it may return ASE_NULL. You need to set a proper freeer to free up
|
||||
* memory allocated for copy.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ase_sll_setcopier, ase_sll_getcopier, ASE_SLL_COPIER
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*ase_sll_copier_t) (
|
||||
ase_sll_t* sll /* a map */,
|
||||
void* dptr /* the pointer to data to copy */,
|
||||
ase_size_t dlen /* the length of data to copy */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* ase.cmn.sll/ase_sll_freeer_t
|
||||
* NAME
|
||||
* ase_sll_freeer_t - define a node destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*ase_sll_freeer_t) (
|
||||
ase_sll_t* sll /* a map */,
|
||||
void* dptr /* the pointer to data to free */,
|
||||
ase_size_t dlen /* the length of data to free */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* ase.cmn.sll/ase_sll_comper_t
|
||||
* NAME
|
||||
* ase_sll_comper_t - define a data comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_comper_t type defines a key comparator that is called when
|
||||
* the list needs to compare data. A singly linked list is created with a
|
||||
* default comparator that performs bitwise comparison.
|
||||
*
|
||||
* The comparator should return 0 if the data are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*ase_sll_comper_t) (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
const void* dptr1 /* a data pointer */,
|
||||
ase_size_t dlen1 /* a data length */,
|
||||
const void* dptr2 /* a data pointer */,
|
||||
ase_size_t dlen2 /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* ase.cmn.sll/ase_sll_walker_t
|
||||
* NAME
|
||||
* ase_sll_walker_t - define a list traversal callback for each node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_walk() calls a callback function of the type ase_sll_walker_t
|
||||
* for each node until it returns ASE_SLL_WALK_STOP. The walker should return
|
||||
* ASE_SLL_WALK_FORWARD to let ase_sll_walk() continue visiting the next node.
|
||||
* The third parameter to ase_sll_walk() is passed to the walker as the third
|
||||
* parameter.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ase_sll_walk, ase_sll_walk_t
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef ase_sll_walk_t (*ase_sll_walker_t) (
|
||||
ase_sll_t* sll /* a map */,
|
||||
ase_sll_node_t* node /* a visited node */,
|
||||
void* arg /* user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****s* ase.cmn.sll/ase_sll_t
|
||||
* NAME
|
||||
* ase_sll_t - define a singly linked list
|
||||
*
|
||||
* DESCRPTION
|
||||
* The ase_sll_t type defines a singly lnked list.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_sll_t
|
||||
{
|
||||
ase_mmgr_t* mmgr; /* memory manager */
|
||||
|
||||
ase_sll_copier_t copier; /* data copier */
|
||||
ase_sll_freeer_t freeer; /* data freeer */
|
||||
ase_sll_comper_t comper; /* data comparator */
|
||||
ase_byte_t scale; /* scale factor */
|
||||
|
||||
ase_size_t size; /* the number of nodes */
|
||||
ase_sll_node_t* head; /* the head node */
|
||||
ase_sll_node_t* tail; /* the tail node */
|
||||
};
|
||||
/******/
|
||||
|
||||
/****s* ase.cmn.sll/ase_sll_node_t
|
||||
* NAME
|
||||
* ase_sll_node_t - define a list node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_node_t type defines a list node containing a data pointer and
|
||||
* and data length.
|
||||
*
|
||||
* SEE ALSO
|
||||
* ASE_SLL_DPTR, ASE_SLL_DLEN, ASE_SLL_NEXT
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_sll_node_t
|
||||
{
|
||||
void* dptr; /* the pointer to data */
|
||||
ase_size_t dlen; /* the length of data */
|
||||
ase_sll_node_t* next; /* the pointer to the next node */
|
||||
};
|
||||
/******/
|
||||
|
||||
#define ASE_SLL_COPIER_SIMPLE ((ase_sll_copier_t)1)
|
||||
#define ASE_SLL_COPIER_INLINE ((ase_sll_copier_t)2)
|
||||
|
||||
#define ASE_SLL_MMGR(sll) ((sll)->mmgr)
|
||||
#define ASE_SLL_XTN(s) ((void*)(((ase_sll_t*)s) + 1))
|
||||
#define ASE_SLL_COPIER(sll) ((sll)->copier)
|
||||
#define ASE_SLL_FREEER(sll) ((sll)->freeer)
|
||||
#define ASE_SLL_COMPER(sll) ((sll)->comper)
|
||||
|
||||
#define ASE_SLL_HEAD(sll) ((sll)->head)
|
||||
#define ASE_SLL_TAIL(sll) ((sll)->tail)
|
||||
#define ASE_SLL_SIZE(sll) ((sll)->size)
|
||||
#define ASE_SLL_SCALE(sll) ((sll)->scale)
|
||||
|
||||
#define ASE_SLL_DPTR(node) ((node)->dptr)
|
||||
#define ASE_SLL_DLEN(node) ((node)->dlen)
|
||||
#define ASE_SLL_NEXT(node) ((node)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_open
|
||||
* NAME
|
||||
* ase_sll_open - create a singly linked list with extension area
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_open() function creates an empty singly linked list.
|
||||
* If the memory manager mmgr is ASE_NULL, the function gets the default
|
||||
* memory manager with ASE_MMGR_GETMMGR() and uses it if it is not ASE_NULL.
|
||||
* The extension area is allocated when the positive extension size extension
|
||||
* is specified. It calls the extension initialization function initializer
|
||||
* after initializing the main area. The extension initializer is passed
|
||||
* the pointer to the singly linked list created.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_sll_open() function returns the pointer to a new singly linked
|
||||
* list on success and ASE_NULL on failure.
|
||||
*
|
||||
* NOTES
|
||||
* In the debug build, it fails an assertion if ASE_MMGR_GETMMGR() returns
|
||||
* ASE_NULL when ASE_NULL is passed as the first parameter. In the release
|
||||
* build, it returns ASE_NULL if such a thing happens.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_t* ase_sll_open (
|
||||
ase_mmgr_t* mmgr /* memory manager */ ,
|
||||
ase_size_t ext /* size of extension area in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_close
|
||||
* NAME
|
||||
* ase_sll_close - destroy a singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_close() function destroys a singly linked list freeing up
|
||||
* the memory.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_close (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_init
|
||||
* NAME
|
||||
* ase_sll_init - initialize a singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_init() function initializes a singly linked list. The memory
|
||||
* should be allocated by a caller and be passed to it. The caller may declare
|
||||
* a static variable of the ase_sll_t type and pass its address. A memory
|
||||
* manager still needs to be passed for node manipulation later.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_sll_init() function returns the first parameter on success and
|
||||
* ASE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_t* ase_sll_init (
|
||||
ase_sll_t* sll /* an uninitialized singly linked list */,
|
||||
ase_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_fini
|
||||
* NAME
|
||||
* ase_sll_init - deinitialize a singly linked list
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_fini (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getxtn
|
||||
* NAME
|
||||
* ase_sll_getxtn - get the pointer to the extension
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_getxtn() function returns the pointer to the extension.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void* ase_sll_getxtn (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getmmgr
|
||||
* NAME
|
||||
* ase_sll_getmmgr - get the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_mmgr_t* ase_sll_getmmgr (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_setmmgr
|
||||
* NAME
|
||||
* ase_sll_setmmgr - set the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_setmmgr (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getsize
|
||||
* NAME
|
||||
* ase_sll_getsize - get the number of nodes
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_getsize() function returns the number of the data nodes held
|
||||
* in a singly linked list.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_sll_getsize (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getscale
|
||||
* NAME
|
||||
* ase_sll_getscale - get the scale factor
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_sll_getscale (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_setscale
|
||||
* NAME
|
||||
* ase_sll_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_setscale() function sets the scale factor of the data length.
|
||||
* A scale factor determines the actual length of data in bytes. A singly
|
||||
* linked list created with a scale factor of 1. The scale factor should be
|
||||
* larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a sll is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_setscale (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getcopier
|
||||
* NAME
|
||||
* ase_sll_getfreeer - get the data copier
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_copier_t ase_sll_getcopier (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_setcopier
|
||||
* NAME
|
||||
* ase_sll_setcopier - set a data copier
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier ASE_SLL_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_setcopier (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_copier_t copier /* a data copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getfreeer
|
||||
* NAME
|
||||
* ase_sll_getfreeer - get the data freeer
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_freeer_t ase_sll_getfreeer (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_setfreeer
|
||||
* NAME
|
||||
* ase_sll_setfreeer - set a data freeer
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_setfreeer (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_freeer_t freeer /* a data freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_getcomper
|
||||
* NAME
|
||||
* ase_sll_getcomper - get the data comparator
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_comper_t ase_sll_getcomper (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_setcomper
|
||||
* NAME
|
||||
* ase_sll_setcomper - set the data comparator
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_setcomper (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_comper_t comper /* a comparator */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_gethead
|
||||
* NAME
|
||||
* ase_sll_gethead - get the head node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_node_t* ase_sll_gethead (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_gettail
|
||||
* NAME
|
||||
* ase_sll_gettail - get the tail node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_node_t* ase_sll_gettail (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_search
|
||||
* NAME
|
||||
* ase_sll_search - find a node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_search() function traverses a list to find a node containing
|
||||
* the same value as the the data pointer and length. The traversal begins
|
||||
* from the next node of the positional node. If the positional node is
|
||||
* ASE_NULL, the traversal begins from the head node.
|
||||
*
|
||||
* RETURN
|
||||
* The pointer to the node found. Otherwise, ASE_NULL.
|
||||
*
|
||||
* NOTES
|
||||
* No reverse search is provided because a reverse traversal can not be
|
||||
* achieved efficiently.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_node_t* ase_sll_search (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_node_t* pos /* a positional node */,
|
||||
const void* dptr /* a data pointer */,
|
||||
ase_size_t dlen /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_insert
|
||||
* NAME
|
||||
* ase_sll_insert - insert data to a new node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* There is performance penalty unless the positional node is neither
|
||||
* the head node nor ASE_NULL. You should consider a different data
|
||||
* structure such as a doubly linked list if you need to insert data
|
||||
* into a random position.
|
||||
*
|
||||
* RETURN
|
||||
* The pointer to a new node on success and ASE_NULL on failure:w
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_sll_node_t* ase_sll_insert (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_node_t* pos /* a node before which a new node is inserted */,
|
||||
void* dptr /* the pointer to the data */,
|
||||
ase_size_t dlen /* the length of the data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_delete
|
||||
* NAME
|
||||
* ase_sll_delete - delete a node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_delete() function deletes a node.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_delete (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_node_t* pos /* a node to delete */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_clear
|
||||
* NAME
|
||||
* ase_sll_clear - delete all nodes
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_sll_clear() function empties a singly linked list by deletinng
|
||||
* all the nodes.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_clear (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_sll_node_t* ase_sll_pushhead (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
ase_sll_node_t* ase_sll_pushtail (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
void* dptr,
|
||||
ase_size_t dlen
|
||||
);
|
||||
|
||||
|
||||
void ase_sll_pophead (
|
||||
ase_sll_t* sll
|
||||
);
|
||||
|
||||
void ase_sll_poptail (
|
||||
ase_sll_t* sll
|
||||
);
|
||||
|
||||
/****f* ase.cmn.sll/ase_sll_walk
|
||||
* NAME
|
||||
* ase_sll_walk - traverse s singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A singly linked list allows uni-directional in-order traversal.
|
||||
* The ase_sll_walk() function traverses a singly linkked list from its
|
||||
* head node down to its tail node as long as the walker function returns
|
||||
* ASE_SLL_WALK_FORWARD. A walker can return ASE_SLL_WALK_STOP to cause
|
||||
* immediate stop of traversal.
|
||||
*
|
||||
* For each node, the walker function is called and it is passed three
|
||||
* parameters: the singly linked list, the visiting node, and the
|
||||
* user-defined data passed as the third parameter in a call to the
|
||||
* ase_sll_walk() function.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_sll_walk (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_walker_t walker /* a user-defined walker function */,
|
||||
void* arg /* the pointer to user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,476 +0,0 @@
|
||||
/*
|
||||
* $Id: str.h 496 2008-12-15 09:56:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_STR_H_
|
||||
#define _ASE_CMN_STR_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****o* ase.cmn.str/string
|
||||
* DESCRIPTION
|
||||
* <ase/cmn/str.h> defines various functions, types, macros to manipulate
|
||||
* strings.
|
||||
*
|
||||
* The ase_cstr_t type and the ase_xstr_t defined in ase/types.h helps you
|
||||
* dealing with a string pointer and length.
|
||||
*
|
||||
* #include <ase/cmn/str.h>
|
||||
*
|
||||
* EXAMPLES
|
||||
* void f (void)
|
||||
* {
|
||||
* }
|
||||
******
|
||||
*/
|
||||
|
||||
|
||||
#define ASE_STR_LEN(s) ((s)->len)
|
||||
#define ASE_STR_PTR(s) ((s)->ptr)
|
||||
#define ASE_STR_CAPA(s) ((s)->capa)
|
||||
#define ASE_STR_CHAR(s,idx) ((s)->ptr[idx])
|
||||
|
||||
#define ASE_STR_MMGR(s) ((s)->mmgr)
|
||||
#define ASE_STR_XTN(s) ((void*)(((ase_str_t*)s) + 1))
|
||||
#define ASE_STR_SIZER(s) ((s)->sizer)
|
||||
|
||||
typedef struct ase_str_t ase_str_t;
|
||||
typedef ase_size_t (*ase_str_sizer_t) (ase_str_t* data, ase_size_t hint);
|
||||
|
||||
struct ase_str_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_str_sizer_t sizer;
|
||||
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
ase_size_t capa;
|
||||
};
|
||||
|
||||
/* int ase_chartonum (ase_char_t c, int base) */
|
||||
#define ASE_CHARTONUM(c,base) \
|
||||
((c>=ASE_T('0') && c<=ASE_T('9'))? ((c-ASE_T('0')<base)? (c-ASE_T('0')): base): \
|
||||
(c>=ASE_T('A') && c<=ASE_T('Z'))? ((c-ASE_T('A')+10<base)? (c-ASE_T('A')+10): base): \
|
||||
(c>=ASE_T('a') && c<=ASE_T('z'))? ((c-ASE_T('a')+10<base)? (c-ASE_T('a')+10): base): base)
|
||||
|
||||
/* ase_strtonum (const ase_char_t* nptr, ase_char_t** endptr, int base) */
|
||||
#define ASE_STRTONUM(value,nptr,endptr,base) \
|
||||
{ \
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const ase_char_t* __ston_ptr = nptr; \
|
||||
for (;;) { \
|
||||
ase_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == ASE_T(' ') || \
|
||||
__ston_c == ASE_T('\t')) { __ston_ptr++; continue; } \
|
||||
if (__ston_c == ASE_T('-')) { __ston_f++; __ston_ptr++; } \
|
||||
if (__ston_c == ASE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = ASE_CHARTONUM(*__ston_ptr, base)) < base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
} \
|
||||
if (endptr != ASE_NULL) *((const ase_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
}
|
||||
|
||||
/* ase_strxtonum (const ase_char_t* nptr, ase_size_t len, ase_char_char** endptr, int base) */
|
||||
#define ASE_STRXTONUM(value,nptr,len,endptr,base) \
|
||||
{ \
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const ase_char_t* __ston_ptr = nptr; \
|
||||
const ase_char_t* __ston_end = __ston_ptr + len; \
|
||||
value = 0; \
|
||||
while (__ston_ptr < __ston_end) { \
|
||||
ase_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == ASE_T(' ') || __ston_c == ASE_T('\t')) { \
|
||||
__ston_ptr++; continue; \
|
||||
} \
|
||||
if (__ston_c == ASE_T('-')) { __ston_f++; __ston_ptr++; } \
|
||||
if (__ston_c == ASE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && \
|
||||
(__ston_v = ASE_CHARTONUM(*__ston_ptr, base)) != base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
} \
|
||||
if (endptr != ASE_NULL) *((const ase_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* basic string functions
|
||||
*/
|
||||
ase_size_t ase_strlen (const ase_char_t* str);
|
||||
ase_size_t ase_strbytes (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_strxcat (
|
||||
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str);
|
||||
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_strxcmp (const ase_char_t* s1, ase_size_t len1, 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);
|
||||
|
||||
/****f* ase.cmn.str/ase_strxncasecmp
|
||||
* NAME
|
||||
* ase_strxncasecmp - compare strings ignoring case
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_strxncasecmp() function compares characters at the same position
|
||||
* in each string after converting them to the same case temporarily.
|
||||
* It accepts two strings and a character class handler. A string is
|
||||
* represented by its beginning pointer and length. You can write your own
|
||||
* character class handler or use ASE_CCLS_GETDFL() to get the default
|
||||
* character class handler.
|
||||
*
|
||||
* For two strings to be equal, they need to have the same length and all
|
||||
* characters in the first string should be equal to their counterpart in the
|
||||
* second string.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_strxncasecmp() returns 0 if two strings are equal, a positive
|
||||
* number if the first string is larger, -1 if the second string is larger.
|
||||
*
|
||||
* EXAMPLES
|
||||
* ase_strxncasecmp (ASE_T("foo"), 3, ASE_T("FoO"), 3, ASE_CCLS_GETDFL());
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_strxncasecmp (
|
||||
const ase_char_t* s1 /* the pointer to the first string */,
|
||||
ase_size_t len1 /* the length of the first string */,
|
||||
const ase_char_t* s2 /* the pointer to the second string */,
|
||||
ase_size_t len2 /* the length of the second string */,
|
||||
ase_ccls_t* ccls /* character class handler */
|
||||
);
|
||||
/******/
|
||||
|
||||
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_strstr (const ase_char_t* str, const ase_char_t* sub);
|
||||
ase_char_t* ase_strxstr (
|
||||
const ase_char_t* str, ase_size_t size, const ase_char_t* sub);
|
||||
ase_char_t* ase_strxnstr (
|
||||
const ase_char_t* str, ase_size_t strsz,
|
||||
const ase_char_t* sub, ase_size_t subsz);
|
||||
|
||||
ase_char_t* ase_strchr (const ase_char_t* str, ase_cint_t c);
|
||||
ase_char_t* ase_strxchr (const ase_char_t* str, ase_size_t len, ase_cint_t c);
|
||||
ase_char_t* ase_strrchr (const ase_char_t* str, ase_cint_t c);
|
||||
ase_char_t* ase_strxrchr (const ase_char_t* str, ase_size_t len, ase_cint_t c);
|
||||
|
||||
/* Checks if a string begins with a substring */
|
||||
ase_char_t* ase_strbeg (const ase_char_t* str, const ase_char_t* sub);
|
||||
ase_char_t* ase_strxbeg (
|
||||
const ase_char_t* str, ase_size_t len, const ase_char_t* sub);
|
||||
ase_char_t* ase_strnbeg (
|
||||
const ase_char_t* str, const ase_char_t* sub, ase_size_t len);
|
||||
ase_char_t* ase_strxnbeg (
|
||||
const ase_char_t* str, ase_size_t len1,
|
||||
const ase_char_t* sub, ase_size_t len2);
|
||||
|
||||
/* Checks if a string ends with a substring */
|
||||
ase_char_t* ase_strend (const ase_char_t* str, const ase_char_t* sub);
|
||||
ase_char_t* ase_strxend (
|
||||
const ase_char_t* str, ase_size_t len, const ase_char_t* sub);
|
||||
ase_char_t* ase_strnend (
|
||||
const ase_char_t* str, const ase_char_t* sub, ase_size_t len);
|
||||
ase_char_t* ase_strxnend (
|
||||
const ase_char_t* str, ase_size_t len1,
|
||||
const ase_char_t* sub, ase_size_t len2);
|
||||
|
||||
/*
|
||||
* string conversion
|
||||
*/
|
||||
int ase_strtoi (const ase_char_t* str);
|
||||
long ase_strtol (const ase_char_t* str);
|
||||
unsigned int ase_strtoui (const ase_char_t* str);
|
||||
unsigned long ase_strtoul (const ase_char_t* str);
|
||||
|
||||
int ase_strxtoi (const ase_char_t* str, ase_size_t len);
|
||||
long ase_strxtol (const ase_char_t* str, ase_size_t len);
|
||||
unsigned int ase_strxtoui (const ase_char_t* str, ase_size_t len);
|
||||
unsigned long ase_strxtoul (const ase_char_t* str, ase_size_t len);
|
||||
|
||||
ase_int_t ase_strtoint (const ase_char_t* str);
|
||||
ase_long_t ase_strtolong (const ase_char_t* str);
|
||||
ase_uint_t ase_strtouint (const ase_char_t* str);
|
||||
ase_ulong_t ase_strtoulong (const ase_char_t* str);
|
||||
|
||||
ase_int_t ase_strxtoint (const ase_char_t* str, ase_size_t len);
|
||||
ase_long_t ase_strxtolong (const ase_char_t* str, ase_size_t len);
|
||||
ase_uint_t ase_strxtouint (const ase_char_t* str, ase_size_t len);
|
||||
ase_ulong_t ase_strxtoulong (const ase_char_t* str, ase_size_t len);
|
||||
|
||||
ase_str_t* ase_str_open (
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t ext,
|
||||
ase_size_t capa
|
||||
);
|
||||
|
||||
void ase_str_close (
|
||||
ase_str_t* str
|
||||
);
|
||||
|
||||
/*
|
||||
* If capa is 0, it doesn't allocate the buffer in advance.
|
||||
*/
|
||||
ase_str_t* ase_str_init (
|
||||
ase_str_t* str,
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t capa
|
||||
);
|
||||
|
||||
void ase_str_fini (
|
||||
ase_str_t* str
|
||||
);
|
||||
|
||||
/****f* ase.cmn.str/ase_str_yield
|
||||
* NAME
|
||||
* ase_str_yield - yield the buffer
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_str_yield() function assigns the buffer to an variable of the
|
||||
* ase_xstr_t type and recreate a new buffer of the new_capa capacity.
|
||||
* The function fails if it fails to allocate a new buffer.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_str_yield() function returns 0 on success, and -1 on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_str_yield (
|
||||
ase_str_t* str /* a dynamic string */,
|
||||
ase_xstr_t* buf /* the pointer to a ase_xstr_t variable */,
|
||||
int new_capa /* new capacity in number of characters */
|
||||
);
|
||||
/******/
|
||||
|
||||
void* ase_str_getxtn (
|
||||
ase_str_t* str
|
||||
);
|
||||
|
||||
ase_mmgr_t* ase_str_getmmgr (
|
||||
ase_str_t* str
|
||||
);
|
||||
|
||||
void ase_str_setmmgr (
|
||||
ase_str_t* str,
|
||||
ase_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get the sizer
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_str_getsizer() function returns the sizer specified.
|
||||
*
|
||||
* RETURNS: a sizer function set or ASE_NULL if no sizer is set.
|
||||
*/
|
||||
ase_str_sizer_t ase_str_getsizer (
|
||||
ase_str_t* str /* a dynamic string */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: specify a sizer
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_str_setsizer() function specify a new sizer for a dynamic string.
|
||||
* With no sizer specified, the dynamic string doubles the current buffer
|
||||
* when it needs to increase its size. The sizer function is passed a dynamic
|
||||
* string and the minimum capacity required to hold data after resizing.
|
||||
* The string is truncated if the sizer function returns a smaller number
|
||||
* than the hint passed.
|
||||
*/
|
||||
void ase_str_setsizer (
|
||||
ase_str_t* str /* a dynamic string */,
|
||||
ase_str_sizer_t sizer /* a sizer function */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get capacity
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_str_getcapa() function returns the current capacity.
|
||||
* You may use ASE_STR_CAPA(str) macro for performance sake.
|
||||
*
|
||||
* RETURNS: the current capacity in number of characters.
|
||||
*/
|
||||
ase_size_t ase_str_getcapa (
|
||||
ase_str_t* str /* a dynamic string */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: set new capacity
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_str_setcapa() function set new capacity. If the new capacity
|
||||
* is smaller than the old, the overflowing characters are removed from
|
||||
* from the buffer.
|
||||
*
|
||||
* RETURNS: -1 on failure, a new capacity on success
|
||||
*/
|
||||
ase_size_t ase_str_setcapa (
|
||||
ase_str_t* str /* a dynamic string */,
|
||||
ase_size_t capa /* a new capacity */
|
||||
);
|
||||
|
||||
void ase_str_clear (
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
ase_size_t ase_mbstowcs (
|
||||
const ase_mchar_t* mbs,
|
||||
ase_wchar_t* wcs,
|
||||
ase_size_t* wcslen
|
||||
);
|
||||
|
||||
/****f* ase.cmn.str/ase_mbsntowcsn
|
||||
* NAME
|
||||
* ase_mbsntowcsn - convert a multibyte string to a wide character string
|
||||
*
|
||||
* RETURN
|
||||
* The ase_mbstowcs() function returns the number of bytes handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_mbsntowcsn (
|
||||
const ase_mchar_t* mbs,
|
||||
ase_size_t mbslen,
|
||||
ase_wchar_t* wcs,
|
||||
ase_size_t* wcslen
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.str/ase_wcstombs
|
||||
* NAME
|
||||
* ase_wcstombs - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_wcstombs() function converts a null-terminated wide character
|
||||
* string to a multibyte string and stores it into the buffer pointed to
|
||||
* by mbs. The pointer to a variable holding the buffer length should be
|
||||
* passed to the function as the third parameter. After conversion, it holds
|
||||
* the length of the multibyte string excluding the terminating-null.
|
||||
* It may not null-terminate the resulting multibyte string if the buffer
|
||||
* is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wcstombs() function returns the number of wide characters handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_wcstombs (
|
||||
const ase_wchar_t* wcs,
|
||||
ase_mchar_t* mbs,
|
||||
ase_size_t* mbslen
|
||||
);
|
||||
|
||||
/****f* ase.cmn.str/ase_wcsntombsn
|
||||
* NAME
|
||||
* ase_wcstombs - convert a wide character string to a multibyte string
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wcstombs() function returns the number of wide characters handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_wcsntombsn (
|
||||
const ase_wchar_t* wcs,
|
||||
ase_size_t wcslen,
|
||||
ase_mchar_t* mbs,
|
||||
ase_size_t* mbslen
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.str/ase_wcstombs_strict
|
||||
* NAME
|
||||
* ase_wcstombs_strict - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_wcstombs_strict() function performs the same as the ase_wcsmbs()
|
||||
* function except that it returns an error if it can't fully convert the
|
||||
* input string and/or the buffer is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wcstombs_strict() function returns 0 on success and -1 on failure.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_wcstombs_strict (
|
||||
const ase_wchar_t* wcs,
|
||||
ase_mchar_t* mbs,
|
||||
ase_size_t mbslen
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_TIME_H_
|
||||
#define _ASE_CMN_TIME_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
#define ASE_EPOCH_YEAR ((ase_ntime_t)1970)
|
||||
#define ASE_EPOCH_MON ((ase_ntime_t)1)
|
||||
#define ASE_EPOCH_DAY ((ase_ntime_t)1)
|
||||
#define ASE_EPOCH_WDAY ((ase_ntime_t)4)
|
||||
|
||||
#define ASE_DAY_IN_WEEK ((ase_ntime_t)7)
|
||||
#define ASE_MON_IN_YEAR ((ase_ntime_t)12)
|
||||
#define ASE_HOUR_IN_DAY ((ase_ntime_t)24)
|
||||
#define ASE_MIN_IN_HOUR ((ase_ntime_t)60)
|
||||
#define ASE_MIN_IN_DAY (ASE_MIN_IN_HOUR * ASE_HOUR_IN_DAY)
|
||||
#define ASE_SEC_IN_MIN ((ase_ntime_t)60)
|
||||
#define ASE_SEC_IN_HOUR (ASE_SEC_IN_MIN * ASE_MIN_IN_HOUR)
|
||||
#define ASE_SEC_IN_DAY (ASE_SEC_IN_MIN * ASE_MIN_IN_DAY)
|
||||
#define ASE_MSEC_IN_SEC ((ase_ntime_t)1000)
|
||||
#define ASE_MSEC_IN_MIN (ASE_MSEC_IN_SEC * ASE_SEC_IN_MIN)
|
||||
#define ASE_MSEC_IN_HOUR (ASE_MSEC_IN_SEC * ASE_SEC_IN_HOUR)
|
||||
#define ASE_MSEC_IN_DAY (ASE_MSEC_IN_SEC * ASE_SEC_IN_DAY)
|
||||
|
||||
#define ASE_USEC_IN_MSEC ((ase_ntime_t)1000)
|
||||
#define ASE_NSEC_IN_USEC ((ase_ntime_t)1000)
|
||||
#define ASE_USEC_IN_SEC ((ase_ntime_t)ASE_USEC_IN_MSEC * ASE_MSEC_IN_SEC)
|
||||
|
||||
#define ASE_IS_LEAPYEAR(year) (!((year)%4) && (((year)%100) || !((year)%400)))
|
||||
#define ASE_DAY_IN_YEAR(year) (ASE_IS_LEAPYEAR(year)? 366: 365)
|
||||
|
||||
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
|
||||
typedef ase_long_t ase_ntime_t;
|
||||
typedef struct ase_btime_t ase_btime_t;
|
||||
|
||||
struct ase_btime_t
|
||||
{
|
||||
int sec; /* 0-61 */
|
||||
int min; /* 0-59 */
|
||||
int hour; /* 0-23 */
|
||||
int mday; /* 1-31 */
|
||||
int mon; /* 0(jan)-11(dec) */
|
||||
int year; /* the number of years since 1900 */
|
||||
int wday; /* 0(sun)-6(sat) */
|
||||
int yday; /* 0(jan 1) to 365 */
|
||||
int isdst;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* ase.cmn/ase_gettime
|
||||
* NAME
|
||||
* ase_gettime - get the current time
|
||||
*
|
||||
* SYNPOSIS
|
||||
*/
|
||||
int ase_gettime (
|
||||
ase_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn/ase_settime
|
||||
* NAME
|
||||
* ase_settime - set the current time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_settime (
|
||||
ase_ntime_t nt
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* ase.cmn/ase_gmtime
|
||||
* NAME
|
||||
* ase_gmtime - convert numeric time to broken-down time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_gmtime (
|
||||
ase_ntime_t nt,
|
||||
ase_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn/ase_localtime
|
||||
* NAME
|
||||
* ase_localtime - convert numeric time to broken-down time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_localtime (
|
||||
ase_ntime_t nt,
|
||||
ase_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn/ase_mktime
|
||||
* NAME
|
||||
* ase_mktime - convert broken-down time to numeric time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_mktime (
|
||||
const ase_btime_t* bt,
|
||||
ase_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn/ase_strftime
|
||||
* NAME
|
||||
* ase_strftime - format time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_strftime (
|
||||
ase_char_t* buf,
|
||||
ase_size_t size,
|
||||
const ase_char_t* fmt,
|
||||
ase_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,299 +0,0 @@
|
||||
/*
|
||||
* $Id: tio.h,v 1.19 2006/01/01 13:50:24 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_TIO_H_
|
||||
#define _ASE_CMN_TIO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
#include <ase/cmn/str.h>
|
||||
|
||||
enum
|
||||
{
|
||||
ASE_TIO_ENOERR = 0,
|
||||
ASE_TIO_ENOMEM, /* out of memory */
|
||||
ASE_TIO_ENOSPC, /* no more space */
|
||||
ASE_TIO_EILSEQ, /* illegal sequence */
|
||||
ASE_TIO_EICSEQ, /* incomplete sequence */
|
||||
ASE_TIO_EILCHR, /* illegal character */
|
||||
ASE_TIO_ENOINF, /* no input function attached */
|
||||
ASE_TIO_EINPUT, /* input function returned an error */
|
||||
ASE_TIO_EINPOP, /* input function failed to open */
|
||||
ASE_TIO_EINPCL, /* input function failed to close */
|
||||
ASE_TIO_ENOUTF, /* no output function attached */
|
||||
ASE_TIO_EOUTPT, /* output function returned an error */
|
||||
ASE_TIO_EOUTOP, /* output function failed to open */
|
||||
ASE_TIO_EOUTCL /* output function failed to close */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/* the size of input buffer should be at least equal to or greater
|
||||
* than the maximum sequence length of the ase_mchar_t string.
|
||||
* (i.e. 6 for utf8)
|
||||
*/
|
||||
ASE_TIO_MAX_INBUF_LEN = 4096,
|
||||
ASE_TIO_MAX_OUTBUF_LEN = 4096
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ASE_TIO_IO_OPEN,
|
||||
ASE_TIO_IO_CLOSE,
|
||||
ASE_TIO_IO_DATA
|
||||
};
|
||||
|
||||
|
||||
#define ASE_TIO_MMGR(tio) ((tio)->mmgr)
|
||||
#define ASE_TIO_XTN(s) ((void*)(((ase_tio_t*)s) + 1))
|
||||
#define ASE_TIO_ERRNUM(tio) ((tio)->errnum)
|
||||
|
||||
/*
|
||||
* TYPE: ase_tio_t
|
||||
* Defines the tio type
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <ase_tio_t> defines a generic type for text-based IO. When ase_char_t is
|
||||
* ase_mchar_t, it handles any byte streams. When ase_char_t is ase_wchar_t,
|
||||
* it handles utf-8 byte streams.
|
||||
*/
|
||||
typedef struct ase_tio_t ase_tio_t;
|
||||
|
||||
/*
|
||||
* TYPE: ase_tio_io_t
|
||||
* Defines a user-defines IO handler
|
||||
*/
|
||||
typedef ase_ssize_t (*ase_tio_io_t) (
|
||||
int cmd, void* arg, void* data, ase_size_t size);
|
||||
|
||||
struct ase_tio_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
int errnum;
|
||||
|
||||
/* io functions */
|
||||
ase_tio_io_t input_func;
|
||||
ase_tio_io_t output_func;
|
||||
void* input_arg;
|
||||
void* output_arg;
|
||||
|
||||
/* for housekeeping */
|
||||
int input_status;
|
||||
ase_size_t inbuf_curp;
|
||||
ase_size_t inbuf_len;
|
||||
ase_size_t outbuf_len;
|
||||
|
||||
ase_mchar_t inbuf[ASE_TIO_MAX_INBUF_LEN];
|
||||
ase_mchar_t outbuf[ASE_TIO_MAX_OUTBUF_LEN];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_open
|
||||
*/
|
||||
ase_tio_t* ase_tio_open (
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t ext
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_close
|
||||
*/
|
||||
int ase_tio_close (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
ase_tio_t* ase_tio_init (
|
||||
ase_tio_t* tip,
|
||||
ase_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
int ase_tio_fini (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
void* ase_tio_getxtn (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
ase_mmgr_t* ase_tio_getmmgr (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
void ase_tio_setmmgr (
|
||||
ase_tio_t* tio,
|
||||
ase_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_geterrnum
|
||||
* Returns an error code
|
||||
*
|
||||
* PARAMETERS:
|
||||
* grep - a grep object
|
||||
*
|
||||
* RETURNS:
|
||||
* Error code set by the last tio function called
|
||||
*/
|
||||
int ase_tio_geterrnum (ase_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_geterrstr
|
||||
* Translates an error code to a string
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* A pointer to a constant string describing the last error occurred
|
||||
*/
|
||||
const ase_char_t* ase_tio_geterrstr (ase_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_attachin
|
||||
* Attaches an input handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
* input - input handler function
|
||||
* arg - user data to be passed to the input handler
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int ase_tio_attachin (
|
||||
ase_tio_t* tio,
|
||||
ase_tio_io_t input,
|
||||
void* arg
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_detachin
|
||||
* Detaches an input handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int ase_tio_detachin (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_attachout
|
||||
* Attaches an output handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
* output - output handler function
|
||||
* arg - user data to be passed to the output handler
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int ase_tio_attachout (
|
||||
ase_tio_t* tio,
|
||||
ase_tio_io_t output,
|
||||
void* arg
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_detachout
|
||||
* Detaches an output handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int ase_tio_detachout (
|
||||
ase_tio_t* tio
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_flush
|
||||
* Flushes the output buffer
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* Number of bytes written on success, -1 on failure
|
||||
*/
|
||||
ase_ssize_t ase_tio_flush (ase_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_purge
|
||||
* Erases all input and output buffered
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
*/
|
||||
void ase_tio_purge (ase_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_getc
|
||||
* Reads a single character
|
||||
*/
|
||||
ase_ssize_t ase_tio_getc (ase_tio_t* tio, ase_char_t* c);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_gets
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <ase_tio_gets> inserts a terminating null if there is a room
|
||||
*/
|
||||
ase_ssize_t ase_tio_gets (ase_tio_t* tio, ase_char_t* buf, ase_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_getsx
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <ase_tio_getsx> doesn't insert a terminating null character
|
||||
*/
|
||||
ase_ssize_t ase_tio_getsx (ase_tio_t* tio, ase_char_t* buf, ase_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_getstr
|
||||
*/
|
||||
ase_ssize_t ase_tio_getstr (ase_tio_t* tio, ase_str_t* buf);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_putc
|
||||
*/
|
||||
ase_ssize_t ase_tio_putc (ase_tio_t* tio, ase_char_t c);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_puts
|
||||
*/
|
||||
ase_ssize_t ase_tio_puts (ase_tio_t* tio, const ase_char_t* str);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_putsx
|
||||
*/
|
||||
ase_ssize_t ase_tio_putsx (ase_tio_t* tio, const ase_char_t* str, ase_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_putsn
|
||||
*/
|
||||
ase_ssize_t ase_tio_putsn (ase_tio_t* tio, ...);
|
||||
|
||||
/*
|
||||
* FUNCTION: ase_tio_putsxn
|
||||
*/
|
||||
ase_ssize_t ase_tio_putsxn (ase_tio_t* tio, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* $Id: conf_msw.h 225 2008-06-26 06:48:38Z baconevi $
|
||||
*
|
||||
* {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*/
|
||||
|
||||
#if defined(__POCC__) || defined(__DMC__)
|
||||
/* 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,134 +0,0 @@
|
||||
/*
|
||||
* $Id: lsp.h 183 2008-06-03 08:18:55Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_LSP_LSP_H_
|
||||
#define _ASE_LSP_LSP_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
typedef struct ase_lsp_t ase_lsp_t;
|
||||
typedef struct ase_lsp_obj_t ase_lsp_obj_t;
|
||||
typedef struct ase_lsp_prmfns_t ase_lsp_prmfns_t;
|
||||
|
||||
typedef ase_ssize_t (*ase_lsp_io_t) (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
||||
|
||||
typedef ase_real_t (*ase_lsp_pow_t) (
|
||||
void* data, ase_real_t x, ase_real_t y);
|
||||
typedef int (*ase_lsp_sprintf_t) (
|
||||
void* data, ase_char_t* buf, ase_size_t size,
|
||||
const ase_char_t* fmt, ...);
|
||||
typedef void (*ase_lsp_dprintf_t) (void* data, const ase_char_t* fmt, ...);
|
||||
|
||||
struct ase_lsp_prmfns_t
|
||||
{
|
||||
ase_mmgr_t mmgr;
|
||||
ase_ccls_t ccls;
|
||||
|
||||
/* utilities */
|
||||
struct
|
||||
{
|
||||
ase_lsp_sprintf_t sprintf;
|
||||
ase_lsp_dprintf_t dprintf;
|
||||
void* data;
|
||||
} misc;
|
||||
};
|
||||
|
||||
/* io function commands */
|
||||
enum
|
||||
{
|
||||
ASE_LSP_IO_OPEN = 0,
|
||||
ASE_LSP_IO_CLOSE = 1,
|
||||
ASE_LSP_IO_READ = 2,
|
||||
ASE_LSP_IO_WRITE = 3
|
||||
};
|
||||
|
||||
/* option code */
|
||||
enum
|
||||
{
|
||||
ASE_LSP_UNDEFSYMBOL = (1 << 0)
|
||||
};
|
||||
|
||||
/* error code */
|
||||
enum
|
||||
{
|
||||
ASE_LSP_ENOERR,
|
||||
ASE_LSP_ENOMEM,
|
||||
|
||||
ASE_LSP_EEXIT,
|
||||
ASE_LSP_EEND,
|
||||
ASE_LSP_EENDSTR,
|
||||
ASE_LSP_ENOINP,
|
||||
ASE_LSP_EINPUT,
|
||||
ASE_LSP_ENOOUTP,
|
||||
ASE_LSP_EOUTPUT,
|
||||
|
||||
ASE_LSP_ESYNTAX,
|
||||
ASE_LSP_ERPAREN,
|
||||
ASE_LSP_EARGBAD,
|
||||
ASE_LSP_EARGFEW,
|
||||
ASE_LSP_EARGMANY,
|
||||
ASE_LSP_EUNDEFFN,
|
||||
ASE_LSP_EBADFN,
|
||||
ASE_LSP_EDUPFML,
|
||||
ASE_LSP_EBADSYM,
|
||||
ASE_LSP_EUNDEFSYM,
|
||||
ASE_LSP_EEMPBDY,
|
||||
ASE_LSP_EVALBAD,
|
||||
ASE_LSP_EDIVBY0
|
||||
};
|
||||
|
||||
typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_lsp_t* ase_lsp_open (
|
||||
const ase_lsp_prmfns_t* prmfns,
|
||||
ase_size_t mem_ubound, ase_size_t mem_ubound_inc);
|
||||
|
||||
void ase_lsp_close (ase_lsp_t* lsp);
|
||||
|
||||
/**
|
||||
* @function ase_lsp_setassocdata
|
||||
* @brief ssociats the user-specified data with an interpreter
|
||||
*/
|
||||
void ase_lsp_setassocdata (ase_lsp_t* lsp, void* data);
|
||||
/**
|
||||
* @function ase_lsp_getassocdata
|
||||
* @brief returns the user-specified data associated with an interpreter
|
||||
*/
|
||||
void* ase_lsp_getassocdata (ase_lsp_t* lsp);
|
||||
|
||||
void ase_lsp_geterror (
|
||||
ase_lsp_t* lsp, int* errnum, const ase_char_t** errmsg);
|
||||
|
||||
void ase_lsp_seterror (
|
||||
ase_lsp_t* lsp, int errnum,
|
||||
const ase_char_t** errarg, ase_size_t argcnt);
|
||||
|
||||
int ase_lsp_attinput (ase_lsp_t* lsp, ase_lsp_io_t input, void* arg);
|
||||
int ase_lsp_detinput (ase_lsp_t* lsp);
|
||||
|
||||
int ase_lsp_attoutput (ase_lsp_t* lsp, ase_lsp_io_t output, void* arg);
|
||||
int ase_lsp_detoutput (ase_lsp_t* lsp);
|
||||
|
||||
ase_lsp_obj_t* ase_lsp_read (ase_lsp_t* lsp);
|
||||
ase_lsp_obj_t* ase_lsp_eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
||||
int ase_lsp_print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj);
|
||||
|
||||
int ase_lsp_addprim (
|
||||
ase_lsp_t* lsp, const ase_char_t* name, ase_size_t name_len,
|
||||
ase_lsp_prim_t prim, ase_size_t min_args, ase_size_t max_args);
|
||||
int ase_lsp_removeprim (ase_lsp_t* lsp, const ase_char_t* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
* $Id: macros.h 455 2008-11-26 09:05:00Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_MACROS_H_
|
||||
#define _ASE_MACROS_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
/*#define ASE_NULL ((ase_uint_t)0)*/
|
||||
#define ASE_NULL (0)
|
||||
#else
|
||||
#define ASE_NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
/****d* ase/ASE_TRUE,ASE_FALSE
|
||||
* NAME
|
||||
* ASE_TRUE - represent a boolean true
|
||||
* ASE_FALSE - represent a boolean false
|
||||
******
|
||||
*/
|
||||
#define ASE_TRUE (0 == 0)
|
||||
#define ASE_FALSE (0 != 0)
|
||||
|
||||
|
||||
/****d* ase/ASE_ALIVE,ASE_ZOMBIE,ASE_DEAD
|
||||
* NAME
|
||||
* ASE_ALIVE - represent a living state
|
||||
* ASE_ZOMBIE - represent a zombie state
|
||||
* ASE_DEAD - represent a dead state
|
||||
******
|
||||
*/
|
||||
#define ASE_ALIVE 1
|
||||
#define ASE_ZOMBIE 0
|
||||
#define ASE_DEAD -1
|
||||
|
||||
|
||||
#define AES_MCHAR_EOF ((ase_mcint_t)-1)
|
||||
#define AES_WCHAR_EOF ((ase_wcint_t)-1)
|
||||
#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);
|
||||
|
||||
/* number of characters to number of bytes */
|
||||
#define ASE_NCTONB(x) ((x)*sizeof(ase_char_t))
|
||||
/* number of bytes to number of characters */
|
||||
#define ASE_NBTONC(x) ((x)/sizeof(ase_char_t))
|
||||
|
||||
#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_Q(val) ASE_MQ(val)
|
||||
#define ASE_C(ch) ASE_MC(ch)
|
||||
#define ASE_S(str) ASE_MS(str)
|
||||
#define ASE_T(txt) ASE_MT(txt)
|
||||
#else
|
||||
#define ASE_Q(val) ASE_WQ(val)
|
||||
#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_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
|
||||
|
||||
/****d* ase/ASE_FNS
|
||||
* NAME
|
||||
* ASE_FNS - define an ASE function name space
|
||||
* DESCRIPTION
|
||||
* The ASE_FNS macro enables you to simulate a function name space for the
|
||||
* types designed properly.
|
||||
* EXAMPLE
|
||||
* ASE_FNS (awk, AWK);
|
||||
* ase_awk_t* awk = AWK.open (....);
|
||||
* AWK.close (awk);
|
||||
******
|
||||
*/
|
||||
#define ASE_NS(type,name) struct ase_ns_##type##_t name = ase_ns_##type##_d
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define ASE_BEGIN_NAMESPACE(x) namespace x {
|
||||
#define ASE_END_NAMESPACE(x) }
|
||||
#define ASE_BEGIN_NAMESPACE2(x,y) namespace x { namespace y {
|
||||
#define ASE_END_NAMESPACE2(y,x) }}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* $Id: tgp.h 235 2008-07-05 07:25:54Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_TGP_TGP_H_
|
||||
#define _ASE_TGP_TGP_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
typedef struct ase_tgp_t ase_tgp_t;
|
||||
|
||||
enum ase_tgp_iocmd_t
|
||||
{
|
||||
ASE_TGP_IO_OPEN = 0,
|
||||
ASE_TGP_IO_CLOSE = 1,
|
||||
ASE_TGP_IO_READ = 2,
|
||||
ASE_TGP_IO_WRITE = 3
|
||||
};
|
||||
|
||||
typedef ase_ssize_t (*ase_tgp_io_t) (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_tgp_t* ase_tgp_open (ase_mmgr_t* mmgr);
|
||||
void ase_tgp_close (ase_tgp_t* tgp);
|
||||
|
||||
void ase_tgp_setassocdata (ase_tgp_t* tgp, void* data);
|
||||
void* ase_tgp_getassocdata (ase_tgp_t* tgp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,439 +0,0 @@
|
||||
/*
|
||||
* $Id: types.h 476 2008-12-12 06:25:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_TYPES_H_
|
||||
#define _ASE_TYPES_H_
|
||||
|
||||
/****o* ase/basic types
|
||||
* DESCRIPTION
|
||||
* <ase/types.h> defines various common basic types. They are designed to be
|
||||
* cross-platform. These types are preferred over native data types in many
|
||||
* contexts.
|
||||
*
|
||||
* #include <ase/types.h>
|
||||
******
|
||||
*/
|
||||
|
||||
/* WARNING: NEVER CHANGE/DELETE THE FOLLOWING LINE */
|
||||
/*#define ASE_HAVE_CONFIG_H*/
|
||||
|
||||
#if defined(ASE_HAVE_CONFIG_H)
|
||||
#include <ase/config.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <ase/conf_msw.h>
|
||||
#elif defined(vms) || defined(__vms)
|
||||
#include <ase/conf_vms.h>
|
||||
/*
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__SPU__)
|
||||
#if !defined(__unix__)
|
||||
#define __unix__
|
||||
#endif
|
||||
#if !defined(__unix)
|
||||
#define __unix
|
||||
#endif
|
||||
#include <ase/config.h>
|
||||
*/
|
||||
#else
|
||||
#error unsupported operating system
|
||||
#endif
|
||||
|
||||
/****t* ase/ase_bool_t
|
||||
* NAME
|
||||
* ase_bool_t - define a boolean type
|
||||
* DESCRIPTION
|
||||
* The ase_bool_t type defines a boolean type that can represent ASE_TRUE
|
||||
* and ASE_FALSE.
|
||||
******
|
||||
*/
|
||||
typedef int ase_bool_t;
|
||||
|
||||
/****t* ase/ase_tri_t
|
||||
* NAME
|
||||
* ase_tri_t - define a tri-state type
|
||||
* DESCRIPTION
|
||||
* The ase_tri_t type defines a tri-state type that can represent ASE_ALIVE,
|
||||
* ASE_ZOMBIE, and ASE_DEAD.
|
||||
******
|
||||
*/
|
||||
typedef int ase_tri_t;
|
||||
|
||||
/****t* ase/ase_int_t,ase_uint_t
|
||||
* NAME
|
||||
* ase_int_t - define a signed integer type as large as a pointer type
|
||||
* ase_uint_t - define an unsigned integer type as large as a pointer type
|
||||
******
|
||||
*/
|
||||
#if (defined(hpux) || defined(__hpux) || defined(__hpux__)) && (ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG)
|
||||
typedef long ase_int_t;
|
||||
typedef unsigned long ase_uint_t;
|
||||
#elif defined(__SPU__) && (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_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
|
||||
|
||||
/****t* ase/ase_long_t,ase_ulong_t
|
||||
* NAME
|
||||
* ase_long_t - define the largest signed integer type supported
|
||||
* ase_ulong_t - define the largest unsigned integer type supported
|
||||
******
|
||||
*/
|
||||
#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
|
||||
|
||||
/****t* ase/ase_int8_t,ase_uint8_t
|
||||
* NAME
|
||||
* ase_int8_t - define an 8-bit signed integer type
|
||||
* ase_uint8_t - define an 8-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#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
|
||||
|
||||
/****t* ase/ase_int16_t,ase_uint16_t
|
||||
* NAME
|
||||
* ase_int16_t - define a 16-bit signed integer type
|
||||
* ase_uint16_t - define a 16-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#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
|
||||
|
||||
/****t* ase/ase_int32_t,ase_uint32_t
|
||||
* NAME
|
||||
* ase_int32_t - define a 32-bit signed integer type
|
||||
* ase_uint32_t - define a 32-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#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
|
||||
|
||||
/****t* ase/ase_int64_t,ase_uint64_t
|
||||
* NAME
|
||||
* ase_int64_t - define a 64-bit signed integer type
|
||||
* ase_uint64_t - define a 64-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#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
|
||||
|
||||
/****t* ase/ase_byte_t
|
||||
* NAME
|
||||
* ase_word_t - define a byte type
|
||||
******
|
||||
*/
|
||||
typedef ase_uint8_t ase_byte_t;
|
||||
|
||||
/****t* ase/ase_size_t
|
||||
* NAME
|
||||
* ase_size_t - define an unsigned integer type that can hold a pointer value
|
||||
******
|
||||
*/
|
||||
#ifdef __SIZE_TYPE__
|
||||
typedef __SIZE_TYPE__ ase_size_t;
|
||||
#else
|
||||
typedef ase_uint_t ase_size_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/ase_ssize_t
|
||||
* NAME
|
||||
* ase_ssize_t - define an signed integer type that can hold a pointer value
|
||||
******
|
||||
*/
|
||||
typedef ase_int_t ase_ssize_t;
|
||||
|
||||
/****t* ase/ase_word_t
|
||||
* NAME
|
||||
* ase_word_t - define an integer type identical to ase_uint_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
|
||||
|
||||
/****t* ase/ase_mchar_t,ase_mcint_t
|
||||
* NAME
|
||||
* ase_mchar_t - define a multi-byte character
|
||||
* ase_mcint_t - define a type that can hold ase_mchar_t and ASE_MCHAR_EOF
|
||||
******
|
||||
*/
|
||||
typedef char ase_mchar_t;
|
||||
typedef int ase_mcint_t;
|
||||
|
||||
/****t* ase/ase_wchar_t,ase_wcint_t
|
||||
* NAME
|
||||
* ase_wchar_t - define a wide character
|
||||
* ase_wcint_t - define a type that can hold ase_wchar_t and ASE_WCHAR_EOF
|
||||
******
|
||||
*/
|
||||
#if defined(__cplusplus) && (!defined(_MSC_VER) || (defined(_MSC_VER)&&defined(_NATIVE_WCHAR_T_DEFINED)))
|
||||
/* C++ */
|
||||
|
||||
typedef wchar_t ase_wchar_t;
|
||||
typedef wchar_t ase_wcint_t;
|
||||
|
||||
/* all the way down from here for C */
|
||||
#elif defined(__WCHAR_TYPE__) && defined(__WINT_TYPE__)
|
||||
typedef __WCHAR_TYPE__ ase_wchar_t;
|
||||
typedef __WINT_TYPE__ ase_wcint_t;
|
||||
#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(__linux))
|
||||
#if defined(_LP64)
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#else
|
||||
typedef long ase_wchar_t;
|
||||
typedef long ase_wcint_t;
|
||||
#endif
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
|
||||
#if defined(__HP_cc) || defined(__HP_aCC)
|
||||
typedef unsigned int ase_wchar_t;
|
||||
#else
|
||||
typedef int ase_wchar_t;
|
||||
#endif
|
||||
typedef int ase_wcint_t;
|
||||
#elif ASE_SIZEOF_LONG == 4
|
||||
typedef long ase_wchar_t;
|
||||
typedef long ase_wcint_t;
|
||||
#elif ASE_SIZEOF_INT == 4
|
||||
typedef int ase_wchar_t;
|
||||
typedef int ase_wcint_t;
|
||||
#else
|
||||
#error no supported data type for wchar_t
|
||||
#endif
|
||||
#else
|
||||
#error unsupported size of wchar_t
|
||||
#endif
|
||||
|
||||
/****t* ase/ase_char_t,ase_cint_t
|
||||
* NAME
|
||||
* ase_char_t - define a character
|
||||
* ase_cint_t - define a type that can hold ase_char_t and ASE_CHAR_EOF
|
||||
******
|
||||
*/
|
||||
#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_xstr_t ase_xstr_t;
|
||||
typedef struct ase_cstr_t ase_cstr_t;
|
||||
typedef struct ase_mmgr_t ase_mmgr_t;
|
||||
typedef struct ase_ccls_t ase_ccls_t;
|
||||
|
||||
/****t* ase/ase_xstr_t
|
||||
* NAME
|
||||
* ase_xstr_t - combine a pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_xstr_t
|
||||
{
|
||||
ase_char_t* ptr; /* this is not a const pointer */
|
||||
ase_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/ase_cstr_t
|
||||
* NAME
|
||||
* ase_cstr_t - combine a constant pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_cstr_t
|
||||
{
|
||||
const ase_char_t* ptr; /* this is a const pointer */
|
||||
ase_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/ase_mmgr_t
|
||||
* NAME
|
||||
* ase_mmgr_t - define a memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_mmgr_t
|
||||
{
|
||||
void* (*alloc) (void* data, ase_size_t n);
|
||||
void* (*realloc) (void* data, void* ptr, ase_size_t n);
|
||||
void (*free) (void* data, void* ptr);
|
||||
void* data;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/ase_ccls_type_t
|
||||
* NAME
|
||||
* ase_ccls_type_t - define types of character class
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum ase_ccls_type_t
|
||||
{
|
||||
ASE_CCLS_UPPER,
|
||||
ASE_CCLS_LOWER,
|
||||
ASE_CCLS_ALPHA,
|
||||
ASE_CCLS_DIGIT,
|
||||
ASE_CCLS_XDIGIT,
|
||||
ASE_CCLS_ALNUM,
|
||||
ASE_CCLS_SPACE,
|
||||
ASE_CCLS_PRINT,
|
||||
ASE_CCLS_GRAPH,
|
||||
ASE_CCLS_CNTRL,
|
||||
ASE_CCLS_PUNCT
|
||||
};
|
||||
/******/
|
||||
|
||||
typedef enum ase_ccls_type_t ase_ccls_type_t;
|
||||
|
||||
/****t* ase/ase_ccls_t
|
||||
* NAME
|
||||
* ase_mmgr_t - define a character class handler
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_ccls_t
|
||||
{
|
||||
ase_bool_t (*is) (void* data, ase_cint_t c, ase_ccls_type_t type);
|
||||
ase_cint_t (*to) (void* data, ase_cint_t c, ase_ccls_type_t type);
|
||||
void* data;
|
||||
};
|
||||
/******/
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* $Id: http.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_UTL_HTTP_H_
|
||||
#define _ASE_UTL_HTTP_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/* returns the type of http method */
|
||||
typedef struct ase_http_req_t ase_http_req_t;
|
||||
typedef struct ase_http_hdr_t ase_http_hdr_t;
|
||||
|
||||
struct ase_http_req_t
|
||||
{
|
||||
ase_char_t* method;
|
||||
|
||||
struct
|
||||
{
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
} path;
|
||||
|
||||
struct
|
||||
{
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
} args;
|
||||
|
||||
struct
|
||||
{
|
||||
char major;
|
||||
char minor;
|
||||
} vers;
|
||||
};
|
||||
|
||||
struct ase_http_hdr_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
} name;
|
||||
|
||||
struct
|
||||
{
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
} value;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_char_t* ase_parsehttpreq (ase_char_t* buf, ase_http_req_t* req);
|
||||
ase_char_t* ase_parsehttphdr (ase_char_t* buf, ase_http_hdr_t* hdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* $Id: main.h 463 2008-12-09 06:52:03Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_UTL_MAIN_H_
|
||||
#define _ASE_UTL_MAIN_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#if defined(ASE_CHAR_IS_MCHAR)
|
||||
#define ase_main main
|
||||
typedef ase_mchar_t ase_achar_t;
|
||||
#else
|
||||
#define ase_main wmain
|
||||
typedef ase_wchar_t ase_achar_t;
|
||||
#endif
|
||||
#else
|
||||
#define ase_main main
|
||||
typedef ase_mchar_t ase_achar_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ase_runmain (int argc, ase_achar_t* argv[], int(*mf) (int,ase_char_t*[]));
|
||||
/* TODO - ase_runmain with env */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* $Id: stdio.h 419 2008-10-13 11:32:58Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_UTL_STDIO_H_
|
||||
#define _ASE_UTL_STDIO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <tchar.h>
|
||||
|
||||
#define ase_printf _tprintf
|
||||
#define ase_vprintf _vtprintf
|
||||
#define ase_fprintf _ftprintf
|
||||
#define ase_vfprintf _vftprintf
|
||||
|
||||
#define ase_fgets(x,y,s) _fgetts(x,y,s)
|
||||
#define ase_fgetc(x) _fgettc(x)
|
||||
#define ase_fputs(x,s) _fputts(x,s)
|
||||
#define ase_fputc(x,s) _fputtc(x,s)
|
||||
#elif defined(ASE_CHAR_IS_MCHAR)
|
||||
#define ase_fgets(x,y,s) fgets(x,y,s)
|
||||
#define ase_fgetc(x) fgetc(x)
|
||||
#define ase_fputs(x,s) fputs(x,s)
|
||||
#define ase_fputc(x,s) fputc(x,s)
|
||||
#else
|
||||
#define ase_fgets(x,y,s) fgetws(x,y,s)
|
||||
#define ase_fgetc(x) fgetwc(x)
|
||||
#define ase_fputs(x,s) fputws(x,s)
|
||||
#define ase_fputc(x,s) fputwc(x,s)
|
||||
#endif
|
||||
|
||||
#define ase_feof(s) feof(s)
|
||||
#define ase_ferror(s) ferror(s)
|
||||
#define ase_clearerr(s) clearerr(s)
|
||||
#define ase_fflush(s) fflush(s)
|
||||
#define ase_fclose(s) fclose(s)
|
||||
|
||||
#define ASE_FILE FILE
|
||||
#define ASE_STDIN stdin
|
||||
#define ASE_STDOUT stdout
|
||||
#define ASE_STDERR stderr
|
||||
|
||||
typedef int (*ase_getdelim_t) (const ase_char_t* ptr,ase_size_t len, void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ase_vsprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, va_list ap);
|
||||
int ase_sprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, ...);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
int ase_vfprintf (ASE_FILE *stream, const ase_char_t* fmt, va_list ap);
|
||||
int ase_vprintf (const ase_char_t* fmt, va_list ap);
|
||||
int ase_fprintf (ASE_FILE* file, const ase_char_t* fmt, ...);
|
||||
int ase_printf (const ase_char_t* fmt, ...);
|
||||
#endif
|
||||
|
||||
int ase_dprintf (const ase_char_t* fmt, ...);
|
||||
ASE_FILE* ase_fopen (const ase_char_t* path, const ase_char_t* mode);
|
||||
ASE_FILE* ase_popen (const ase_char_t* cmd, const ase_char_t* mode);
|
||||
|
||||
/**
|
||||
* returns -2 on error, -1 on eof, length of data read on success
|
||||
*/
|
||||
ase_ssize_t ase_getline (ase_char_t **buf, ase_size_t *n, ASE_FILE *fp);
|
||||
/**
|
||||
* returns -3 on line breaker error, -2 on error, -1 on eof,
|
||||
* length of data read on success
|
||||
*/
|
||||
ase_ssize_t ase_getdelim (
|
||||
ase_char_t **buf, ase_size_t *n,
|
||||
ase_getdelim_t fn, void* fnarg, ASE_FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -2,4 +2,4 @@
|
||||
AUTOMAKE_OPTIONS = no-dependencies
|
||||
|
||||
# EXTRA_DIST = README
|
||||
SUBDIRS = ase
|
||||
SUBDIRS = qse
|
||||
|
@ -38,7 +38,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
@ -182,7 +182,7 @@ top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = no-dependencies
|
||||
|
||||
# EXTRA_DIST = README
|
||||
SUBDIRS = ase
|
||||
SUBDIRS = qse
|
||||
all: all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -4,16 +4,16 @@
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_AWK_HPP_
|
||||
#define _ASE_AWK_AWK_HPP_
|
||||
#ifndef _QSE_AWK_AWK_HPP_
|
||||
#define _QSE_AWK_AWK_HPP_
|
||||
|
||||
#include <ase/awk/awk.h>
|
||||
#include <ase/cmn/map.h>
|
||||
#include <ase/cmn/chr.h>
|
||||
#include <qse/awk/awk.h>
|
||||
#include <qse/cmn/map.h>
|
||||
#include <qse/cmn/chr.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/////////////////////////////////
|
||||
ASE_BEGIN_NAMESPACE(ASE)
|
||||
QSE_BEGIN_NAMESPACE(ASE)
|
||||
/////////////////////////////////
|
||||
|
||||
/**
|
||||
@ -23,46 +23,46 @@ class Awk
|
||||
{
|
||||
public:
|
||||
/** Boolean data type */
|
||||
typedef ase_bool_t bool_t;
|
||||
typedef qse_bool_t bool_t;
|
||||
/** Data type that can hold any character */
|
||||
typedef ase_char_t char_t;
|
||||
typedef qse_char_t char_t;
|
||||
/** Data type that can hold any character or an end-of-file value */
|
||||
typedef ase_cint_t cint_t;
|
||||
typedef qse_cint_t cint_t;
|
||||
/** Represents an unsigned integer number of the same size as void* */
|
||||
typedef ase_size_t size_t;
|
||||
typedef qse_size_t size_t;
|
||||
/** Signed version of size_t */
|
||||
typedef ase_ssize_t ssize_t;
|
||||
typedef qse_ssize_t ssize_t;
|
||||
/** Represents an integer */
|
||||
typedef ase_long_t long_t;
|
||||
typedef qse_long_t long_t;
|
||||
/** Represents a floating-point number */
|
||||
typedef ase_real_t real_t;
|
||||
typedef qse_real_t real_t;
|
||||
/** Represents the internal hash table */
|
||||
typedef ase_map_t map_t;
|
||||
typedef qse_map_t map_t;
|
||||
/** Represents a key/value pair */
|
||||
typedef ase_map_pair_t pair_t;
|
||||
typedef qse_map_pair_t pair_t;
|
||||
|
||||
/** Represents an internal awk value */
|
||||
typedef ase_awk_val_t val_t;
|
||||
typedef qse_awk_val_t val_t;
|
||||
/** Represents the external I/O context */
|
||||
typedef ase_awk_extio_t extio_t;
|
||||
typedef qse_awk_extio_t extio_t;
|
||||
/** Represents the run-time context */
|
||||
typedef ase_awk_run_t run_t;
|
||||
typedef qse_awk_run_t run_t;
|
||||
/** Represents the underlying interpreter */
|
||||
typedef ase_awk_t awk_t;
|
||||
typedef qse_awk_t awk_t;
|
||||
|
||||
enum ccls_type_t
|
||||
{
|
||||
CCLS_UPPER = ASE_CCLS_UPPER,
|
||||
CCLS_LOWER = ASE_CCLS_LOWER,
|
||||
CCLS_ALPHA = ASE_CCLS_ALPHA,
|
||||
CCLS_DIGIT = ASE_CCLS_DIGIT,
|
||||
CCLS_XDIGIT = ASE_CCLS_XDIGIT,
|
||||
CCLS_ALNUM = ASE_CCLS_ALNUM,
|
||||
CCLS_SPACE = ASE_CCLS_SPACE,
|
||||
CCLS_PRINT = ASE_CCLS_PRINT,
|
||||
CCLS_GRAPH = ASE_CCLS_GRAPH,
|
||||
CCLS_CNTRL = ASE_CCLS_CNTRL,
|
||||
CCLS_PUNCT = ASE_CCLS_PUNCT
|
||||
CCLS_UPPER = QSE_CCLS_UPPER,
|
||||
CCLS_LOWER = QSE_CCLS_LOWER,
|
||||
CCLS_ALPHA = QSE_CCLS_ALPHA,
|
||||
CCLS_DIGIT = QSE_CCLS_DIGIT,
|
||||
CCLS_XDIGIT = QSE_CCLS_XDIGIT,
|
||||
CCLS_ALNUM = QSE_CCLS_ALNUM,
|
||||
CCLS_SPACE = QSE_CCLS_SPACE,
|
||||
CCLS_PRINT = QSE_CCLS_PRINT,
|
||||
CCLS_GRAPH = QSE_CCLS_GRAPH,
|
||||
CCLS_CNTRL = QSE_CCLS_CNTRL,
|
||||
CCLS_PUNCT = QSE_CCLS_PUNCT
|
||||
};
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the value set with Source::setHandle.
|
||||
* ASE_NULL is returned if it has not been set with
|
||||
* QSE_NULL is returned if it has not been set with
|
||||
* Source::setHandle. You usually call this method
|
||||
* from Awk::readSource, Awk::writeSource, and
|
||||
* Awk::closeSource to get the value set in Awk::openSource
|
||||
@ -159,7 +159,7 @@ public:
|
||||
* </pre>
|
||||
*
|
||||
* @return an arbitrary value of type void* set with
|
||||
* Source::setHandle or ASE_NULL
|
||||
* Source::setHandle or QSE_NULL
|
||||
*/
|
||||
const void* getHandle () const;
|
||||
|
||||
@ -236,8 +236,8 @@ public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_PIPE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_PIPE_WRITE
|
||||
READ = QSE_AWK_EXTIO_PIPE_READ,
|
||||
WRITE = QSE_AWK_EXTIO_PIPE_WRITE
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -257,9 +257,9 @@ public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_FILE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_FILE_WRITE,
|
||||
APPEND = ASE_AWK_EXTIO_FILE_APPEND
|
||||
READ = QSE_AWK_EXTIO_FILE_READ,
|
||||
WRITE = QSE_AWK_EXTIO_FILE_WRITE,
|
||||
APPEND = QSE_AWK_EXTIO_FILE_APPEND
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -279,8 +279,8 @@ public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_CONSOLE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_CONSOLE_WRITE
|
||||
READ = QSE_AWK_EXTIO_CONSOLE_READ,
|
||||
WRITE = QSE_AWK_EXTIO_CONSOLE_WRITE
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -362,8 +362,8 @@ public:
|
||||
Run* run;
|
||||
val_t* val;
|
||||
|
||||
ase_long_t inum;
|
||||
ase_real_t rnum;
|
||||
qse_long_t inum;
|
||||
qse_real_t rnum;
|
||||
mutable struct
|
||||
{
|
||||
char_t* ptr;
|
||||
@ -417,135 +417,135 @@ public:
|
||||
/** Defines the error code */
|
||||
enum ErrorCode
|
||||
{
|
||||
ERR_NOERR = ASE_AWK_ENOERR,
|
||||
ERR_CUSTOM = ASE_AWK_ECUSTOM,
|
||||
ERR_INVAL = ASE_AWK_EINVAL,
|
||||
ERR_NOMEM = ASE_AWK_ENOMEM,
|
||||
ERR_NOSUP = ASE_AWK_ENOSUP,
|
||||
ERR_NOPER = ASE_AWK_ENOPER,
|
||||
ERR_NODEV = ASE_AWK_ENODEV,
|
||||
ERR_NOSPC = ASE_AWK_ENOSPC,
|
||||
ERR_MFILE = ASE_AWK_EMFILE,
|
||||
ERR_MLINK = ASE_AWK_EMLINK,
|
||||
ERR_AGAIN = ASE_AWK_EAGAIN,
|
||||
ERR_NOENT = ASE_AWK_ENOENT,
|
||||
ERR_EXIST = ASE_AWK_EEXIST,
|
||||
ERR_FTBIG = ASE_AWK_EFTBIG,
|
||||
ERR_TBUSY = ASE_AWK_ETBUSY,
|
||||
ERR_ISDIR = ASE_AWK_EISDIR,
|
||||
ERR_IOERR = ASE_AWK_EIOERR,
|
||||
ERR_OPEN = ASE_AWK_EOPEN,
|
||||
ERR_READ = ASE_AWK_EREAD,
|
||||
ERR_WRITE = ASE_AWK_EWRITE,
|
||||
ERR_CLOSE = ASE_AWK_ECLOSE,
|
||||
ERR_INTERN = ASE_AWK_EINTERN,
|
||||
ERR_RUNTIME = ASE_AWK_ERUNTIME,
|
||||
ERR_BLKNST = ASE_AWK_EBLKNST,
|
||||
ERR_EXPRNST = ASE_AWK_EEXPRNST,
|
||||
ERR_SINOP = ASE_AWK_ESINOP,
|
||||
ERR_SINCL = ASE_AWK_ESINCL,
|
||||
ERR_SINRD = ASE_AWK_ESINRD,
|
||||
ERR_SOUTOP = ASE_AWK_ESOUTOP,
|
||||
ERR_SOUTCL = ASE_AWK_ESOUTCL,
|
||||
ERR_SOUTWR = ASE_AWK_ESOUTWR,
|
||||
ERR_LXCHR = ASE_AWK_ELXCHR,
|
||||
ERR_LXDIG = ASE_AWK_ELXDIG,
|
||||
ERR_LXUNG = ASE_AWK_ELXUNG,
|
||||
ERR_ENDSRC = ASE_AWK_EENDSRC,
|
||||
ERR_ENDCMT = ASE_AWK_EENDCMT,
|
||||
ERR_ENDSTR = ASE_AWK_EENDSTR,
|
||||
ERR_ENDREX = ASE_AWK_EENDREX,
|
||||
ERR_LBRACE = ASE_AWK_ELBRACE,
|
||||
ERR_LPAREN = ASE_AWK_ELPAREN,
|
||||
ERR_RPAREN = ASE_AWK_ERPAREN,
|
||||
ERR_RBRACK = ASE_AWK_ERBRACK,
|
||||
ERR_COMMA = ASE_AWK_ECOMMA,
|
||||
ERR_SCOLON = ASE_AWK_ESCOLON,
|
||||
ERR_COLON = ASE_AWK_ECOLON,
|
||||
ERR_STMEND = ASE_AWK_ESTMEND,
|
||||
ERR_IN = ASE_AWK_EIN,
|
||||
ERR_NOTVAR = ASE_AWK_ENOTVAR,
|
||||
ERR_EXPRES = ASE_AWK_EEXPRES,
|
||||
ERR_FUNC = ASE_AWK_EFUNC,
|
||||
ERR_WHILE = ASE_AWK_EWHILE,
|
||||
ERR_ASSIGN = ASE_AWK_EASSIGN,
|
||||
ERR_IDENT = ASE_AWK_EIDENT,
|
||||
ERR_FNNAME = ASE_AWK_EFNNAME,
|
||||
ERR_BLKBEG = ASE_AWK_EBLKBEG,
|
||||
ERR_BLKEND = ASE_AWK_EBLKEND,
|
||||
ERR_DUPBEG = ASE_AWK_EDUPBEG,
|
||||
ERR_DUPEND = ASE_AWK_EDUPEND,
|
||||
ERR_BFNRED = ASE_AWK_EBFNRED,
|
||||
ERR_AFNRED = ASE_AWK_EAFNRED,
|
||||
ERR_GBLRED = ASE_AWK_EGBLRED,
|
||||
ERR_PARRED = ASE_AWK_EPARRED,
|
||||
ERR_VARRED = ASE_AWK_EVARRED,
|
||||
ERR_DUPPAR = ASE_AWK_EDUPPAR,
|
||||
ERR_DUPGBL = ASE_AWK_EDUPGBL,
|
||||
ERR_DUPLCL = ASE_AWK_EDUPLCL,
|
||||
ERR_BADPAR = ASE_AWK_EBADPAR,
|
||||
ERR_BADVAR = ASE_AWK_EBADVAR,
|
||||
ERR_UNDEF = ASE_AWK_EUNDEF,
|
||||
ERR_LVALUE = ASE_AWK_ELVALUE,
|
||||
ERR_GBLTM = ASE_AWK_EGBLTM,
|
||||
ERR_LCLTM = ASE_AWK_ELCLTM,
|
||||
ERR_PARTM = ASE_AWK_EPARTM,
|
||||
ERR_DELETE = ASE_AWK_EDELETE,
|
||||
ERR_BREAK = ASE_AWK_EBREAK,
|
||||
ERR_CONTINUE = ASE_AWK_ECONTINUE,
|
||||
ERR_NEXTBEG = ASE_AWK_ENEXTBEG,
|
||||
ERR_NEXTEND = ASE_AWK_ENEXTEND,
|
||||
ERR_NEXTFBEG = ASE_AWK_ENEXTFBEG,
|
||||
ERR_NEXTFEND = ASE_AWK_ENEXTFEND,
|
||||
ERR_PRINTFARG = ASE_AWK_EPRINTFARG,
|
||||
ERR_PREPST = ASE_AWK_EPREPST,
|
||||
ERR_GLNCPS = ASE_AWK_EGLNCPS,
|
||||
ERR_DIVBY0 = ASE_AWK_EDIVBY0,
|
||||
ERR_OPERAND = ASE_AWK_EOPERAND,
|
||||
ERR_POSIDX = ASE_AWK_EPOSIDX,
|
||||
ERR_ARGTF = ASE_AWK_EARGTF,
|
||||
ERR_ARGTM = ASE_AWK_EARGTM,
|
||||
ERR_FNNONE = ASE_AWK_EFNNONE,
|
||||
ERR_NOTIDX = ASE_AWK_ENOTIDX,
|
||||
ERR_NOTDEL = ASE_AWK_ENOTDEL,
|
||||
ERR_NOTMAP = ASE_AWK_ENOTMAP,
|
||||
ERR_NOTMAPIN = ASE_AWK_ENOTMAPIN,
|
||||
ERR_NOTMAPNILIN = ASE_AWK_ENOTMAPNILIN,
|
||||
ERR_NOTREF = ASE_AWK_ENOTREF,
|
||||
ERR_NOTASS = ASE_AWK_ENOTASS,
|
||||
ERR_IDXVALASSMAP = ASE_AWK_EIDXVALASSMAP,
|
||||
ERR_POSVALASSMAP = ASE_AWK_EPOSVALASSMAP,
|
||||
ERR_MAPTOSCALAR = ASE_AWK_EMAPTOSCALAR,
|
||||
ERR_SCALARTOMAP = ASE_AWK_ESCALARTOMAP,
|
||||
ERR_MAPNOTALLOWED = ASE_AWK_EMAPNOTALLOWED,
|
||||
ERR_VALTYPE = ASE_AWK_EVALTYPE,
|
||||
ERR_RDELETE = ASE_AWK_ERDELETE,
|
||||
ERR_RNEXTBEG = ASE_AWK_ERNEXTBEG,
|
||||
ERR_RNEXTEND = ASE_AWK_ERNEXTEND,
|
||||
ERR_RNEXTFBEG = ASE_AWK_ERNEXTFBEG,
|
||||
ERR_RNEXTFEND = ASE_AWK_ERNEXTFEND,
|
||||
ERR_BFNUSER = ASE_AWK_EBFNUSER,
|
||||
ERR_BFNIMPL = ASE_AWK_EBFNIMPL,
|
||||
ERR_IOUSER = ASE_AWK_EIOUSER,
|
||||
ERR_IONONE = ASE_AWK_EIONONE,
|
||||
ERR_IOIMPL = ASE_AWK_EIOIMPL,
|
||||
ERR_IONMEM = ASE_AWK_EIONMEM,
|
||||
ERR_IONMNL = ASE_AWK_EIONMNL,
|
||||
ERR_FMTARG = ASE_AWK_EFMTARG,
|
||||
ERR_FMTCNV = ASE_AWK_EFMTCNV,
|
||||
ERR_CONVFMTCHR = ASE_AWK_ECONVFMTCHR,
|
||||
ERR_OFMTCHR = ASE_AWK_EOFMTCHR,
|
||||
ERR_REXRECUR = ASE_AWK_EREXRECUR,
|
||||
ERR_REXRPAREN = ASE_AWK_EREXRPAREN,
|
||||
ERR_REXRBRACKET = ASE_AWK_EREXRBRACKET,
|
||||
ERR_REXRBRACE = ASE_AWK_EREXRBRACE,
|
||||
ERR_REXUNBALPAR = ASE_AWK_EREXUNBALPAR,
|
||||
ERR_REXCOLON = ASE_AWK_EREXCOLON,
|
||||
ERR_REXCRANGE = ASE_AWK_EREXCRANGE,
|
||||
ERR_REXCCLASS = ASE_AWK_EREXCCLASS,
|
||||
ERR_REXBRANGE = ASE_AWK_EREXBRANGE,
|
||||
ERR_REXEND = ASE_AWK_EREXEND,
|
||||
ERR_REXGARBAGE = ASE_AWK_EREXGARBAGE,
|
||||
ERR_NOERR = QSE_AWK_ENOERR,
|
||||
ERR_CUSTOM = QSE_AWK_ECUSTOM,
|
||||
ERR_INVAL = QSE_AWK_EINVAL,
|
||||
ERR_NOMEM = QSE_AWK_ENOMEM,
|
||||
ERR_NOSUP = QSE_AWK_ENOSUP,
|
||||
ERR_NOPER = QSE_AWK_ENOPER,
|
||||
ERR_NODEV = QSE_AWK_ENODEV,
|
||||
ERR_NOSPC = QSE_AWK_ENOSPC,
|
||||
ERR_MFILE = QSE_AWK_EMFILE,
|
||||
ERR_MLINK = QSE_AWK_EMLINK,
|
||||
ERR_AGAIN = QSE_AWK_EAGAIN,
|
||||
ERR_NOENT = QSE_AWK_ENOENT,
|
||||
ERR_EXIST = QSE_AWK_EEXIST,
|
||||
ERR_FTBIG = QSE_AWK_EFTBIG,
|
||||
ERR_TBUSY = QSE_AWK_ETBUSY,
|
||||
ERR_ISDIR = QSE_AWK_EISDIR,
|
||||
ERR_IOERR = QSE_AWK_EIOERR,
|
||||
ERR_OPEN = QSE_AWK_EOPEN,
|
||||
ERR_READ = QSE_AWK_EREAD,
|
||||
ERR_WRITE = QSE_AWK_EWRITE,
|
||||
ERR_CLOSE = QSE_AWK_ECLOSE,
|
||||
ERR_INTERN = QSE_AWK_EINTERN,
|
||||
ERR_RUNTIME = QSE_AWK_ERUNTIME,
|
||||
ERR_BLKNST = QSE_AWK_EBLKNST,
|
||||
ERR_EXPRNST = QSE_AWK_EEXPRNST,
|
||||
ERR_SINOP = QSE_AWK_ESINOP,
|
||||
ERR_SINCL = QSE_AWK_ESINCL,
|
||||
ERR_SINRD = QSE_AWK_ESINRD,
|
||||
ERR_SOUTOP = QSE_AWK_ESOUTOP,
|
||||
ERR_SOUTCL = QSE_AWK_ESOUTCL,
|
||||
ERR_SOUTWR = QSE_AWK_ESOUTWR,
|
||||
ERR_LXCHR = QSE_AWK_ELXCHR,
|
||||
ERR_LXDIG = QSE_AWK_ELXDIG,
|
||||
ERR_LXUNG = QSE_AWK_ELXUNG,
|
||||
ERR_ENDSRC = QSE_AWK_EENDSRC,
|
||||
ERR_ENDCMT = QSE_AWK_EENDCMT,
|
||||
ERR_ENDSTR = QSE_AWK_EENDSTR,
|
||||
ERR_ENDREX = QSE_AWK_EENDREX,
|
||||
ERR_LBRACE = QSE_AWK_ELBRACE,
|
||||
ERR_LPAREN = QSE_AWK_ELPAREN,
|
||||
ERR_RPAREN = QSE_AWK_ERPAREN,
|
||||
ERR_RBRACK = QSE_AWK_ERBRACK,
|
||||
ERR_COMMA = QSE_AWK_ECOMMA,
|
||||
ERR_SCOLON = QSE_AWK_ESCOLON,
|
||||
ERR_COLON = QSE_AWK_ECOLON,
|
||||
ERR_STMEND = QSE_AWK_ESTMEND,
|
||||
ERR_IN = QSE_AWK_EIN,
|
||||
ERR_NOTVAR = QSE_AWK_ENOTVAR,
|
||||
ERR_EXPRES = QSE_AWK_EEXPRES,
|
||||
ERR_FUNC = QSE_AWK_EFUNC,
|
||||
ERR_WHILE = QSE_AWK_EWHILE,
|
||||
ERR_ASSIGN = QSE_AWK_EASSIGN,
|
||||
ERR_IDENT = QSE_AWK_EIDENT,
|
||||
ERR_FNNAME = QSE_AWK_EFNNAME,
|
||||
ERR_BLKBEG = QSE_AWK_EBLKBEG,
|
||||
ERR_BLKEND = QSE_AWK_EBLKEND,
|
||||
ERR_DUPBEG = QSE_AWK_EDUPBEG,
|
||||
ERR_DUPEND = QSE_AWK_EDUPEND,
|
||||
ERR_BFNRED = QSE_AWK_EBFNRED,
|
||||
ERR_AFNRED = QSE_AWK_EAFNRED,
|
||||
ERR_GBLRED = QSE_AWK_EGBLRED,
|
||||
ERR_PARRED = QSE_AWK_EPARRED,
|
||||
ERR_VARRED = QSE_AWK_EVARRED,
|
||||
ERR_DUPPAR = QSE_AWK_EDUPPAR,
|
||||
ERR_DUPGBL = QSE_AWK_EDUPGBL,
|
||||
ERR_DUPLCL = QSE_AWK_EDUPLCL,
|
||||
ERR_BADPAR = QSE_AWK_EBADPAR,
|
||||
ERR_BADVAR = QSE_AWK_EBADVAR,
|
||||
ERR_UNDEF = QSE_AWK_EUNDEF,
|
||||
ERR_LVALUE = QSE_AWK_ELVALUE,
|
||||
ERR_GBLTM = QSE_AWK_EGBLTM,
|
||||
ERR_LCLTM = QSE_AWK_ELCLTM,
|
||||
ERR_PARTM = QSE_AWK_EPARTM,
|
||||
ERR_DELETE = QSE_AWK_EDELETE,
|
||||
ERR_BREAK = QSE_AWK_EBREAK,
|
||||
ERR_CONTINUE = QSE_AWK_ECONTINUE,
|
||||
ERR_NEXTBEG = QSE_AWK_ENEXTBEG,
|
||||
ERR_NEXTEND = QSE_AWK_ENEXTEND,
|
||||
ERR_NEXTFBEG = QSE_AWK_ENEXTFBEG,
|
||||
ERR_NEXTFEND = QSE_AWK_ENEXTFEND,
|
||||
ERR_PRINTFARG = QSE_AWK_EPRINTFARG,
|
||||
ERR_PREPST = QSE_AWK_EPREPST,
|
||||
ERR_GLNCPS = QSE_AWK_EGLNCPS,
|
||||
ERR_DIVBY0 = QSE_AWK_EDIVBY0,
|
||||
ERR_OPERAND = QSE_AWK_EOPERAND,
|
||||
ERR_POSIDX = QSE_AWK_EPOSIDX,
|
||||
ERR_ARGTF = QSE_AWK_EARGTF,
|
||||
ERR_ARGTM = QSE_AWK_EARGTM,
|
||||
ERR_FNNONE = QSE_AWK_EFNNONE,
|
||||
ERR_NOTIDX = QSE_AWK_ENOTIDX,
|
||||
ERR_NOTDEL = QSE_AWK_ENOTDEL,
|
||||
ERR_NOTMAP = QSE_AWK_ENOTMAP,
|
||||
ERR_NOTMAPIN = QSE_AWK_ENOTMAPIN,
|
||||
ERR_NOTMAPNILIN = QSE_AWK_ENOTMAPNILIN,
|
||||
ERR_NOTREF = QSE_AWK_ENOTREF,
|
||||
ERR_NOTASS = QSE_AWK_ENOTASS,
|
||||
ERR_IDXVALASSMAP = QSE_AWK_EIDXVALASSMAP,
|
||||
ERR_POSVALASSMAP = QSE_AWK_EPOSVALASSMAP,
|
||||
ERR_MAPTOSCALAR = QSE_AWK_EMAPTOSCALAR,
|
||||
ERR_SCALARTOMAP = QSE_AWK_ESCALARTOMAP,
|
||||
ERR_MAPNOTALLOWED = QSE_AWK_EMAPNOTALLOWED,
|
||||
ERR_VALTYPE = QSE_AWK_EVALTYPE,
|
||||
ERR_RDELETE = QSE_AWK_ERDELETE,
|
||||
ERR_RNEXTBEG = QSE_AWK_ERNEXTBEG,
|
||||
ERR_RNEXTEND = QSE_AWK_ERNEXTEND,
|
||||
ERR_RNEXTFBEG = QSE_AWK_ERNEXTFBEG,
|
||||
ERR_RNEXTFEND = QSE_AWK_ERNEXTFEND,
|
||||
ERR_BFNUSER = QSE_AWK_EBFNUSER,
|
||||
ERR_BFNIMPL = QSE_AWK_EBFNIMPL,
|
||||
ERR_IOUSER = QSE_AWK_EIOUSER,
|
||||
ERR_IONONE = QSE_AWK_EIONONE,
|
||||
ERR_IOIMPL = QSE_AWK_EIOIMPL,
|
||||
ERR_IONMEM = QSE_AWK_EIONMEM,
|
||||
ERR_IONMNL = QSE_AWK_EIONMNL,
|
||||
ERR_FMTARG = QSE_AWK_EFMTARG,
|
||||
ERR_FMTCNV = QSE_AWK_EFMTCNV,
|
||||
ERR_CONVFMTCHR = QSE_AWK_ECONVFMTCHR,
|
||||
ERR_OFMTCHR = QSE_AWK_EOFMTCHR,
|
||||
ERR_REXRECUR = QSE_AWK_EREXRECUR,
|
||||
ERR_REXRPAREN = QSE_AWK_EREXRPAREN,
|
||||
ERR_REXRBRACKET = QSE_AWK_EREXRBRACKET,
|
||||
ERR_REXRBRACE = QSE_AWK_EREXRBRACE,
|
||||
ERR_REXUNBALPAR = QSE_AWK_EREXUNBALPAR,
|
||||
ERR_REXCOLON = QSE_AWK_EREXCOLON,
|
||||
ERR_REXCRANGE = QSE_AWK_EREXCRANGE,
|
||||
ERR_REXCCLASS = QSE_AWK_EREXCCLASS,
|
||||
ERR_REXBRANGE = QSE_AWK_EREXBRANGE,
|
||||
ERR_REXEND = QSE_AWK_EREXEND,
|
||||
ERR_REXGARBAGE = QSE_AWK_EREXGARBAGE,
|
||||
};
|
||||
// end of enum ErrorCode
|
||||
|
||||
@ -554,58 +554,58 @@ public:
|
||||
/** Defines options */
|
||||
enum Option
|
||||
{
|
||||
OPT_IMPLICIT = ASE_AWK_IMPLICIT,
|
||||
OPT_EXPLICIT = ASE_AWK_EXPLICIT,
|
||||
OPT_BXOR = ASE_AWK_BXOR,
|
||||
OPT_SHIFT = ASE_AWK_SHIFT,
|
||||
OPT_IDIV = ASE_AWK_IDIV,
|
||||
OPT_EXTIO = ASE_AWK_EXTIO,
|
||||
OPT_COPROC = ASE_AWK_COPROC,
|
||||
OPT_IMPLICIT = QSE_AWK_IMPLICIT,
|
||||
OPT_EXPLICIT = QSE_AWK_EXPLICIT,
|
||||
OPT_BXOR = QSE_AWK_BXOR,
|
||||
OPT_SHIFT = QSE_AWK_SHIFT,
|
||||
OPT_IDIV = QSE_AWK_IDIV,
|
||||
OPT_EXTIO = QSE_AWK_EXTIO,
|
||||
OPT_COPROC = QSE_AWK_COPROC,
|
||||
|
||||
/** Can terminate a statement with a new line */
|
||||
OPT_NEWLINE = ASE_AWK_NEWLINE,
|
||||
OPT_NEWLINE = QSE_AWK_NEWLINE,
|
||||
|
||||
OPT_BASEONE = ASE_AWK_BASEONE,
|
||||
OPT_STRIPSPACES = ASE_AWK_STRIPSPACES,
|
||||
OPT_BASEONE = QSE_AWK_BASEONE,
|
||||
OPT_STRIPSPACES = QSE_AWK_STRIPSPACES,
|
||||
|
||||
/** Support the nextofile statement */
|
||||
OPT_NEXTOFILE = ASE_AWK_NEXTOFILE,
|
||||
OPT_NEXTOFILE = QSE_AWK_NEXTOFILE,
|
||||
/** Use CR+LF instead of LF for line breaking. */
|
||||
OPT_CRLF = ASE_AWK_CRLF,
|
||||
OPT_CRLF = QSE_AWK_CRLF,
|
||||
/**
|
||||
* When set, the values specified in a call to Awk::run
|
||||
* as the second and the third parameter are passed to
|
||||
* the function specified as the first parameter.
|
||||
*/
|
||||
OPT_ARGSTOMAIN = ASE_AWK_ARGSTOMAIN,
|
||||
OPT_ARGSTOMAIN = QSE_AWK_ARGSTOMAIN,
|
||||
/** Enables the keyword 'reset' */
|
||||
OPT_RESET = ASE_AWK_RESET,
|
||||
OPT_RESET = QSE_AWK_RESET,
|
||||
/** Allows the assignment of a map value to a variable */
|
||||
OPT_MAPTOVAR = ASE_AWK_MAPTOVAR,
|
||||
OPT_MAPTOVAR = QSE_AWK_MAPTOVAR,
|
||||
/** Allows BEGIN, END, pattern-action blocks */
|
||||
OPT_PABLOCK = ASE_AWK_PABLOCK
|
||||
OPT_PABLOCK = QSE_AWK_PABLOCK
|
||||
};
|
||||
// end of enum Option
|
||||
|
||||
enum Global
|
||||
{
|
||||
GBL_ARGC = ASE_AWK_GLOBAL_ARGC,
|
||||
GBL_ARGV = ASE_AWK_GLOBAL_ARGV,
|
||||
GBL_CONVFMT = ASE_AWK_GLOBAL_CONVFMT,
|
||||
GBL_FILENAME = ASE_AWK_GLOBAL_FILENAME,
|
||||
GBL_FNR = ASE_AWK_GLOBAL_FNR,
|
||||
GBL_FS = ASE_AWK_GLOBAL_FS,
|
||||
GBL_IGNORECASE = ASE_AWK_GLOBAL_IGNORECASE,
|
||||
GBL_NF = ASE_AWK_GLOBAL_NF,
|
||||
GBL_NR = ASE_AWK_GLOBAL_NR,
|
||||
GBL_OFILENAME = ASE_AWK_GLOBAL_OFILENAME,
|
||||
GBL_OFMT = ASE_AWK_GLOBAL_OFMT,
|
||||
GBL_OFS = ASE_AWK_GLOBAL_OFS,
|
||||
GBL_ORS = ASE_AWK_GLOBAL_ORS,
|
||||
GBL_RLENGTH = ASE_AWK_GLOBAL_RLENGTH,
|
||||
GBL_RS = ASE_AWK_GLOBAL_RS,
|
||||
GBL_RSTART = ASE_AWK_GLOBAL_RSTART,
|
||||
GBL_SUBSEP = ASE_AWK_GLOBAL_SUBSEP
|
||||
GBL_ARGC = QSE_AWK_GLOBAL_ARGC,
|
||||
GBL_ARGV = QSE_AWK_GLOBAL_ARGV,
|
||||
GBL_CONVFMT = QSE_AWK_GLOBAL_CONVFMT,
|
||||
GBL_FILENAME = QSE_AWK_GLOBAL_FILENAME,
|
||||
GBL_FNR = QSE_AWK_GLOBAL_FNR,
|
||||
GBL_FS = QSE_AWK_GLOBAL_FS,
|
||||
GBL_IGNORECASE = QSE_AWK_GLOBAL_IGNORECASE,
|
||||
GBL_NF = QSE_AWK_GLOBAL_NF,
|
||||
GBL_NR = QSE_AWK_GLOBAL_NR,
|
||||
GBL_OFILENAME = QSE_AWK_GLOBAL_OFILENAME,
|
||||
GBL_OFMT = QSE_AWK_GLOBAL_OFMT,
|
||||
GBL_OFS = QSE_AWK_GLOBAL_OFS,
|
||||
GBL_ORS = QSE_AWK_GLOBAL_ORS,
|
||||
GBL_RLENGTH = QSE_AWK_GLOBAL_RLENGTH,
|
||||
GBL_RS = QSE_AWK_GLOBAL_RS,
|
||||
GBL_RSTART = QSE_AWK_GLOBAL_RSTART,
|
||||
GBL_SUBSEP = QSE_AWK_GLOBAL_SUBSEP
|
||||
};
|
||||
|
||||
/** Represents the execution context */
|
||||
@ -799,12 +799,12 @@ public:
|
||||
/** Defines the depth ID */
|
||||
enum Depth
|
||||
{
|
||||
DEPTH_BLOCK_PARSE = ASE_AWK_DEPTH_BLOCK_PARSE,
|
||||
DEPTH_BLOCK_RUN = ASE_AWK_DEPTH_BLOCK_RUN,
|
||||
DEPTH_EXPR_PARSE = ASE_AWK_DEPTH_EXPR_PARSE,
|
||||
DEPTH_EXPR_RUN = ASE_AWK_DEPTH_EXPR_RUN,
|
||||
DEPTH_REX_BUILD = ASE_AWK_DEPTH_REX_BUILD,
|
||||
DEPTH_REX_MATCH = ASE_AWK_DEPTH_REX_MATCH
|
||||
DEPTH_BLOCK_PARSE = QSE_AWK_DEPTH_BLOCK_PARSE,
|
||||
DEPTH_BLOCK_RUN = QSE_AWK_DEPTH_BLOCK_RUN,
|
||||
DEPTH_EXPR_PARSE = QSE_AWK_DEPTH_EXPR_PARSE,
|
||||
DEPTH_EXPR_RUN = QSE_AWK_DEPTH_EXPR_RUN,
|
||||
DEPTH_REX_BUILD = QSE_AWK_DEPTH_REX_BUILD,
|
||||
DEPTH_REX_MATCH = QSE_AWK_DEPTH_REX_MATCH
|
||||
};
|
||||
|
||||
/** Sets the maximum depth */
|
||||
@ -816,16 +816,16 @@ public:
|
||||
virtual int setErrorString (ErrorCode num, const char_t* str);
|
||||
|
||||
virtual int getWord (
|
||||
const char_t* ow, ase_size_t owl,
|
||||
const char_t** nw, ase_size_t* nwl);
|
||||
const char_t* ow, qse_size_t owl,
|
||||
const char_t** nw, qse_size_t* nwl);
|
||||
virtual int setWord (
|
||||
const char_t* ow, const char_t* nw);
|
||||
virtual int setWord (
|
||||
const char_t* ow, ase_size_t owl,
|
||||
const char_t* nw, ase_size_t nwl);
|
||||
const char_t* ow, qse_size_t owl,
|
||||
const char_t* nw, qse_size_t nwl);
|
||||
|
||||
virtual int unsetWord (const char_t* ow);
|
||||
virtual int unsetWord (const char_t* ow, ase_size_t owl);
|
||||
virtual int unsetWord (const char_t* ow, qse_size_t owl);
|
||||
virtual int unsetAllWords ();
|
||||
|
||||
/**
|
||||
@ -870,8 +870,8 @@ public:
|
||||
* with Awk::enableRunCallback and Awk::disableRunCallback.
|
||||
* Call Awk::getErrorCode to get extended error information.
|
||||
*/
|
||||
virtual int run (const char_t* main = ASE_NULL,
|
||||
const char_t** args = ASE_NULL, size_t nargs = 0);
|
||||
virtual int run (const char_t* main = QSE_NULL,
|
||||
const char_t** args = QSE_NULL, size_t nargs = 0);
|
||||
|
||||
/**
|
||||
* Requests aborting execution of the parse tree
|
||||
@ -1071,8 +1071,8 @@ protected:
|
||||
static void* reallocMem (void* data, void* ptr, size_t n);
|
||||
static void freeMem (void* data, void* ptr);
|
||||
|
||||
static bool_t isType (void* data, cint_t c, ase_ccls_type_t type);
|
||||
static cint_t transCase (void* data, cint_t c, ase_ccls_type_t type);
|
||||
static bool_t isType (void* data, cint_t c, qse_ccls_type_t type);
|
||||
static cint_t transCase (void* data, cint_t c, qse_ccls_type_t type);
|
||||
|
||||
static real_t pow (void* data, real_t x, real_t y);
|
||||
static int sprintf (void* data, char_t* buf, size_t size,
|
||||
@ -1097,13 +1097,13 @@ private:
|
||||
|
||||
void triggerOnRunStart (Run& run);
|
||||
|
||||
ase_mmgr_t mmgr;
|
||||
ase_ccls_t ccls;
|
||||
ase_awk_prmfns_t prmfns;
|
||||
qse_mmgr_t mmgr;
|
||||
qse_ccls_t ccls;
|
||||
qse_awk_prmfns_t prmfns;
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
ASE_END_NAMESPACE(ASE)
|
||||
QSE_END_NAMESPACE(ASE)
|
||||
/////////////////////////////////
|
||||
|
||||
#endif
|
@ -4,13 +4,13 @@
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_STDAWK_HPP_
|
||||
#define _ASE_AWK_STDAWK_HPP_
|
||||
#ifndef _QSE_AWK_STDAWK_HPP_
|
||||
#define _QSE_AWK_STDAWK_HPP_
|
||||
|
||||
#include <ase/awk/Awk.hpp>
|
||||
#include <qse/awk/Awk.hpp>
|
||||
|
||||
/////////////////////////////////
|
||||
ASE_BEGIN_NAMESPACE(ASE)
|
||||
QSE_BEGIN_NAMESPACE(ASE)
|
||||
/////////////////////////////////
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ protected:
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
ASE_END_NAMESPACE(ASE)
|
||||
QSE_END_NAMESPACE(ASE)
|
||||
/////////////////////////////////
|
||||
|
||||
#endif
|
1210
qse/include/qse/awk/awk.h
Normal file
1210
qse/include/qse/awk/awk.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,5 +5,5 @@ if ENABLE_CXX
|
||||
pkginclude_HEADERS += Awk.hpp StdAwk.hpp
|
||||
endif
|
||||
|
||||
pkgincludedir= $(includedir)/ase/awk
|
||||
pkgincludedir= $(includedir)/qse/awk
|
||||
CLEANFILES = *dist
|
@ -32,7 +32,7 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@ENABLE_CXX_TRUE@am__append_1 = Awk.hpp StdAwk.hpp
|
||||
subdir = include/ase/awk
|
||||
subdir = include/qse/awk
|
||||
DIST_COMMON = $(am__pkginclude_HEADERS_DIST) $(srcdir)/makefile.am \
|
||||
$(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -40,7 +40,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
@ -57,7 +57,7 @@ HEADERS = $(pkginclude_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase/awk
|
||||
pkgincludedir = $(includedir)/qse/awk
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -194,9 +194,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/awk/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/awk/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/awk/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/awk/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
97
qse/include/qse/cmn/chr.h
Normal file
97
qse/include/qse/cmn/chr.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* $Id: ctype.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_CHR_H_
|
||||
#define _QSE_CMN_CHR_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/* gets a pointer to the default memory manager */
|
||||
#define QSE_CCLS_GETDFL() (qse_ccls)
|
||||
|
||||
/* sets a pointer to the default memory manager */
|
||||
#define QSE_CCLS_SETDFL(m) ((qse_ccls)=(m))
|
||||
|
||||
#define QSE_CCLS_IS(ccls,c,type) ((ccls)->is((ccls)->data,c,type))
|
||||
#define QSE_CCLS_TO(ccls,c,type) ((ccls)->to((ccls)->data,c,type))
|
||||
|
||||
#define QSE_CCLS_ISUPPER(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_UPPER)
|
||||
#define QSE_CCLS_ISLOWER(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_LOWER)
|
||||
#define QSE_CCLS_ISALPHA(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_ALPHA)
|
||||
#define QSE_CCLS_ISDIGIT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_DIGIT)
|
||||
#define QSE_CCLS_ISXDIGIT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_XDIGIT)
|
||||
#define QSE_CCLS_ISALNUM(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_ALNUM)
|
||||
#define QSE_CCLS_ISSPACE(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_SPACE)
|
||||
#define QSE_CCLS_ISPRINT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_PRINT)
|
||||
#define QSE_CCLS_ISGRAPH(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_GRAPH)
|
||||
#define QSE_CCLS_ISCNTRL(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_CNTRL)
|
||||
#define QSE_CCLS_ISPUNCT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_PUNCT)
|
||||
#define QSE_CCLS_TOUPPER(ccls,c) QSE_CCLS_TO(ccls,c,QSE_CCLS_UPPER)
|
||||
#define QSE_CCLS_TOLOWER(ccls,c) QSE_CCLS_TO(ccls,c,QSE_CCLS_LOWER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern qse_ccls_t* qse_ccls;
|
||||
|
||||
qse_bool_t qse_ccls_is (
|
||||
qse_cint_t c,
|
||||
qse_ccls_type_t type
|
||||
);
|
||||
|
||||
qse_cint_t qse_ccls_to (
|
||||
qse_cint_t c,
|
||||
qse_ccls_type_t type
|
||||
);
|
||||
|
||||
|
||||
|
||||
qse_size_t qse_mblen (
|
||||
const qse_mchar_t* mb,
|
||||
qse_size_t mblen
|
||||
);
|
||||
|
||||
/****f* qse.cmn.chr/qse_mbtowc
|
||||
* NAME
|
||||
* qse_mbtowc - convert a multibyte sequence to a wide character.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_mbtowc() function returns 0 if an invalid multibyte sequence is
|
||||
* detected, mblen + 1 if the sequence is incomplete. It returns the number
|
||||
* of bytes processed to form a wide character.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_mbtowc (
|
||||
const qse_mchar_t* mb,
|
||||
qse_size_t mblen,
|
||||
qse_wchar_t* wc
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.chr/qse_wctomb
|
||||
* NAME
|
||||
* qse_wctomb - convert a wide character to a multibyte sequence
|
||||
*
|
||||
* RETURN
|
||||
* The qse_wctomb() functions returns 0 if the wide character is illegal,
|
||||
* mblen + 1 if mblen is not large enough to hold the multibyte sequence.
|
||||
* On successful conversion, it returns the number of bytes in the sequence.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_wctomb (
|
||||
qse_wchar_t wc,
|
||||
qse_mchar_t* mb,
|
||||
qse_size_t mblen
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
260
qse/include/qse/cmn/dll.h
Normal file
260
qse/include/qse/cmn/dll.h
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* $Id: map.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_DLL_H_
|
||||
#define _QSE_CMN_DLL_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/*
|
||||
* Doubly Linked List
|
||||
*/
|
||||
typedef struct qse_dll_t qse_dll_t;
|
||||
typedef struct qse_dll_node_t qse_dll_node_t;
|
||||
|
||||
/* data copier */
|
||||
typedef void* (*qse_dll_copier_t) (qse_dll_t* dll, void* dptr, qse_size_t dlen);
|
||||
|
||||
/* data freeer */
|
||||
typedef void (*qse_dll_freeer_t) (qse_dll_t* dll, void* dptr, qse_size_t dlen);
|
||||
|
||||
/* node visitor */
|
||||
typedef int (*qse_dll_walker_t) (
|
||||
qse_dll_t* dll, qse_dll_node_t* node, void* arg);
|
||||
|
||||
struct qse_dll_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
|
||||
qse_dll_copier_t copier;
|
||||
qse_dll_freeer_t freeer;
|
||||
|
||||
qse_size_t size;
|
||||
qse_dll_node_t* head;
|
||||
qse_dll_node_t* tail;
|
||||
};
|
||||
|
||||
struct qse_dll_node_t
|
||||
{
|
||||
void* dptr; /* pointer to the beginning of data */
|
||||
qse_size_t dlen; /* length of data in bytes */
|
||||
qse_dll_node_t* next; /* pointer to the next node */
|
||||
qse_dll_node_t* prev; /* pointer to the prev node */
|
||||
};
|
||||
|
||||
|
||||
enum qse_dll_walk_t
|
||||
{
|
||||
QSE_DLL_WALK_STOP = 0,
|
||||
QSE_DLL_WALK_FORWARD = 1
|
||||
};
|
||||
|
||||
#define QSE_DLL_COPIER_INLINE qse_dll_copyinline
|
||||
|
||||
#define QSE_DLL_HEAD(dll) ((dll)->head)
|
||||
#define QSE_DLL_TAIL(dll) ((dll)->tail)
|
||||
#define QSE_DLL_SIZE(dll) ((dll)->size)
|
||||
|
||||
#define QSE_DLL_DPTR(n) ((n)->dptr)
|
||||
#define QSE_DLL_DLEN(n) ((n)->dlen)
|
||||
#define QSE_DLL_NEXT(n) ((n)->next)
|
||||
#define QSE_DLL_PREV(n) ((n)->prev)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NAME: creates a doubly linked list with extension area
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The qse_dll_open() function creates an empty doubly linked list.
|
||||
* If the memory manager mmgr is QSE_NULL, the function gets the default
|
||||
* memory manager with QSE_MMGR_GETMMGR() and uses it if it is not QSE_NULL.
|
||||
* The extension area is allocated when the positive extension size extension
|
||||
* is specified. It calls the extension initialization function initializer
|
||||
* after initializing the main area. The extension initializer is passed
|
||||
* the pointer to the doubly linked list created.
|
||||
*
|
||||
* RETURNS:
|
||||
* the pointer to a newly created doubly linked list on success.
|
||||
* QSE_NULL on failure.
|
||||
*
|
||||
* WARNING:
|
||||
* In the debug build, it fails the assertion if QSE_MMGR_SETMMGR() returns
|
||||
* QSE_NULL when QSE_NULL is passed as the first parameter. In the release
|
||||
* build, it returns QSE_NULL if such a thing happens.
|
||||
*/
|
||||
|
||||
qse_dll_t* qse_dll_open (
|
||||
qse_mmgr_t* mmgr /* memory manager */ ,
|
||||
qse_size_t ext /* size of extension area in bytes */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME destroys a singly linked list
|
||||
*/
|
||||
void qse_dll_close (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME deletes all elements of a singly linked list
|
||||
*/
|
||||
void qse_dll_clear (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier QSE_DLL_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to QSE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*/
|
||||
void qse_dll_setcopier (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
qse_dll_copier_t copier /* a element copier */
|
||||
);
|
||||
|
||||
qse_dll_copier_t qse_dll_getcopier (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*/
|
||||
void qse_dll_setfreeer (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
qse_dll_freeer_t freeer /* a element freeer */
|
||||
);
|
||||
|
||||
qse_dll_freeer_t qse_dll_getfreeer (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the pointer to the extension area
|
||||
* RETURN the pointer to the extension area
|
||||
*/
|
||||
void* qse_dll_getxtn (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get the pointer to the memory manager in use
|
||||
*/
|
||||
qse_mmgr_t* qse_dll_getmmgr (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
void qse_dll_setmmgr (qse_dll_t* dll, qse_mmgr_t* mmgr);
|
||||
|
||||
/*
|
||||
* NAME Gets the number of elements held in a singly linked list
|
||||
* RETURN the number of elements the list holds
|
||||
*/
|
||||
qse_size_t qse_dll_getsize (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the head(first) node
|
||||
* RETURN the tail node of a singly linked list
|
||||
*/
|
||||
qse_dll_node_t* qse_dll_gethead (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Gets the tail(last) node
|
||||
* RETURN the tail node of a singly linked list
|
||||
*/
|
||||
qse_dll_node_t* qse_dll_gettail (
|
||||
qse_dll_t* dll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Inserts data before a positional node given
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Inserts data.
|
||||
*/
|
||||
qse_dll_node_t* qse_dll_insert (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
qse_dll_node_t* pos /* a node before which a new node is inserted */,
|
||||
void* dptr /* the pointer to the data */ ,
|
||||
qse_size_t dlen /* the length of the data in bytes */
|
||||
);
|
||||
|
||||
qse_dll_node_t* qse_dll_pushhead (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_dll_node_t* qse_dll_pushtail (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
void qse_dll_delete (
|
||||
qse_dll_t* dll,
|
||||
qse_dll_node_t* pos
|
||||
);
|
||||
|
||||
void qse_dll_pophead (
|
||||
qse_dll_t* dll
|
||||
);
|
||||
|
||||
void qse_dll_poptail (
|
||||
qse_dll_t* dll
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME Traverses s singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A singly linked list allows uni-directional in-order traversal.
|
||||
* The qse_dll_walk() function traverses a singly linkked list from its
|
||||
* head node down to its tail node as long as the walker function returns
|
||||
* QSE_DLL_WALK_FORWARD. A walker can return QSE_DLL_WALK_STOP to cause
|
||||
* immediate stop of traversal.
|
||||
* For each node, the walker function is called and it is passed three
|
||||
* parameters: the singly linked list, the visiting node, and the
|
||||
* user-defined data passed as the third parameter in a call to the
|
||||
* qse_dll_walk() function.
|
||||
*/
|
||||
void qse_dll_walk (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
qse_dll_walker_t walker /* a user-defined walker function */,
|
||||
void* arg /* pointer to user-defined data */
|
||||
);
|
||||
|
||||
/*
|
||||
* Causes a singly linked list to copy in data to a node.
|
||||
* Use QSE_DLL_COPIER_INLINE instead.
|
||||
*/
|
||||
void* qse_dll_copyinline (
|
||||
qse_dll_t* dll /* a singly linked list */,
|
||||
void* data /* pointer to data to copy */ ,
|
||||
qse_size_t len /* length of data in bytes */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
152
qse/include/qse/cmn/fio.h
Normal file
152
qse/include/qse/cmn/fio.h
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_FIO_H_
|
||||
#define _QSE_CMN_FIO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
enum qse_fio_open_flag_t
|
||||
{
|
||||
/* treat the file name pointer as a handle pointer */
|
||||
QSE_FIO_HANDLE = (1 << 0),
|
||||
|
||||
QSE_FIO_READ = (1 << 1),
|
||||
QSE_FIO_WRITE = (1 << 2),
|
||||
QSE_FIO_APPEND = (1 << 3),
|
||||
|
||||
QSE_FIO_CREATE = (1 << 4),
|
||||
QSE_FIO_TRUNCATE = (1 << 5),
|
||||
QSE_FIO_EXCLUSIVE = (1 << 6),
|
||||
QSE_FIO_SYNC = (1 << 7),
|
||||
|
||||
/* for ms windows only */
|
||||
QSE_FIO_NOSHRD = (1 << 16),
|
||||
QSE_FIO_NOSHWR = (1 << 17)
|
||||
};
|
||||
|
||||
/* seek origin */
|
||||
enum qse_fio_seek_origin_t
|
||||
{
|
||||
QSE_FIO_BEGIN = 0,
|
||||
QSE_FIO_CURRENT = 1,
|
||||
QSE_FIO_END = 2
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
/* <winnt.h> typedef PVOID HANDLE; */
|
||||
typedef void* qse_fio_hnd_t;
|
||||
#else
|
||||
typedef int qse_fio_hnd_t;
|
||||
#endif
|
||||
|
||||
/* file offset */
|
||||
typedef qse_int64_t qse_fio_off_t;
|
||||
typedef enum qse_fio_seek_origin_t qse_fio_ori_t;
|
||||
|
||||
typedef struct qse_fio_t qse_fio_t;
|
||||
|
||||
struct qse_fio_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
qse_fio_hnd_t handle;
|
||||
};
|
||||
|
||||
#define QSE_FIO_MMGR(fio) ((fio)->mmgr)
|
||||
#define QSE_FIO_HANDLE(fio) ((fio)->handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.fio/qse_fio_open
|
||||
* NAME
|
||||
* qse_fio_open - open a file
|
||||
*
|
||||
* DESCRIPTION
|
||||
* To open a file, you should set the flags with at least one of
|
||||
* QSE_FIO_READ, QSE_FIO_WRITE, QSE_FIO_APPEND.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_fio_t* qse_fio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
const qse_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.fio/qse_fio_close
|
||||
* NAME
|
||||
* qse_fio_close - close a file
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_fio_close (
|
||||
qse_fio_t* fio
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_fio_t* qse_fio_init (
|
||||
qse_fio_t* fio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
|
||||
void qse_fio_fini (
|
||||
qse_fio_t* fio
|
||||
);
|
||||
|
||||
qse_fio_hnd_t qse_fio_gethandle (
|
||||
qse_fio_t* fio
|
||||
);
|
||||
|
||||
/****f* qse.cmn.fio/qse_fio_sethandle
|
||||
* SYNOPSIS
|
||||
* qse_fio_sethandle - set the file handle
|
||||
* WARNING
|
||||
* Avoid using this function if you don't know what you are doing.
|
||||
* You may have to retrieve the previous handle using qse_fio_gethandle()
|
||||
* to take relevant actions before resetting it with qse_fio_sethandle().
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_fio_sethandle (
|
||||
qse_fio_t* fio,
|
||||
qse_fio_hnd_t handle
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_fio_off_t qse_fio_seek (
|
||||
qse_fio_t* fio,
|
||||
qse_fio_off_t offset,
|
||||
qse_fio_ori_t origin
|
||||
);
|
||||
|
||||
int qse_fio_truncate (
|
||||
qse_fio_t* fio,
|
||||
qse_fio_off_t size
|
||||
);
|
||||
|
||||
qse_ssize_t qse_fio_read (
|
||||
qse_fio_t* fio,
|
||||
void* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
qse_ssize_t qse_fio_write (
|
||||
qse_fio_t* fio,
|
||||
const void* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
74
qse/include/qse/cmn/io.h
Normal file
74
qse/include/qse/cmn/io.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* $Id: sysapi.h,v 1.56 2006/03/21 16:15:16 bacon Ease $
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_IO_H_
|
||||
#define _QSE_CMN_IO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/* flags for qse_open */
|
||||
enum
|
||||
{
|
||||
QSE_OPEN_READ = (1 << 0),
|
||||
QSE_OPEN_WRITE = (1 << 1),
|
||||
QSE_OPEN_CREATE = (1 << 2),
|
||||
QSE_OPEN_TRUNCATE = (1 << 3),
|
||||
QSE_OPEN_EXCLUSIVE = (1 << 4),
|
||||
QSE_OPEN_APPEND = (1 << 5),
|
||||
QSE_OPEN_NONBLOCK = (1 << 6)
|
||||
};
|
||||
|
||||
/* origin for qse_seek */
|
||||
enum
|
||||
{
|
||||
QSE_SEEK_BEGIN = 0,
|
||||
QSE_SEEK_CURRENT = 1,
|
||||
QSE_SEEK_END = 2
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_hnd_t qse_open (
|
||||
const qse_char_t* path,
|
||||
int flag,
|
||||
...
|
||||
);
|
||||
|
||||
int qse_close (
|
||||
qse_hnd_t handle
|
||||
);
|
||||
|
||||
qse_ssize_t qse_read (
|
||||
qse_hnd_t handle,
|
||||
void* buf,
|
||||
qse_size_t sz
|
||||
);
|
||||
|
||||
qse_ssize_t qse_write (
|
||||
qse_hnd_t handle,
|
||||
const void* data,
|
||||
qse_size_t sz
|
||||
);
|
||||
|
||||
qse_off_t qse_seek (
|
||||
qse_hnd_t handle,
|
||||
qse_off_t offset,
|
||||
int origin
|
||||
);
|
||||
|
||||
/*
|
||||
int qse_hstat (qse_hnd_t handle, qse_stat_t* buf);
|
||||
int qse_hchmod (qse_hnd_t handle, qse_mode_t mode);
|
||||
*/
|
||||
int qse_htruncate (qse_hnd_t handle, qse_off_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
477
qse/include/qse/cmn/lda.h
Normal file
477
qse/include/qse/cmn/lda.h
Normal file
@ -0,0 +1,477 @@
|
||||
/*
|
||||
* $Id: lda.h 363 2008-09-04 10:58:08Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_LDA_H_
|
||||
#define _QSE_CMN_LDA_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/****o* qse.cmn.lda/linear dynamic array
|
||||
* DESCRIPTION
|
||||
* <qse/cmn/lda.h> provides a linear dynamic array. It grows as more items
|
||||
* are added. T
|
||||
*
|
||||
* #include <qse/cmn/lda.h>
|
||||
******
|
||||
*/
|
||||
|
||||
enum qse_lda_walk_t
|
||||
{
|
||||
QSE_LDA_WALK_STOP = 0,
|
||||
QSE_LDA_WALK_FORWARD = 1,
|
||||
QSE_LDA_WALK_BACKWARD = 2
|
||||
};
|
||||
|
||||
typedef struct qse_lda_t qse_lda_t;
|
||||
typedef struct qse_lda_node_t qse_lda_node_t;
|
||||
typedef enum qse_lda_walk_t qse_lda_walk_t;
|
||||
|
||||
#define QSE_LDA_COPIER_SIMPLE ((qse_lda_copier_t)1)
|
||||
#define QSE_LDA_COPIER_INLINE ((qse_lda_copier_t)2)
|
||||
|
||||
#define QSE_LDA_INVALID ((qse_size_t)-1)
|
||||
|
||||
#define QSE_LDA_SIZE(lda) ((lda)->size)
|
||||
#define QSE_LDA_CAPA(lda) ((lda)->capa)
|
||||
|
||||
#define QSE_LDA_NODE(lda,index) ((lda)->node[index])
|
||||
#define QSE_LDA_DPTR(lda,index) ((lda)->node[index]->dptr)
|
||||
#define QSE_LDA_DLEN(lda,index) ((lda)->node[index]->dlen)
|
||||
|
||||
#define QSE_LDA_MMGR(lda) ((lda)->mmgr)
|
||||
#define QSE_LDA_XTN(lda) ((void*)(((qse_lda_t*)lda) + 1))
|
||||
|
||||
#define QSE_LDA_COPIER(lda) ((lda)->copier)
|
||||
#define QSE_LDA_FREEER(lda) ((lda)->freeer)
|
||||
#define QSE_LDA_COMPER(lda) ((lda)->comper)
|
||||
#define QSE_LDA_KEEPER(lda) ((lda)->keeper)
|
||||
#define QSE_LDA_SIZER(lda) ((lda)->sizer)
|
||||
|
||||
|
||||
|
||||
/****b* qse.cmn.lda/qse_lda_copier_t
|
||||
* NAME
|
||||
* qse_lda_copier_t - define a node contruction callback
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_copier_t defines a callback function for node construction.
|
||||
* A node is contructed when a user adds data to a list. The user can
|
||||
* define how the data to add can be maintained in the list. A singly
|
||||
* linked list not specified with any copiers stores the data pointer and
|
||||
* the data length into a node. A special copier QSE_LDA_COPIER_INLINE copies
|
||||
* the contents of the data a user provided into the node. You can use the
|
||||
* qse_lda_setcopier() function to change the copier.
|
||||
*
|
||||
* A copier should return the pointer to the copied data. If it fails to copy
|
||||
* data, it may return QSE_NULL. You need to set a proper freeer to free up
|
||||
* memory allocated for copy.
|
||||
*
|
||||
* SEE ALSO
|
||||
* qse_lda_setcopier, qse_lda_getcopier, QSE_LDA_COPIER
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*qse_lda_copier_t) (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
void* dptr /* the pointer to data to copy */,
|
||||
qse_size_t dlen /* the length of data to copy */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* qse.cmn.lda/qse_lda_freeer_t
|
||||
* NAME
|
||||
* qse_lda_freeer_t - define a node destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*qse_lda_freeer_t) (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
void* dptr /* the pointer to data to free */,
|
||||
qse_size_t dlen /* the length of data to free */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.lda/qse_lda_comper_t
|
||||
* NAME
|
||||
* qse_lda_comper_t - define a data comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_comper_t type defines a key comparator that is called when
|
||||
* the list needs to compare data. A linear dynamic array is created with a
|
||||
* default comparator that performs bitwise comparison.
|
||||
*
|
||||
* The comparator should return 0 if the data are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*qse_lda_comper_t) (
|
||||
qse_lda_t* lda /* a linear dynamic array */,
|
||||
const void* dptr1 /* a data pointer */,
|
||||
qse_size_t dlen1 /* a data length */,
|
||||
const void* dptr2 /* a data pointer */,
|
||||
qse_size_t dlen2 /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.lda/qse_lda_keeper_t
|
||||
* NAME
|
||||
* qse_lda_keeper_t - define a value keeper
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_keeper_t type defines a value keeper that is called when
|
||||
* a value is retained in the context that it should be destroyed because
|
||||
* it is identical to a new value. Two values are identical if their beginning
|
||||
* pointers and their lengths are equal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*qse_lda_keeper_t) (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
qse_size_t vlen /* the length of a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.lda/qse_lda_sizer_t
|
||||
* NAME
|
||||
* qse_lda_sizer_t - define an array size calculator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_sizer_t type defines an array size claculator that is called
|
||||
* when the array needs to be resized.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef qse_size_t (*qse_lda_sizer_t) (
|
||||
qse_lda_t* lda, /* a linear dynamic array */
|
||||
qse_size_t hint /* a sizing hint */
|
||||
);
|
||||
/******/
|
||||
|
||||
typedef qse_lda_walk_t (*qse_lda_walker_t) (
|
||||
qse_lda_t* lda /* a linear dynamic array */,
|
||||
qse_size_t index /* the index to the visited node */,
|
||||
void* arg /* user-defined data */
|
||||
);
|
||||
|
||||
/****s* qse.cmn.lda/qse_lda_t
|
||||
* NAME
|
||||
* qse_lda_t - define a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_lda_t
|
||||
{
|
||||
qse_mmgr_t* mmgr; /* memory manager */
|
||||
|
||||
qse_lda_copier_t copier; /* data copier */
|
||||
qse_lda_freeer_t freeer; /* data freeer */
|
||||
qse_lda_comper_t comper; /* data comparator */
|
||||
qse_lda_keeper_t keeper; /* data keeper */
|
||||
qse_lda_sizer_t sizer; /* size calculator */
|
||||
qse_byte_t scale; /* scale factor */
|
||||
qse_size_t size; /* the number of items */
|
||||
qse_size_t capa; /* capacity */
|
||||
qse_lda_node_t** node;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****s*
|
||||
* NAME
|
||||
* qse_lda_node_t - define a linear dynamic array node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_lda_node_t
|
||||
{
|
||||
void* dptr;
|
||||
qse_size_t dlen;
|
||||
};
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_open
|
||||
* NAME
|
||||
* qse_lda_open - create a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_lda_t* qse_lda_open (
|
||||
qse_mmgr_t* lda,
|
||||
qse_size_t ext,
|
||||
qse_size_t capa
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_close
|
||||
* NAME
|
||||
* qse_lda_close - destroy a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_close (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_init
|
||||
* NAME
|
||||
* qse_lda_init - initialize a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_lda_t* qse_lda_init (
|
||||
qse_lda_t* lda,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_fini
|
||||
* NAME
|
||||
* qse_lda_fini - deinitialize a linear dynamic array
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_fini (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_getxtn
|
||||
* NAME
|
||||
* qse_lda_getxtn - get the pointer to the extension
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_getxtn() function returns the pointer to the extension.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void* qse_lda_getxtn (
|
||||
qse_lda_t* lda /* a linear dynamic array */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_getmmgr
|
||||
* NAME
|
||||
* qse_lda_getmmgr - get the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_mmgr_t* qse_lda_getmmgr (
|
||||
qse_lda_t* lda /* a linear dynamic array */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_setmmgr
|
||||
* NAME
|
||||
* qse_lda_setmmgr - set the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_setmmgr (
|
||||
qse_lda_t* lda /* a linear dynamic array */,
|
||||
qse_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
int qse_lda_getscale (
|
||||
qse_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_setscale
|
||||
* NAME
|
||||
* qse_lda_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_setscale() function sets the scale factor of the length
|
||||
* of a key and a value. A scale factor determines the actual length of
|
||||
* a key and a value in bytes. A lda is created with a scale factor of 1.
|
||||
* The scale factor should be larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a lda is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_setscale (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_lda_copier_t qse_lda_getcopier (
|
||||
qse_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_setcopier
|
||||
* NAME
|
||||
* qse_lda_setcopier - specify how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier QSE_LDA_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to QSE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_setcopier (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
qse_lda_copier_t copier /* an element copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_lda_freeer_t qse_lda_getfreeer (
|
||||
qse_lda_t* lda /* a lda */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_setfreeer
|
||||
* NAME
|
||||
* qse_lda_setfreeer - specify how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_lda_setfreeer (
|
||||
qse_lda_t* lda /* a lda */,
|
||||
qse_lda_freeer_t freeer /* an element freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_lda_keeper_t qse_lda_getkeeper (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
|
||||
void qse_lda_setkeeper (
|
||||
qse_lda_t* lda,
|
||||
qse_lda_keeper_t keeper
|
||||
);
|
||||
|
||||
qse_lda_sizer_t qse_lda_getsizer (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
|
||||
void qse_lda_setsizer (
|
||||
qse_lda_t* lda,
|
||||
qse_lda_sizer_t sizer
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_getsize (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_getcapa (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
|
||||
qse_lda_t* qse_lda_setcapa (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t capa
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_search (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t pos,
|
||||
const void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_rsearch (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t pos,
|
||||
const void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_upsert (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t index,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_insert (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t index,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_size_t qse_lda_update (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t pos,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_delete
|
||||
* NAME
|
||||
* qse_lda_delete - delete data
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_delete() function deletes the as many data as the count
|
||||
* from the index.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_lda_delete() function returns the number of data deleted.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_lda_delete (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t index,
|
||||
qse_size_t count
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.lda/qse_lda_uplete
|
||||
* NAME
|
||||
* qse_lda_uplete - delete data node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_lda_uplete() function deletes data node without compaction.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_lda_uplete() function returns the number of data affected.
|
||||
*
|
||||
*/
|
||||
qse_size_t qse_lda_uplete (
|
||||
qse_lda_t* lda,
|
||||
qse_size_t index,
|
||||
qse_size_t count
|
||||
);
|
||||
/******/
|
||||
|
||||
void qse_lda_clear (
|
||||
qse_lda_t* lda
|
||||
);
|
||||
|
||||
void qse_lda_walk (
|
||||
qse_lda_t* lda,
|
||||
qse_lda_walker_t walker,
|
||||
void* arg
|
||||
);
|
||||
|
||||
void qse_lda_rwalk (
|
||||
qse_lda_t* lda,
|
||||
qse_lda_walker_t walker,
|
||||
void* arg
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h tio.h sio.h time.h
|
||||
|
||||
pkgincludedir= $(includedir)/ase/cmn
|
||||
pkgincludedir= $(includedir)/qse/cmn
|
||||
|
||||
CLEANFILES = *dist
|
||||
|
@ -31,7 +31,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/ase/cmn
|
||||
subdir = include/qse/cmn
|
||||
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/makefile.am \
|
||||
$(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -39,7 +39,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
@ -55,7 +55,7 @@ HEADERS = $(pkginclude_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase/cmn
|
||||
pkgincludedir = $(includedir)/qse/cmn
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -192,9 +192,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/cmn/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/cmn/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/cmn/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/cmn/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
566
qse/include/qse/cmn/map.h
Normal file
566
qse/include/qse/cmn/map.h
Normal file
@ -0,0 +1,566 @@
|
||||
/*
|
||||
* $Id: map.h 496 2008-12-15 09:56:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_MAP_H_
|
||||
#define _QSE_CMN_MAP_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/****o* qse.cmn.map/hash map
|
||||
* DESCRIPTION
|
||||
* A hash map maintains buckets for key/value pairs with the same key hash
|
||||
* chained under the same bucket.
|
||||
*
|
||||
* #include <qse/cmn/map.h>
|
||||
*
|
||||
* EXAMPLES
|
||||
* void f (void)
|
||||
* {
|
||||
* }
|
||||
******
|
||||
*/
|
||||
|
||||
/* values that can be returned by qse_map_walker_t */
|
||||
enum qse_map_walk_t
|
||||
{
|
||||
QSE_MAP_WALK_STOP = 0,
|
||||
QSE_MAP_WALK_FORWARD = 1
|
||||
};
|
||||
|
||||
enum qse_map_id_t
|
||||
{
|
||||
QSE_MAP_KEY = 0,
|
||||
QSE_MAP_VAL = 1
|
||||
};
|
||||
|
||||
typedef struct qse_map_t qse_map_t;
|
||||
typedef struct qse_map_pair_t qse_map_pair_t;
|
||||
typedef enum qse_map_walk_t qse_map_walk_t;
|
||||
typedef enum qse_map_id_t qse_map_id_t;
|
||||
|
||||
/****b* qse.cmn.map/qse_map_copier_t
|
||||
* NAME
|
||||
* qse_map_copier_t - define a pair contruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*qse_map_copier_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
void* dptr /* the pointer to a key or a value */,
|
||||
qse_size_t dlen /* the length of a key or a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* qse.cmn.map/qse_map_freeer_t
|
||||
* NAME
|
||||
* qse_map_freeer_t - define a key/value destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*qse_map_freeer_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
void* dptr /* the pointer to a key or a value */,
|
||||
qse_size_t dlen /* the length of a key or a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/* key hasher */
|
||||
typedef qse_size_t (*qse_map_hasher_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the length of a key in bytes */
|
||||
);
|
||||
|
||||
/****t* qse.cmn.map/qse_map_comper_t
|
||||
* NAME
|
||||
* qse_map_comper_t - define a key comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_comper_t type defines a key comparator that is called when
|
||||
* the map needs to compare keys. A map is created with a default comparator
|
||||
* which performs bitwise comparison between two keys.
|
||||
*
|
||||
* The comparator should return 0 if the keys are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*qse_map_comper_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
const void* kptr1 /* the pointer to a key */,
|
||||
qse_size_t klen1 /* the length of a key */,
|
||||
const void* kptr2 /* the pointer to a key */,
|
||||
qse_size_t klen2 /* the length of a key */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.map/qse_map_keeper_t
|
||||
* NAME
|
||||
* qse_map_keeper_t - define a value keeper
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_keeper_t type defines a value keeper that is called when
|
||||
* a value is retained in the context that it should be destroyed because
|
||||
* it is identical to a new value. Two values are identical if their beginning
|
||||
* pointers and their lengths are equal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*qse_map_keeper_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
qse_size_t vlen /* the length of a value */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.map/qse_map_sizer_t
|
||||
* NAME
|
||||
* qse_map_sizer_t - define a bucket size calculator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_sizer_T type defines a bucket size claculator that is called
|
||||
* when a map should resize the bucket. The current bucket size +1 is passed
|
||||
* as the hint.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef qse_size_t (*qse_map_sizer_t) (
|
||||
qse_map_t* map, /* a map */
|
||||
qse_size_t hint /* a sizing hint */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.map/qse_map_walker_t
|
||||
* NAME
|
||||
* qse_map_walker_t - define a pair visitor
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef qse_map_walk_t (*qse_map_walker_t) (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_pair_t* pair /* the pointer to a key/value pair */,
|
||||
void* arg /* the pointer to user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****s* qse.cmn.map/qse_map_pair_t
|
||||
* NAME
|
||||
* qse_map_pair_t - define a pair
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A pair is composed of a key and a value. It maintains pointers to the
|
||||
* beginning of a key and a value plus their length. The length is scaled
|
||||
* down with the scale factor specified in an owning map. Use macros defined
|
||||
* in the SEE ALSO section below to access individual fields.
|
||||
*
|
||||
* SEE ALSO
|
||||
* QSE_MAP_KPTR, QSE_MAP_KLEN, QSE_MAP_VPTR, QSE_MAP_VLEN
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_map_pair_t
|
||||
{
|
||||
void* kptr; /* the pointer to a key */
|
||||
qse_size_t klen; /* the length of a key */
|
||||
void* vptr; /* the pointer to a value */
|
||||
qse_size_t vlen; /* the length of a value */
|
||||
qse_map_pair_t* next; /* the next pair under the same slot */
|
||||
};
|
||||
/*****/
|
||||
|
||||
/****s* qse.cmn.map/qse_map_t
|
||||
* NAME
|
||||
* qse_map_t - define a hash map
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_map_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
qse_map_copier_t copier[2];
|
||||
qse_map_freeer_t freeer[2];
|
||||
qse_map_hasher_t hasher; /* key hasher */
|
||||
qse_map_comper_t comper; /* key comparator */
|
||||
qse_map_keeper_t keeper; /* value keeper */
|
||||
qse_map_sizer_t sizer; /* bucket capacity recalculator */
|
||||
qse_byte_t scale[2]; /* length scale */
|
||||
qse_byte_t factor; /* load factor */
|
||||
qse_byte_t filler0;
|
||||
qse_size_t size;
|
||||
qse_size_t capa;
|
||||
qse_size_t threshold;
|
||||
qse_map_pair_t** bucket;
|
||||
};
|
||||
/******/
|
||||
|
||||
#define QSE_MAP_COPIER_SIMPLE ((qse_map_copier_t)1)
|
||||
#define QSE_MAP_COPIER_INLINE ((qse_map_copier_t)2)
|
||||
|
||||
/****d* qse.cmn.map/QSE_MAP_SIZE
|
||||
* NAME
|
||||
* QSE_MAP_SIZE - get the number of pairs
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The QSE_MAP_SIZE() macro returns the number of pairs in a map.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
#define QSE_MAP_SIZE(m) ((m)->size)
|
||||
/*****/
|
||||
|
||||
/****d* qse.cmn.map/QSE_MAP_CAPA
|
||||
* NAME
|
||||
* QSE_MAP_CAPA - get the capacity of a map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The QSE_MAP_CAPA() macro returns the maximum number of pairs a map can hold.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
#define QSE_MAP_CAPA(m) ((m)->capa)
|
||||
/*****/
|
||||
|
||||
#define QSE_MAP_MMGR(m) ((m)->mmgr)
|
||||
#define QSE_MAP_XTN(m) ((void*)(((qse_map_t*)m) + 1))
|
||||
|
||||
#define QSE_MAP_KCOPIER(m) ((m)->copier[QSE_MAP_KEY])
|
||||
#define QSE_MAP_VCOPIER(m) ((m)->copier[QSE_MAP_VAL])
|
||||
#define QSE_MAP_KFREEER(m) ((m)->freeer[QSE_MAP_KEY])
|
||||
#define QSE_MAP_VFREEER(m) ((m)->freeer[QSE_MAP_VAL])
|
||||
#define QSE_MAP_HASHER(m) ((m)->hasher)
|
||||
#define QSE_MAP_COMPER(m) ((m)->comper)
|
||||
#define QSE_MAP_KEEPER(m) ((m)->keeper)
|
||||
#define QSE_MAP_SIZER(m) ((m)->sizer)
|
||||
|
||||
#define QSE_MAP_FACTOR(m) ((m)->factor)
|
||||
#define QSE_MAP_KSCALE(m) ((m)->scale[QSE_MAP_KEY])
|
||||
#define QSE_MAP_VSCALE(m) ((m)->scale[QSE_MAP_VAL])
|
||||
|
||||
#define QSE_MAP_KPTR(p) ((p)->kptr)
|
||||
#define QSE_MAP_KLEN(p) ((p)->klen)
|
||||
#define QSE_MAP_VPTR(p) ((p)->vptr)
|
||||
#define QSE_MAP_VLEN(p) ((p)->vlen)
|
||||
#define QSE_MAP_NEXT(p) ((p)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.cmn.map/qse_map_open
|
||||
* NAME
|
||||
* qse_map_open - creates a hash map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_open() function creates a hash map with a dynamic array
|
||||
* bucket and a list of values chained. The initial capacity should be larger
|
||||
* than 0. The load factor should be between 0 and 100 inclusive and the load
|
||||
* factor of 0 disables bucket resizing. If you need extra space associated
|
||||
* with a map, you may pass a non-zero value as the second parameter.
|
||||
* The QSE_MAP_XTN() macro and the qse_map_getxtn() function
|
||||
* return the pointer to the beginning of the extension.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_map_open() function returns an qse_map_t pointer on success and
|
||||
* QSE_NULL on failure.
|
||||
*
|
||||
* SEE ALSO
|
||||
* QSE_MAP_XTN, qse_map_getxtn
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_map_t* qse_map_open (
|
||||
qse_mmgr_t* mmgr /* a memory manager */,
|
||||
qse_size_t ext /* extension size in bytes */,
|
||||
qse_size_t capa /* initial capacity */,
|
||||
int factor /* load factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* qse.cmn.map/qse_map_close
|
||||
* NAME
|
||||
* qse_map_close - destroy a hash map
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_close() function destroys a hash map.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_map_close (
|
||||
qse_map_t* map /* a map */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_map_t* qse_map_init (
|
||||
qse_map_t* map,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa,
|
||||
int factor
|
||||
);
|
||||
|
||||
void qse_map_fini (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
void* qse_map_getxtn (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_map_getmmgr (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
void qse_map_setmmgr (
|
||||
qse_map_t* map,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/* get the number of key/value pairs in a map */
|
||||
qse_size_t qse_map_getsize (
|
||||
qse_map_t* map /* a map */
|
||||
);
|
||||
|
||||
qse_size_t qse_map_getcapa (
|
||||
qse_map_t* map /* a map */
|
||||
);
|
||||
|
||||
int qse_map_getscale (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.map/qse_map_setscale
|
||||
* NAME
|
||||
* qse_map_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_setscale() function sets the scale factor of the length
|
||||
* of a key and a value. A scale factor determines the actual length of
|
||||
* a key and a value in bytes. A map is created with a scale factor of 1.
|
||||
* The scale factor should be larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a map is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_map_setscale (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_map_copier_t qse_map_getcopier (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.map/qse_map_setcopier
|
||||
* NAME
|
||||
* qse_map_setcopier - specify how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier QSE_MAP_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to QSE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_map_setcopier (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */,
|
||||
qse_map_copier_t copier /* an element copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_map_freeer_t qse_map_getfreeer (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* qse.cmn.map/qse_map_setfreeer
|
||||
* NAME
|
||||
* qse_map_setfreeer - specify how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_map_setfreeer (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */,
|
||||
qse_map_freeer_t freeer /* an element freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
qse_map_hasher_t qse_map_gethasher (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
void qse_map_sethasher (
|
||||
qse_map_t* map,
|
||||
qse_map_hasher_t hasher
|
||||
);
|
||||
|
||||
qse_map_comper_t qse_map_getcomper (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
void qse_map_setcomper (
|
||||
qse_map_t* map,
|
||||
qse_map_comper_t comper
|
||||
);
|
||||
|
||||
qse_map_keeper_t qse_map_getkeeper (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
void qse_map_setkeeper (
|
||||
qse_map_t* map,
|
||||
qse_map_keeper_t keeper
|
||||
);
|
||||
|
||||
qse_map_sizer_t qse_map_getsizer (
|
||||
qse_map_t* map
|
||||
);
|
||||
|
||||
/* the sizer function is passed a map object and map->capa + 1 */
|
||||
void qse_map_setsizer (
|
||||
qse_map_t* map,
|
||||
qse_map_sizer_t sizer
|
||||
);
|
||||
|
||||
int qse_map_put (
|
||||
qse_map_t* map,
|
||||
void* kptr,
|
||||
qse_size_t klen,
|
||||
void* vptr,
|
||||
qse_size_t vlen,
|
||||
qse_map_pair_t** px
|
||||
);
|
||||
|
||||
/****f* qse.cmn.map/qse_map_search
|
||||
* NAME
|
||||
* qse_map_search - find a pair with a matching key
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_search() function searches a map to find a pair with a
|
||||
* matching key. It returns the pointer to the pair found. If it fails
|
||||
* to find one, it returns QSE_NULL.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_map_search() function returns the pointer to the pair with a
|
||||
* maching key, and QSE_NULL if no match is found.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_map_pair_t* qse_map_search (
|
||||
qse_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the size of the key in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.map/qse_map_upsert
|
||||
* NAME
|
||||
* qse_map_upsert - update an existing pair or inesrt a new pair
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_upsert() function searches a map for the pair with a matching
|
||||
* key. If one is found, it updates the pair. Otherwise, it inserts a new
|
||||
* pair with a key and a value. It returns the pointer to the pair updated
|
||||
* or inserted.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_map_upsert() function returns a pointer to the updated or inserted
|
||||
* pair on success, and QSE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_map_pair_t* qse_map_upsert (
|
||||
qse_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
qse_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.map/qse_map_insert
|
||||
* NAME
|
||||
* qse_map_insert - insert a new pair with a key and a value
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_map_insert() function inserts a new pair with the key and the value
|
||||
* given. If there exists a pair with the key given, the function returns
|
||||
* QSE_NULL without channging the value.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_map_insert() function returns a pointer to the pair created on
|
||||
* success, and QSE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_map_pair_t* qse_map_insert (
|
||||
qse_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
qse_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/* update the value of a existing pair with a matching key */
|
||||
qse_map_pair_t* qse_map_update (
|
||||
qse_map_t* map /* a map */,
|
||||
void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the length of the key in bytes */,
|
||||
void* vptr /* the pointer to a value */,
|
||||
qse_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
|
||||
/* delete a pair with a matching key */
|
||||
int qse_map_delete (
|
||||
qse_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
qse_size_t klen /* the size of the key in bytes */
|
||||
);
|
||||
|
||||
/* clear a map */
|
||||
void qse_map_clear (
|
||||
qse_map_t* map /* a map */
|
||||
);
|
||||
|
||||
/* traverse a map */
|
||||
void qse_map_walk (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_walker_t walker /* the pointer to the function for each pair */,
|
||||
void* arg /* a pointer to user-specific data */
|
||||
);
|
||||
|
||||
/* get the pointer to the first pair in the map. */
|
||||
qse_map_pair_t* qse_map_getfirstpair (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_size_t* buckno
|
||||
);
|
||||
|
||||
/* get the pointer to the next pair in the map. */
|
||||
qse_map_pair_t* qse_map_getnextpair (
|
||||
qse_map_t* map /* a map */,
|
||||
qse_map_pair_t* pair,
|
||||
qse_size_t* buckno
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,28 +4,28 @@
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_MEM_H_
|
||||
#define _ASE_CMN_MEM_H_
|
||||
#ifndef _QSE_CMN_MEM_H_
|
||||
#define _QSE_CMN_MEM_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/* gets a pointer to the default memory manager */
|
||||
#define ASE_MMGR_GETDFL() (ase_mmgr)
|
||||
#define QSE_MMGR_GETDFL() (qse_mmgr)
|
||||
|
||||
/* sets a pointer to the default memory manager */
|
||||
#define ASE_MMGR_SETDFL(m) ((ase_mmgr)=(m))
|
||||
#define QSE_MMGR_SETDFL(m) ((qse_mmgr)=(m))
|
||||
|
||||
/* allocate a memory block */
|
||||
#define ASE_MMGR_ALLOC(mmgr,size) \
|
||||
#define QSE_MMGR_ALLOC(mmgr,size) \
|
||||
((mmgr)->alloc((mmgr)->data,size))
|
||||
|
||||
/* reallocate a memory block */
|
||||
#define ASE_MMGR_REALLOC(mmgr,ptr,size) \
|
||||
#define QSE_MMGR_REALLOC(mmgr,ptr,size) \
|
||||
((mmgr)->realloc((mmgr)->data,ptr,size))
|
||||
|
||||
/* free a memory block */
|
||||
#define ASE_MMGR_FREE(mmgr,ptr) \
|
||||
#define QSE_MMGR_FREE(mmgr,ptr) \
|
||||
((mmgr)->free((mmgr)->data,ptr))
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -36,66 +36,66 @@ extern "C" {
|
||||
* NAME: holds a pointer to the default memory manager
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ASE_MMGR_GETDFL() macro returns the default memory manager.
|
||||
* You may use ASE_MMGR_SETDFL() to change the default memory manager.
|
||||
* The QSE_MMGR_GETDFL() macro returns the default memory manager.
|
||||
* You may use QSE_MMGR_SETDFL() to change the default memory manager.
|
||||
*/
|
||||
extern ase_mmgr_t* ase_mmgr;
|
||||
extern qse_mmgr_t* qse_mmgr;
|
||||
|
||||
/*
|
||||
* NAME: copy a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memcpy() functions copies n bytes from the source memory block src
|
||||
* The qse_memcpy() functions copies n bytes from the source memory block src
|
||||
* to the destinaion memory block dst.
|
||||
*
|
||||
* RETURNS: the destination memory block dst.
|
||||
*
|
||||
* WARNING:
|
||||
* The memory blocks should not overlap. Use the ase_memmove() function if
|
||||
* The memory blocks should not overlap. Use the qse_memmove() function if
|
||||
* they overlap.
|
||||
*/
|
||||
|
||||
void* ase_memcpy (
|
||||
void* qse_memcpy (
|
||||
void* dst /* a pointer to the destination memory block */ ,
|
||||
const void* src /* a pointer to the source memory block */ ,
|
||||
ase_size_t n /* the number of bytes to copy */
|
||||
qse_size_t n /* the number of bytes to copy */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: copy a memory block with more care
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memmove() functions copies n bytes from the source memory block src
|
||||
* The qse_memmove() functions copies n bytes from the source memory block src
|
||||
* to the destinaion memory block dst without corrupting overlapping zone.
|
||||
*
|
||||
* RETURNS: the destination memory block dst.
|
||||
*/
|
||||
void* ase_memmove (
|
||||
void* qse_memmove (
|
||||
void* dst /* a pointer to the destination memory block */,
|
||||
const void* src /* a pointer to the source memory block */,
|
||||
ase_size_t n /* the number of bytes to copy */
|
||||
qse_size_t n /* the number of bytes to copy */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: fill a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memset() function fills leading n bytes of the destination
|
||||
* The qse_memset() function fills leading n bytes of the destination
|
||||
* memory block dst with the byte val.
|
||||
*
|
||||
* RETURNS: the destination memory block dst
|
||||
*/
|
||||
void* ase_memset (
|
||||
void* qse_memset (
|
||||
void* dst /* a pointer to the destination memory block */,
|
||||
int val /* the byte to fill the memory block with */,
|
||||
ase_size_t n /* the number of bytes to fill */
|
||||
qse_size_t n /* the number of bytes to fill */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: compare memory blocks
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memcmp() function compares leading n bytes of two memory blocks
|
||||
* The qse_memcmp() function compares leading n bytes of two memory blocks
|
||||
* s1 and s2.
|
||||
*
|
||||
* RETURNS:
|
||||
@ -104,91 +104,91 @@ void* ase_memset (
|
||||
* of s2.
|
||||
* a negative number if the first different byte of s1 is less than that of s2.
|
||||
*/
|
||||
int ase_memcmp (
|
||||
int qse_memcmp (
|
||||
const void* s1 /* a pointer to the first memory block to compare */,
|
||||
const void* s2 /* a pointer to the second memory block to compare */,
|
||||
ase_size_t n /* the number of bytes to compare */
|
||||
qse_size_t n /* the number of bytes to compare */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: find a byte forward in a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_membyte() function scans the memory block s from the first byte
|
||||
* The qse_membyte() function scans the memory block s from the first byte
|
||||
* up to the nth byte in search of the byte val. If it finds a match,
|
||||
* it aborts scanning the memory block and returns the pointer to the matching
|
||||
* location.
|
||||
*
|
||||
* RETURNS:
|
||||
* ASE_NULL if the byte val is not found.
|
||||
* QSE_NULL if the byte val is not found.
|
||||
* The pointer to the location in the memory block s matching the byte val
|
||||
* if a match is found.
|
||||
*/
|
||||
void* ase_membyte (
|
||||
void* qse_membyte (
|
||||
const void* s /* a pointer to the memory block to scan */,
|
||||
int val /* a byte to find */,
|
||||
ase_size_t n /* the number of bytes to scan */
|
||||
qse_size_t n /* the number of bytes to scan */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: find a byte backward in a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memrbyte() function scans the memory block s from the nth byte
|
||||
* The qse_memrbyte() function scans the memory block s from the nth byte
|
||||
* backward to the first byte in search of the byte val. If it finds a match,
|
||||
* it aborts scanning the memory block and returns the pointer to the matching
|
||||
* location.
|
||||
*
|
||||
* RETURNS:
|
||||
* ASE_NULL if the byte val is not found.
|
||||
* QSE_NULL if the byte val is not found.
|
||||
* The pointer to the location in the memory block s matching the byte val
|
||||
* if a match is found.
|
||||
*/
|
||||
void* ase_memrbyte (
|
||||
void* qse_memrbyte (
|
||||
const void* s /* a pointer to the memory block to scan */,
|
||||
int val /* a byte to find */,
|
||||
ase_size_t n /* the number of bytes to scan */
|
||||
qse_size_t n /* the number of bytes to scan */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: find a block of bytes forward in a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memmem() functions scans the first hl bytes of the memory block hs
|
||||
* The qse_memmem() functions scans the first hl bytes of the memory block hs
|
||||
* in search of the byte block nd of the length nl bytes.
|
||||
*
|
||||
* RETURNS:
|
||||
* ASE_NULL if the byte val is not found.
|
||||
* QSE_NULL if the byte val is not found.
|
||||
* The pointer to the location in the memory block s matching the byte val
|
||||
* if a match is found.
|
||||
*
|
||||
* RETURNS:
|
||||
* ASE_NULL if no match is found.
|
||||
* QSE_NULL if no match is found.
|
||||
* The pointer to the start of the matching location if a match is found.
|
||||
*/
|
||||
void* ase_memmem (
|
||||
void* qse_memmem (
|
||||
const void* hs /* a pointer to the memory block to scan */,
|
||||
ase_size_t hl /* the number of bytes to scan */,
|
||||
qse_size_t hl /* the number of bytes to scan */,
|
||||
const void* nd /* a pointer to the byte block to find */,
|
||||
ase_size_t nl /* the number of bytes in the block */
|
||||
qse_size_t nl /* the number of bytes in the block */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: find a block of bytes backward in a memory block
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_memrmem() functions scans the first hl bytes of the memory block hs
|
||||
* The qse_memrmem() functions scans the first hl bytes of the memory block hs
|
||||
* backward in search of the byte block nd of the length nl bytes.
|
||||
*
|
||||
* RETURNS:
|
||||
* ASE_NULL if no match is found.
|
||||
* QSE_NULL if no match is found.
|
||||
* The pointer to the start of the matching location if a match is found.
|
||||
*/
|
||||
void* ase_memrmem (
|
||||
void* qse_memrmem (
|
||||
const void* hs /* a pointer to the memory block to scan */,
|
||||
ase_size_t hl /* the number of bytes to scan */,
|
||||
qse_size_t hl /* the number of bytes to scan */,
|
||||
const void* nd /* a pointer to the byte block to find */,
|
||||
ase_size_t nl /* the number of bytes in the block */
|
||||
qse_size_t nl /* the number of bytes in the block */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
63
qse/include/qse/cmn/opt.h
Normal file
63
qse/include/qse/cmn/opt.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* $Id: getopt.h 290 2008-07-27 06:16:54Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_OPT_H_
|
||||
#define _QSE_CMN_OPT_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
typedef struct qse_opt_t qse_opt_t;
|
||||
typedef struct qse_opt_lng_t qse_opt_lng_t;
|
||||
|
||||
struct qse_opt_lng_t
|
||||
{
|
||||
const qse_char_t* str;
|
||||
qse_cint_t val;
|
||||
};
|
||||
|
||||
struct qse_opt_t
|
||||
{
|
||||
/* input */
|
||||
const qse_char_t* str; /* option string */
|
||||
qse_opt_lng_t* lng; /* long options */
|
||||
|
||||
/* output */
|
||||
qse_cint_t opt; /* character checked for validity */
|
||||
qse_char_t* arg; /* argument associated with an option */
|
||||
|
||||
/* output */
|
||||
const qse_char_t* lngopt;
|
||||
|
||||
/* input + output */
|
||||
int ind; /* index into parent argv vector */
|
||||
|
||||
/* input + output - internal*/
|
||||
qse_char_t* cur;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.cmn.opt/qse_getopt
|
||||
* NAME
|
||||
* qse_getopt - parse command line options
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_cint_t qse_getopt (
|
||||
int argc /* argument count */,
|
||||
qse_char_t* const* argv /* argument array */,
|
||||
qse_opt_t* opt /* option configuration */
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
94
qse/include/qse/cmn/rex.h
Normal file
94
qse/include/qse/cmn/rex.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* $Id: rex.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_REX_H_
|
||||
#define _QSE_CMN_REX_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/*
|
||||
* Regular Esseression Syntax
|
||||
* A regular expression is zero or more branches, separated by '|'.
|
||||
* ......
|
||||
* ......
|
||||
*
|
||||
* Compiled form of a regular expression:
|
||||
*
|
||||
* | expression |
|
||||
* | header | branch | branch | branch |
|
||||
* | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd |
|
||||
*
|
||||
* nb: the number of branches
|
||||
* el: the length of a expression including the length of nb and el
|
||||
* na: the number of atoms
|
||||
* bl: the length of a branch including the length of na and bl
|
||||
* cmd: The command and repetition info encoded together.
|
||||
* Some commands require an argument to follow them but some other don't.
|
||||
* It is encoded as follows:
|
||||
*
|
||||
* Subexpressions can be nested by having the command "GROUP"
|
||||
* and a subexpression as its argument.
|
||||
*
|
||||
* Examples:
|
||||
* a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c|
|
||||
* ab|xy -> |2|10|4|ORD_CHAR(no bound)|a|ORD_CHAR(no bound)|b|4|ORD_CHAR(no bound)|x|ORD_CHAR(no bound)|y|
|
||||
*/
|
||||
|
||||
#define QSE_REX_NA(code) (*(qse_size_t*)(code))
|
||||
|
||||
#define QSE_REX_LEN(code) \
|
||||
(*(qse_size_t*)((qse_byte_t*)(code)+QSE_SIZEOF(qse_size_t)))
|
||||
|
||||
enum qse_rex_option_t
|
||||
{
|
||||
QSE_REX_IGNORECASE = (1 << 0)
|
||||
};
|
||||
|
||||
enum qse_rex_errnum_t
|
||||
{
|
||||
QSE_REX_ENOERR = 0,
|
||||
QSE_REX_ENOMEM,
|
||||
QSE_REX_ERECUR, /* recursion too deep */
|
||||
QSE_REX_ERPAREN, /* a right parenthesis is expected */
|
||||
QSE_REX_ERBRACKET, /* a right bracket is expected */
|
||||
QSE_REX_ERBRACE, /* a right brace is expected */
|
||||
QSE_REX_EUNBALPAR, /* unbalanced parenthesis */
|
||||
QSE_REX_ECOLON, /* a colon is expected */
|
||||
QSE_REX_ECRANGE, /* invalid character range */
|
||||
QSE_REX_ECCLASS, /* invalid character class */
|
||||
QSE_REX_EBRANGE, /* invalid boundary range */
|
||||
QSE_REX_EEND, /* unexpected end of the pattern */
|
||||
QSE_REX_EGARBAGE /* garbage after the pattern */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* qse_buildrex (
|
||||
qse_mmgr_t* mmgr, qse_size_t depth,
|
||||
const qse_char_t* ptn, qse_size_t len, int* errnum);
|
||||
|
||||
int qse_matchrex (
|
||||
qse_mmgr_t* mmgr, qse_ccls_t* ccls, qse_size_t depth,
|
||||
void* code, int option,
|
||||
const qse_char_t* str, qse_size_t len,
|
||||
const qse_char_t** match_ptr, qse_size_t* match_len, int* errnum);
|
||||
|
||||
void qse_freerex (qse_mmgr_t* mmgr, void* code);
|
||||
|
||||
qse_bool_t qse_isemptyrex (void* code);
|
||||
|
||||
#if 0
|
||||
void qse_dprintrex (qse_rex_t* rex, void* rex);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
142
qse/include/qse/cmn/sio.h
Normal file
142
qse/include/qse/cmn/sio.h
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* $Id: sio.h,v 1.29 2005/12/26 05:38:24 bacon Ease $
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_SIO_H_
|
||||
#define _QSE_CMN_SIO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/fio.h>
|
||||
#include <qse/cmn/tio.h>
|
||||
|
||||
enum qse_sio_open_flag_t
|
||||
{
|
||||
QSE_SIO_HANDLE = QSE_FIO_HANDLE,
|
||||
|
||||
QSE_SIO_READ = QSE_FIO_READ,
|
||||
QSE_SIO_WRITE = QSE_FIO_WRITE,
|
||||
QSE_SIO_APPEND = QSE_FIO_APPEND,
|
||||
|
||||
QSE_SIO_CREATE = QSE_FIO_CREATE,
|
||||
QSE_SIO_TRUNCATE = QSE_FIO_TRUNCATE,
|
||||
QSE_SIO_EXCLUSIVE = QSE_FIO_EXCLUSIVE,
|
||||
QSE_SIO_SYNC = QSE_FIO_SYNC,
|
||||
|
||||
QSE_SIO_NOSHRD = QSE_FIO_NOSHRD,
|
||||
QSE_SIO_NOSHWR = QSE_FIO_NOSHWR
|
||||
};
|
||||
|
||||
typedef qse_fio_off_t qse_sio_off_t;
|
||||
typedef qse_fio_hnd_t qse_sio_hnd_t;
|
||||
|
||||
typedef struct qse_sio_t qse_sio_t;
|
||||
|
||||
struct qse_sio_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
qse_fio_t fio;
|
||||
qse_tio_t tio;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern qse_sio_t* qse_sio_in;
|
||||
extern qse_sio_t* qse_sio_out;
|
||||
extern qse_sio_t* qse_sio_err;
|
||||
|
||||
qse_sio_t* qse_sio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
const qse_char_t* file,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_sio_close (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
qse_sio_t* qse_sio_init (
|
||||
qse_sio_t* sio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* file,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_sio_fini (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
qse_fio_hnd_t qse_sio_gethandle (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_flush (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
void qse_sio_purge (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_getc (
|
||||
qse_sio_t* sio,
|
||||
qse_char_t* c
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_gets (
|
||||
qse_sio_t* sio,
|
||||
qse_char_t* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_getsx (
|
||||
qse_sio_t* sio,
|
||||
qse_char_t* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_getstr (
|
||||
qse_sio_t* sio,
|
||||
qse_str_t* buf
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_putc (
|
||||
qse_sio_t* sio,
|
||||
qse_char_t c
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_puts (
|
||||
qse_sio_t* sio,
|
||||
const qse_char_t* str
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_putsx (
|
||||
qse_sio_t* sio,
|
||||
const qse_char_t* str,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
#if 0
|
||||
qse_ssize_t qse_sio_putsn (qse_sio_t* sio, ...);
|
||||
qse_ssize_t qse_sio_putsxn (qse_sio_t* sio, ...);
|
||||
qse_ssize_t qse_sio_putsv (qse_sio_t* sio, qse_va_list ap);
|
||||
qse_ssize_t qse_sio_putsxv (qse_sio_t* sio, qse_va_list ap);
|
||||
|
||||
/* WARNING:
|
||||
* getpos may not return the desired postion because of the buffering
|
||||
*/
|
||||
int qse_sio_getpos (qse_sio_t* sio, qse_sio_off_t* pos);
|
||||
int qse_sio_setpos (qse_sio_t* sio, qse_sio_off_t pos);
|
||||
int qse_sio_rewind (qse_sio_t* sio);
|
||||
int qse_sio_movetoend (qse_sio_t* sio);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
582
qse/include/qse/cmn/sll.h
Normal file
582
qse/include/qse/cmn/sll.h
Normal file
@ -0,0 +1,582 @@
|
||||
/*
|
||||
* $Id: sll.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_SLL_H_
|
||||
#define _QSE_CMN_SLL_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/****t* qse.cmn.sll/qse_sll_walk_t
|
||||
* NAME
|
||||
* qse_sll_walk_t - define return values for qse_sll_walker_t
|
||||
*
|
||||
* SEE ALSO
|
||||
* qse_sll_walk, qse_sll_walker_t
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum qse_sll_walk_t
|
||||
{
|
||||
QSE_SLL_WALK_STOP = 0,
|
||||
QSE_SLL_WALK_FORWARD = 1
|
||||
};
|
||||
/******/
|
||||
|
||||
typedef struct qse_sll_t qse_sll_t;
|
||||
typedef struct qse_sll_node_t qse_sll_node_t;
|
||||
typedef enum qse_sll_walk_t qse_sll_walk_t;
|
||||
|
||||
/****b* qse.cmn.sll/qse_sll_copier_t
|
||||
* NAME
|
||||
* qse_sll_copier_t - define a node contruction callback
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_copier_t defines a callback function for node construction.
|
||||
* A node is contructed when a user adds data to a list. The user can
|
||||
* define how the data to add can be maintained in the list. A singly
|
||||
* linked list not specified with any copiers stores the data pointer and
|
||||
* the data length into a node. A special copier QSE_SLL_COPIER_INLINE copies
|
||||
* the contents of the data a user provided into the node. You can use the
|
||||
* qse_sll_setcopier() function to change the copier.
|
||||
*
|
||||
* A copier should return the pointer to the copied data. If it fails to copy
|
||||
* data, it may return QSE_NULL. You need to set a proper freeer to free up
|
||||
* memory allocated for copy.
|
||||
*
|
||||
* SEE ALSO
|
||||
* qse_sll_setcopier, qse_sll_getcopier, QSE_SLL_COPIER
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void* (*qse_sll_copier_t) (
|
||||
qse_sll_t* sll /* a map */,
|
||||
void* dptr /* the pointer to data to copy */,
|
||||
qse_size_t dlen /* the length of data to copy */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* qse.cmn.sll/qse_sll_freeer_t
|
||||
* NAME
|
||||
* qse_sll_freeer_t - define a node destruction callback
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef void (*qse_sll_freeer_t) (
|
||||
qse_sll_t* sll /* a map */,
|
||||
void* dptr /* the pointer to data to free */,
|
||||
qse_size_t dlen /* the length of data to free */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****t* qse.cmn.sll/qse_sll_comper_t
|
||||
* NAME
|
||||
* qse_sll_comper_t - define a data comparator
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_comper_t type defines a key comparator that is called when
|
||||
* the list needs to compare data. A singly linked list is created with a
|
||||
* default comparator that performs bitwise comparison.
|
||||
*
|
||||
* The comparator should return 0 if the data are the same and a non-zero
|
||||
* integer otherwise.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef int (*qse_sll_comper_t) (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
const void* dptr1 /* a data pointer */,
|
||||
qse_size_t dlen1 /* a data length */,
|
||||
const void* dptr2 /* a data pointer */,
|
||||
qse_size_t dlen2 /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****b* qse.cmn.sll/qse_sll_walker_t
|
||||
* NAME
|
||||
* qse_sll_walker_t - define a list traversal callback for each node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_walk() calls a callback function of the type qse_sll_walker_t
|
||||
* for each node until it returns QSE_SLL_WALK_STOP. The walker should return
|
||||
* QSE_SLL_WALK_FORWARD to let qse_sll_walk() continue visiting the next node.
|
||||
* The third parameter to qse_sll_walk() is passed to the walker as the third
|
||||
* parameter.
|
||||
*
|
||||
* SEE ALSO
|
||||
* qse_sll_walk, qse_sll_walk_t
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
typedef qse_sll_walk_t (*qse_sll_walker_t) (
|
||||
qse_sll_t* sll /* a map */,
|
||||
qse_sll_node_t* node /* a visited node */,
|
||||
void* arg /* user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****s* qse.cmn.sll/qse_sll_t
|
||||
* NAME
|
||||
* qse_sll_t - define a singly linked list
|
||||
*
|
||||
* DESCRPTION
|
||||
* The qse_sll_t type defines a singly lnked list.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_sll_t
|
||||
{
|
||||
qse_mmgr_t* mmgr; /* memory manager */
|
||||
|
||||
qse_sll_copier_t copier; /* data copier */
|
||||
qse_sll_freeer_t freeer; /* data freeer */
|
||||
qse_sll_comper_t comper; /* data comparator */
|
||||
qse_byte_t scale; /* scale factor */
|
||||
|
||||
qse_size_t size; /* the number of nodes */
|
||||
qse_sll_node_t* head; /* the head node */
|
||||
qse_sll_node_t* tail; /* the tail node */
|
||||
};
|
||||
/******/
|
||||
|
||||
/****s* qse.cmn.sll/qse_sll_node_t
|
||||
* NAME
|
||||
* qse_sll_node_t - define a list node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_node_t type defines a list node containing a data pointer and
|
||||
* and data length.
|
||||
*
|
||||
* SEE ALSO
|
||||
* QSE_SLL_DPTR, QSE_SLL_DLEN, QSE_SLL_NEXT
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_sll_node_t
|
||||
{
|
||||
void* dptr; /* the pointer to data */
|
||||
qse_size_t dlen; /* the length of data */
|
||||
qse_sll_node_t* next; /* the pointer to the next node */
|
||||
};
|
||||
/******/
|
||||
|
||||
#define QSE_SLL_COPIER_SIMPLE ((qse_sll_copier_t)1)
|
||||
#define QSE_SLL_COPIER_INLINE ((qse_sll_copier_t)2)
|
||||
|
||||
#define QSE_SLL_MMGR(sll) ((sll)->mmgr)
|
||||
#define QSE_SLL_XTN(s) ((void*)(((qse_sll_t*)s) + 1))
|
||||
#define QSE_SLL_COPIER(sll) ((sll)->copier)
|
||||
#define QSE_SLL_FREEER(sll) ((sll)->freeer)
|
||||
#define QSE_SLL_COMPER(sll) ((sll)->comper)
|
||||
|
||||
#define QSE_SLL_HEAD(sll) ((sll)->head)
|
||||
#define QSE_SLL_TAIL(sll) ((sll)->tail)
|
||||
#define QSE_SLL_SIZE(sll) ((sll)->size)
|
||||
#define QSE_SLL_SCALE(sll) ((sll)->scale)
|
||||
|
||||
#define QSE_SLL_DPTR(node) ((node)->dptr)
|
||||
#define QSE_SLL_DLEN(node) ((node)->dlen)
|
||||
#define QSE_SLL_NEXT(node) ((node)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_open
|
||||
* NAME
|
||||
* qse_sll_open - create a singly linked list with extension area
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_open() function creates an empty singly linked list.
|
||||
* If the memory manager mmgr is QSE_NULL, the function gets the default
|
||||
* memory manager with QSE_MMGR_GETMMGR() and uses it if it is not QSE_NULL.
|
||||
* The extension area is allocated when the positive extension size extension
|
||||
* is specified. It calls the extension initialization function initializer
|
||||
* after initializing the main area. The extension initializer is passed
|
||||
* the pointer to the singly linked list created.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_sll_open() function returns the pointer to a new singly linked
|
||||
* list on success and QSE_NULL on failure.
|
||||
*
|
||||
* NOTES
|
||||
* In the debug build, it fails an assertion if QSE_MMGR_GETMMGR() returns
|
||||
* QSE_NULL when QSE_NULL is passed as the first parameter. In the release
|
||||
* build, it returns QSE_NULL if such a thing happens.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_t* qse_sll_open (
|
||||
qse_mmgr_t* mmgr /* memory manager */ ,
|
||||
qse_size_t ext /* size of extension area in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_close
|
||||
* NAME
|
||||
* qse_sll_close - destroy a singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_close() function destroys a singly linked list freeing up
|
||||
* the memory.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_close (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_init
|
||||
* NAME
|
||||
* qse_sll_init - initialize a singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_init() function initializes a singly linked list. The memory
|
||||
* should be allocated by a caller and be passed to it. The caller may declare
|
||||
* a static variable of the qse_sll_t type and pass its address. A memory
|
||||
* manager still needs to be passed for node manipulation later.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_sll_init() function returns the first parameter on success and
|
||||
* QSE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_t* qse_sll_init (
|
||||
qse_sll_t* sll /* an uninitialized singly linked list */,
|
||||
qse_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_fini
|
||||
* NAME
|
||||
* qse_sll_init - deinitialize a singly linked list
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_fini (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getxtn
|
||||
* NAME
|
||||
* qse_sll_getxtn - get the pointer to the extension
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_getxtn() function returns the pointer to the extension.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void* qse_sll_getxtn (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getmmgr
|
||||
* NAME
|
||||
* qse_sll_getmmgr - get the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_mmgr_t* qse_sll_getmmgr (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_setmmgr
|
||||
* NAME
|
||||
* qse_sll_setmmgr - set the memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_setmmgr (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_mmgr_t* mmgr /* a memory manager */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getsize
|
||||
* NAME
|
||||
* qse_sll_getsize - get the number of nodes
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_getsize() function returns the number of the data nodes held
|
||||
* in a singly linked list.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_sll_getsize (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getscale
|
||||
* NAME
|
||||
* qse_sll_getscale - get the scale factor
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_sll_getscale (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_setscale
|
||||
* NAME
|
||||
* qse_sll_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_setscale() function sets the scale factor of the data length.
|
||||
* A scale factor determines the actual length of data in bytes. A singly
|
||||
* linked list created with a scale factor of 1. The scale factor should be
|
||||
* larger than 0 and less than 256.
|
||||
*
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a sll is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_setscale (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
int scale /* a scale factor */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getcopier
|
||||
* NAME
|
||||
* qse_sll_getfreeer - get the data copier
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_copier_t qse_sll_getcopier (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_setcopier
|
||||
* NAME
|
||||
* qse_sll_setcopier - set a data copier
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier QSE_SLL_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to QSE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_setcopier (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_copier_t copier /* a data copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getfreeer
|
||||
* NAME
|
||||
* qse_sll_getfreeer - get the data freeer
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_freeer_t qse_sll_getfreeer (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_setfreeer
|
||||
* NAME
|
||||
* qse_sll_setfreeer - set a data freeer
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_setfreeer (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_freeer_t freeer /* a data freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_getcomper
|
||||
* NAME
|
||||
* qse_sll_getcomper - get the data comparator
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_comper_t qse_sll_getcomper (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_setcomper
|
||||
* NAME
|
||||
* qse_sll_setcomper - set the data comparator
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_setcomper (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_comper_t comper /* a comparator */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_gethead
|
||||
* NAME
|
||||
* qse_sll_gethead - get the head node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_node_t* qse_sll_gethead (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_gettail
|
||||
* NAME
|
||||
* qse_sll_gettail - get the tail node
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_node_t* qse_sll_gettail (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_search
|
||||
* NAME
|
||||
* qse_sll_search - find a node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_search() function traverses a list to find a node containing
|
||||
* the same value as the the data pointer and length. The traversal begins
|
||||
* from the next node of the positional node. If the positional node is
|
||||
* QSE_NULL, the traversal begins from the head node.
|
||||
*
|
||||
* RETURN
|
||||
* The pointer to the node found. Otherwise, QSE_NULL.
|
||||
*
|
||||
* NOTES
|
||||
* No reverse search is provided because a reverse traversal can not be
|
||||
* achieved efficiently.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_node_t* qse_sll_search (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_node_t* pos /* a positional node */,
|
||||
const void* dptr /* a data pointer */,
|
||||
qse_size_t dlen /* a data length */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_insert
|
||||
* NAME
|
||||
* qse_sll_insert - insert data to a new node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* There is performance penalty unless the positional node is neither
|
||||
* the head node nor QSE_NULL. You should consider a different data
|
||||
* structure such as a doubly linked list if you need to insert data
|
||||
* into a random position.
|
||||
*
|
||||
* RETURN
|
||||
* The pointer to a new node on success and QSE_NULL on failure:w
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_sll_node_t* qse_sll_insert (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_node_t* pos /* a node before which a new node is inserted */,
|
||||
void* dptr /* the pointer to the data */,
|
||||
qse_size_t dlen /* the length of the data */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_delete
|
||||
* NAME
|
||||
* qse_sll_delete - delete a node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_delete() function deletes a node.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_delete (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_node_t* pos /* a node to delete */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_clear
|
||||
* NAME
|
||||
* qse_sll_clear - delete all nodes
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_sll_clear() function empties a singly linked list by deletinng
|
||||
* all the nodes.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_clear (
|
||||
qse_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_sll_node_t* qse_sll_pushhead (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
qse_sll_node_t* qse_sll_pushtail (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
void* dptr,
|
||||
qse_size_t dlen
|
||||
);
|
||||
|
||||
|
||||
void qse_sll_pophead (
|
||||
qse_sll_t* sll
|
||||
);
|
||||
|
||||
void qse_sll_poptail (
|
||||
qse_sll_t* sll
|
||||
);
|
||||
|
||||
/****f* qse.cmn.sll/qse_sll_walk
|
||||
* NAME
|
||||
* qse_sll_walk - traverse s singly linked list
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A singly linked list allows uni-directional in-order traversal.
|
||||
* The qse_sll_walk() function traverses a singly linkked list from its
|
||||
* head node down to its tail node as long as the walker function returns
|
||||
* QSE_SLL_WALK_FORWARD. A walker can return QSE_SLL_WALK_STOP to cause
|
||||
* immediate stop of traversal.
|
||||
*
|
||||
* For each node, the walker function is called and it is passed three
|
||||
* parameters: the singly linked list, the visiting node, and the
|
||||
* user-defined data passed as the third parameter in a call to the
|
||||
* qse_sll_walk() function.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_sll_walk (
|
||||
qse_sll_t* sll /* a singly linked list */,
|
||||
qse_sll_walker_t walker /* a user-defined walker function */,
|
||||
void* arg /* the pointer to user-defined data */
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
476
qse/include/qse/cmn/str.h
Normal file
476
qse/include/qse/cmn/str.h
Normal file
@ -0,0 +1,476 @@
|
||||
/*
|
||||
* $Id: str.h 496 2008-12-15 09:56:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_STR_H_
|
||||
#define _QSE_CMN_STR_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/****o* qse.cmn.str/string
|
||||
* DESCRIPTION
|
||||
* <qse/cmn/str.h> defines various functions, types, macros to manipulate
|
||||
* strings.
|
||||
*
|
||||
* The qse_cstr_t type and the qse_xstr_t defined in ase/types.h helps you
|
||||
* dealing with a string pointer and length.
|
||||
*
|
||||
* #include <qse/cmn/str.h>
|
||||
*
|
||||
* EXAMPLES
|
||||
* void f (void)
|
||||
* {
|
||||
* }
|
||||
******
|
||||
*/
|
||||
|
||||
|
||||
#define QSE_STR_LEN(s) ((s)->len)
|
||||
#define QSE_STR_PTR(s) ((s)->ptr)
|
||||
#define QSE_STR_CAPA(s) ((s)->capa)
|
||||
#define QSE_STR_CHAR(s,idx) ((s)->ptr[idx])
|
||||
|
||||
#define QSE_STR_MMGR(s) ((s)->mmgr)
|
||||
#define QSE_STR_XTN(s) ((void*)(((qse_str_t*)s) + 1))
|
||||
#define QSE_STR_SIZER(s) ((s)->sizer)
|
||||
|
||||
typedef struct qse_str_t qse_str_t;
|
||||
typedef qse_size_t (*qse_str_sizer_t) (qse_str_t* data, qse_size_t hint);
|
||||
|
||||
struct qse_str_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
qse_str_sizer_t sizer;
|
||||
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
qse_size_t capa;
|
||||
};
|
||||
|
||||
/* int qse_chartonum (qse_char_t c, int base) */
|
||||
#define QSE_CHARTONUM(c,base) \
|
||||
((c>=QSE_T('0') && c<=QSE_T('9'))? ((c-QSE_T('0')<base)? (c-QSE_T('0')): base): \
|
||||
(c>=QSE_T('A') && c<=QSE_T('Z'))? ((c-QSE_T('A')+10<base)? (c-QSE_T('A')+10): base): \
|
||||
(c>=QSE_T('a') && c<=QSE_T('z'))? ((c-QSE_T('a')+10<base)? (c-QSE_T('a')+10): base): base)
|
||||
|
||||
/* qse_strtonum (const qse_char_t* nptr, qse_char_t** endptr, int base) */
|
||||
#define QSE_STRTONUM(value,nptr,endptr,base) \
|
||||
{ \
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_char_t* __ston_ptr = nptr; \
|
||||
for (;;) { \
|
||||
qse_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_T(' ') || \
|
||||
__ston_c == QSE_T('\t')) { __ston_ptr++; continue; } \
|
||||
if (__ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \
|
||||
if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_CHARTONUM(*__ston_ptr, base)) < base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
} \
|
||||
if (endptr != QSE_NULL) *((const qse_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
}
|
||||
|
||||
/* qse_strxtonum (const qse_char_t* nptr, qse_size_t len, qse_char_char** endptr, int base) */
|
||||
#define QSE_STRXTONUM(value,nptr,len,endptr,base) \
|
||||
{ \
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_char_t* __ston_ptr = nptr; \
|
||||
const qse_char_t* __ston_end = __ston_ptr + len; \
|
||||
value = 0; \
|
||||
while (__ston_ptr < __ston_end) { \
|
||||
qse_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_T(' ') || __ston_c == QSE_T('\t')) { \
|
||||
__ston_ptr++; continue; \
|
||||
} \
|
||||
if (__ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \
|
||||
if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && \
|
||||
(__ston_v = QSE_CHARTONUM(*__ston_ptr, base)) != base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
} \
|
||||
if (endptr != QSE_NULL) *((const qse_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* basic string functions
|
||||
*/
|
||||
qse_size_t qse_strlen (const qse_char_t* str);
|
||||
qse_size_t qse_strbytes (const qse_char_t* str);
|
||||
|
||||
qse_size_t qse_strcpy (
|
||||
qse_char_t* buf, const qse_char_t* str);
|
||||
qse_size_t qse_strxcpy (
|
||||
qse_char_t* buf, qse_size_t bsz, const qse_char_t* str);
|
||||
qse_size_t qse_strncpy (
|
||||
qse_char_t* buf, const qse_char_t* str, qse_size_t len);
|
||||
qse_size_t qse_strxncpy (
|
||||
qse_char_t* buf, qse_size_t bsz, const qse_char_t* str, qse_size_t len);
|
||||
|
||||
qse_size_t qse_strxcat (
|
||||
qse_char_t* buf, qse_size_t bsz, const qse_char_t* str);
|
||||
qse_size_t qse_strxncat (
|
||||
qse_char_t* buf, qse_size_t bsz, const qse_char_t* str, qse_size_t len);
|
||||
|
||||
int qse_strcmp (const qse_char_t* s1, const qse_char_t* s2);
|
||||
int qse_strxcmp (const qse_char_t* s1, qse_size_t len1, const qse_char_t* s2);
|
||||
int qse_strxncmp (
|
||||
const qse_char_t* s1, qse_size_t len1,
|
||||
const qse_char_t* s2, qse_size_t len2);
|
||||
|
||||
int qse_strcasecmp (
|
||||
const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls);
|
||||
|
||||
/****f* qse.cmn.str/qse_strxncasecmp
|
||||
* NAME
|
||||
* qse_strxncasecmp - compare strings ignoring case
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_strxncasecmp() function compares characters at the same position
|
||||
* in each string after converting them to the same case temporarily.
|
||||
* It accepts two strings and a character class handler. A string is
|
||||
* represented by its beginning pointer and length. You can write your own
|
||||
* character class handler or use QSE_CCLS_GETDFL() to get the default
|
||||
* character class handler.
|
||||
*
|
||||
* For two strings to be equal, they need to have the same length and all
|
||||
* characters in the first string should be equal to their counterpart in the
|
||||
* second string.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_strxncasecmp() returns 0 if two strings are equal, a positive
|
||||
* number if the first string is larger, -1 if the second string is larger.
|
||||
*
|
||||
* EXAMPLES
|
||||
* qse_strxncasecmp (QSE_T("foo"), 3, QSE_T("FoO"), 3, QSE_CCLS_GETDFL());
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_strxncasecmp (
|
||||
const qse_char_t* s1 /* the pointer to the first string */,
|
||||
qse_size_t len1 /* the length of the first string */,
|
||||
const qse_char_t* s2 /* the pointer to the second string */,
|
||||
qse_size_t len2 /* the length of the second string */,
|
||||
qse_ccls_t* ccls /* character class handler */
|
||||
);
|
||||
/******/
|
||||
|
||||
qse_char_t* qse_strdup (const qse_char_t* str, qse_mmgr_t* mmgr);
|
||||
qse_char_t* qse_strxdup (
|
||||
const qse_char_t* str, qse_size_t len, qse_mmgr_t* mmgr);
|
||||
qse_char_t* qse_strxdup2 (
|
||||
const qse_char_t* str1, qse_size_t len1,
|
||||
const qse_char_t* str2, qse_size_t len2, qse_mmgr_t* mmgr);
|
||||
|
||||
qse_char_t* qse_strstr (const qse_char_t* str, const qse_char_t* sub);
|
||||
qse_char_t* qse_strxstr (
|
||||
const qse_char_t* str, qse_size_t size, const qse_char_t* sub);
|
||||
qse_char_t* qse_strxnstr (
|
||||
const qse_char_t* str, qse_size_t strsz,
|
||||
const qse_char_t* sub, qse_size_t subsz);
|
||||
|
||||
qse_char_t* qse_strchr (const qse_char_t* str, qse_cint_t c);
|
||||
qse_char_t* qse_strxchr (const qse_char_t* str, qse_size_t len, qse_cint_t c);
|
||||
qse_char_t* qse_strrchr (const qse_char_t* str, qse_cint_t c);
|
||||
qse_char_t* qse_strxrchr (const qse_char_t* str, qse_size_t len, qse_cint_t c);
|
||||
|
||||
/* Checks if a string begins with a substring */
|
||||
qse_char_t* qse_strbeg (const qse_char_t* str, const qse_char_t* sub);
|
||||
qse_char_t* qse_strxbeg (
|
||||
const qse_char_t* str, qse_size_t len, const qse_char_t* sub);
|
||||
qse_char_t* qse_strnbeg (
|
||||
const qse_char_t* str, const qse_char_t* sub, qse_size_t len);
|
||||
qse_char_t* qse_strxnbeg (
|
||||
const qse_char_t* str, qse_size_t len1,
|
||||
const qse_char_t* sub, qse_size_t len2);
|
||||
|
||||
/* Checks if a string ends with a substring */
|
||||
qse_char_t* qse_strend (const qse_char_t* str, const qse_char_t* sub);
|
||||
qse_char_t* qse_strxend (
|
||||
const qse_char_t* str, qse_size_t len, const qse_char_t* sub);
|
||||
qse_char_t* qse_strnend (
|
||||
const qse_char_t* str, const qse_char_t* sub, qse_size_t len);
|
||||
qse_char_t* qse_strxnend (
|
||||
const qse_char_t* str, qse_size_t len1,
|
||||
const qse_char_t* sub, qse_size_t len2);
|
||||
|
||||
/*
|
||||
* string conversion
|
||||
*/
|
||||
int qse_strtoi (const qse_char_t* str);
|
||||
long qse_strtol (const qse_char_t* str);
|
||||
unsigned int qse_strtoui (const qse_char_t* str);
|
||||
unsigned long qse_strtoul (const qse_char_t* str);
|
||||
|
||||
int qse_strxtoi (const qse_char_t* str, qse_size_t len);
|
||||
long qse_strxtol (const qse_char_t* str, qse_size_t len);
|
||||
unsigned int qse_strxtoui (const qse_char_t* str, qse_size_t len);
|
||||
unsigned long qse_strxtoul (const qse_char_t* str, qse_size_t len);
|
||||
|
||||
qse_int_t qse_strtoint (const qse_char_t* str);
|
||||
qse_long_t qse_strtolong (const qse_char_t* str);
|
||||
qse_uint_t qse_strtouint (const qse_char_t* str);
|
||||
qse_ulong_t qse_strtoulong (const qse_char_t* str);
|
||||
|
||||
qse_int_t qse_strxtoint (const qse_char_t* str, qse_size_t len);
|
||||
qse_long_t qse_strxtolong (const qse_char_t* str, qse_size_t len);
|
||||
qse_uint_t qse_strxtouint (const qse_char_t* str, qse_size_t len);
|
||||
qse_ulong_t qse_strxtoulong (const qse_char_t* str, qse_size_t len);
|
||||
|
||||
qse_str_t* qse_str_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
qse_size_t capa
|
||||
);
|
||||
|
||||
void qse_str_close (
|
||||
qse_str_t* str
|
||||
);
|
||||
|
||||
/*
|
||||
* If capa is 0, it doesn't allocate the buffer in advance.
|
||||
*/
|
||||
qse_str_t* qse_str_init (
|
||||
qse_str_t* str,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa
|
||||
);
|
||||
|
||||
void qse_str_fini (
|
||||
qse_str_t* str
|
||||
);
|
||||
|
||||
/****f* qse.cmn.str/qse_str_yield
|
||||
* NAME
|
||||
* qse_str_yield - yield the buffer
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_str_yield() function assigns the buffer to an variable of the
|
||||
* qse_xstr_t type and recreate a new buffer of the new_capa capacity.
|
||||
* The function fails if it fails to allocate a new buffer.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_str_yield() function returns 0 on success, and -1 on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_str_yield (
|
||||
qse_str_t* str /* a dynamic string */,
|
||||
qse_xstr_t* buf /* the pointer to a qse_xstr_t variable */,
|
||||
int new_capa /* new capacity in number of characters */
|
||||
);
|
||||
/******/
|
||||
|
||||
void* qse_str_getxtn (
|
||||
qse_str_t* str
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_str_getmmgr (
|
||||
qse_str_t* str
|
||||
);
|
||||
|
||||
void qse_str_setmmgr (
|
||||
qse_str_t* str,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get the sizer
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The qse_str_getsizer() function returns the sizer specified.
|
||||
*
|
||||
* RETURNS: a sizer function set or QSE_NULL if no sizer is set.
|
||||
*/
|
||||
qse_str_sizer_t qse_str_getsizer (
|
||||
qse_str_t* str /* a dynamic string */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: specify a sizer
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The qse_str_setsizer() function specify a new sizer for a dynamic string.
|
||||
* With no sizer specified, the dynamic string doubles the current buffer
|
||||
* when it needs to increase its size. The sizer function is passed a dynamic
|
||||
* string and the minimum capacity required to hold data after resizing.
|
||||
* The string is truncated if the sizer function returns a smaller number
|
||||
* than the hint passed.
|
||||
*/
|
||||
void qse_str_setsizer (
|
||||
qse_str_t* str /* a dynamic string */,
|
||||
qse_str_sizer_t sizer /* a sizer function */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: get capacity
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The qse_str_getcapa() function returns the current capacity.
|
||||
* You may use QSE_STR_CAPA(str) macro for performance sake.
|
||||
*
|
||||
* RETURNS: the current capacity in number of characters.
|
||||
*/
|
||||
qse_size_t qse_str_getcapa (
|
||||
qse_str_t* str /* a dynamic string */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: set new capacity
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The qse_str_setcapa() function set new capacity. If the new capacity
|
||||
* is smaller than the old, the overflowing characters are removed from
|
||||
* from the buffer.
|
||||
*
|
||||
* RETURNS: -1 on failure, a new capacity on success
|
||||
*/
|
||||
qse_size_t qse_str_setcapa (
|
||||
qse_str_t* str /* a dynamic string */,
|
||||
qse_size_t capa /* a new capacity */
|
||||
);
|
||||
|
||||
void qse_str_clear (
|
||||
qse_str_t* str
|
||||
);
|
||||
|
||||
void qse_str_swap (
|
||||
qse_str_t* str,
|
||||
qse_str_t* str2
|
||||
);
|
||||
|
||||
qse_size_t qse_str_cpy (
|
||||
qse_str_t* str,
|
||||
const qse_char_t* s
|
||||
);
|
||||
|
||||
qse_size_t qse_str_ncpy (
|
||||
qse_str_t* str,
|
||||
const qse_char_t* s,
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
qse_size_t qse_str_cat (
|
||||
qse_str_t* str,
|
||||
const qse_char_t* s
|
||||
);
|
||||
|
||||
qse_size_t qse_str_ncat (
|
||||
qse_str_t* str,
|
||||
const qse_char_t* s,
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
qse_size_t qse_str_ccat (
|
||||
qse_str_t* str,
|
||||
qse_char_t c
|
||||
);
|
||||
|
||||
qse_size_t qse_str_nccat (
|
||||
qse_str_t* str,
|
||||
qse_char_t c,
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
|
||||
qse_size_t qse_mbstowcs (
|
||||
const qse_mchar_t* mbs,
|
||||
qse_wchar_t* wcs,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
|
||||
/****f* qse.cmn.str/qse_mbsntowcsn
|
||||
* NAME
|
||||
* qse_mbsntowcsn - convert a multibyte string to a wide character string
|
||||
*
|
||||
* RETURN
|
||||
* The qse_mbstowcs() function returns the number of bytes handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_mbsntowcsn (
|
||||
const qse_mchar_t* mbs,
|
||||
qse_size_t mbslen,
|
||||
qse_wchar_t* wcs,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.str/qse_wcstombs
|
||||
* NAME
|
||||
* qse_wcstombs - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_wcstombs() function converts a null-terminated wide character
|
||||
* string to a multibyte string and stores it into the buffer pointed to
|
||||
* by mbs. The pointer to a variable holding the buffer length should be
|
||||
* passed to the function as the third parameter. After conversion, it holds
|
||||
* the length of the multibyte string excluding the terminating-null.
|
||||
* It may not null-terminate the resulting multibyte string if the buffer
|
||||
* is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_wcstombs() function returns the number of wide characters handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_wcstombs (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
|
||||
/****f* qse.cmn.str/qse_wcsntombsn
|
||||
* NAME
|
||||
* qse_wcstombs - convert a wide character string to a multibyte string
|
||||
*
|
||||
* RETURN
|
||||
* The qse_wcstombs() function returns the number of wide characters handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_wcsntombsn (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_size_t wcslen,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.str/qse_wcstombs_strict
|
||||
* NAME
|
||||
* qse_wcstombs_strict - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_wcstombs_strict() function performs the same as the qse_wcsmbs()
|
||||
* function except that it returns an error if it can't fully convert the
|
||||
* input string and/or the buffer is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The qse_wcstombs_strict() function returns 0 on success and -1 on failure.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_wcstombs_strict (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t mbslen
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
134
qse/include/qse/cmn/time.h
Normal file
134
qse/include/qse/cmn/time.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_TIME_H_
|
||||
#define _QSE_CMN_TIME_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
#define QSE_EPOCH_YEAR ((qse_ntime_t)1970)
|
||||
#define QSE_EPOCH_MON ((qse_ntime_t)1)
|
||||
#define QSE_EPOCH_DAY ((qse_ntime_t)1)
|
||||
#define QSE_EPOCH_WDAY ((qse_ntime_t)4)
|
||||
|
||||
#define QSE_DAY_IN_WEEK ((qse_ntime_t)7)
|
||||
#define QSE_MON_IN_YEAR ((qse_ntime_t)12)
|
||||
#define QSE_HOUR_IN_DAY ((qse_ntime_t)24)
|
||||
#define QSE_MIN_IN_HOUR ((qse_ntime_t)60)
|
||||
#define QSE_MIN_IN_DAY (QSE_MIN_IN_HOUR * QSE_HOUR_IN_DAY)
|
||||
#define QSE_SEC_IN_MIN ((qse_ntime_t)60)
|
||||
#define QSE_SEC_IN_HOUR (QSE_SEC_IN_MIN * QSE_MIN_IN_HOUR)
|
||||
#define QSE_SEC_IN_DAY (QSE_SEC_IN_MIN * QSE_MIN_IN_DAY)
|
||||
#define QSE_MSEC_IN_SEC ((qse_ntime_t)1000)
|
||||
#define QSE_MSEC_IN_MIN (QSE_MSEC_IN_SEC * QSE_SEC_IN_MIN)
|
||||
#define QSE_MSEC_IN_HOUR (QSE_MSEC_IN_SEC * QSE_SEC_IN_HOUR)
|
||||
#define QSE_MSEC_IN_DAY (QSE_MSEC_IN_SEC * QSE_SEC_IN_DAY)
|
||||
|
||||
#define QSE_USEC_IN_MSEC ((qse_ntime_t)1000)
|
||||
#define QSE_NSEC_IN_USEC ((qse_ntime_t)1000)
|
||||
#define QSE_USEC_IN_SEC ((qse_ntime_t)QSE_USEC_IN_MSEC * QSE_MSEC_IN_SEC)
|
||||
|
||||
#define QSE_IS_LEAPYEAR(year) (!((year)%4) && (((year)%100) || !((year)%400)))
|
||||
#define QSE_DAY_IN_YEAR(year) (QSE_IS_LEAPYEAR(year)? 366: 365)
|
||||
|
||||
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
|
||||
typedef qse_long_t qse_ntime_t;
|
||||
typedef struct qse_btime_t qse_btime_t;
|
||||
|
||||
struct qse_btime_t
|
||||
{
|
||||
int sec; /* 0-61 */
|
||||
int min; /* 0-59 */
|
||||
int hour; /* 0-23 */
|
||||
int mday; /* 1-31 */
|
||||
int mon; /* 0(jan)-11(dec) */
|
||||
int year; /* the number of years since 1900 */
|
||||
int wday; /* 0(sun)-6(sat) */
|
||||
int yday; /* 0(jan 1) to 365 */
|
||||
int isdst;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* qse.cmn/qse_gettime
|
||||
* NAME
|
||||
* qse_gettime - get the current time
|
||||
*
|
||||
* SYNPOSIS
|
||||
*/
|
||||
int qse_gettime (
|
||||
qse_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/qse_settime
|
||||
* NAME
|
||||
* qse_settime - set the current time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_settime (
|
||||
qse_ntime_t nt
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
/****f* qse.cmn/qse_gmtime
|
||||
* NAME
|
||||
* qse_gmtime - convert numeric time to broken-down time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_gmtime (
|
||||
qse_ntime_t nt,
|
||||
qse_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/qse_localtime
|
||||
* NAME
|
||||
* qse_localtime - convert numeric time to broken-down time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_localtime (
|
||||
qse_ntime_t nt,
|
||||
qse_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/qse_mktime
|
||||
* NAME
|
||||
* qse_mktime - convert broken-down time to numeric time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_mktime (
|
||||
const qse_btime_t* bt,
|
||||
qse_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/qse_strftime
|
||||
* NAME
|
||||
* qse_strftime - format time
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_strftime (
|
||||
qse_char_t* buf,
|
||||
qse_size_t size,
|
||||
const qse_char_t* fmt,
|
||||
qse_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
299
qse/include/qse/cmn/tio.h
Normal file
299
qse/include/qse/cmn/tio.h
Normal file
@ -0,0 +1,299 @@
|
||||
/*
|
||||
* $Id: tio.h,v 1.19 2006/01/01 13:50:24 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_TIO_H_
|
||||
#define _QSE_CMN_TIO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/str.h>
|
||||
|
||||
enum
|
||||
{
|
||||
QSE_TIO_ENOERR = 0,
|
||||
QSE_TIO_ENOMEM, /* out of memory */
|
||||
QSE_TIO_ENOSPC, /* no more space */
|
||||
QSE_TIO_EILSEQ, /* illegal sequence */
|
||||
QSE_TIO_EICSEQ, /* incomplete sequence */
|
||||
QSE_TIO_EILCHR, /* illegal character */
|
||||
QSE_TIO_ENOINF, /* no input function attached */
|
||||
QSE_TIO_EINPUT, /* input function returned an error */
|
||||
QSE_TIO_EINPOP, /* input function failed to open */
|
||||
QSE_TIO_EINPCL, /* input function failed to close */
|
||||
QSE_TIO_ENOUTF, /* no output function attached */
|
||||
QSE_TIO_EOUTPT, /* output function returned an error */
|
||||
QSE_TIO_EOUTOP, /* output function failed to open */
|
||||
QSE_TIO_EOUTCL /* output function failed to close */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/* the size of input buffer should be at least equal to or greater
|
||||
* than the maximum sequence length of the qse_mchar_t string.
|
||||
* (i.e. 6 for utf8)
|
||||
*/
|
||||
QSE_TIO_MAX_INBUF_LEN = 4096,
|
||||
QSE_TIO_MAX_OUTBUF_LEN = 4096
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QSE_TIO_IO_OPEN,
|
||||
QSE_TIO_IO_CLOSE,
|
||||
QSE_TIO_IO_DATA
|
||||
};
|
||||
|
||||
|
||||
#define QSE_TIO_MMGR(tio) ((tio)->mmgr)
|
||||
#define QSE_TIO_XTN(s) ((void*)(((qse_tio_t*)s) + 1))
|
||||
#define QSE_TIO_ERRNUM(tio) ((tio)->errnum)
|
||||
|
||||
/*
|
||||
* TYPE: qse_tio_t
|
||||
* Defines the tio type
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <qse_tio_t> defines a generic type for text-based IO. When qse_char_t is
|
||||
* qse_mchar_t, it handles any byte streams. When qse_char_t is qse_wchar_t,
|
||||
* it handles utf-8 byte streams.
|
||||
*/
|
||||
typedef struct qse_tio_t qse_tio_t;
|
||||
|
||||
/*
|
||||
* TYPE: qse_tio_io_t
|
||||
* Defines a user-defines IO handler
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_tio_io_t) (
|
||||
int cmd, void* arg, void* data, qse_size_t size);
|
||||
|
||||
struct qse_tio_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
int errnum;
|
||||
|
||||
/* io functions */
|
||||
qse_tio_io_t input_func;
|
||||
qse_tio_io_t output_func;
|
||||
void* input_arg;
|
||||
void* output_arg;
|
||||
|
||||
/* for housekeeping */
|
||||
int input_status;
|
||||
qse_size_t inbuf_curp;
|
||||
qse_size_t inbuf_len;
|
||||
qse_size_t outbuf_len;
|
||||
|
||||
qse_mchar_t inbuf[QSE_TIO_MAX_INBUF_LEN];
|
||||
qse_mchar_t outbuf[QSE_TIO_MAX_OUTBUF_LEN];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_open
|
||||
*/
|
||||
qse_tio_t* qse_tio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_close
|
||||
*/
|
||||
int qse_tio_close (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
qse_tio_t* qse_tio_init (
|
||||
qse_tio_t* tip,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
int qse_tio_fini (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
void* qse_tio_getxtn (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_tio_getmmgr (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
void qse_tio_setmmgr (
|
||||
qse_tio_t* tio,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_geterrnum
|
||||
* Returns an error code
|
||||
*
|
||||
* PARAMETERS:
|
||||
* grep - a grep object
|
||||
*
|
||||
* RETURNS:
|
||||
* Error code set by the last tio function called
|
||||
*/
|
||||
int qse_tio_geterrnum (qse_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_geterrstr
|
||||
* Translates an error code to a string
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* A pointer to a constant string describing the last error occurred
|
||||
*/
|
||||
const qse_char_t* qse_tio_geterrstr (qse_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_attachin
|
||||
* Attaches an input handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
* input - input handler function
|
||||
* arg - user data to be passed to the input handler
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_attachin (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_t input,
|
||||
void* arg
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_detachin
|
||||
* Detaches an input handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_detachin (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_attachout
|
||||
* Attaches an output handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
* output - output handler function
|
||||
* arg - user data to be passed to the output handler
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_attachout (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_t output,
|
||||
void* arg
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_detachout
|
||||
* Detaches an output handler function
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_detachout (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_flush
|
||||
* Flushes the output buffer
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
* RETURNS:
|
||||
* Number of bytes written on success, -1 on failure
|
||||
*/
|
||||
qse_ssize_t qse_tio_flush (qse_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_purge
|
||||
* Erases all input and output buffered
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
*/
|
||||
void qse_tio_purge (qse_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_getc
|
||||
* Reads a single character
|
||||
*/
|
||||
qse_ssize_t qse_tio_getc (qse_tio_t* tio, qse_char_t* c);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_gets
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <qse_tio_gets> inserts a terminating null if there is a room
|
||||
*/
|
||||
qse_ssize_t qse_tio_gets (qse_tio_t* tio, qse_char_t* buf, qse_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_getsx
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <qse_tio_getsx> doesn't insert a terminating null character
|
||||
*/
|
||||
qse_ssize_t qse_tio_getsx (qse_tio_t* tio, qse_char_t* buf, qse_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_getstr
|
||||
*/
|
||||
qse_ssize_t qse_tio_getstr (qse_tio_t* tio, qse_str_t* buf);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putc
|
||||
*/
|
||||
qse_ssize_t qse_tio_putc (qse_tio_t* tio, qse_char_t c);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_puts
|
||||
*/
|
||||
qse_ssize_t qse_tio_puts (qse_tio_t* tio, const qse_char_t* str);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsx
|
||||
*/
|
||||
qse_ssize_t qse_tio_putsx (qse_tio_t* tio, const qse_char_t* str, qse_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsn
|
||||
*/
|
||||
qse_ssize_t qse_tio_putsn (qse_tio_t* tio, ...);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsxn
|
||||
*/
|
||||
qse_ssize_t qse_tio_putsxn (qse_tio_t* tio, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
64
qse/include/qse/conf_msw.h
Normal file
64
qse/include/qse/conf_msw.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* $Id: conf_msw.h 225 2008-06-26 06:48:38Z baconevi $
|
||||
*
|
||||
* {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 QSE_ENDIAN_LITTLE
|
||||
|
||||
#define QSE_SIZEOF_CHAR 1
|
||||
#define QSE_SIZEOF_SHORT 2
|
||||
#define QSE_SIZEOF_INT 4
|
||||
|
||||
/*#ifdef _WIN64
|
||||
#define QSE_SIZEOF_LONG 8
|
||||
#else*/
|
||||
#define QSE_SIZEOF_LONG 4
|
||||
/*#endif*/
|
||||
|
||||
#if defined(__POCC__) || defined(__DMC__)
|
||||
/* pelles c with no microsoft extension */
|
||||
#define QSE_SIZEOF_LONG_LONG 8
|
||||
|
||||
#define QSE_SIZEOF___INT8 0
|
||||
#define QSE_SIZEOF___INT16 0
|
||||
#define QSE_SIZEOF___INT32 0
|
||||
#define QSE_SIZEOF___INT64 0
|
||||
#define QSE_SIZEOF___INT96 0
|
||||
#define QSE_SIZEOF___INT128 0
|
||||
#else
|
||||
#define QSE_SIZEOF_LONG_LONG 0
|
||||
|
||||
#define QSE_SIZEOF___INT8 1
|
||||
#define QSE_SIZEOF___INT16 2
|
||||
#define QSE_SIZEOF___INT32 4
|
||||
#define QSE_SIZEOF___INT64 8
|
||||
#define QSE_SIZEOF___INT96 0
|
||||
#define QSE_SIZEOF___INT128 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define QSE_SIZEOF_VOID_P 8
|
||||
#else
|
||||
#define QSE_SIZEOF_VOID_P 4
|
||||
#endif
|
||||
|
||||
#define QSE_SIZEOF_FLOAT 4
|
||||
#define QSE_SIZEOF_DOUBLE 8
|
||||
#define QSE_SIZEOF_LONG_DOUBLE 16
|
||||
#define QSE_SIZEOF_WCHAR_T 2
|
@ -5,68 +5,68 @@
|
||||
*/
|
||||
|
||||
/* all of vax, alpha, ia64 are in the little endian. */
|
||||
#define ASE_ENDIAN_LITTLE
|
||||
#define QSE_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
|
||||
#define QSE_SIZEOF_CHAR 1
|
||||
#define QSE_SIZEOF_SHORT 2
|
||||
#define QSE_SIZEOF_INT 4
|
||||
#define QSE_SIZEOF_LONG 4
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
#define QSE_SIZEOF_LONG_LONG 0
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF_LONG_LONG 8
|
||||
#define QSE_SIZEOF_LONG_LONG 8
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF_LONG_LONG 8
|
||||
#define QSE_SIZEOF_LONG_LONG 8
|
||||
#else
|
||||
#define ASE_SIZEOF_LONG_LONG 0
|
||||
#define QSE_SIZEOF_LONG_LONG 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF___INT8 1
|
||||
#define ASE_SIZEOF___INT16 2
|
||||
#define ASE_SIZEOF___INT32 4
|
||||
#define QSE_SIZEOF___INT8 1
|
||||
#define QSE_SIZEOF___INT16 2
|
||||
#define QSE_SIZEOF___INT32 4
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#define QSE_SIZEOF___INT64 0
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF___INT64 8
|
||||
#define QSE_SIZEOF___INT64 8
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF___INT64 8
|
||||
#define QSE_SIZEOF___INT64 8
|
||||
#else
|
||||
#define ASE_SIZEOF___INT64 0
|
||||
#define QSE_SIZEOF___INT64 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF___INT96 0
|
||||
#define ASE_SIZEOF___INT128 0
|
||||
#define QSE_SIZEOF___INT96 0
|
||||
#define QSE_SIZEOF___INT128 0
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#define QSE_SIZEOF_VOID_P 4
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#if __INITIAL_POINTER_SIZE==64
|
||||
#pragma pointer_size 64
|
||||
#define ASE_SIZEOF_VOID_P 8
|
||||
#define QSE_SIZEOF_VOID_P 8
|
||||
#elif __INITIAL_POINTER_SIZE==32
|
||||
#pragma pointer_size 32
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#define QSE_SIZEOF_VOID_P 4
|
||||
#elif __INITIAL_POINTER_SIZE==0
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#define QSE_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
|
||||
#define QSE_SIZEOF_VOID_P 8
|
||||
#elif __INITIAL_POINTER_SIZE==32
|
||||
#pragma pointer_size 32
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#define QSE_SIZEOF_VOID_P 4
|
||||
#elif __INITIAL_POINTER_SIZE==0
|
||||
#define ASE_SIZEOF_VOID_P 4
|
||||
#define QSE_SIZEOF_VOID_P 4
|
||||
#else
|
||||
#error "unsupported initial pointer size"
|
||||
#endif
|
||||
@ -74,17 +74,17 @@
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF_FLOAT 4
|
||||
#define ASE_SIZEOF_DOUBLE 8
|
||||
#define QSE_SIZEOF_FLOAT 4
|
||||
#define QSE_SIZEOF_DOUBLE 8
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 8
|
||||
#define QSE_SIZEOF_LONG_DOUBLE 8
|
||||
#elif defined(alpha) || defined(__alpha)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 16
|
||||
#define QSE_SIZEOF_LONG_DOUBLE 16
|
||||
#elif defined(ia64) || defined(__ia64)
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 16
|
||||
#define QSE_SIZEOF_LONG_DOUBLE 16
|
||||
#else
|
||||
#define ASE_SIZEOF_LONG_DOUBLE 0
|
||||
#define QSE_SIZEOF_LONG_DOUBLE 0
|
||||
#endif
|
||||
|
||||
#define ASE_SIZEOF_WCHAR_T 4
|
||||
#define QSE_SIZEOF_WCHAR_T 4
|
@ -1,82 +1,4 @@
|
||||
/* include/ase/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* author's email address */
|
||||
#undef ASE_AUTHOR
|
||||
|
||||
/* char is mchar */
|
||||
#undef ASE_CHAR_IS_MCHAR
|
||||
|
||||
/* char is wchar */
|
||||
#undef ASE_CHAR_IS_WCHAR
|
||||
|
||||
/* Big Endian */
|
||||
#undef ASE_ENDIAN_BIG
|
||||
|
||||
/* Little Endian */
|
||||
#undef ASE_ENDIAN_LITTLE
|
||||
|
||||
/* Unknown Endian */
|
||||
#undef ASE_ENDIAN_UNKNOWN
|
||||
|
||||
/* sizeof(char) */
|
||||
#undef ASE_SIZEOF_CHAR
|
||||
|
||||
/* sizeof(double) */
|
||||
#undef ASE_SIZEOF_DOUBLE
|
||||
|
||||
/* sizeof(float) */
|
||||
#undef ASE_SIZEOF_FLOAT
|
||||
|
||||
/* sizeof(int) */
|
||||
#undef ASE_SIZEOF_INT
|
||||
|
||||
/* sizeof(long) */
|
||||
#undef ASE_SIZEOF_LONG
|
||||
|
||||
/* sizeof(long double) */
|
||||
#undef ASE_SIZEOF_LONG_DOUBLE
|
||||
|
||||
/* sizeof(long long) */
|
||||
#undef ASE_SIZEOF_LONG_LONG
|
||||
|
||||
/* sizeof(short) */
|
||||
#undef ASE_SIZEOF_SHORT
|
||||
|
||||
/* sizeof(void*) */
|
||||
#undef ASE_SIZEOF_VOID_P
|
||||
|
||||
/* sizeof(wchar_t) */
|
||||
#undef ASE_SIZEOF_WCHAR_T
|
||||
|
||||
/* sizeof(__int128) */
|
||||
#undef ASE_SIZEOF___INT128
|
||||
|
||||
/* sizeof(__int16) */
|
||||
#undef ASE_SIZEOF___INT16
|
||||
|
||||
/* sizeof(__int32) */
|
||||
#undef ASE_SIZEOF___INT32
|
||||
|
||||
/* sizeof(__int64) */
|
||||
#undef ASE_SIZEOF___INT64
|
||||
|
||||
/* sizeof(__int8) */
|
||||
#undef ASE_SIZEOF___INT8
|
||||
|
||||
/* use the syscall() function */
|
||||
#undef ASE_USE_SYSCALL
|
||||
|
||||
/* package version */
|
||||
#undef ASE_VERSION
|
||||
|
||||
/* major version number */
|
||||
#undef ASE_VERSION_MAJOR
|
||||
|
||||
/* minor version number */
|
||||
#undef ASE_VERSION_MINOR
|
||||
|
||||
/* patch level */
|
||||
#undef ASE_VERSION_PATCH
|
||||
/* include/qse/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the `atan' function. */
|
||||
#undef HAVE_ATAN
|
||||
@ -258,6 +180,84 @@
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* author's email address */
|
||||
#undef QSE_AUTHOR
|
||||
|
||||
/* char is mchar */
|
||||
#undef QSE_CHAR_IS_MCHAR
|
||||
|
||||
/* char is wchar */
|
||||
#undef QSE_CHAR_IS_WCHAR
|
||||
|
||||
/* Big Endian */
|
||||
#undef QSE_ENDIAN_BIG
|
||||
|
||||
/* Little Endian */
|
||||
#undef QSE_ENDIAN_LITTLE
|
||||
|
||||
/* Unknown Endian */
|
||||
#undef QSE_ENDIAN_UNKNOWN
|
||||
|
||||
/* sizeof(char) */
|
||||
#undef QSE_SIZEOF_CHAR
|
||||
|
||||
/* sizeof(double) */
|
||||
#undef QSE_SIZEOF_DOUBLE
|
||||
|
||||
/* sizeof(float) */
|
||||
#undef QSE_SIZEOF_FLOAT
|
||||
|
||||
/* sizeof(int) */
|
||||
#undef QSE_SIZEOF_INT
|
||||
|
||||
/* sizeof(long) */
|
||||
#undef QSE_SIZEOF_LONG
|
||||
|
||||
/* sizeof(long double) */
|
||||
#undef QSE_SIZEOF_LONG_DOUBLE
|
||||
|
||||
/* sizeof(long long) */
|
||||
#undef QSE_SIZEOF_LONG_LONG
|
||||
|
||||
/* sizeof(short) */
|
||||
#undef QSE_SIZEOF_SHORT
|
||||
|
||||
/* sizeof(void*) */
|
||||
#undef QSE_SIZEOF_VOID_P
|
||||
|
||||
/* sizeof(wchar_t) */
|
||||
#undef QSE_SIZEOF_WCHAR_T
|
||||
|
||||
/* sizeof(__int128) */
|
||||
#undef QSE_SIZEOF___INT128
|
||||
|
||||
/* sizeof(__int16) */
|
||||
#undef QSE_SIZEOF___INT16
|
||||
|
||||
/* sizeof(__int32) */
|
||||
#undef QSE_SIZEOF___INT32
|
||||
|
||||
/* sizeof(__int64) */
|
||||
#undef QSE_SIZEOF___INT64
|
||||
|
||||
/* sizeof(__int8) */
|
||||
#undef QSE_SIZEOF___INT8
|
||||
|
||||
/* use the syscall() function */
|
||||
#undef QSE_USE_SYSCALL
|
||||
|
||||
/* package version */
|
||||
#undef QSE_VERSION
|
||||
|
||||
/* major version number */
|
||||
#undef QSE_VERSION_MAJOR
|
||||
|
||||
/* minor version number */
|
||||
#undef QSE_VERSION_MINOR
|
||||
|
||||
/* patch level */
|
||||
#undef QSE_VERSION_PATCH
|
||||
|
||||
/* The size of `char', as computed by sizeof. */
|
||||
#undef SIZEOF_CHAR
|
||||
|
134
qse/include/qse/lsp/lsp.h
Normal file
134
qse/include/qse/lsp/lsp.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* $Id: lsp.h 183 2008-06-03 08:18:55Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_LSP_LSP_H_
|
||||
#define _QSE_LSP_LSP_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
typedef struct qse_lsp_t qse_lsp_t;
|
||||
typedef struct qse_lsp_obj_t qse_lsp_obj_t;
|
||||
typedef struct qse_lsp_prmfns_t qse_lsp_prmfns_t;
|
||||
|
||||
typedef qse_ssize_t (*qse_lsp_io_t) (
|
||||
int cmd, void* arg, qse_char_t* data, qse_size_t count);
|
||||
|
||||
typedef qse_real_t (*qse_lsp_pow_t) (
|
||||
void* data, qse_real_t x, qse_real_t y);
|
||||
typedef int (*qse_lsp_sprintf_t) (
|
||||
void* data, qse_char_t* buf, qse_size_t size,
|
||||
const qse_char_t* fmt, ...);
|
||||
typedef void (*qse_lsp_dprintf_t) (void* data, const qse_char_t* fmt, ...);
|
||||
|
||||
struct qse_lsp_prmfns_t
|
||||
{
|
||||
qse_mmgr_t mmgr;
|
||||
qse_ccls_t ccls;
|
||||
|
||||
/* utilities */
|
||||
struct
|
||||
{
|
||||
qse_lsp_sprintf_t sprintf;
|
||||
qse_lsp_dprintf_t dprintf;
|
||||
void* data;
|
||||
} misc;
|
||||
};
|
||||
|
||||
/* io function commands */
|
||||
enum
|
||||
{
|
||||
QSE_LSP_IO_OPEN = 0,
|
||||
QSE_LSP_IO_CLOSE = 1,
|
||||
QSE_LSP_IO_READ = 2,
|
||||
QSE_LSP_IO_WRITE = 3
|
||||
};
|
||||
|
||||
/* option code */
|
||||
enum
|
||||
{
|
||||
QSE_LSP_UNDEFSYMBOL = (1 << 0)
|
||||
};
|
||||
|
||||
/* error code */
|
||||
enum
|
||||
{
|
||||
QSE_LSP_ENOERR,
|
||||
QSE_LSP_ENOMEM,
|
||||
|
||||
QSE_LSP_EEXIT,
|
||||
QSE_LSP_EEND,
|
||||
QSE_LSP_EENDSTR,
|
||||
QSE_LSP_ENOINP,
|
||||
QSE_LSP_EINPUT,
|
||||
QSE_LSP_ENOOUTP,
|
||||
QSE_LSP_EOUTPUT,
|
||||
|
||||
QSE_LSP_ESYNTAX,
|
||||
QSE_LSP_ERPAREN,
|
||||
QSE_LSP_EARGBAD,
|
||||
QSE_LSP_EARGFEW,
|
||||
QSE_LSP_EARGMANY,
|
||||
QSE_LSP_EUNDEFFN,
|
||||
QSE_LSP_EBADFN,
|
||||
QSE_LSP_EDUPFML,
|
||||
QSE_LSP_EBADSYM,
|
||||
QSE_LSP_EUNDEFSYM,
|
||||
QSE_LSP_EEMPBDY,
|
||||
QSE_LSP_EVALBAD,
|
||||
QSE_LSP_EDIVBY0
|
||||
};
|
||||
|
||||
typedef qse_lsp_obj_t* (*qse_lsp_prim_t) (qse_lsp_t* lsp, qse_lsp_obj_t* obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_lsp_t* qse_lsp_open (
|
||||
const qse_lsp_prmfns_t* prmfns,
|
||||
qse_size_t mem_ubound, qse_size_t mem_ubound_inc);
|
||||
|
||||
void qse_lsp_close (qse_lsp_t* lsp);
|
||||
|
||||
/**
|
||||
* @function qse_lsp_setassocdata
|
||||
* @brief ssociats the user-specified data with an interpreter
|
||||
*/
|
||||
void qse_lsp_setassocdata (qse_lsp_t* lsp, void* data);
|
||||
/**
|
||||
* @function qse_lsp_getassocdata
|
||||
* @brief returns the user-specified data associated with an interpreter
|
||||
*/
|
||||
void* qse_lsp_getassocdata (qse_lsp_t* lsp);
|
||||
|
||||
void qse_lsp_geterror (
|
||||
qse_lsp_t* lsp, int* errnum, const qse_char_t** errmsg);
|
||||
|
||||
void qse_lsp_seterror (
|
||||
qse_lsp_t* lsp, int errnum,
|
||||
const qse_char_t** errarg, qse_size_t argcnt);
|
||||
|
||||
int qse_lsp_attinput (qse_lsp_t* lsp, qse_lsp_io_t input, void* arg);
|
||||
int qse_lsp_detinput (qse_lsp_t* lsp);
|
||||
|
||||
int qse_lsp_attoutput (qse_lsp_t* lsp, qse_lsp_io_t output, void* arg);
|
||||
int qse_lsp_detoutput (qse_lsp_t* lsp);
|
||||
|
||||
qse_lsp_obj_t* qse_lsp_read (qse_lsp_t* lsp);
|
||||
qse_lsp_obj_t* qse_lsp_eval (qse_lsp_t* lsp, qse_lsp_obj_t* obj);
|
||||
int qse_lsp_print (qse_lsp_t* lsp, const qse_lsp_obj_t* obj);
|
||||
|
||||
int qse_lsp_addprim (
|
||||
qse_lsp_t* lsp, const qse_char_t* name, qse_size_t name_len,
|
||||
qse_lsp_prim_t prim, qse_size_t min_args, qse_size_t max_args);
|
||||
int qse_lsp_removeprim (qse_lsp_t* lsp, const qse_char_t* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = lsp.h
|
||||
pkgincludedir= $(includedir)/ase/lsp
|
||||
pkgincludedir= $(includedir)/qse/lsp
|
||||
|
||||
CLEANFILES = *dist
|
@ -31,7 +31,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/ase/lsp
|
||||
subdir = include/qse/lsp
|
||||
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/makefile.am \
|
||||
$(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -39,7 +39,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
@ -55,7 +55,7 @@ HEADERS = $(pkginclude_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase/lsp
|
||||
pkgincludedir = $(includedir)/qse/lsp
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -192,9 +192,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/lsp/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/lsp/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/lsp/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/lsp/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
171
qse/include/qse/macros.h
Normal file
171
qse/include/qse/macros.h
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* $Id: macros.h 455 2008-11-26 09:05:00Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_MACROS_H_
|
||||
#define _QSE_MACROS_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
/*#define QSE_NULL ((qse_uint_t)0)*/
|
||||
#define QSE_NULL (0)
|
||||
#else
|
||||
#define QSE_NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
/****d* ase/QSE_TRUE,QSE_FALSE
|
||||
* NAME
|
||||
* QSE_TRUE - represent a boolean true
|
||||
* QSE_FALSE - represent a boolean false
|
||||
******
|
||||
*/
|
||||
#define QSE_TRUE (0 == 0)
|
||||
#define QSE_FALSE (0 != 0)
|
||||
|
||||
|
||||
/****d* ase/QSE_ALIVE,QSE_ZOMBIE,QSE_DEAD
|
||||
* NAME
|
||||
* QSE_ALIVE - represent a living state
|
||||
* QSE_ZOMBIE - represent a zombie state
|
||||
* QSE_DEAD - represent a dead state
|
||||
******
|
||||
*/
|
||||
#define QSE_ALIVE 1
|
||||
#define QSE_ZOMBIE 0
|
||||
#define QSE_DEAD -1
|
||||
|
||||
|
||||
#define AES_MCHAR_EOF ((qse_mcint_t)-1)
|
||||
#define AES_WCHAR_EOF ((qse_wcint_t)-1)
|
||||
#define QSE_CHAR_EOF ((qse_cint_t)-1)
|
||||
|
||||
#define QSE_SIZEOF(n) (sizeof(n))
|
||||
#define QSE_COUNTOF(n) (sizeof(n)/sizeof(n[0]))
|
||||
#define QSE_OFFSETOF(type,member) ((qse_size_t)&((type*)0)->member)
|
||||
|
||||
#define QSE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
|
||||
#define QSE_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
|
||||
|
||||
#define QSE_TYPE_SIGNED_MAX(type) \
|
||||
((type)~((type)1 << (QSE_SIZEOF(type) * 8 - 1)))
|
||||
#define QSE_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
|
||||
|
||||
#define QSE_TYPE_SIGNED_MIN(type) \
|
||||
((type)((type)1 << (QSE_SIZEOF(type) * 8 - 1)))
|
||||
#define QSE_TYPE_UNSIGNED_MIN(type) ((type)0)
|
||||
|
||||
#define QSE_TYPE_MAX(type) \
|
||||
((QSE_TYPE_IS_SIGNED(type)? QSE_TYPE_SIGNED_MAX(type): QSE_TYPE_UNSIGNED_MAX(type)))
|
||||
#define QSE_TYPE_MIN(type) \
|
||||
((QSE_TYPE_IS_SIGNED(type)? QSE_TYPE_SIGNED_MIN(type): QSE_TYPE_UNSIGNED_MIN(type)))
|
||||
|
||||
#define QSE_IS_POWOF2(x) (((x) & ((x) - 1)) == 0)
|
||||
|
||||
#define QSE_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 QSE_ABS(x) ((x) < 0? -(x): (x))
|
||||
|
||||
#define QSE_LOOP_CONTINUE(id) goto __loop_ ## id ## _begin__;
|
||||
#define QSE_LOOP_BREAK(id) goto __loop_ ## id ## _end__;
|
||||
#define QSE_LOOP_BEGIN(id) __loop_ ## id ## _begin__: {
|
||||
#define QSE_LOOP_END(id) QSE_LOOP_CONTINUE(id) } __loop_ ## id ## _end__:;
|
||||
|
||||
#define QSE_REPEAT(n,blk) \
|
||||
do { \
|
||||
qse_size_t __qse_repeat_x1__ = (qse_size_t)(n); \
|
||||
qse_size_t __qse_repeat_x2__ = __qse_repeat_x1__ >> 4; \
|
||||
__qse_repeat_x1__ &= 15; \
|
||||
while (__qse_repeat_x1__-- > 0) { blk; } \
|
||||
while (__qse_repeat_x2__-- > 0) { \
|
||||
blk; blk; blk; blk; blk; blk; blk; blk; \
|
||||
blk; blk; blk; blk; blk; blk; blk; blk; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
/* number of characters to number of bytes */
|
||||
#define QSE_NCTONB(x) ((x)*sizeof(qse_char_t))
|
||||
/* number of bytes to number of characters */
|
||||
#define QSE_NBTONC(x) ((x)/sizeof(qse_char_t))
|
||||
|
||||
#define QSE_MQ_I(val) #val
|
||||
#define QSE_MQ(val) QSE_MQ_I(val)
|
||||
#define QSE_MC(ch) ((qse_mchar_t)ch)
|
||||
#define QSE_MS(str) ((const qse_mchar_t*)str)
|
||||
#define QSE_MT(txt) (txt)
|
||||
|
||||
#define QSE_WQ_I(val) (L ## #val)
|
||||
#define QSE_WQ(val) QSE_WQ_I(val)
|
||||
#define QSE_WC(ch) ((qse_wchar_t)L ## ch)
|
||||
#define QSE_WS(str) ((const qse_wchar_t*)L ## str)
|
||||
#define QSE_WT(txt) (L ## txt)
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
#define QSE_Q(val) QSE_MQ(val)
|
||||
#define QSE_C(ch) QSE_MC(ch)
|
||||
#define QSE_S(str) QSE_MS(str)
|
||||
#define QSE_T(txt) QSE_MT(txt)
|
||||
#else
|
||||
#define QSE_Q(val) QSE_WQ(val)
|
||||
#define QSE_C(ch) QSE_WC(ch)
|
||||
#define QSE_S(str) QSE_WS(str)
|
||||
#define QSE_T(txt) QSE_WT(txt)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define QSE_BEGIN_PACKED_STRUCT(x) struct x {
|
||||
#define QSE_END_PACKED_STRUCT() } __attribute__((packed));
|
||||
#else
|
||||
#define QSE_BEGIN_PACKED_STRUCT(x) struct x {
|
||||
#define QSE_END_PACKED_STRUCT() };
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define QSE_ASSERT(expr) ((void)0)
|
||||
#define QSE_ASSERTX(expr,desc) ((void)0)
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void qse_assert_failed (
|
||||
const qse_char_t* expr, const qse_char_t* desc,
|
||||
const qse_char_t* file, qse_size_t line);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define QSE_ASSERT(expr) (void)((expr) || \
|
||||
(qse_assert_failed (QSE_T(#expr), QSE_NULL, QSE_T(__FILE__), __LINE__), 0))
|
||||
#define QSE_ASSERTX(expr,desc) (void)((expr) || \
|
||||
(qse_assert_failed (QSE_T(#expr), QSE_T(desc), QSE_T(__FILE__), __LINE__), 0))
|
||||
#endif
|
||||
|
||||
/****d* ase/QSE_FNS
|
||||
* NAME
|
||||
* QSE_FNS - define an ASE function name space
|
||||
* DESCRIPTION
|
||||
* The QSE_FNS macro enables you to simulate a function name space for the
|
||||
* types designed properly.
|
||||
* EXAMPLE
|
||||
* QSE_FNS (awk, AWK);
|
||||
* qse_awk_t* awk = AWK.open (....);
|
||||
* AWK.close (awk);
|
||||
******
|
||||
*/
|
||||
#define QSE_NS(type,name) struct qse_ns_##type##_t name = qse_ns_##type##_d
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define QSE_BEGIN_NAMESPACE(x) namespace x {
|
||||
#define QSE_END_NAMESPACE(x) }
|
||||
#define QSE_BEGIN_NAMESPACE2(x,y) namespace x { namespace y {
|
||||
#define QSE_END_NAMESPACE2(y,x) }}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,14 +4,14 @@ SUBDIRS = cmn awk lsp tgp utl
|
||||
|
||||
pkginclude_HEADERS = config.h.in conf_msw.h conf_vms.h types.h macros.h pack1.h unpack.h
|
||||
|
||||
pkgincludedir= $(includedir)/ase
|
||||
pkgincludedir= $(includedir)/qse
|
||||
|
||||
CLEANFILES = *dist
|
||||
|
||||
install-data-hook:
|
||||
@"$(GREP)" -E "#define[ ]+ASE_" "$(srcdir)/config.h" > "$(pkgincludedir)/config.h"
|
||||
@"$(GREP)" -E "#define[ ]+QSE_" "$(srcdir)/config.h" > "$(pkgincludedir)/config.h"
|
||||
@"$(RM)" -f "$(pkgincludedir)/config.h.in"
|
||||
@"$(SED)" 's|/\*#define ASE_HAVE_CONFIG_H\*/|#define ASE_HAVE_CONFIG_H|' "$(srcdir)/types.h" > "$(pkgincludedir)/types.h"
|
||||
@"$(SED)" 's|/\*#define QSE_HAVE_CONFIG_H\*/|#define QSE_HAVE_CONFIG_H|' "$(srcdir)/types.h" > "$(pkgincludedir)/types.h"
|
||||
|
||||
uninstall-hook:
|
||||
@"$(RM)" -f "$(pkgincludedir)/config.h"
|
@ -31,7 +31,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/ase
|
||||
subdir = include/qse
|
||||
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/config.h.in \
|
||||
$(srcdir)/makefile.am $(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -65,7 +65,7 @@ ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase
|
||||
pkgincludedir = $(includedir)/qse
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -206,9 +206,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
@ -235,7 +235,7 @@ config.h: stamp-h1
|
||||
|
||||
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status include/ase/config.h
|
||||
cd $(top_builddir) && $(SHELL) ./config.status include/qse/config.h
|
||||
$(srcdir)/config.h.in: $(am__configure_deps)
|
||||
cd $(top_srcdir) && $(AUTOHEADER)
|
||||
rm -f stamp-h1
|
||||
@ -552,9 +552,9 @@ uninstall-am: uninstall-pkgincludeHEADERS
|
||||
|
||||
|
||||
install-data-hook:
|
||||
@"$(GREP)" -E "#define[ ]+ASE_" "$(srcdir)/config.h" > "$(pkgincludedir)/config.h"
|
||||
@"$(GREP)" -E "#define[ ]+QSE_" "$(srcdir)/config.h" > "$(pkgincludedir)/config.h"
|
||||
@"$(RM)" -f "$(pkgincludedir)/config.h.in"
|
||||
@"$(SED)" 's|/\*#define ASE_HAVE_CONFIG_H\*/|#define ASE_HAVE_CONFIG_H|' "$(srcdir)/types.h" > "$(pkgincludedir)/types.h"
|
||||
@"$(SED)" 's|/\*#define QSE_HAVE_CONFIG_H\*/|#define QSE_HAVE_CONFIG_H|' "$(srcdir)/types.h" > "$(pkgincludedir)/types.h"
|
||||
|
||||
uninstall-hook:
|
||||
@"$(RM)" -f "$(pkgincludedir)/config.h"
|
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = tgp.h
|
||||
pkgincludedir= $(includedir)/ase/tgp
|
||||
pkgincludedir= $(includedir)/qse/tgp
|
||||
|
||||
CLEANFILES = *dist
|
@ -31,7 +31,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/ase/tgp
|
||||
subdir = include/qse/tgp
|
||||
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/makefile.am \
|
||||
$(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -39,7 +39,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
@ -55,7 +55,7 @@ HEADERS = $(pkginclude_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase/tgp
|
||||
pkgincludedir = $(includedir)/qse/tgp
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -192,9 +192,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/tgp/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/tgp/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/tgp/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/tgp/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
40
qse/include/qse/tgp/tgp.h
Normal file
40
qse/include/qse/tgp/tgp.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* $Id: tgp.h 235 2008-07-05 07:25:54Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_TGP_TGP_H_
|
||||
#define _QSE_TGP_TGP_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
typedef struct qse_tgp_t qse_tgp_t;
|
||||
|
||||
enum qse_tgp_iocmd_t
|
||||
{
|
||||
QSE_TGP_IO_OPEN = 0,
|
||||
QSE_TGP_IO_CLOSE = 1,
|
||||
QSE_TGP_IO_READ = 2,
|
||||
QSE_TGP_IO_WRITE = 3
|
||||
};
|
||||
|
||||
typedef qse_ssize_t (*qse_tgp_io_t) (
|
||||
int cmd, void* arg, qse_char_t* data, qse_size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_tgp_t* qse_tgp_open (qse_mmgr_t* mmgr);
|
||||
void qse_tgp_close (qse_tgp_t* tgp);
|
||||
|
||||
void qse_tgp_setassocdata (qse_tgp_t* tgp, void* data);
|
||||
void* qse_tgp_getassocdata (qse_tgp_t* tgp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
439
qse/include/qse/types.h
Normal file
439
qse/include/qse/types.h
Normal file
@ -0,0 +1,439 @@
|
||||
/*
|
||||
* $Id: types.h 476 2008-12-12 06:25:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_TYPES_H_
|
||||
#define _QSE_TYPES_H_
|
||||
|
||||
/****o* ase/basic types
|
||||
* DESCRIPTION
|
||||
* <qse/types.h> defines various common basic types. They are designed to be
|
||||
* cross-platform. These types are preferred over native data types in many
|
||||
* contexts.
|
||||
*
|
||||
* #include <qse/types.h>
|
||||
******
|
||||
*/
|
||||
|
||||
/* WARNING: NEVER CHANGE/DELETE THE FOLLOWING LINE */
|
||||
/*#define QSE_HAVE_CONFIG_H*/
|
||||
|
||||
#if defined(QSE_HAVE_CONFIG_H)
|
||||
#include <qse/config.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <qse/conf_msw.h>
|
||||
#elif defined(vms) || defined(__vms)
|
||||
#include <qse/conf_vms.h>
|
||||
/*
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__SPU__)
|
||||
#if !defined(__unix__)
|
||||
#define __unix__
|
||||
#endif
|
||||
#if !defined(__unix)
|
||||
#define __unix
|
||||
#endif
|
||||
#include <qse/config.h>
|
||||
*/
|
||||
#else
|
||||
#error unsupported operating system
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_bool_t
|
||||
* NAME
|
||||
* qse_bool_t - define a boolean type
|
||||
* DESCRIPTION
|
||||
* The qse_bool_t type defines a boolean type that can represent QSE_TRUE
|
||||
* and QSE_FALSE.
|
||||
******
|
||||
*/
|
||||
typedef int qse_bool_t;
|
||||
|
||||
/****t* ase/qse_tri_t
|
||||
* NAME
|
||||
* qse_tri_t - define a tri-state type
|
||||
* DESCRIPTION
|
||||
* The qse_tri_t type defines a tri-state type that can represent QSE_ALIVE,
|
||||
* QSE_ZOMBIE, and QSE_DEAD.
|
||||
******
|
||||
*/
|
||||
typedef int qse_tri_t;
|
||||
|
||||
/****t* ase/qse_int_t,qse_uint_t
|
||||
* NAME
|
||||
* qse_int_t - define a signed integer type as large as a pointer type
|
||||
* qse_uint_t - define an unsigned integer type as large as a pointer type
|
||||
******
|
||||
*/
|
||||
#if (defined(hpux) || defined(__hpux) || defined(__hpux__)) && (QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG)
|
||||
typedef long qse_int_t;
|
||||
typedef unsigned long qse_uint_t;
|
||||
#elif defined(__SPU__) && (QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG)
|
||||
typedef long qse_int_t;
|
||||
typedef unsigned long qse_uint_t;
|
||||
#elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_INT
|
||||
typedef int qse_int_t;
|
||||
typedef unsigned int qse_uint_t;
|
||||
#elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG
|
||||
typedef long qse_int_t;
|
||||
typedef unsigned long qse_uint_t;
|
||||
#elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG_LONG
|
||||
typedef long long qse_int_t;
|
||||
typedef unsigned long long qse_uint_t;
|
||||
#elif QSE_SIZEOF_VOID_P == QSE_SIZEOF___INT32
|
||||
typedef __int32 qse_int_t;
|
||||
typedef unsigned __int32 qse_uint_t;
|
||||
#elif QSE_SIZEOF_VOID_P == QSE_SIZEOF___INT64
|
||||
typedef __int64 qse_int_t;
|
||||
typedef unsigned __int64 qse_uint_t;
|
||||
#else
|
||||
#error unsupported pointer size
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_long_t,qse_ulong_t
|
||||
* NAME
|
||||
* qse_long_t - define the largest signed integer type supported
|
||||
* qse_ulong_t - define the largest unsigned integer type supported
|
||||
******
|
||||
*/
|
||||
#if QSE_SIZEOF_LONG_LONG > 0
|
||||
typedef long long qse_long_t;
|
||||
typedef unsigned long long qse_ulong_t;
|
||||
#elif QSE_SIZEOF___INT64 > 0
|
||||
typedef __int64 qse_long_t;
|
||||
typedef unsigned __int64 qse_ulong_t;
|
||||
#else
|
||||
typedef long qse_long_t;
|
||||
typedef unsigned long qse_ulong_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_int8_t,qse_uint8_t
|
||||
* NAME
|
||||
* qse_int8_t - define an 8-bit signed integer type
|
||||
* qse_uint8_t - define an 8-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#if QSE_SIZEOF_CHAR == 1
|
||||
typedef char qse_int8_t;
|
||||
typedef unsigned char qse_uint8_t;
|
||||
#elif QSE_SIZEOF___INT8 == 1
|
||||
typedef __int8 qse_int8_t;
|
||||
typedef unsigned __int8 qse_uint8_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_int16_t,qse_uint16_t
|
||||
* NAME
|
||||
* qse_int16_t - define a 16-bit signed integer type
|
||||
* qse_uint16_t - define a 16-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#if QSE_SIZEOF_SHORT == 2
|
||||
typedef short qse_int16_t;
|
||||
typedef unsigned short qse_uint16_t;
|
||||
#elif QSE_SIZEOF___INT16 == 2
|
||||
typedef __int16 qse_int16_t;
|
||||
typedef unsigned __int16 qse_uint16_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_int32_t,qse_uint32_t
|
||||
* NAME
|
||||
* qse_int32_t - define a 32-bit signed integer type
|
||||
* qse_uint32_t - define a 32-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#if QSE_SIZEOF_INT == 4
|
||||
typedef int qse_int32_t;
|
||||
typedef unsigned int qse_uint32_t;
|
||||
#elif QSE_SIZEOF_LONG == 4
|
||||
typedef long qse_int32_t;
|
||||
typedef unsigned long qse_uint32_t;
|
||||
#elif QSE_SIZEOF___INT32 == 4
|
||||
typedef __int32 qse_int32_t;
|
||||
typedef unsigned __int32 qse_uint32_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_int64_t,qse_uint64_t
|
||||
* NAME
|
||||
* qse_int64_t - define a 64-bit signed integer type
|
||||
* qse_uint64_t - define a 64-bit unsigned integer type
|
||||
******
|
||||
*/
|
||||
#if QSE_SIZEOF_INT == 8
|
||||
#define QSE_HAVE_INT64_T
|
||||
#define QSE_HAVE_UINT64_T
|
||||
typedef int qse_int64_t;
|
||||
typedef unsigned int qse_uint64_t;
|
||||
#elif QSE_SIZEOF_LONG == 8
|
||||
#define QSE_HAVE_INT64_T
|
||||
#define QSE_HAVE_UINT64_T
|
||||
typedef long qse_int64_t;
|
||||
typedef unsigned long qse_uint64_t;
|
||||
#elif QSE_SIZEOF_LONG_LONG == 8
|
||||
#define QSE_HAVE_INT64_T
|
||||
#define QSE_HAVE_UINT64_T
|
||||
typedef long long qse_int64_t;
|
||||
typedef unsigned long long qse_uint64_t;
|
||||
#elif QSE_SIZEOF___INT64 == 8
|
||||
#define QSE_HAVE_INT64_T
|
||||
#define QSE_HAVE_UINT64_T
|
||||
typedef __int64 qse_int64_t;
|
||||
typedef unsigned __int64 qse_uint64_t;
|
||||
#endif
|
||||
|
||||
#if QSE_SIZEOF_INT == 16
|
||||
#define QSE_HAVE_INT128_T
|
||||
#define QSE_HAVE_UINT128_T
|
||||
typedef int qse_int128_t;
|
||||
typedef unsigned int qse_uint128_t;
|
||||
#elif QSE_SIZEOF_LONG == 16
|
||||
#define QSE_HAVE_INT128_T
|
||||
#define QSE_HAVE_UINT128_T
|
||||
typedef long qse_int128_t;
|
||||
typedef unsigned long qse_uint128_t;
|
||||
#elif QSE_SIZEOF_LONG_LONG == 16
|
||||
#define QSE_HAVE_INT128_T
|
||||
#define QSE_HAVE_UINT128_T
|
||||
typedef long long qse_int128_t;
|
||||
typedef unsigned long long qse_uint128_t;
|
||||
#elif QSE_SIZEOF___INT128 == 16
|
||||
#define QSE_HAVE_INT128_T
|
||||
#define QSE_HAVE_UINT128_T
|
||||
typedef __int128 qse_int128_t;
|
||||
typedef unsigned __int128 qse_uint128_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_byte_t
|
||||
* NAME
|
||||
* qse_word_t - define a byte type
|
||||
******
|
||||
*/
|
||||
typedef qse_uint8_t qse_byte_t;
|
||||
|
||||
/****t* ase/qse_size_t
|
||||
* NAME
|
||||
* qse_size_t - define an unsigned integer type that can hold a pointer value
|
||||
******
|
||||
*/
|
||||
#ifdef __SIZE_TYPE__
|
||||
typedef __SIZE_TYPE__ qse_size_t;
|
||||
#else
|
||||
typedef qse_uint_t qse_size_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_ssize_t
|
||||
* NAME
|
||||
* qse_ssize_t - define an signed integer type that can hold a pointer value
|
||||
******
|
||||
*/
|
||||
typedef qse_int_t qse_ssize_t;
|
||||
|
||||
/****t* ase/qse_word_t
|
||||
* NAME
|
||||
* qse_word_t - define an integer type identical to qse_uint_t
|
||||
******
|
||||
*/
|
||||
typedef qse_uint_t qse_word_t;
|
||||
|
||||
/* floating-point number */
|
||||
#if defined(__FreeBSD__)
|
||||
/* TODO: check if the support for long double is complete.
|
||||
* if so, use long double for qse_real_t */
|
||||
#define QSE_SIZEOF_REAL QSE_SIZEOF_DOUBLE
|
||||
typedef double qse_real_t;
|
||||
#elif QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE
|
||||
#define QSE_SIZEOF_REAL QSE_SIZEOF_LONG_DOUBLE
|
||||
typedef long double qse_real_t;
|
||||
#else
|
||||
#define QSE_SIZEOF_REAL QSE_SIZEOF_DOUBLE
|
||||
typedef double qse_real_t;
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_mchar_t,qse_mcint_t
|
||||
* NAME
|
||||
* qse_mchar_t - define a multi-byte character
|
||||
* qse_mcint_t - define a type that can hold qse_mchar_t and QSE_MCHAR_EOF
|
||||
******
|
||||
*/
|
||||
typedef char qse_mchar_t;
|
||||
typedef int qse_mcint_t;
|
||||
|
||||
/****t* ase/qse_wchar_t,qse_wcint_t
|
||||
* NAME
|
||||
* qse_wchar_t - define a wide character
|
||||
* qse_wcint_t - define a type that can hold qse_wchar_t and QSE_WCHAR_EOF
|
||||
******
|
||||
*/
|
||||
#if defined(__cplusplus) && (!defined(_MSC_VER) || (defined(_MSC_VER)&&defined(_NATIVE_WCHAR_T_DEFINED)))
|
||||
/* C++ */
|
||||
|
||||
typedef wchar_t qse_wchar_t;
|
||||
typedef wchar_t qse_wcint_t;
|
||||
|
||||
/* all the way down from here for C */
|
||||
#elif defined(__WCHAR_TYPE__) && defined(__WINT_TYPE__)
|
||||
typedef __WCHAR_TYPE__ qse_wchar_t;
|
||||
typedef __WINT_TYPE__ qse_wcint_t;
|
||||
#elif (QSE_SIZEOF_WCHAR_T == 2) || (QSE_SIZEOF_WCHAR_T == 0)
|
||||
typedef unsigned short qse_wchar_t;
|
||||
typedef unsigned short qse_wcint_t;
|
||||
#elif (QSE_SIZEOF_WCHAR_T == 4)
|
||||
#if defined(vms) || defined(__vms)
|
||||
typedef unsigned int qse_wchar_t;
|
||||
typedef int qse_wcint_t;
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
typedef int qse_wchar_t;
|
||||
typedef int qse_wcint_t;
|
||||
#elif (defined(sun) || defined(__sun) || defined(__linux))
|
||||
#if defined(_LP64)
|
||||
typedef int qse_wchar_t;
|
||||
typedef int qse_wcint_t;
|
||||
#else
|
||||
typedef long qse_wchar_t;
|
||||
typedef long qse_wcint_t;
|
||||
#endif
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
typedef int qse_wchar_t;
|
||||
typedef int qse_wcint_t;
|
||||
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
|
||||
#if defined(__HP_cc) || defined(__HP_aCC)
|
||||
typedef unsigned int qse_wchar_t;
|
||||
#else
|
||||
typedef int qse_wchar_t;
|
||||
#endif
|
||||
typedef int qse_wcint_t;
|
||||
#elif QSE_SIZEOF_LONG == 4
|
||||
typedef long qse_wchar_t;
|
||||
typedef long qse_wcint_t;
|
||||
#elif QSE_SIZEOF_INT == 4
|
||||
typedef int qse_wchar_t;
|
||||
typedef int qse_wcint_t;
|
||||
#else
|
||||
#error no supported data type for wchar_t
|
||||
#endif
|
||||
#else
|
||||
#error unsupported size of wchar_t
|
||||
#endif
|
||||
|
||||
/****t* ase/qse_char_t,qse_cint_t
|
||||
* NAME
|
||||
* qse_char_t - define a character
|
||||
* qse_cint_t - define a type that can hold qse_char_t and QSE_CHAR_EOF
|
||||
******
|
||||
*/
|
||||
#if defined(_WIN32) && (defined(UNICODE)||defined(_UNICODE))
|
||||
#define QSE_CHAR_IS_WCHAR
|
||||
typedef qse_wchar_t qse_char_t;
|
||||
typedef qse_wcint_t qse_cint_t;
|
||||
#else
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
typedef qse_mchar_t qse_char_t;
|
||||
typedef qse_mcint_t qse_cint_t;
|
||||
#elif defined(QSE_CHAR_IS_WCHAR)
|
||||
typedef qse_wchar_t qse_char_t;
|
||||
typedef qse_wcint_t qse_cint_t;
|
||||
#elif defined(_MBCS)
|
||||
#define QSE_CHAR_IS_MCHAR
|
||||
typedef qse_mchar_t qse_char_t;
|
||||
typedef qse_mcint_t qse_cint_t;
|
||||
#else
|
||||
#define QSE_CHAR_IS_WCHAR
|
||||
typedef qse_wchar_t qse_char_t;
|
||||
typedef qse_wcint_t qse_cint_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(QSE_CHAR_IS_WCHAR) && defined(_WIN32)
|
||||
#ifndef UNICODE
|
||||
#define UNICODE
|
||||
#endif
|
||||
#ifndef _UNICODE
|
||||
#define _UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct qse_xstr_t qse_xstr_t;
|
||||
typedef struct qse_cstr_t qse_cstr_t;
|
||||
typedef struct qse_mmgr_t qse_mmgr_t;
|
||||
typedef struct qse_ccls_t qse_ccls_t;
|
||||
|
||||
/****t* ase/qse_xstr_t
|
||||
* NAME
|
||||
* qse_xstr_t - combine a pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_xstr_t
|
||||
{
|
||||
qse_char_t* ptr; /* this is not a const pointer */
|
||||
qse_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/qse_cstr_t
|
||||
* NAME
|
||||
* qse_cstr_t - combine a constant pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_cstr_t
|
||||
{
|
||||
const qse_char_t* ptr; /* this is a const pointer */
|
||||
qse_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/qse_mmgr_t
|
||||
* NAME
|
||||
* qse_mmgr_t - define a memory manager
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_mmgr_t
|
||||
{
|
||||
void* (*alloc) (void* data, qse_size_t n);
|
||||
void* (*realloc) (void* data, void* ptr, qse_size_t n);
|
||||
void (*free) (void* data, void* ptr);
|
||||
void* data;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/qse_ccls_type_t
|
||||
* NAME
|
||||
* qse_ccls_type_t - define types of character class
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum qse_ccls_type_t
|
||||
{
|
||||
QSE_CCLS_UPPER,
|
||||
QSE_CCLS_LOWER,
|
||||
QSE_CCLS_ALPHA,
|
||||
QSE_CCLS_DIGIT,
|
||||
QSE_CCLS_XDIGIT,
|
||||
QSE_CCLS_ALNUM,
|
||||
QSE_CCLS_SPACE,
|
||||
QSE_CCLS_PRINT,
|
||||
QSE_CCLS_GRAPH,
|
||||
QSE_CCLS_CNTRL,
|
||||
QSE_CCLS_PUNCT
|
||||
};
|
||||
/******/
|
||||
|
||||
typedef enum qse_ccls_type_t qse_ccls_type_t;
|
||||
|
||||
/****t* ase/qse_ccls_t
|
||||
* NAME
|
||||
* qse_mmgr_t - define a character class handler
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_ccls_t
|
||||
{
|
||||
qse_bool_t (*is) (void* data, qse_cint_t c, qse_ccls_type_t type);
|
||||
qse_cint_t (*to) (void* data, qse_cint_t c, qse_ccls_type_t type);
|
||||
void* data;
|
||||
};
|
||||
/******/
|
||||
|
||||
#endif
|
66
qse/include/qse/utl/http.h
Normal file
66
qse/include/qse/utl/http.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* $Id: http.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_UTL_HTTP_H_
|
||||
#define _QSE_UTL_HTTP_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/* returns the type of http method */
|
||||
typedef struct qse_http_req_t qse_http_req_t;
|
||||
typedef struct qse_http_hdr_t qse_http_hdr_t;
|
||||
|
||||
struct qse_http_req_t
|
||||
{
|
||||
qse_char_t* method;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
} path;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
} args;
|
||||
|
||||
struct
|
||||
{
|
||||
char major;
|
||||
char minor;
|
||||
} vers;
|
||||
};
|
||||
|
||||
struct qse_http_hdr_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
} name;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
} value;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_char_t* qse_parsehttpreq (qse_char_t* buf, qse_http_req_t* req);
|
||||
qse_char_t* qse_parsehttphdr (qse_char_t* buf, qse_http_hdr_t* hdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
37
qse/include/qse/utl/main.h
Normal file
37
qse/include/qse/utl/main.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $Id: main.h 463 2008-12-09 06:52:03Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_UTL_MAIN_H_
|
||||
#define _QSE_UTL_MAIN_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
#define qse_main main
|
||||
typedef qse_mchar_t qse_achar_t;
|
||||
#else
|
||||
#define qse_main wmain
|
||||
typedef qse_wchar_t qse_achar_t;
|
||||
#endif
|
||||
#else
|
||||
#define qse_main main
|
||||
typedef qse_mchar_t qse_achar_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int qse_runmain (int argc, qse_achar_t* argv[], int(*mf) (int,qse_char_t*[]));
|
||||
/* TODO - qse_runmain with env */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
|
||||
pkginclude_HEADERS = http.h main.h stdio.h
|
||||
|
||||
pkgincludedir= $(includedir)/ase/utl
|
||||
pkgincludedir= $(includedir)/qse/utl
|
||||
|
||||
CLEANFILES = *dist
|
@ -31,7 +31,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/ase/utl
|
||||
subdir = include/qse/utl
|
||||
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/makefile.am \
|
||||
$(srcdir)/makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -39,7 +39,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/ase/config.h
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
@ -55,7 +55,7 @@ HEADERS = $(pkginclude_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/ase/utl
|
||||
pkgincludedir = $(includedir)/qse/utl
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
@ -192,9 +192,9 @@ $(srcdir)/makefile.in: $(srcdir)/makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/ase/utl/makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/utl/makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/ase/utl/makefile
|
||||
$(AUTOMAKE) --foreign include/qse/utl/makefile
|
||||
.PRECIOUS: makefile
|
||||
makefile: $(srcdir)/makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
88
qse/include/qse/utl/stdio.h
Normal file
88
qse/include/qse/utl/stdio.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* $Id: stdio.h 419 2008-10-13 11:32:58Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _QSE_UTL_STDIO_H_
|
||||
#define _QSE_UTL_STDIO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <tchar.h>
|
||||
|
||||
#define qse_printf _tprintf
|
||||
#define qse_vprintf _vtprintf
|
||||
#define qse_fprintf _ftprintf
|
||||
#define qse_vfprintf _vftprintf
|
||||
|
||||
#define qse_fgets(x,y,s) _fgetts(x,y,s)
|
||||
#define qse_fgetc(x) _fgettc(x)
|
||||
#define qse_fputs(x,s) _fputts(x,s)
|
||||
#define qse_fputc(x,s) _fputtc(x,s)
|
||||
#elif defined(QSE_CHAR_IS_MCHAR)
|
||||
#define qse_fgets(x,y,s) fgets(x,y,s)
|
||||
#define qse_fgetc(x) fgetc(x)
|
||||
#define qse_fputs(x,s) fputs(x,s)
|
||||
#define qse_fputc(x,s) fputc(x,s)
|
||||
#else
|
||||
#define qse_fgets(x,y,s) fgetws(x,y,s)
|
||||
#define qse_fgetc(x) fgetwc(x)
|
||||
#define qse_fputs(x,s) fputws(x,s)
|
||||
#define qse_fputc(x,s) fputwc(x,s)
|
||||
#endif
|
||||
|
||||
#define qse_feof(s) feof(s)
|
||||
#define qse_ferror(s) ferror(s)
|
||||
#define qse_clearerr(s) clearerr(s)
|
||||
#define qse_fflush(s) fflush(s)
|
||||
#define qse_fclose(s) fclose(s)
|
||||
|
||||
#define QSE_FILE FILE
|
||||
#define QSE_STDIN stdin
|
||||
#define QSE_STDOUT stdout
|
||||
#define QSE_STDERR stderr
|
||||
|
||||
typedef int (*qse_getdelim_t) (const qse_char_t* ptr,qse_size_t len, void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int qse_vsprintf (qse_char_t* buf, size_t size, const qse_char_t* fmt, va_list ap);
|
||||
int qse_sprintf (qse_char_t* buf, size_t size, const qse_char_t* fmt, ...);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
int qse_vfprintf (QSE_FILE *stream, const qse_char_t* fmt, va_list ap);
|
||||
int qse_vprintf (const qse_char_t* fmt, va_list ap);
|
||||
int qse_fprintf (QSE_FILE* file, const qse_char_t* fmt, ...);
|
||||
int qse_printf (const qse_char_t* fmt, ...);
|
||||
#endif
|
||||
|
||||
int qse_dprintf (const qse_char_t* fmt, ...);
|
||||
QSE_FILE* qse_fopen (const qse_char_t* path, const qse_char_t* mode);
|
||||
QSE_FILE* qse_popen (const qse_char_t* cmd, const qse_char_t* mode);
|
||||
|
||||
/**
|
||||
* returns -2 on error, -1 on eof, length of data read on success
|
||||
*/
|
||||
qse_ssize_t qse_getline (qse_char_t **buf, qse_size_t *n, QSE_FILE *fp);
|
||||
/**
|
||||
* returns -3 on line breaker error, -2 on error, -1 on eof,
|
||||
* length of data read on success
|
||||
*/
|
||||
qse_ssize_t qse_getdelim (
|
||||
qse_char_t **buf, qse_size_t *n,
|
||||
qse_getdelim_t fn, void* fnarg, QSE_FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user