added more documentation

This commit is contained in:
hyung-hwan 2009-02-02 04:12:49 +00:00
parent 6affaf4d37
commit 0836d3e319
26 changed files with 520 additions and 631 deletions

View File

@ -1,8 +1,15 @@
QSE provides a script engine for various scripting languages. It aims to produce a script engine framework that can be embedded into an application. A hosting application can access various aspects of the embedded script engine and vice versa. QSE provides a script engine for various scripting languages. It aims to produce a script engine framework that can be embedded into an application. A hosting application can access various aspects of the embedded script engine and vice versa.
[INSTALL] << INSTALL >>
Cross compiling for WIN32 with MINGW32 Cross compiling for WIN32 with MINGW32
./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --enable-syscall ./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --enable-syscall
make make
<< DOCUMENTATION >>
Generate the API documents with robodoc.
robodoc --rc doc/robodoc.rc --src include/qse --doc ./doc/qse --multidoc --index --html --source_line_numbers --nopre

View File

@ -20,7 +20,7 @@ item order:
SYNOPSIS SYNOPSIS
DESCRIPTION DESCRIPTION
INPUT INPUT
INTPUTS INPUTS
OUTPUT OUTPUT
OUTPUTS OUTPUTS
RETURN RETURN

View File

@ -24,7 +24,7 @@
#include <qse/cmn/map.h> #include <qse/cmn/map.h>
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
/****o* qse.awk/awk interpreter /****o* awk/awk interpreter
* DESCRIPTION * DESCRIPTION
* The library includes an AWK interpreter that can be embedded into other * The library includes an AWK interpreter that can be embedded into other
* applications or can run stand-alone. * applications or can run stand-alone.
@ -36,7 +36,7 @@
typedef struct qse_awk_t qse_awk_t; typedef struct qse_awk_t qse_awk_t;
typedef struct qse_awk_rtx_t qse_awk_rtx_t; /* (R)untime con(T)e(X)t */ typedef struct qse_awk_rtx_t qse_awk_rtx_t; /* (R)untime con(T)e(X)t */
typedef struct qse_awk_val_t qse_awk_val_t; typedef struct qse_awk_val_t qse_awk_val_t;
typedef struct qse_awk_eio_t qse_awk_eio_t; /* External IO */ typedef struct qse_awk_eio_t qse_awk_eio_t; /* (E)xternal (IO) */
typedef struct qse_awk_prmfns_t qse_awk_prmfns_t; typedef struct qse_awk_prmfns_t qse_awk_prmfns_t;
typedef struct qse_awk_srcios_t qse_awk_srcios_t; typedef struct qse_awk_srcios_t qse_awk_srcios_t;
@ -44,18 +44,31 @@ typedef struct qse_awk_runios_t qse_awk_runios_t;
typedef struct qse_awk_runcbs_t qse_awk_runcbs_t; typedef struct qse_awk_runcbs_t qse_awk_runcbs_t;
typedef struct qse_awk_rexfns_t qse_awk_rexfns_t; typedef struct qse_awk_rexfns_t qse_awk_rexfns_t;
typedef qse_real_t (*qse_awk_pow_t) (void* data, qse_real_t x, qse_real_t y); typedef qse_real_t (*qse_awk_pow_t) (
void* data,
qse_real_t x,
qse_real_t y
);
typedef int (*qse_awk_sprintf_t) ( typedef int (*qse_awk_sprintf_t) (
void* data, qse_char_t* buf, qse_size_t size, void* data,
const qse_char_t* fmt, ...); qse_char_t* buf,
qse_size_t size,
const qse_char_t* fmt,
...
);
typedef qse_ssize_t (*qse_awk_io_t) ( typedef qse_ssize_t (*qse_awk_io_t) (
int cmd, void* arg, qse_char_t* data, qse_size_t count); int cmd,
void* arg,
qse_char_t* data,
qse_size_t count
);
struct qse_awk_eio_t struct qse_awk_eio_t
{ {
qse_awk_rtx_t* rtx; /* [IN] */ qse_awk_rtx_t* rtx; /* [IN] */
int type; /* [IN] console, file, coproc, pipe */ int type; /* [IN] console, file, pipe */
int mode; /* [IN] read, write, etc */ int mode; /* [IN] read, write, etc */
qse_char_t* name; /* [IN] */ qse_char_t* name; /* [IN] */
void* data; /* [IN] */ void* data; /* [IN] */
@ -100,7 +113,6 @@ struct qse_awk_srcios_t
struct qse_awk_runios_t struct qse_awk_runios_t
{ {
qse_awk_io_t pipe; qse_awk_io_t pipe;
qse_awk_io_t coproc;
qse_awk_io_t file; qse_awk_io_t file;
qse_awk_io_t console; qse_awk_io_t console;
void* data; void* data;
@ -128,19 +140,34 @@ struct qse_awk_runcbs_t
struct qse_awk_rexfns_t struct qse_awk_rexfns_t
{ {
/* TODO: implement functions to get/set rexfns */
void* (*build) ( void* (*build) (
qse_awk_t* awk, const qse_char_t* ptn, qse_awk_t* awk,
qse_size_t len, int* errnum); const qse_char_t* ptn,
qse_size_t len,
int* errnum
);
int (*match) ( int (*match) (
qse_awk_t* awk, void* code, int option, qse_awk_t* awk,
const qse_char_t* str, qse_size_t len, void* code,
const qse_char_t** mptr, qse_size_t* mlen, int option,
int* errnum); const qse_char_t* str,
qse_size_t len,
const qse_char_t** mptr,
qse_size_t* mlen,
int* errnum
);
void (*free) (qse_awk_t* awk, void* code); void (*free) (
qse_awk_t* awk,
void* code
);
qse_bool_t (*isempty) (qse_awk_t* awk, void* code); qse_bool_t (*isempty) (
qse_awk_t* awk,
void* code
);
}; };
/* io function commands */ /* io function commands */
@ -571,6 +598,7 @@ struct qse_awk_val_ref_t
* directly. */ * directly. */
qse_awk_val_t** adr; qse_awk_val_t** adr;
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -590,75 +618,76 @@ extern qse_awk_val_t* qse_awk_val_zero;
/** represents a numeric value 1 */ /** represents a numeric value 1 */
extern qse_awk_val_t* qse_awk_val_one; extern qse_awk_val_t* qse_awk_val_one;
/****f* qse.awk/qse_awk_open /****f* awk/qse_awk_open
* NAME * NAME
* qse_awk_open - create an awk object * qse_awk_open - create an awk object
*
* DESCRIPTION * DESCRIPTION
* The qse_awk_open() function creates a new qse_awk_t instance. * The qse_awk_open() function creates a new qse_awk_t instance.
* The instance created can be passed to other qse_awk_xxx() functions and * The instance created can be passed to other qse_awk_xxx() functions and
* is valid until it is successfully destroyed using the qse_qse_close() * is valid until it is successfully destroyed using the qse_qse_close()
* function. * function.
*
* RETURN * RETURN
* The qse_awk_open() function returns the pointer to an qse_awk_t instance * The qse_awk_open() function returns the pointer to a qse_awk_t instance
* on success and QSE_NULL on failure. * on success and QSE_NULL on failure.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_t* qse_awk_open ( qse_awk_t* qse_awk_open (
qse_mmgr_t* mmgr /* a memory manager */, qse_mmgr_t* mmgr /* a memory manager */,
qse_size_t xtnsize /* size of extension area in bytes */ qse_size_t xtnsize /* the size of extension in bytes */
); );
/******/ /******/
/****f* qse.awk/qse_awk_close /****f* awk/qse_awk_close
* NAME * NAME
* qse_awk_close - destroy an awk object * qse_awk_close - destroy an awk object
* * DESCRIPTION
* An qse_awk_t instance should be destroyed using the qse_awk_close() function * A qse_awk_t instance must be destroyed using the qse_awk_close() function
* when finished being used. The instance passed is not valid any more once * when finished being used. The instance passed is not valid any more once
* the function returns success. * the function returns success.
*
* RETURN * RETURN
* 0 on success, -1 on failure * 0 on success, -1 on failure
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_close ( int qse_awk_close (
qse_awk_t* awk /* an awk object */ qse_awk_t* awk
); );
/******/ /******/
/****f* qse.awk/qse_awk_getmmgr /****f* awk/qse_awk_getmmgr
* NAME * NAME
* qse_awk_getmmgr - get the memory manager * qse_awk_getmmgr - get the memory manager
*
* DESCRIPTION * DESCRIPTION
* The qse_awk_getmmgr() function returns the pointer to the memory manager. * The qse_awk_getmmgr() function returns the pointer to the memory manager.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_mmgr_t* qse_awk_getmmgr ( qse_mmgr_t* qse_awk_getmmgr (
qse_awk_t* awk /* an awk object */ qse_awk_t* awk
); );
/******/ /******/
/****f* awk/qse_awk_setmmgr
* NAME
* qse_awk_setmmgr - set the extension
* DESCRIPTION
* The qse_awk_setmmgr() specify the memory manager to use. As the memory
* manager is specified into qse_awk_open(), you are not encouraged to change
* it by calling this function. Doing so may cause a lot of problems.
* SYNOPSIS
*/
void qse_awk_setmmgr ( void qse_awk_setmmgr (
qse_awk_t* awk, qse_awk_t* awk,
qse_mmgr_t* mmgr qse_mmgr_t* mmgr
); );
/******/
/****f* qse.awk/qse_awk_getxtn /****f* awk/qse_awk_getxtn
* NAME * NAME
* qse_awk_getxtn - get the extension * qse_awk_getxtn - get the extension
*
* DESCRIPTION * DESCRIPTION
* The extension area is allocated in the qse_awk_open() function when it is * The extension area is allocated in the qse_awk_open() function when it is
* given a positive extension size. The pointer to the beginning of the area * given a positive extension size. The pointer to the beginning of the area
* can be acquired using the qse_awk_getxtn() function and be utilized * can be acquired using the qse_awk_getxtn() function and be utilized
* for various purposes. * for various purposes.
*
* SYNOPSIS * SYNOPSIS
*/ */
void* qse_awk_getxtn ( void* qse_awk_getxtn (
@ -666,39 +695,53 @@ void* qse_awk_getxtn (
); );
/******/ /******/
/****f* awk/qse_awk_getccls
* NAME
* qse_awk_getccls - get a character classifier
* SYNOPSIS
*/
qse_ccls_t* qse_awk_getccls ( qse_ccls_t* qse_awk_getccls (
qse_awk_t* awk qse_awk_t* awk
); );
/******/
/* /****f* awk/qse_awk_setccls
* set the character classfier * NAME
* qse_awk_setccls - set the character classfier
* SYNOPSIS
*/ */
void qse_awk_setccls ( void qse_awk_setccls (
/* the pointer to an qse_awk_t instance */
qse_awk_t* awk, qse_awk_t* awk,
/* the pointer to a character classfiler */
qse_ccls_t* ccls qse_ccls_t* ccls
); );
/******/
/****f* awk/qse_awk_getprmfns
* NAME
* qse_awk_getprmfns - get primitive functions
* SYNOPSIS
*/
qse_awk_prmfns_t* qse_awk_getprmfns ( qse_awk_prmfns_t* qse_awk_getprmfns (
qse_awk_t* awk qse_awk_t* awk
); );
/******/
/* /****f* awk/qse_awk_setprmfns
* set primitive functions * NAME
* qse_awk_setprmfns - set primitive functions
* SYNOPSIS
*/ */
void qse_awk_setprmfns ( void qse_awk_setprmfns (
/* the pointer to an qse_awk_t instance */
qse_awk_t* awk, qse_awk_t* awk,
/* the pointer to a primitive function structure */
qse_awk_prmfns_t* prmfns qse_awk_prmfns_t* prmfns
); );
/******/
/****f* qse.awk/qse_awk_clear /****f* awk/qse_awk_clear
* NAME * NAME
* qse_awk_clear - clear a qse_awk_t object * qse_awk_clear - clear a qse_awk_t object
* DESCRIPTION * DESCRIPTION
* If you want to reuse an qse_awk_t instance that finished being used, * If you want to reuse a qse_awk_t instance that finished being used,
* you may call qse_awk_close instead of destroying and creating a new * you may call qse_awk_close instead of destroying and creating a new
* qse_awk_t instance using qse_awk_close() and qse_awk_open(). * qse_awk_t instance using qse_awk_close() and qse_awk_open().
* RETURN * RETURN
@ -710,7 +753,7 @@ int qse_awk_clear (
); );
/******/ /******/
/****f* qse.awk/qse_awk_geterrstr /****f* awk/qse_awk_geterrstr
* NAME * NAME
* qse_awk_geterrstr - get a format string for an error * qse_awk_geterrstr - get a format string for an error
* DESCRIPTION * DESCRIPTION
@ -724,7 +767,7 @@ const qse_char_t* qse_awk_geterrstr (
); );
/******/ /******/
/****f* qse.awk/qse_awk_seterrstr /****f* awk/qse_awk_seterrstr
* NAME * NAME
* qse_awk_geterrstr - set a format string for an error * qse_awk_geterrstr - set a format string for an error
* DESCRIPTION * DESCRIPTION
@ -779,11 +822,25 @@ void qse_awk_seterror (
qse_size_t argcnt qse_size_t argcnt
); );
int qse_awk_getoption (qse_awk_t* awk); int qse_awk_getoption (
void qse_awk_setoption (qse_awk_t* awk, int opt); qse_awk_t* awk
);
qse_size_t qse_awk_getmaxdepth (qse_awk_t* awk, int type); void qse_awk_setoption (
void qse_awk_setmaxdepth (qse_awk_t* awk, int types, qse_size_t depth); qse_awk_t* awk,
int opt
);
qse_size_t qse_awk_getmaxdepth (
qse_awk_t* awk,
int type
);
void qse_awk_setmaxdepth (
qse_awk_t* awk,
int types,
qse_size_t depth
);
int qse_awk_getword ( int qse_awk_getword (
qse_awk_t* awk, qse_awk_t* awk,
@ -817,7 +874,7 @@ void qse_awk_unsetallwords (
* RETURN: 0 on success, -1 on failure * RETURN: 0 on success, -1 on failure
*/ */
int qse_awk_setword ( int qse_awk_setword (
/* the pointer to an qse_awk_t instance */ /* the pointer to a qse_awk_t instance */
qse_awk_t* awk, qse_awk_t* awk,
/* the pointer to an old keyword */ /* the pointer to an old keyword */
const qse_char_t* okw, const qse_char_t* okw,
@ -829,21 +886,12 @@ int qse_awk_setword (
qse_size_t nlen qse_size_t nlen
); );
/* /****f* awk/qse_awk_addglobal
* set the customized regular processing routine. (TODO: NOT YET IMPLEMENTED)
*
* RETURNS 0 on success, -1 on failure
*/
int qse_awk_setrexfns (qse_awk_t* awk, qse_awk_rexfns_t* rexfns);
/****f* qse.awk/qse_awk_addglobal
* NAME * NAME
* qse_awk_addglobal - add an intrinsic global variable. * qse_awk_addglobal - add an intrinsic global variable.
*
* RETURN * RETURN
* On success, the ID of the global variable added is returned. * The qse_awk_addglobal() function returns the ID of the global variable
* On failure, -1 is returned. * added on success and -1 on failure.
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_addglobal ( int qse_awk_addglobal (
@ -853,10 +901,9 @@ int qse_awk_addglobal (
); );
/******/ /******/
/****f* qse.awk/qse_awk_delglobal /****f* awk/qse_awk_delglobal
* NAME * NAME
* qse_awk_delglobal - delete an instrinsic global variable. * qse_awk_delglobal - delete an instrinsic global variable.
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_delglobal ( int qse_awk_delglobal (
@ -866,10 +913,9 @@ int qse_awk_delglobal (
); );
/******/ /******/
/****f* qse.awk/qse_awk_parse /****f* awk/qse_awk_parse
* NAME * NAME
* qse_awk_parse - parse source code * qse_awk_parse - parse source code
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_parse ( int qse_awk_parse (
@ -879,10 +925,9 @@ int qse_awk_parse (
/******/ /******/
/****f* qse.awk/qse_awk_opensimple /****f* awk/qse_awk_opensimple
* NAME * NAME
* qse_awk_opensimple - create an awk object * qse_awk_opensimple - create an awk object
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_t* qse_awk_opensimple ( qse_awk_t* qse_awk_opensimple (
@ -890,10 +935,9 @@ qse_awk_t* qse_awk_opensimple (
); );
/******/ /******/
/****f* qse.awk/qse_awk_parsesimple /****f* awk/qse_awk_parsesimple
* NAME * NAME
* qse_awk_parsesimple - parse source code * qse_awk_parsesimple - parse source code
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_parsesimple ( int qse_awk_parsesimple (
@ -904,10 +948,9 @@ int qse_awk_parsesimple (
); );
/******/ /******/
/****f* qse.awk/qse_awk_runsimple /****f* awk/qse_awk_runsimple
* NAME * NAME
* qse_awk_runsimple - run a parsed program * qse_awk_runsimple - run a parsed program
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_runsimple ( int qse_awk_runsimple (
@ -917,11 +960,10 @@ int qse_awk_runsimple (
); );
/******/ /******/
/****f* qse.awk/qse_awk_run /****f* awk/qse_awk_run
* NAME * NAME
* qse_awk_run - execute a parsed program * qse_awk_run - execute a parsed program
* DESCRIPTION * DESCRIPTION
* The qse_awk_run() function returns 0 on success and -1 on failure.
* A runtime context is required for it to start running the program. * A runtime context is required for it to start running the program.
* Once a runtime context is created, the program starts to run. * Once a runtime context is created, the program starts to run.
* The failure of context creation is reported by the return value of -1. * The failure of context creation is reported by the return value of -1.
@ -967,22 +1009,22 @@ void qse_awk_clrfnc (
qse_awk_t* awk qse_awk_t* awk
); );
/****f* qse.awk/qse_awk_rtx_stopall /****f* awk/qse_awk_stopall
* NAME * NAME
* qse_awk_rtx_stop - stop all runtime contexts * qse_awk_stopall - stop all runtime contexts
* DESCRIPTION * DESCRIPTION
* The qse_awk_rtx_stopall() function aborts all active qse_awk_run() functions * The qse_awk_stopall() function aborts all active qse_awk_run() functions
* invoked with the awk parameter. * invoked with the awk parameter.
* SYNOPSIS * SYNOPSIS
*/ */
void qse_awk_rtx_stopall ( void qse_awk_stopall (
qse_awk_t* awk qse_awk_t* awk
); );
/******/ /******/
/****f* qse.awk/qse_awk_shouldstop /****f* awk/qse_awk_shouldstop
* NAME * NAME
* qse_awk_rtx_stop - test if qse_awk_rtx_stop() is called * qse_awk_shouldstop - test if qse_awk_rtx_stop() is called
* SYNOPSIS * SYNOPSIS
*/ */
qse_bool_t qse_awk_rtx_shouldstop ( qse_bool_t qse_awk_rtx_shouldstop (
@ -990,7 +1032,7 @@ qse_bool_t qse_awk_rtx_shouldstop (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_stop /****f* awk/qse_awk_rtx_stop
* NAME * NAME
* qse_awk_rtx_stop - stop a runtime context * qse_awk_rtx_stop - stop a runtime context
* DESCRIPTION * DESCRIPTION
@ -1003,7 +1045,7 @@ void qse_awk_rtx_stop (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getnargs /****f* awk/qse_awk_rtx_getnargs
* NAME * NAME
* qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run() * qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run()
* SYNOPSIS * SYNOPSIS
@ -1013,7 +1055,7 @@ qse_size_t qse_awk_rtx_getnargs (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getarg /****f* awk/qse_awk_rtx_getarg
* NAME * NAME
* qse_awk_rtx_getarg - get an argument passed to qse_awk_run * qse_awk_rtx_getarg - get an argument passed to qse_awk_run
* SYNOPSIS * SYNOPSIS
@ -1024,18 +1066,16 @@ qse_awk_val_t* qse_awk_rtx_getarg (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getglobal /****f* awk/qse_awk_rtx_getglobal
* NAME * NAME
* qse_awk_rtx_getglobal - gets the value of a global variable * qse_awk_rtx_getglobal - gets the value of a global variable
* * INPUTS
* PARAMETERS * * rtx - a runtime context
* id - A global variable id. An ID is one of the predefined global * * id - a global variable ID. It is one of the predefined global
* variable IDs or the value returned by qse_awk_addglobal(). * variable IDs or a value returned by qse_awk_addglobal().
*
* RETURN * RETURN
* The pointer to a value is returned. This function never fails * The pointer to a value is returned. This function never fails
* so long as id is valid. Otherwise, you may fall into trouble. * so long as the ID is valid. Otherwise, you may fall into trouble.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_val_t* qse_awk_rtx_getglobal ( qse_awk_val_t* qse_awk_rtx_getglobal (
@ -1044,10 +1084,9 @@ qse_awk_val_t* qse_awk_rtx_getglobal (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_setglobal /****f* awk/qse_awk_rtx_setglobal
* NAME * NAME
* qse_awk_rtx_setglobal - set the value of a global variable * qse_awk_rtx_setglobal - set the value of a global variable
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_rtx_setglobal ( int qse_awk_rtx_setglobal (
@ -1057,7 +1096,7 @@ int qse_awk_rtx_setglobal (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_setretval /****f* awk/qse_awk_rtx_setretval
* NAME * NAME
* qse_awk_rtx_setretval - set the return value * qse_awk_rtx_setretval - set the return value
* DESCRIPTION * DESCRIPTION
@ -1075,7 +1114,7 @@ void qse_awk_rtx_setretval (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_setfilename /****f* awk/qse_awk_rtx_setfilename
* NAME * NAME
* qse_awk_rtx_setfilename - set FILENAME * qse_awk_rtx_setfilename - set FILENAME
* SYNOPSIS * SYNOPSIS
@ -1087,7 +1126,7 @@ int qse_awk_rtx_setfilename (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_setofilename /****f* awk/qse_awk_rtx_setofilename
* NAME * NAME
* qse_awk_rtx_setofilename - set OFILENAME * qse_awk_rtx_setofilename - set OFILENAME
* SYNOPSIS * SYNOPSIS
@ -1099,7 +1138,7 @@ int qse_awk_rtx_setofilename (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getawk /****f* awk/qse_awk_rtx_getawk
* NAME * NAME
* qse_awk_rtx_getawk - get the owning awk object * qse_awk_rtx_getawk - get the owning awk object
* SYNOPSIS * SYNOPSIS
@ -1109,7 +1148,7 @@ qse_awk_t* qse_awk_rtx_getawk (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getmmgr /****f* awk/qse_awk_rtx_getmmgr
* NAME * NAME
* qse_awk_rtx_getmmgr - get the memory manager of a runtime context * qse_awk_rtx_getmmgr - get the memory manager of a runtime context
* SYNOPSIS * SYNOPSIS
@ -1119,7 +1158,7 @@ qse_mmgr_t* qse_awk_rtx_getmmgr (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getdata /****f* awk/qse_awk_rtx_getdata
* NAME * NAME
* qse_awk_rtx_getdata - get the user-specified data for a runtime context * qse_awk_rtx_getdata - get the user-specified data for a runtime context
* SYNOPSIS * SYNOPSIS
@ -1129,7 +1168,7 @@ void* qse_awk_rtx_getdata (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_getnvmap /****f* awk/qse_awk_rtx_getnvmap
* NAME * NAME
* qse_awk_rtx_getnvmap - get the map of named variables * qse_awk_rtx_getnvmap - get the map of named variables
* SYNOPSIS * SYNOPSIS
@ -1139,7 +1178,7 @@ qse_map_t* qse_awk_rtx_getnvmap (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_geterrnum /****f* awk/qse_awk_rtx_geterrnum
* NAME * NAME
* qse_awk_rtx_geterrnum - get the error number of a runtime context * qse_awk_rtx_geterrnum - get the error number of a runtime context
* SYNOPSIS * SYNOPSIS
@ -1198,7 +1237,7 @@ int qse_awk_rtx_setrec (
qse_size_t len qse_size_t len
); );
/****f* qse.awk/qse_awk_alloc /****f* awk/qse_awk_alloc
* NAME * NAME
* qse_awk_alloc - allocate dynamic memory * qse_awk_alloc - allocate dynamic memory
* RETURN * RETURN
@ -1206,41 +1245,41 @@ int qse_awk_rtx_setrec (
* SYNOPSIS * SYNOPSIS
*/ */
void* qse_awk_alloc ( void* qse_awk_alloc (
qse_awk_t* awk /* the pointer to an qse_awk_t instance */, qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
qse_size_t size /* the size of memory to allocate in bytes */ qse_size_t size /* the size of memory to allocate in bytes */
); );
/******/ /******/
/****f* qse.awk/qse_awk_free /****f* awk/qse_awk_free
* NAME * NAME
* qse_awk_free - free dynamic memory * qse_awk_free - free dynamic memory
* SYNOPSIS * SYNOPSIS
*/ */
void qse_awk_free ( void qse_awk_free (
qse_awk_t* awk /* the pointer to an qse_awk_t instance */, qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
void* ptr /* the pointer to the memory area to free */ void* ptr /* the pointer to the memory area to free */
); );
/******/ /******/
/****f* qse.awk/qse_awk_strdup /****f* awk/qse_awk_strdup
* NAME * NAME
* qse_awk_strdup - duplicate a null-terminated string * qse_awk_strdup - duplicate a null-terminated string
* DESCRIPTION * DESCRIPTION
* The qse_awk_strdup() function is used to duplicate a string using * The qse_awk_strdup() function is used to duplicate a string using
* the memory manager used by the associated qse_awk_t instance. * the memory manager used by the associated qse_awk_t instance.
* The new string should be freed using the qse_awk_free() function. * The new string should be freed using the qse_awk_free() function.
* RETURNS * RETURN
* The qse_awk_strdup() function returns the pointer to a new string which * The qse_awk_strdup() function returns the pointer to a new string which
* is a duplicate of the string s. It returns QSE_NULL on failure. * is a duplicate of the string s. It returns QSE_NULL on failure.
* SYNOPSIS * SYNOPSIS
*/ */
qse_char_t* qse_awk_strdup ( qse_char_t* qse_awk_strdup (
qse_awk_t* awk /* the pointer to an qse_awk_t instance */, qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
const qse_char_t* str /* the pointer to a string */ const qse_char_t* str /* the pointer to a string */
); );
/******/ /******/
/****f* qse.awk/qse_awk_strxdup /****f* awk/qse_awk_strxdup
* NAME * NAME
* qse_awk_strxdup - duplicate a length-delimited string * qse_awk_strxdup - duplicate a length-delimited string
* DESCRIPTION * DESCRIPTION
@ -1248,7 +1287,7 @@ qse_char_t* qse_awk_strdup (
* is as long as len characters using the memory manager used by the * is as long as len characters using the memory manager used by the
* qse_awk_t instance. The new string should be freed using the qse_awk_free() * qse_awk_t instance. The new string should be freed using the qse_awk_free()
* function. * function.
* RETURNS * RETURN
* The qse_awk_strxdup() function returns the pointer to a new string which * The qse_awk_strxdup() function returns the pointer to a new string which
* is a duplicate of the string s on success. It returns QSE_NULL on failure. * is a duplicate of the string s on success. It returns QSE_NULL on failure.
* SYNOPSIS * SYNOPSIS
@ -1374,7 +1413,7 @@ qse_char_t* qse_awk_rtx_valtostr (
qse_size_t* len qse_size_t* len
); );
/****f* qse.awk/qse_awk_rtx_valtonum /****f* awk/qse_awk_rtx_valtonum
* NAME * NAME
* qse_awk_rtx_valtonum - convert a value to a number * qse_awk_rtx_valtonum - convert a value to a number
* DESCRIPTION * DESCRIPTION
@ -1404,7 +1443,7 @@ int qse_awk_rtx_valtonum (
); );
/******/ /******/
/****f* qse.awk/qse_awk_rtx_strtonum /****f* awk/qse_awk_rtx_strtonum
* NAME * NAME
* qse_awk_rtx_strtonum - convert a string to a number * qse_awk_rtx_strtonum - convert a string to a number
* SYNOPSIS * SYNOPSIS

View File

@ -91,7 +91,7 @@ struct qse_fio_t
/* note that qse_fio_t is instantiated statically /* note that qse_fio_t is instantiated statically
* in sio.c. make sure that you update the static instantiation * in sio.c. make sure that you update the static instantiation
* when you change the structure of qse_fio_t */ * when you change the structure of qse_fio_t */
QSE_DEFINE_STD_FIELDS (fio) QSE_DEFINE_COMMON_FIELDS (fio)
int errnum; int errnum;
qse_fio_hnd_t handle; qse_fio_hnd_t handle;
qse_tio_t* tio; qse_tio_t* tio;
@ -112,9 +112,9 @@ struct qse_fio_lck_t
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_STD_FUNCTIONS (fio) QSE_DEFINE_COMMON_FUNCTIONS (fio)
/****f* qse.fio/qse_fio_open /****f* qse.cmn.fio/qse_fio_open
* NAME * NAME
* qse_fio_open - open a file * qse_fio_open - open a file
* *
@ -133,7 +133,7 @@ qse_fio_t* qse_fio_open (
); );
/******/ /******/
/****f* qse.fio/qse_fio_close /****f* qse.cmn.fio/qse_fio_close
* NAME * NAME
* qse_fio_close - close a file * qse_fio_close - close a file
* *

View File

@ -25,7 +25,7 @@
/****o* qse.cmn.lda/linear dynamic array /****o* qse.cmn.lda/linear dynamic array
* DESCRIPTION * DESCRIPTION
* <qse/cmn/lda.h> provides a linear dynamic array. It grows as more items * <qse/cmn/lda.h> provides a linear dynamic array. It grows as more items
* are added. T * are added.
* *
* #include <qse/cmn/lda.h> * #include <qse/cmn/lda.h>
****** ******
@ -54,9 +54,6 @@ typedef enum qse_lda_walk_t qse_lda_walk_t;
#define QSE_LDA_DPTR(lda,index) ((lda)->node[index]->dptr) #define QSE_LDA_DPTR(lda,index) ((lda)->node[index]->dptr)
#define QSE_LDA_DLEN(lda,index) ((lda)->node[index]->dlen) #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_COPIER(lda) ((lda)->copier)
#define QSE_LDA_FREEER(lda) ((lda)->freeer) #define QSE_LDA_FREEER(lda) ((lda)->freeer)
#define QSE_LDA_COMPER(lda) ((lda)->comper) #define QSE_LDA_COMPER(lda) ((lda)->comper)
@ -178,7 +175,7 @@ typedef qse_lda_walk_t (*qse_lda_walker_t) (
*/ */
struct qse_lda_t struct qse_lda_t
{ {
qse_mmgr_t* mmgr; /* memory manager */ QSE_DEFINE_COMMON_FIELDS (lda)
qse_lda_copier_t copier; /* data copier */ qse_lda_copier_t copier; /* data copier */
qse_lda_freeer_t freeer; /* data freeer */ qse_lda_freeer_t freeer; /* data freeer */
@ -209,6 +206,8 @@ struct qse_lda_node_t
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_COMMON_FUNCTIONS (lda)
/****f* qse.cmn.lda/qse_lda_open /****f* qse.cmn.lda/qse_lda_open
* NAME * NAME
* qse_lda_open - create a linear dynamic array * qse_lda_open - create a linear dynamic array
@ -257,43 +256,6 @@ void qse_lda_fini (
); );
/******/ /******/
/****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 ( int qse_lda_getscale (
qse_lda_t* lda /* a lda */ qse_lda_t* lda /* a lda */
); );

View File

@ -28,11 +28,6 @@
* chained under the same bucket. * chained under the same bucket.
* *
* #include <qse/cmn/map.h> * #include <qse/cmn/map.h>
*
* EXAMPLES
* void f (void)
* {
* }
****** ******
*/ */
@ -190,7 +185,8 @@ struct qse_map_pair_t
*/ */
struct qse_map_t struct qse_map_t
{ {
qse_mmgr_t* mmgr; QSE_DEFINE_COMMON_FIELDS (map)
qse_map_copier_t copier[2]; qse_map_copier_t copier[2];
qse_map_freeer_t freeer[2]; qse_map_freeer_t freeer[2];
qse_map_hasher_t hasher; /* key hasher */ qse_map_hasher_t hasher; /* key hasher */
@ -213,10 +209,8 @@ struct qse_map_t
/****d* qse.cmn.map/QSE_MAP_SIZE /****d* qse.cmn.map/QSE_MAP_SIZE
* NAME * NAME
* QSE_MAP_SIZE - get the number of pairs * QSE_MAP_SIZE - get the number of pairs
*
* DESCRIPTION * DESCRIPTION
* The QSE_MAP_SIZE() macro returns the number of pairs in a map. * The QSE_MAP_SIZE() macro returns the number of pairs in a map.
*
* SYNOPSIS * SYNOPSIS
*/ */
#define QSE_MAP_SIZE(m) ((m)->size) #define QSE_MAP_SIZE(m) ((m)->size)
@ -234,9 +228,6 @@ struct qse_map_t
#define QSE_MAP_CAPA(m) ((m)->capa) #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_KCOPIER(m) ((m)->copier[QSE_MAP_KEY])
#define QSE_MAP_VCOPIER(m) ((m)->copier[QSE_MAP_VAL]) #define QSE_MAP_VCOPIER(m) ((m)->copier[QSE_MAP_VAL])
#define QSE_MAP_KFREEER(m) ((m)->freeer[QSE_MAP_KEY]) #define QSE_MAP_KFREEER(m) ((m)->freeer[QSE_MAP_KEY])
@ -260,26 +251,24 @@ struct qse_map_t
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_COMMON_FUNCTIONS (map)
/****f* qse.cmn.map/qse_map_open /****f* qse.cmn.map/qse_map_open
* NAME * NAME
* qse_map_open - creates a hash map * qse_map_open - creates a hash map
*
* DESCRIPTION * DESCRIPTION
* The qse_map_open() function creates a hash map with a dynamic array * 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 * 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 * 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 * 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. * 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 * The QSE_MAP_XTN() macro and the qse_map_getxtn() function return the
* return the pointer to the beginning of the extension. * pointer to the beginning of the extension.
*
* RETURN * RETURN
* The qse_map_open() function returns an qse_map_t pointer on success and * The qse_map_open() function returns an qse_map_t pointer on success and
* QSE_NULL on failure. * QSE_NULL on failure.
*
* SEE ALSO * SEE ALSO
* QSE_MAP_XTN, qse_map_getxtn * QSE_MAP_XTN, qse_map_getxtn
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_map_t* qse_map_open ( qse_map_t* qse_map_open (
@ -294,10 +283,8 @@ qse_map_t* qse_map_open (
/****f* qse.cmn.map/qse_map_close /****f* qse.cmn.map/qse_map_close
* NAME * NAME
* qse_map_close - destroy a hash map * qse_map_close - destroy a hash map
*
* DESCRIPTION * DESCRIPTION
* The qse_map_close() function destroys a hash map. * The qse_map_close() function destroys a hash map.
*
* SYNOPSIS * SYNOPSIS
*/ */
void qse_map_close ( void qse_map_close (
@ -316,19 +303,6 @@ void qse_map_fini (
qse_map_t* map 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 */ /* get the number of key/value pairs in a map */
qse_size_t qse_map_getsize ( qse_size_t qse_map_getsize (
qse_map_t* map /* a map */ qse_map_t* map /* a map */
@ -450,28 +424,16 @@ void qse_map_setsizer (
qse_map_sizer_t sizer 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 /****f* qse.cmn.map/qse_map_search
* NAME * NAME
* qse_map_search - find a pair with a matching key * qse_map_search - find a pair with a matching key
*
* DESCRIPTION * DESCRIPTION
* The qse_map_search() function searches a map to find a pair with a * 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 * matching key. It returns the pointer to the pair found. If it fails
* to find one, it returns QSE_NULL. * to find one, it returns QSE_NULL.
*
* RETURN * RETURN
* The qse_map_search() function returns the pointer to the pair with a * The qse_map_search() function returns the pointer to the pair with a
* maching key, and QSE_NULL if no match is found. * maching key, and QSE_NULL if no match is found.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_map_pair_t* qse_map_search ( qse_map_pair_t* qse_map_search (
@ -484,17 +446,14 @@ qse_map_pair_t* qse_map_search (
/****f* qse.cmn.map/qse_map_upsert /****f* qse.cmn.map/qse_map_upsert
* NAME * NAME
* qse_map_upsert - update an existing pair or inesrt a new pair * qse_map_upsert - update an existing pair or inesrt a new pair
*
* DESCRIPTION * DESCRIPTION
* The qse_map_upsert() function searches a map for the pair with a matching * 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 * 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 * pair with a key and a value. It returns the pointer to the pair updated
* or inserted. * or inserted.
*
* RETURN * RETURN
* The qse_map_upsert() function returns a pointer to the updated or inserted * The qse_map_upsert() function returns a pointer to the updated or inserted
* pair on success, and QSE_NULL on failure. * pair on success, and QSE_NULL on failure.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_map_pair_t* qse_map_upsert ( qse_map_pair_t* qse_map_upsert (
@ -509,16 +468,13 @@ qse_map_pair_t* qse_map_upsert (
/****f* qse.cmn.map/qse_map_insert /****f* qse.cmn.map/qse_map_insert
* NAME * NAME
* qse_map_insert - insert a new pair with a key and a value * qse_map_insert - insert a new pair with a key and a value
*
* DESCRIPTION * DESCRIPTION
* The qse_map_insert() function inserts a new pair with the key and the value * 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 * given. If there exists a pair with the key given, the function returns
* QSE_NULL without channging the value. * QSE_NULL without channging the value.
*
* RETURN * RETURN
* The qse_map_insert() function returns a pointer to the pair created on * The qse_map_insert() function returns a pointer to the pair created on
* success, and QSE_NULL on failure. * success, and QSE_NULL on failure.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_map_pair_t* qse_map_insert ( qse_map_pair_t* qse_map_insert (

View File

@ -25,12 +25,23 @@
typedef struct qse_opt_t qse_opt_t; typedef struct qse_opt_t qse_opt_t;
typedef struct qse_opt_lng_t qse_opt_lng_t; typedef struct qse_opt_lng_t qse_opt_lng_t;
/****t* qse.cmn.opt/qse_opt_lng_t
* NAME
* qse_opt_lng_t - define a long option
* SYNOPSIS
*/
struct qse_opt_lng_t struct qse_opt_lng_t
{ {
const qse_char_t* str; const qse_char_t* str;
qse_cint_t val; qse_cint_t val;
}; };
/*****/
/****t* qse.cmn.opt/qse_opt_t
* NAME
* qse_opt_t - define a command line option table
* SYNOPSIS
*/
struct qse_opt_t struct qse_opt_t
{ {
/* input */ /* input */
@ -50,6 +61,7 @@ struct qse_opt_t
/* input + output - internal*/ /* input + output - internal*/
qse_char_t* cur; qse_char_t* cur;
}; };
/******/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -57,8 +69,10 @@ extern "C" {
/****f* qse.cmn.opt/qse_getopt /****f* qse.cmn.opt/qse_getopt
* NAME * NAME
* qse_getopt - parse command line options * qse_getopt - process command line options
* * DESCRIPTION
* The qse_getopt() function returns QSE_CHAR_EOF when it finishes processing
* command line options. The return values of QSE_T('?') indicates an error.
* SYNOPSIS * SYNOPSIS
*/ */
qse_cint_t qse_getopt ( qse_cint_t qse_getopt (

View File

@ -101,15 +101,21 @@ struct qse_pio_pin_t
qse_pio_t* self; qse_pio_t* self;
}; };
/****s* cmn/qse_pio_t
* NAME
* qse_pio_t - define an pipe IO type
* SYNOPSIS
*/
struct qse_pio_t struct qse_pio_t
{ {
QSE_DEFINE_STD_FIELDS(pio) QSE_DEFINE_COMMON_FIELDS(pio)
int flags; int flags;
qse_pio_err_t errnum; qse_pio_err_t errnum;
qse_pio_pid_t child; qse_pio_pid_t child;
qse_pio_pin_t pin[3]; qse_pio_pin_t pin[3];
}; };
/*****/
#define QSE_PIO_ERRNUM(pio) ((pio)->errnum) #define QSE_PIO_ERRNUM(pio) ((pio)->errnum)
#define QSE_PIO_FLAGS(pio) ((pio)->flags) #define QSE_PIO_FLAGS(pio) ((pio)->flags)
@ -120,9 +126,9 @@ struct qse_pio_t
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_STD_FUNCTIONS (pio) QSE_DEFINE_COMMON_FUNCTIONS (pio)
/****f* qse.cmn.pio/qse_pio_open /****f* cmn/qse_pio_open
* NAME * NAME
* qse_pio_open - open pipes to a child process * qse_pio_open - open pipes to a child process
* *
@ -140,7 +146,7 @@ qse_pio_t* qse_pio_open (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_close /****f* cmn/qse_pio_close
* NAME * NAME
* qse_pio_close - close pipes to a child process * qse_pio_close - close pipes to a child process
* *
@ -151,7 +157,7 @@ void qse_pio_close (
); );
/******/ /******/
/****f* qse.cmn/pio/qse_pio_init /****f* cmn/qse_pio_init
* NAME * NAME
* qse_pio_init - initialize pipes to a child process * qse_pio_init - initialize pipes to a child process
* *
@ -165,7 +171,7 @@ qse_pio_t* qse_pio_init (
); );
/******/ /******/
/****f* qse.cmn/pio/qse_pio_fini /****f* cmn/qse_pio_fini
* NAME * NAME
* qse_pio_fini - finalize pipes to a child process * qse_pio_fini - finalize pipes to a child process
* *
@ -186,7 +192,7 @@ void qse_pio_setflags (
int op int op
); );
/****f* qse.cmn.pio/qse_pio_geterrnum /****f* cmn/qse_pio_geterrnum
* NAME * NAME
* qse_pio_geterrnum - get an error code * qse_pio_geterrnum - get an error code
* *
@ -197,7 +203,7 @@ qse_pio_err_t qse_pio_geterrnum (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_geterrstr /****f* cmn/qse_pio_geterrmsg
* NAME * NAME
* qse_pio_geterrstr - transllate an error code to a string * qse_pio_geterrstr - transllate an error code to a string
* *
@ -212,7 +218,7 @@ const qse_char_t* qse_pio_geterrstr (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_gethandle /****f* cmn/qse_pio_gethandle
* NAME * NAME
* qse_pio_gethandle - get native handle * qse_pio_gethandle - get native handle
* *
@ -224,7 +230,7 @@ qse_pio_hnd_t qse_pio_gethandle (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_getchild /****f* cmn/qse_pio_getchild
* NAME * NAME
* qse_pio_getchild - get the PID of a child process * qse_pio_getchild - get the PID of a child process
* *
@ -235,10 +241,9 @@ qse_pio_pid_t qse_pio_getchild (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_read /****f* cmn/qse_pio_read
* NAME * NAME
* qse_pio_read - read data * qse_pio_read - read data
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_ssize_t qse_pio_read ( qse_ssize_t qse_pio_read (
@ -249,14 +254,12 @@ qse_ssize_t qse_pio_read (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_write /****f* cmn/qse_pio_write
* NAME * NAME
* qse_pio_write - write data * qse_pio_write - write data
*
* DESCRIPTION * DESCRIPTION
* If the parameter 'size' is zero, qse_pio_write() closes the the writing * If the parameter 'size' is zero, qse_pio_write() closes the the writing
* stream causing the child process reach the end of the stream. * stream causing the child process reach the end of the stream.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_ssize_t qse_pio_write ( qse_ssize_t qse_pio_write (
@ -267,7 +270,7 @@ qse_ssize_t qse_pio_write (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_flush /****f* cmn/qse_pio_flush
* NAME * NAME
* qse_pio_flush - flush data * qse_pio_flush - flush data
* *
@ -279,7 +282,7 @@ qse_ssize_t qse_pio_flush (
); );
/*****/ /*****/
/****f* qse.cmn.pio/qse_pio_end /****f* cmn/qse_pio_end
* NAME * NAME
* qse_pio_end - close native handle * qse_pio_end - close native handle
* *
@ -291,10 +294,9 @@ void qse_pio_end (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_wait /****f* cmn/qse_pio_wait
* NAME * NAME
* qse_pio_wait - wait for a child process * qse_pio_wait - wait for a child process
*
* DESCRIPTION * DESCRIPTION
* QSE_PIO_WAIT_NORETRY causes the function to return an error and set the * QSE_PIO_WAIT_NORETRY causes the function to return an error and set the
* errnum field to QSE_PIO_EINTR if the underlying system call is interrupted. * errnum field to QSE_PIO_EINTR if the underlying system call is interrupted.
@ -302,12 +304,10 @@ void qse_pio_end (
* When QSE_PIO_WAIT_NOBLOCK is used, the return value of 256 indicates that * When QSE_PIO_WAIT_NOBLOCK is used, the return value of 256 indicates that
* the child process has not terminated. If the flag is not used, 256 is never * the child process has not terminated. If the flag is not used, 256 is never
* returned. * returned.
*
* RETURN * RETURN
* -1 on error, 256 if the child is alive and QSE_PIO_NOBLOCK is used, * -1 on error, 256 if the child is alive and QSE_PIO_NOBLOCK is used,
* a number between 0 and 255 inclusive if the child process ends normally, * a number between 0 and 255 inclusive if the child process ends normally,
* 256 + signal number if the child process is terminated by a signal. * 256 + signal number if the child process is terminated by a signal.
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_pio_wait ( int qse_pio_wait (
@ -315,15 +315,13 @@ int qse_pio_wait (
); );
/******/ /******/
/****f* qse.cmn.pio/qse_pio_kill /****f* cmn/qse_pio_kill
* NAME * NAME
* qse_pio_kill - terminate the child process * qse_pio_kill - terminate the child process
*
* NOTES * NOTES
* You should know the danger of calling this function as the function can * You should know the danger of calling this function as the function can
* kill a process that is not your child process if it has terminated but * kill a process that is not your child process if it has terminated but
* there is a new process with the same process handle. * there is a new process with the same process handle.
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_pio_kill ( int qse_pio_kill (

View File

@ -22,13 +22,19 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* qse.cmn.sll/singly linked list
* DESCRIPTION
* <qse/cmn/sll.h> provides a singly linked list
*
* #include <qse/cmn/sll.h>
******
*/
/****t* qse.cmn.sll/qse_sll_walk_t /****t* qse.cmn.sll/qse_sll_walk_t
* NAME * NAME
* qse_sll_walk_t - define return values for qse_sll_walker_t * qse_sll_walk_t - define return values for qse_sll_walker_t
*
* SEE ALSO * SEE ALSO
* qse_sll_walk, qse_sll_walker_t * qse_sll_walker_t
*
* SYNOPSIS * SYNOPSIS
*/ */
enum qse_sll_walk_t enum qse_sll_walk_t
@ -45,7 +51,6 @@ typedef enum qse_sll_walk_t qse_sll_walk_t;
/****b* qse.cmn.sll/qse_sll_copier_t /****b* qse.cmn.sll/qse_sll_copier_t
* NAME * NAME
* qse_sll_copier_t - define a node contruction callback * qse_sll_copier_t - define a node contruction callback
*
* DESCRIPTION * DESCRIPTION
* The qse_sll_copier_t defines a callback function for node construction. * 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 * A node is contructed when a user adds data to a list. The user can
@ -58,10 +63,8 @@ typedef enum qse_sll_walk_t qse_sll_walk_t;
* A copier should return the pointer to the copied data. If it fails to copy * 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 * data, it may return QSE_NULL. You need to set a proper freeer to free up
* memory allocated for copy. * memory allocated for copy.
*
* SEE ALSO * SEE ALSO
* qse_sll_setcopier, qse_sll_getcopier, QSE_SLL_COPIER * qse_sll_setcopier, qse_sll_getcopier, QSE_SLL_COPIER
*
* SYNOPSIS * SYNOPSIS
*/ */
typedef void* (*qse_sll_copier_t) ( typedef void* (*qse_sll_copier_t) (
@ -140,7 +143,7 @@ typedef qse_sll_walk_t (*qse_sll_walker_t) (
*/ */
struct qse_sll_t struct qse_sll_t
{ {
qse_mmgr_t* mmgr; /* memory manager */ QSE_DEFINE_COMMON_FIELDS (sll)
qse_sll_copier_t copier; /* data copier */ qse_sll_copier_t copier; /* data copier */
qse_sll_freeer_t freeer; /* data freeer */ qse_sll_freeer_t freeer; /* data freeer */
@ -153,17 +156,14 @@ struct qse_sll_t
}; };
/******/ /******/
/****s* qse.cmn.sll/qse_sll_node_t /****s* cmn/qse_sll_node_t
* NAME * NAME
* qse_sll_node_t - define a list node * qse_sll_node_t - define a list node
*
* DESCRIPTION * DESCRIPTION
* The qse_sll_node_t type defines a list node containing a data pointer and * The qse_sll_node_t type defines a list node containing a data pointer and
* and data length. * and data length.
*
* SEE ALSO * SEE ALSO
* QSE_SLL_DPTR, QSE_SLL_DLEN, QSE_SLL_NEXT * QSE_SLL_DPTR, QSE_SLL_DLEN, QSE_SLL_NEXT
*
* SYNOPSIS * SYNOPSIS
*/ */
struct qse_sll_node_t struct qse_sll_node_t
@ -177,8 +177,6 @@ struct qse_sll_node_t
#define QSE_SLL_COPIER_SIMPLE ((qse_sll_copier_t)1) #define QSE_SLL_COPIER_SIMPLE ((qse_sll_copier_t)1)
#define QSE_SLL_COPIER_INLINE ((qse_sll_copier_t)2) #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_COPIER(sll) ((sll)->copier)
#define QSE_SLL_FREEER(sll) ((sll)->freeer) #define QSE_SLL_FREEER(sll) ((sll)->freeer)
#define QSE_SLL_COMPER(sll) ((sll)->comper) #define QSE_SLL_COMPER(sll) ((sll)->comper)
@ -188,14 +186,36 @@ struct qse_sll_node_t
#define QSE_SLL_SIZE(sll) ((sll)->size) #define QSE_SLL_SIZE(sll) ((sll)->size)
#define QSE_SLL_SCALE(sll) ((sll)->scale) #define QSE_SLL_SCALE(sll) ((sll)->scale)
/****d* cmn/QSE_SLL_DPTR
* NAME
* QSE_SLL_DPTR - get the data pointer in a node
* SYNOPSIS
*/
#define QSE_SLL_DPTR(node) ((node)->dptr) #define QSE_SLL_DPTR(node) ((node)->dptr)
/******/
/****d* cmn/QSE_SLL_DLEN
* NAME
* QSE_SLL_DLEN - get the length of data in a node
* SYNOPSIS
*/
#define QSE_SLL_DLEN(node) ((node)->dlen) #define QSE_SLL_DLEN(node) ((node)->dlen)
/******/
/****d* cmn/QSE_SLL_NEXT
* NAME
* QSE_SLL_NEXT - get the next node
* SYNOPSIS
*/
#define QSE_SLL_NEXT(node) ((node)->next) #define QSE_SLL_NEXT(node) ((node)->next)
/******/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_COMMON_FUNCTIONS (sll)
/****f* qse.cmn.sll/qse_sll_open /****f* qse.cmn.sll/qse_sll_open
* NAME * NAME
* qse_sll_open - create a singly linked list with extension area * qse_sll_open - create a singly linked list with extension area
@ -274,43 +294,6 @@ void qse_sll_fini (
); );
/******/ /******/
/****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 /****f* qse.cmn.sll/qse_sll_getsize
* NAME * NAME
* qse_sll_getsize - get the number of nodes * qse_sll_getsize - get the number of nodes

View File

@ -22,7 +22,7 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* qse.cmn.str/string /****o* cmn/string
* DESCRIPTION * DESCRIPTION
* <qse/cmn/str.h> defines various functions, types, macros to manipulate * <qse/cmn/str.h> defines various functions, types, macros to manipulate
* strings. * strings.
@ -31,11 +31,6 @@
* dealing with a string pointer and length. * dealing with a string pointer and length.
* *
* #include <qse/cmn/str.h> * #include <qse/cmn/str.h>
*
* EXAMPLES
* void f (void)
* {
* }
****** ******
*/ */
@ -44,23 +39,26 @@
#define QSE_STR_PTR(s) ((s)->ptr) #define QSE_STR_PTR(s) ((s)->ptr)
#define QSE_STR_CAPA(s) ((s)->capa) #define QSE_STR_CAPA(s) ((s)->capa)
#define QSE_STR_CHAR(s,idx) ((s)->ptr[idx]) #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) #define QSE_STR_SIZER(s) ((s)->sizer)
typedef struct qse_str_t qse_str_t; typedef struct qse_str_t qse_str_t;
typedef qse_size_t (*qse_str_sizer_t) (qse_str_t* data, qse_size_t hint); typedef qse_size_t (*qse_str_sizer_t) (qse_str_t* data, qse_size_t hint);
/****s* cmn/qse_str_t
* NAME
* qse_str_t - define a dynamically resizable string
* SYNOPSIS
*/
struct qse_str_t struct qse_str_t
{ {
qse_mmgr_t* mmgr; QSE_DEFINE_COMMON_FIELDS (str)
qse_str_sizer_t sizer;
qse_str_sizer_t sizer;
qse_char_t* ptr; qse_char_t* ptr;
qse_size_t len; qse_size_t len;
qse_size_t capa; qse_size_t capa;
}; };
/******/
/* int qse_chartonum (qse_char_t c, int base) */ /* int qse_chartonum (qse_char_t c, int base) */
#define QSE_CHARTONUM(c,base) \ #define QSE_CHARTONUM(c,base) \
@ -145,10 +143,9 @@ int qse_strxncmp (
int qse_strcasecmp ( int qse_strcasecmp (
const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls); const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls);
/****f* qse.cmn.str/qse_strxncasecmp /****f* cmn/qse_strxncasecmp
* NAME * NAME
* qse_strxncasecmp - compare strings ignoring case * qse_strxncasecmp - compare strings ignoring case
*
* DESCRIPTION * DESCRIPTION
* The qse_strxncasecmp() function compares characters at the same position * The qse_strxncasecmp() function compares characters at the same position
* in each string after converting them to the same case temporarily. * in each string after converting them to the same case temporarily.
@ -160,14 +157,11 @@ int qse_strcasecmp (
* For two strings to be equal, they need to have the same length and all * 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 * characters in the first string should be equal to their counterpart in the
* second string. * second string.
*
* RETURN * RETURN
* The qse_strxncasecmp() returns 0 if two strings are equal, a positive * 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. * number if the first string is larger, -1 if the second string is larger.
*
* EXAMPLES * EXAMPLES
* qse_strxncasecmp (QSE_T("foo"), 3, QSE_T("FoO"), 3, QSE_CCLS_GETDFL()); * qse_strxncasecmp (QSE_T("foo"), 3, QSE_T("FoO"), 3, QSE_CCLS_GETDFL());
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_strxncasecmp ( int qse_strxncasecmp (
@ -241,6 +235,8 @@ 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_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_ulong_t qse_strxtoulong (const qse_char_t* str, qse_size_t len);
QSE_DEFINE_COMMON_FUNCTIONS (str)
qse_str_t* qse_str_open ( qse_str_t* qse_str_open (
qse_mmgr_t* mmgr, qse_mmgr_t* mmgr,
qse_size_t ext, qse_size_t ext,
@ -264,7 +260,7 @@ void qse_str_fini (
qse_str_t* str qse_str_t* str
); );
/****f* qse.cmn.str/qse_str_yield /****f* cmn/qse_str_yield
* NAME * NAME
* qse_str_yield - yield the buffer * qse_str_yield - yield the buffer
* *
@ -285,46 +281,34 @@ int qse_str_yield (
); );
/******/ /******/
void* qse_str_getxtn ( /****f* cmn/qse_str_getsizer
qse_str_t* str * NAME
); * qse_str_getsizer - get the sizer
* RETURN
qse_mmgr_t* qse_str_getmmgr ( * a sizer function set or QSE_NULL if no sizer is set.
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_sizer_t qse_str_getsizer (
qse_str_t* str /* a dynamic string */ qse_str_t* str
); );
/******/
/* /****f* cmn/qse_str_setsizer
* NAME: specify a sizer * NAME
* * qse_str_setsizer - specify a sizer
* DESCRIPTION: * DESCRIPTION
* The qse_str_setsizer() function specify a new sizer for a dynamic string. * The qse_str_setsizer() function specify a new sizer for a dynamic string.
* With no sizer specified, the dynamic string doubles the current buffer * 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 * 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. * string and the minimum capacity required to hold data after resizing.
* The string is truncated if the sizer function returns a smaller number * The string is truncated if the sizer function returns a smaller number
* than the hint passed. * than the hint passed.
* SYNOPSIS
*/ */
void qse_str_setsizer ( void qse_str_setsizer (
qse_str_t* str /* a dynamic string */, qse_str_t* str,
qse_str_sizer_t sizer /* a sizer function */ qse_str_sizer_t sizer
); );
/******/
/* /*
* NAME: get capacity * NAME: get capacity
@ -396,10 +380,9 @@ qse_size_t qse_str_nccat (
qse_size_t len qse_size_t len
); );
/****f* qse.cmn.str/qse_strspl /****f* cmn/qse_strspl
* NAME * NAME
* qse_strspl - split a string * qse_strspl - split a string
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_strspl ( int qse_strspl (
@ -411,10 +394,9 @@ int qse_strspl (
); );
/******/ /******/
/****f* qse.cmn.str/qse_mbstowcs /****f* cmn/qse_mbstowcs
* NAME * NAME
* qse_mbstowcs - convert a multibyte string to a wide character string * qse_mbstowcs - convert a multibyte string to a wide character string
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_mbstowcs ( qse_size_t qse_mbstowcs (
@ -424,13 +406,11 @@ qse_size_t qse_mbstowcs (
); );
/******/ /******/
/****f* qse.cmn.str/qse_mbsntowcsn /****f* cmn/qse_mbsntowcsn
* NAME * NAME
* qse_mbsntowcsn - convert a multibyte string to a wide character string * qse_mbsntowcsn - convert a multibyte string to a wide character string
*
* RETURN * RETURN
* The qse_mbstowcs() function returns the number of bytes handled. * The qse_mbstowcs() function returns the number of bytes handled.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_mbsntowcsn ( qse_size_t qse_mbsntowcsn (
@ -441,20 +421,17 @@ qse_size_t qse_mbsntowcsn (
); );
/******/ /******/
/****f* qse.cmn.str/qse_wcstombslen /****f* cmn/qse_wcstombslen
* NAME * NAME
* qse_wcstombslen - get the length * qse_wcstombslen - get the length
*
* DESCRIPTION * DESCRIPTION
* The qse_wcstombslen() function scans a null-terminated wide character * The qse_wcstombslen() function scans a null-terminated wide character
* string to get the total number of multibyte characters that it can be * string to get the total number of multibyte characters that it can be
* converted to. The resulting number of characters is stored into memory * converted to. The resulting number of characters is stored into memory
* pointed to by mbslen. * pointed to by mbslen.
*
* RETURN * RETURN
* The qse_wcstombslen() function returns the number of wide characters * The qse_wcstombslen() function returns the number of wide characters
* handled. * handled.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_wcstombslen ( qse_size_t qse_wcstombslen (
@ -463,20 +440,17 @@ qse_size_t qse_wcstombslen (
); );
/******/ /******/
/****f* qse.cmn.str/qse_wcsntombsnlen /****f* cmn/qse_wcsntombsnlen
* NAME * NAME
* qse_wcsntombsnlen - get the length * qse_wcsntombsnlen - get the length
*
* DESCRIPTION * DESCRIPTION
* The qse_wcsntombsnlen() function scans a wide character wcs as long as * The qse_wcsntombsnlen() function scans a wide character wcs as long as
* wcslen characters to get the get the total number of multibyte characters * wcslen characters to get the get the total number of multibyte characters
* that it can be converted to. The resulting number of characters is stored * that it can be converted to. The resulting number of characters is stored
* into memory pointed to by mbslen. * into memory pointed to by mbslen.
*
* RETURN * RETURN
* The qse_wcsntombsnlen() function returns the number of wide characters * The qse_wcsntombsnlen() function returns the number of wide characters
* handled. * handled.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_wcsntombsnlen ( qse_size_t qse_wcsntombsnlen (
@ -486,10 +460,9 @@ qse_size_t qse_wcsntombsnlen (
); );
/******/ /******/
/****f* qse.cmn.str/qse_wcstombs /****f* cmn/qse_wcstombs
* NAME * NAME
* qse_wcstombs - convert a wide character string to a multibyte string. * qse_wcstombs - convert a wide character string to a multibyte string.
*
* DESCRIPTION * DESCRIPTION
* The qse_wcstombs() function converts a null-terminated wide character * The qse_wcstombs() function converts a null-terminated wide character
* string to a multibyte string and stores it into the buffer pointed to * string to a multibyte string and stores it into the buffer pointed to
@ -499,10 +472,8 @@ qse_size_t qse_wcsntombsnlen (
* It may not null-terminate the resulting multibyte string if the buffer * It may not null-terminate the resulting multibyte string if the buffer
* is not large enough. You can check if the resulting mbslen is equal to * is not large enough. You can check if the resulting mbslen is equal to
* the input mbslen to know it. * the input mbslen to know it.
*
* RETURN * RETURN
* The qse_wcstombs() function returns the number of wide characters handled. * The qse_wcstombs() function returns the number of wide characters handled.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_wcstombs ( qse_size_t qse_wcstombs (
@ -510,14 +481,13 @@ qse_size_t qse_wcstombs (
qse_mchar_t* mbs, qse_mchar_t* mbs,
qse_size_t* mbslen qse_size_t* mbslen
); );
/******/
/****f* qse.cmn.str/qse_wcsntombsn /****f* cmn/qse_wcsntombsn
* NAME * NAME
* qse_wcstombs - convert a wide character string to a multibyte string * qse_wcstombs - convert a wide character string to a multibyte string
*
* RETURN * RETURN
* The qse_wcstombs() function returns the number of wide characters handled. * The qse_wcstombs() function returns the number of wide characters handled.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_wcsntombsn ( qse_size_t qse_wcsntombsn (
@ -528,15 +498,13 @@ qse_size_t qse_wcsntombsn (
); );
/******/ /******/
/****f* qse.cmn.str/qse_wcstombs_strict /****f* cmn/qse_wcstombs_strict
* NAME * NAME
* qse_wcstombs_strict - convert a wide character string to a multibyte string. * qse_wcstombs_strict - convert a wide character string to a multibyte string.
*
* DESCRIPTION * DESCRIPTION
* The qse_wcstombs_strict() function performs the same as the qse_wcsmbs() * 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 * function except that it returns an error if it can't fully convert the
* input string and/or the buffer is not large enough. * input string and/or the buffer is not large enough.
*
* RETURN * RETURN
* The qse_wcstombs_strict() function returns 0 on success and -1 on failure. * The qse_wcstombs_strict() function returns 0 on success and -1 on failure.
* SYNOPSIS * SYNOPSIS

View File

@ -72,10 +72,9 @@ struct qse_btime_t
extern "C" { extern "C" {
#endif #endif
/****f* qse.cmn/qse_gettime /****f* qse.cmn.time/qse_gettime
* NAME * NAME
* qse_gettime - get the current time * qse_gettime - get the current time
*
* SYNPOSIS * SYNPOSIS
*/ */
int qse_gettime ( int qse_gettime (
@ -83,10 +82,9 @@ int qse_gettime (
); );
/******/ /******/
/****f* qse.cmn/qse_settime /****f* qse.cmn.time/qse_settime
* NAME * NAME
* qse_settime - set the current time * qse_settime - set the current time
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_settime ( int qse_settime (
@ -95,10 +93,9 @@ int qse_settime (
/******/ /******/
/****f* qse.cmn/qse_gmtime /****f* qse.cmn.time/qse_gmtime
* NAME * NAME
* qse_gmtime - convert numeric time to broken-down time * qse_gmtime - convert numeric time to broken-down time
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_gmtime ( int qse_gmtime (
@ -107,10 +104,9 @@ int qse_gmtime (
); );
/******/ /******/
/****f* qse.cmn/qse_localtime /****f* qse.cmn.time/qse_localtime
* NAME * NAME
* qse_localtime - convert numeric time to broken-down time * qse_localtime - convert numeric time to broken-down time
*
* SYNOPSIS * SYNOPSIS
*/ */
int qse_localtime ( int qse_localtime (
@ -119,7 +115,7 @@ int qse_localtime (
); );
/******/ /******/
/****f* qse.cmn/qse_timegm /****f* qse.cmn.time/qse_timegm
* NAME * NAME
* qse_timegm - convert broken-down time to numeric time * qse_timegm - convert broken-down time to numeric time
* *
@ -131,7 +127,7 @@ int qse_timegm (
); );
/******/ /******/
/****f* qse.cmn/qse_timelocal /****f* qse.cmn.time/qse_timelocal
* NAME * NAME
* qse_timelocal - convert broken-down time to numeric time * qse_timelocal - convert broken-down time to numeric time
* *
@ -143,7 +139,7 @@ int qse_timelcoal (
); );
/******/ /******/
/****f* qse.cmn/qse_strftime /****f* qse.cmn.time/qse_strftime
* NAME * NAME
* qse_strftime - format time * qse_strftime - format time
* *

View File

@ -60,32 +60,35 @@ enum
QSE_TIO_IO_DATA 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) #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; typedef struct qse_tio_t qse_tio_t;
/* /****t* cmn/qse_tio_io_t
* TYPE: qse_tio_io_t * NAME
* Defines a user-defines IO handler * qse_tio_io_t - define a text IO handler type
* SYNOPSIS
*/ */
typedef qse_ssize_t (*qse_tio_io_t) ( typedef qse_ssize_t (*qse_tio_io_t) (
int cmd, void* arg, void* data, qse_size_t size); int cmd,
void* arg,
void* data,
qse_size_t size
);
/******/
/****s* cmn/qse_tio_t
* NAME
* qse_tio_t - define a text IO type
* DESCRIPTION
* The qse_tio_t type defines a generic type for text IO. When qse_char_t is
* qse_mchar_t, it handles any byte streams. When qse_char_t is qse_wchar_t,
* it handles a multi-byte stream converted to a wide character stream.
* SYNOPSIS
*/
struct qse_tio_t struct qse_tio_t
{ {
QSE_DEFINE_STD_FIELDS (tio) QSE_DEFINE_COMMON_FIELDS (tio)
qse_tio_err_t errnum; qse_tio_err_t errnum;
/* io functions */ /* io functions */
@ -103,38 +106,57 @@ struct qse_tio_t
qse_mchar_t inbuf[QSE_TIO_MAX_INBUF_LEN]; qse_mchar_t inbuf[QSE_TIO_MAX_INBUF_LEN];
qse_mchar_t outbuf[QSE_TIO_MAX_OUTBUF_LEN]; qse_mchar_t outbuf[QSE_TIO_MAX_OUTBUF_LEN];
}; };
/******/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
QSE_DEFINE_STD_FUNCTIONS (tio) QSE_DEFINE_COMMON_FUNCTIONS (tio)
/* /****f* cmn/qse_tio_open
* FUNCTION: qse_tio_open * NAME
* qse_tio_open - create an text IO processor
* SYNOPSIS
*/ */
qse_tio_t* qse_tio_open ( qse_tio_t* qse_tio_open (
qse_mmgr_t* mmgr, qse_mmgr_t* mmgr,
qse_size_t ext qse_size_t ext
); );
/******/
/* /****f* cmn/qse_tio_close
* FUNCTION: qse_tio_close * NAME
* qse_tio_close - destroy an text IO processor
* SYNOPSIS
*/ */
int qse_tio_close ( int qse_tio_close (
qse_tio_t* tio qse_tio_t* tio
); );
/******/
/****f* cmn/qse_tio_init
* NAME
* qse_tio_init - initialize an text IO processor
* SYNOPSIS
*/
qse_tio_t* qse_tio_init ( qse_tio_t* qse_tio_init (
qse_tio_t* tip, qse_tio_t* tip,
qse_mmgr_t* mmgr qse_mmgr_t* mmgr
); );
/******/
/****f* cmn/qse_tio_fini
* NAME
* qse_tio_fini - finalize an text IO processor
* SYNOPSIS
*/
int qse_tio_fini ( int qse_tio_fini (
qse_tio_t* tio qse_tio_t* tio
); );
/******/
/****f* qse.cmn.tio/qse_tio_geterrnum /****f* cmn/qse_tio_geterrnum
* NAME * NAME
* qse_tio_geterrnum - get an error code * qse_tio_geterrnum - get an error code
* *
@ -145,92 +167,75 @@ qse_tio_err_t qse_tio_geterrnum (
); );
/******/ /******/
/* /****f* cmn/qse_tio_geterrmsg
* FUNCTION: qse_tio_geterrstr * NAME
* Translates an error code to a string * qse_tio_geterrmsg - translate an error code to a string
* * RETURN
* PARAMETERS: * A pointer to a constant string describing the last error occurred.
* tio - a tio object
*
* RETURNS:
* A pointer to a constant string describing the last error occurred
*/ */
const qse_char_t* qse_tio_geterrstr ( const qse_char_t* qse_tio_geterrmsg (
qse_tio_t* tio qse_tio_t* tio
); );
/******/
/* /****f* cmn/qse_tio_attachin
* FUNCTION: qse_tio_attachin * NAME
* Attaches an input handler function * qse_tio_attachin - attaches an input handler
* * RETURN
* 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 * 0 on success, -1 on failure
* SYNOPSIS
*/ */
int qse_tio_attachin ( int qse_tio_attachin (
qse_tio_t* tio, qse_tio_t* tio,
qse_tio_io_t input, qse_tio_io_t input,
void* arg void* arg
); );
/******/
/* /****f* cmn/qse_tio_detachin
* FUNCTION: qse_tio_detachin * NAME
* Detaches an input handler function * qse_tio_detachin - detach an input handler
* * RETURN
* PARAMETERS:
* tio - a tio object
*
* RETURNS:
* 0 on success, -1 on failure * 0 on success, -1 on failure
* SYNOPSIS
*/ */
int qse_tio_detachin ( int qse_tio_detachin (
qse_tio_t* tio qse_tio_t* tio
); );
/******/
/* /****f* cmn/qse_tio_attachout
* FUNCTION: qse_tio_attachout * NAME
* Attaches an output handler function * qse_tio_attachout - attaches an output handler
* * RETURN
* 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 * 0 on success, -1 on failure
* SYNOPSIS
*/ */
int qse_tio_attachout ( int qse_tio_attachout (
qse_tio_t* tio, qse_tio_t* tio,
qse_tio_io_t output, qse_tio_io_t output,
void* arg void* arg
); );
/******/
/* /****f* cmn/qse_tio_detachout
* FUNCTION: qse_tio_detachout * NAME
* Detaches an output handler function * qse_tio_detachout - detaches an output handler
* * RETURN
* PARAMETERS:
* tio - a tio object
*
* RETURNS:
* 0 on success, -1 on failure * 0 on success, -1 on failure
* SYNOPSIS
*/ */
int qse_tio_detachout ( int qse_tio_detachout (
qse_tio_t* tio qse_tio_t* tio
); );
/******/
/****f* qse.cmn.tio/qse_tio_flush /****f* cmn/qse_tio_flush
* NAME * NAME
* qse_tio_flush - flush the output buffer * qse_tio_flush - flush the output buffer
*
* RETURNS * RETURNS
* The qse_tio_flush() function return the number of bytes written on * The qse_tio_flush() function return the number of bytes written on
* success, -1 on failure. * success, -1 on failure.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_ssize_t qse_tio_flush ( qse_ssize_t qse_tio_flush (
@ -238,10 +243,9 @@ qse_ssize_t qse_tio_flush (
); );
/******/ /******/
/****f* qse.cmn.tio/qse_tio_purge /****f* cmn/qse_tio_purge
* NAME * NAME
* qse_tio_purge - erase input and output buffered * qse_tio_purge - empty input and output buffers
*
* SYNOPSIS * SYNOPSIS
*/ */
void qse_tio_purge ( void qse_tio_purge (
@ -249,10 +253,9 @@ void qse_tio_purge (
); );
/******/ /******/
/****f* qse.cmn.tio/qse_tio_read /****f* cmn/qse_tio_read
* NAME * NAME
* qse_tio_read - read text * qse_tio_read - read text
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_ssize_t qse_tio_read ( qse_ssize_t qse_tio_read (
@ -262,14 +265,12 @@ qse_ssize_t qse_tio_read (
); );
/******/ /******/
/****f* qse.cmn.tio/qse_tio_write /****f* cmn/qse_tio_write
* NAME * NAME
* qse_tio_write - write text * qse_tio_write - write text
*
* DESCRIPTION * DESCRIPTION
* If the size paramenter is (qse_size_t)-1, the function treats the data * If the size paramenter is (qse_size_t)-1, the function treats the data
* parameter as a pointer to a null-terminated string. * parameter as a pointer to a null-terminated string.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_ssize_t qse_tio_write ( qse_ssize_t qse_tio_write (

View File

@ -16,7 +16,7 @@
# define QSE_NULL ((void*)0) # define QSE_NULL ((void*)0)
#endif #endif
/****d* ase/QSE_TRUE,QSE_FALSE /****d* qse/QSE_TRUE,qse/QSE_FALSE
* NAME * NAME
* QSE_TRUE - represent a boolean true * QSE_TRUE - represent a boolean true
* QSE_FALSE - represent a boolean false * QSE_FALSE - represent a boolean false
@ -26,7 +26,7 @@
#define QSE_FALSE (0 != 0) #define QSE_FALSE (0 != 0)
/****d* ase/QSE_ALIVE,QSE_ZOMBIE,QSE_DEAD /****d* qse/QSE_ALIVE,qse/QSE_ZOMBIE,qse/QSE_DEAD
* NAME * NAME
* QSE_ALIVE - represent a living state * QSE_ALIVE - represent a living state
* QSE_ZOMBIE - represent a zombie state * QSE_ZOMBIE - represent a zombie state
@ -38,8 +38,8 @@
#define QSE_DEAD -1 #define QSE_DEAD -1
#define AES_MCHAR_EOF ((qse_mcint_t)-1) #define QSE_MCHAR_EOF ((qse_mcint_t)-1)
#define AES_WCHAR_EOF ((qse_wcint_t)-1) #define QSE_WCHAR_EOF ((qse_wcint_t)-1)
#define QSE_CHAR_EOF ((qse_cint_t)-1) #define QSE_CHAR_EOF ((qse_cint_t)-1)
#define QSE_SIZEOF(n) (sizeof(n)) #define QSE_SIZEOF(n) (sizeof(n))
@ -157,15 +157,32 @@
# define QSE_END_NAMESPACE2(y,x) }} # define QSE_END_NAMESPACE2(y,x) }}
#endif #endif
#define QSE_DEFINE_STD_FIELDS(name) \ /****d* qse/QSE_DEFINE_COMMON_FIELDS
* NAME
* QSE_DEFINE_COMMON_FIELDS - define common fields
* SYNOPSIS
*/
#define QSE_DEFINE_COMMON_FIELDS(name) \
qse_mmgr_t* mmgr; qse_mmgr_t* mmgr;
/******/
#define QSE_DEFINE_STD_FUNCTIONS(name) \ /****d* qse/QSE_DEFINE_COMMON_FUNCTIONS
* NAME
* QSE_DEFINE_COMMON_FUNCTIONS - define common functions
* SYNOPSIS
*/
#define QSE_DEFINE_COMMON_FUNCTIONS(name) \
void qse_##name##_setmmgr (qse_##name##_t* name, qse_mmgr_t* mmgr); \ void qse_##name##_setmmgr (qse_##name##_t* name, qse_mmgr_t* mmgr); \
qse_mmgr_t* qse_##name##_getmmgr (qse_##name##_t* name); \ qse_mmgr_t* qse_##name##_getmmgr (qse_##name##_t* name); \
void* qse_##name##_getxtn (qse_##name##_t* name); void* qse_##name##_getxtn (qse_##name##_t* name);
/******/
#define QSE_IMPLEMENT_STD_FUNCTIONS(name) \ /****d* qse/QSE_IMPLEMENT_COMMON_FUNCTIONS
* NAME
* QSE_IMPLEMENT_COMMON_FUNCTIONS - implement common functions
* SYNOPSIS
*/
#define QSE_IMPLEMENT_COMMON_FUNCTIONS(name) \
void qse_##name##_setmmgr (qse_##name##_t* name, qse_mmgr_t* mmgr) \ void qse_##name##_setmmgr (qse_##name##_t* name, qse_mmgr_t* mmgr) \
{ \ { \
name->mmgr = mmgr; \ name->mmgr = mmgr; \
@ -178,5 +195,6 @@ void* qse_##name##_getxtn (qse_##name##_t* name) \
{ \ { \
return (void*)(name + 1); \ return (void*)(name + 1); \
} }
/******/
#endif #endif

View File

@ -7,7 +7,7 @@
#ifndef _QSE_TYPES_H_ #ifndef _QSE_TYPES_H_
#define _QSE_TYPES_H_ #define _QSE_TYPES_H_
/****o* ase/basic types /****o* qse/basic types
* DESCRIPTION * DESCRIPTION
* <qse/types.h> defines various common basic types. They are designed to be * <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 * cross-platform. These types are preferred over native data types in many
@ -30,7 +30,7 @@
# error unsupported operating system # error unsupported operating system
#endif #endif
/****t* ase/qse_bool_t /****t* qse/qse_bool_t
* NAME * NAME
* qse_bool_t - define a boolean type * qse_bool_t - define a boolean type
* DESCRIPTION * DESCRIPTION
@ -40,7 +40,7 @@
*/ */
typedef int qse_bool_t; typedef int qse_bool_t;
/****t* ase/qse_tri_t /****t* qse/qse_tri_t
* NAME * NAME
* qse_tri_t - define a tri-state type * qse_tri_t - define a tri-state type
* DESCRIPTION * DESCRIPTION
@ -50,7 +50,7 @@ typedef int qse_bool_t;
*/ */
typedef int qse_tri_t; typedef int qse_tri_t;
/****t* ase/qse_int_t,qse_uint_t /****t* qse/qse_int_t,qse/qse_uint_t
* NAME * NAME
* qse_int_t - define a signed integer type as large as a pointer type * 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 * qse_uint_t - define an unsigned integer type as large as a pointer type
@ -82,7 +82,7 @@ typedef int qse_tri_t;
# error unsupported pointer size # error unsupported pointer size
#endif #endif
/****t* ase/qse_long_t,qse_ulong_t /****t* qse/qse_long_t,qse/qse_ulong_t
* NAME * NAME
* qse_long_t - define the largest signed integer type supported * qse_long_t - define the largest signed integer type supported
* qse_ulong_t - define the largest unsigned integer type supported * qse_ulong_t - define the largest unsigned integer type supported
@ -99,7 +99,7 @@ typedef int qse_tri_t;
typedef unsigned long qse_ulong_t; typedef unsigned long qse_ulong_t;
#endif #endif
/****t* ase/qse_int8_t,qse_uint8_t /****t* qse/qse_int8_t,qse/qse_uint8_t
* NAME * NAME
* qse_int8_t - define an 8-bit signed integer type * qse_int8_t - define an 8-bit signed integer type
* qse_uint8_t - define an 8-bit unsigned integer type * qse_uint8_t - define an 8-bit unsigned integer type
@ -113,7 +113,7 @@ typedef int qse_tri_t;
typedef unsigned __int8 qse_uint8_t; typedef unsigned __int8 qse_uint8_t;
#endif #endif
/****t* ase/qse_int16_t,qse_uint16_t /****t* qse/qse_int16_t,qse/qse_uint16_t
* NAME * NAME
* qse_int16_t - define a 16-bit signed integer type * qse_int16_t - define a 16-bit signed integer type
* qse_uint16_t - define a 16-bit unsigned integer type * qse_uint16_t - define a 16-bit unsigned integer type
@ -127,7 +127,7 @@ typedef int qse_tri_t;
typedef unsigned __int16 qse_uint16_t; typedef unsigned __int16 qse_uint16_t;
#endif #endif
/****t* ase/qse_int32_t,qse_uint32_t /****t* qse/qse_int32_t,qse/qse_uint32_t
* NAME * NAME
* qse_int32_t - define a 32-bit signed integer type * qse_int32_t - define a 32-bit signed integer type
* qse_uint32_t - define a 32-bit unsigned integer type * qse_uint32_t - define a 32-bit unsigned integer type
@ -144,7 +144,7 @@ typedef int qse_tri_t;
typedef unsigned __int32 qse_uint32_t; typedef unsigned __int32 qse_uint32_t;
#endif #endif
/****t* ase/qse_int64_t,qse_uint64_t /****t* qse/qse_int64_t,qse/qse_uint64_t
* NAME * NAME
* qse_int64_t - define a 64-bit signed integer type * qse_int64_t - define a 64-bit signed integer type
* qse_uint64_t - define a 64-bit unsigned integer type * qse_uint64_t - define a 64-bit unsigned integer type
@ -194,14 +194,14 @@ typedef int qse_tri_t;
typedef unsigned __int128 qse_uint128_t; typedef unsigned __int128 qse_uint128_t;
#endif #endif
/****t* ase/qse_byte_t /****t* qse/qse_byte_t
* NAME * NAME
* qse_byte_t - define a byte type * qse_byte_t - define a byte type
****** ******
*/ */
typedef qse_uint8_t qse_byte_t; typedef qse_uint8_t qse_byte_t;
/****t* ase/qse_size_t /****t* qse/qse_size_t
* NAME * NAME
* qse_size_t - define an unsigned integer type that can hold a pointer value * qse_size_t - define an unsigned integer type that can hold a pointer value
****** ******
@ -212,14 +212,14 @@ typedef qse_uint8_t qse_byte_t;
typedef qse_uint_t qse_size_t; typedef qse_uint_t qse_size_t;
#endif #endif
/****t* ase/qse_ssize_t /****t* qse/qse_ssize_t
* NAME * NAME
* qse_ssize_t - define an signed integer type that can hold a pointer value * qse_ssize_t - define an signed integer type that can hold a pointer value
****** ******
*/ */
typedef qse_int_t qse_ssize_t; typedef qse_int_t qse_ssize_t;
/****t* ase/qse_word_t /****t* qse/qse_word_t
* NAME * NAME
* qse_word_t - define an integer type identical to qse_uint_t * qse_word_t - define an integer type identical to qse_uint_t
****** ******
@ -240,7 +240,7 @@ typedef qse_uint_t qse_word_t;
typedef double qse_real_t; typedef double qse_real_t;
#endif #endif
/****t* ase/qse_mchar_t,qse_mcint_t /****t* qse/qse_mchar_t,qse/qse_mcint_t
* NAME * NAME
* qse_mchar_t - define a multi-byte character * qse_mchar_t - define a multi-byte character
* qse_mcint_t - define a type that can hold qse_mchar_t and QSE_MCHAR_EOF * qse_mcint_t - define a type that can hold qse_mchar_t and QSE_MCHAR_EOF
@ -249,7 +249,7 @@ typedef qse_uint_t qse_word_t;
typedef char qse_mchar_t; typedef char qse_mchar_t;
typedef int qse_mcint_t; typedef int qse_mcint_t;
/****t* ase/qse_wchar_t,qse_wcint_t /****t* qse/qse_wchar_t,qse/qse_wcint_t
* NAME * NAME
* qse_wchar_t - define a wide character * qse_wchar_t - define a wide character
* qse_wcint_t - define a type that can hold qse_wchar_t and QSE_WCHAR_EOF * qse_wcint_t - define a type that can hold qse_wchar_t and QSE_WCHAR_EOF
@ -308,7 +308,7 @@ typedef int qse_mcint_t;
# error unsupported size of wchar_t # error unsupported size of wchar_t
#endif #endif
/****t* ase/qse_char_t,qse_cint_t /****t* qse/qse_char_t,qse/qse_cint_t
* NAME * NAME
* qse_char_t - define a character * qse_char_t - define a character
* qse_cint_t - define a type that can hold qse_char_t and QSE_CHAR_EOF * qse_cint_t - define a type that can hold qse_char_t and QSE_CHAR_EOF
@ -350,10 +350,9 @@ typedef struct qse_cstr_t qse_cstr_t;
typedef struct qse_mmgr_t qse_mmgr_t; typedef struct qse_mmgr_t qse_mmgr_t;
typedef struct qse_ccls_t qse_ccls_t; typedef struct qse_ccls_t qse_ccls_t;
/****t* ase/qse_xstr_t /****t* qse/qse_xstr_t
* NAME * NAME
* qse_xstr_t - combine a pointer and length * qse_xstr_t - combine a pointer and length
*
* SYNOPSIS * SYNOPSIS
*/ */
struct qse_xstr_t struct qse_xstr_t
@ -363,10 +362,9 @@ struct qse_xstr_t
}; };
/******/ /******/
/****t* ase/qse_cstr_t /****t* qse/qse_cstr_t
* NAME * NAME
* qse_cstr_t - combine a constant pointer and length * qse_cstr_t - combine a constant pointer and length
*
* SYNOPSIS * SYNOPSIS
*/ */
struct qse_cstr_t struct qse_cstr_t
@ -376,10 +374,9 @@ struct qse_cstr_t
}; };
/******/ /******/
/****t* ase/qse_mmgr_t /****t* qse/qse_mmgr_t
* NAME * NAME
* qse_mmgr_t - define a memory manager * qse_mmgr_t - define a memory manager
*
* SYNOPSIS * SYNOPSIS
*/ */
struct qse_mmgr_t struct qse_mmgr_t
@ -391,10 +388,9 @@ struct qse_mmgr_t
}; };
/******/ /******/
/****t* ase/qse_ccls_type_t /****t* qse/qse_ccls_type_t
* NAME * NAME
* qse_ccls_type_t - define character class types * qse_ccls_type_t - define character class types
*
* SYNOPSIS * SYNOPSIS
*/ */
enum qse_ccls_type_t enum qse_ccls_type_t
@ -415,10 +411,9 @@ enum qse_ccls_type_t
typedef enum qse_ccls_type_t qse_ccls_type_t; typedef enum qse_ccls_type_t qse_ccls_type_t;
/****t* ase/qse_ccls_t /****t* qse/qse_ccls_t
* NAME * NAME
* qse_mmgr_t - define a character class handler * qse_mmgr_t - define a character classifier
*
* SYNOPSIS * SYNOPSIS
*/ */
struct qse_ccls_t struct qse_ccls_t

View File

@ -92,7 +92,7 @@ Awk::EIO::operator Awk::eio_t* () const
Awk::EIO::operator Awk::run_t* () const Awk::EIO::operator Awk::run_t* () const
{ {
return eio->run; return eio->rtx;
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
@ -142,12 +142,12 @@ int Awk::Console::setFileName (const char_t* name)
if (eio->mode == READ) if (eio->mode == READ)
{ {
return qse_awk_rtx_setfilename ( return qse_awk_rtx_setfilename (
eio->run, name, qse_strlen(name)); eio->rtx, name, qse_strlen(name));
} }
else else
{ {
return qse_awk_rtx_setofilename ( return qse_awk_rtx_setofilename (
eio->run, name, qse_strlen(name)); eio->rtx, name, qse_strlen(name));
} }
} }
@ -156,12 +156,12 @@ int Awk::Console::setFNR (long_t fnr)
qse_awk_val_t* tmp; qse_awk_val_t* tmp;
int n; int n;
tmp = qse_awk_rtx_makeintval (eio->run, fnr); tmp = qse_awk_rtx_makeintval (eio->rtx, fnr);
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_rtx_refupval (eio->run, tmp); qse_awk_rtx_refupval (eio->rtx, tmp);
n = qse_awk_rtx_setglobal (eio->run, QSE_AWK_GLOBAL_FNR, tmp); n = qse_awk_rtx_setglobal (eio->rtx, QSE_AWK_GLOBAL_FNR, tmp);
qse_awk_rtx_refdownval (eio->run, tmp); qse_awk_rtx_refdownval (eio->rtx, tmp);
return n; return n;
} }
@ -1204,7 +1204,7 @@ int Awk::open ()
return -1; return -1;
} }
*(Awk**)QSE_MAP_XTN(functionMap) = this; *(Awk**)qse_map_getxtn(functionMap) = this;
qse_map_setcopier (functionMap, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (functionMap, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (functionMap, QSE_MAP_VAL, freeFunctionMapValue); qse_map_setfreeer (functionMap, QSE_MAP_VAL, freeFunctionMapValue);
qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
@ -1402,7 +1402,7 @@ int Awk::run (const char_t* main, const char_t** args, size_t nargs)
void Awk::stop () void Awk::stop ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
qse_awk_rtx_stopall (awk); qse_awk_stopall (awk);
} }
int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
@ -1717,7 +1717,7 @@ int Awk::functionHandler (
void Awk::freeFunctionMapValue (map_t* map, void* dptr, size_t dlen) void Awk::freeFunctionMapValue (map_t* map, void* dptr, size_t dlen)
{ {
//Awk* awk = (Awk*)owner; //Awk* awk = (Awk*)owner;
Awk* awk = *(Awk**)QSE_MAP_XTN(map); Awk* awk = *(Awk**)qse_map_getxtn(map);
qse_awk_free (awk->awk, dptr); qse_awk_free (awk->awk, dptr);
} }

View File

@ -35,7 +35,7 @@
static void free_fun (qse_map_t* map, void* vptr, qse_size_t vlen) static void free_fun (qse_map_t* map, void* vptr, qse_size_t vlen)
{ {
qse_awk_t* awk = *(qse_awk_t**)QSE_MAP_XTN(map); qse_awk_t* awk = *(qse_awk_t**)qse_map_getxtn(map);
qse_awk_fun_t* f = (qse_awk_fun_t*)vptr; qse_awk_fun_t* f = (qse_awk_fun_t*)vptr;
/* f->name doesn't have to be freed */ /* f->name doesn't have to be freed */
@ -47,7 +47,7 @@ static void free_fun (qse_map_t* map, void* vptr, qse_size_t vlen)
static void free_fnc (qse_map_t* map, void* vptr, qse_size_t vlen) static void free_fnc (qse_map_t* map, void* vptr, qse_size_t vlen)
{ {
qse_awk_t* awk = *(qse_awk_t**)QSE_MAP_XTN(map); qse_awk_t* awk = *(qse_awk_t**)qse_map_getxtn(map);
qse_awk_fnc_t* f = (qse_awk_fnc_t*)vptr; qse_awk_fnc_t* f = (qse_awk_fnc_t*)vptr;
QSE_AWK_FREE (awk, f); QSE_AWK_FREE (awk, f);
@ -78,7 +78,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->wtab = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70); awk->wtab = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70);
if (awk->wtab == QSE_NULL) goto oops; if (awk->wtab == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->wtab) = awk; *(qse_awk_t**)qse_map_getxtn(awk->wtab) = awk;
qse_map_setcopier (awk->wtab, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->wtab, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setcopier (awk->wtab, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->wtab, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE);
qse_map_setscale (awk->wtab, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->wtab, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
@ -86,7 +86,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->rwtab = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70); awk->rwtab = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70);
if (awk->rwtab == QSE_NULL) goto oops; if (awk->rwtab == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->rwtab) = awk; *(qse_awk_t**)qse_map_getxtn(awk->rwtab) = awk;
qse_map_setcopier (awk->rwtab, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->rwtab, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setcopier (awk->rwtab, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->rwtab, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE);
qse_map_setscale (awk->rwtab, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->rwtab, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
@ -95,21 +95,21 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
/* TODO: initial map size?? */ /* TODO: initial map size?? */
awk->tree.funs = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70); awk->tree.funs = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70);
if (awk->tree.funs == QSE_NULL) goto oops; if (awk->tree.funs == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->tree.funs) = awk; *(qse_awk_t**)qse_map_getxtn(awk->tree.funs) = awk;
qse_map_setcopier (awk->tree.funs, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->tree.funs, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (awk->tree.funs, QSE_MAP_VAL, free_fun); qse_map_setfreeer (awk->tree.funs, QSE_MAP_VAL, free_fun);
qse_map_setscale (awk->tree.funs, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->tree.funs, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
awk->parse.funs = qse_map_open (mmgr, QSE_SIZEOF(awk), 256, 70); awk->parse.funs = qse_map_open (mmgr, QSE_SIZEOF(awk), 256, 70);
if (awk->parse.funs == QSE_NULL) goto oops; if (awk->parse.funs == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->parse.funs) = awk; *(qse_awk_t**)qse_map_getxtn(awk->parse.funs) = awk;
qse_map_setcopier (awk->parse.funs, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->parse.funs, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setcopier (awk->parse.funs, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->parse.funs, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE);
qse_map_setscale (awk->parse.funs, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->parse.funs, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
awk->parse.named = qse_map_open (mmgr, QSE_SIZEOF(awk), 256, 70); awk->parse.named = qse_map_open (mmgr, QSE_SIZEOF(awk), 256, 70);
if (awk->parse.named == QSE_NULL) goto oops; if (awk->parse.named == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->parse.named) = awk; *(qse_awk_t**)qse_map_getxtn(awk->parse.named) = awk;
qse_map_setcopier (awk->parse.named, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->parse.named, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setcopier (awk->parse.named, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->parse.named, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE);
qse_map_setscale (awk->parse.named, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->parse.named, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
@ -122,15 +122,15 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->parse.locals == QSE_NULL || awk->parse.locals == QSE_NULL ||
awk->parse.params == QSE_NULL) goto oops; awk->parse.params == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_LDA_XTN(awk->parse.globals) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.globals) = awk;
qse_lda_setcopier (awk->parse.globals, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.globals, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.globals, QSE_SIZEOF(qse_char_t)); qse_lda_setscale (awk->parse.globals, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)QSE_LDA_XTN(awk->parse.locals) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.locals) = awk;
qse_lda_setcopier (awk->parse.locals, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.locals, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.locals, QSE_SIZEOF(qse_char_t)); qse_lda_setscale (awk->parse.locals, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)QSE_LDA_XTN(awk->parse.params) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.params) = awk;
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t)); qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t));
@ -168,7 +168,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->fnc.sys = QSE_NULL; awk->fnc.sys = QSE_NULL;
awk->fnc.user = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70); awk->fnc.user = qse_map_open (mmgr, QSE_SIZEOF(awk), 512, 70);
if (awk->fnc.user == QSE_NULL) goto oops; if (awk->fnc.user == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_MAP_XTN(awk->fnc.user) = awk; *(qse_awk_t**)qse_map_getxtn(awk->fnc.user) = awk;
qse_map_setcopier (awk->fnc.user, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->fnc.user, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (awk->fnc.user, QSE_MAP_VAL, free_fnc); qse_map_setfreeer (awk->fnc.user, QSE_MAP_VAL, free_fnc);
qse_map_setscale (awk->fnc.user, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->fnc.user, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
@ -366,7 +366,7 @@ void qse_awk_setoption (qse_awk_t* awk, int opt)
} }
void qse_awk_rtx_stopall (qse_awk_t* awk) void qse_awk_stopall (qse_awk_t* awk)
{ {
awk->stopall = QSE_TRUE; awk->stopall = QSE_TRUE;
} }
@ -448,7 +448,8 @@ int qse_awk_setword (qse_awk_t* awk,
return 0; return 0;
} }
/* TODO: XXXX */ #if 0
/* TODO: qse_awk_setrexfns... */
int qse_awk_setrexfns (qse_awk_t* awk, qse_awk_rexfns_t* rexfns) int qse_awk_setrexfns (qse_awk_t* awk, qse_awk_rexfns_t* rexfns)
{ {
if (rexfns->build == QSE_NULL || if (rexfns->build == QSE_NULL ||
@ -463,3 +464,4 @@ int qse_awk_setrexfns (qse_awk_t* awk, qse_awk_rexfns_t* rexfns)
awk->rexfns = rexfns; awk->rexfns = rexfns;
return 0; return 0;
} }
#endif

View File

@ -1445,7 +1445,7 @@ struct check_global_t
static qse_lda_walk_t check_global (qse_lda_t* lda, qse_size_t index, void* arg) static qse_lda_walk_t check_global (qse_lda_t* lda, qse_size_t index, void* arg)
{ {
qse_cstr_t tmp; qse_cstr_t tmp;
qse_awk_t* awk = *(qse_awk_t**)QSE_LDA_XTN(lda); qse_awk_t* awk = *(qse_awk_t**)qse_lda_getxtn(lda);
check_global_t* cg = (check_global_t*)arg; check_global_t* cg = (check_global_t*)arg;
tmp.ptr = QSE_LDA_DPTR(lda,index); tmp.ptr = QSE_LDA_DPTR(lda,index);

View File

@ -740,13 +740,13 @@ qse_bool_t qse_awk_rtx_shouldstop (qse_awk_rtx_t* run)
static void free_namedval (qse_map_t* map, void* dptr, qse_size_t dlen) static void free_namedval (qse_map_t* map, void* dptr, qse_size_t dlen)
{ {
qse_awk_rtx_refdownval ( qse_awk_rtx_refdownval (
*(qse_awk_rtx_t**)QSE_MAP_XTN(map), dptr); *(qse_awk_rtx_t**)qse_map_getxtn(map), dptr);
} }
static void same_namedval (qse_map_t* map, void* dptr, qse_size_t dlen) static void same_namedval (qse_map_t* map, void* dptr, qse_size_t dlen)
{ {
qse_awk_rtx_refdownval_nofree ( qse_awk_rtx_refdownval_nofree (
*(qse_awk_rtx_t**)QSE_MAP_XTN(map), dptr); *(qse_awk_rtx_t**)qse_map_getxtn(map), dptr);
} }
static int init_run ( static int init_run (
@ -813,7 +813,7 @@ static int init_run (
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL, 0); qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL, 0);
return -1; return -1;
} }
*(qse_awk_rtx_t**)QSE_MAP_XTN(run->named) = run; *(qse_awk_rtx_t**)qse_map_getxtn(run->named) = run;
qse_map_setcopier (run->named, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (run->named, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (run->named, QSE_MAP_VAL, free_namedval); qse_map_setfreeer (run->named, QSE_MAP_VAL, free_namedval);
qse_map_setkeeper (run->named, same_namedval); qse_map_setkeeper (run->named, same_namedval);

View File

@ -445,7 +445,7 @@ static void same_mapval (void* run, void* v)
*/ */
static void free_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) static void free_mapval (qse_map_t* map, void* dptr, qse_size_t dlen)
{ {
qse_awk_rtx_t* run = *(qse_awk_rtx_t**)QSE_MAP_XTN(map); qse_awk_rtx_t* run = *(qse_awk_rtx_t**)qse_map_getxtn(map);
#ifdef DEBUG_VAL #ifdef DEBUG_VAL
qse_dprintf (QSE_T("refdown in map free...")); qse_dprintf (QSE_T("refdown in map free..."));
@ -458,7 +458,7 @@ static void free_mapval (qse_map_t* map, void* dptr, qse_size_t dlen)
static void same_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) static void same_mapval (qse_map_t* map, void* dptr, qse_size_t dlen)
{ {
qse_awk_rtx_t* run = *(qse_awk_rtx_t**)QSE_MAP_XTN(map); qse_awk_rtx_t* run = *(qse_awk_rtx_t**)qse_map_getxtn(map);
#ifdef DEBUG_VAL #ifdef DEBUG_VAL
qse_dprintf (QSE_T("refdown nofree in map free...")); qse_dprintf (QSE_T("refdown nofree in map free..."));
qse_awk_dprintval (run, dptr); qse_awk_dprintval (run, dptr);
@ -516,7 +516,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM); qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
return QSE_NULL; return QSE_NULL;
} }
*(qse_awk_rtx_t**)QSE_MAP_XTN(val->map) = run; *(qse_awk_rtx_t**)qse_map_getxtn(val->map) = run;
/* the key is copied inline into a pair and is freed when the pair /* the key is copied inline into a pair and is freed when the pair
* is destroyed */ * is destroyed */
@ -1156,7 +1156,7 @@ static qse_map_walk_t print_pair (
{ {
qse_awk_rtx_t* run = (qse_awk_rtx_t*)arg; qse_awk_rtx_t* run = (qse_awk_rtx_t*)arg;
QSE_ASSERT (run == *(qse_awk_rtx_t**)QSE_MAP_XTN(map)); QSE_ASSERT (run == *(qse_awk_rtx_t**)qse_map_getxtn(map));
DPRINTF (DCUSTOM, QSE_T(" %.*s=>"), DPRINTF (DCUSTOM, QSE_T(" %.*s=>"),
(int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair)); (int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair));

View File

@ -31,7 +31,7 @@
# include <limits.h> # include <limits.h>
#endif #endif
QSE_IMPLEMENT_STD_FUNCTIONS (fio) QSE_IMPLEMENT_COMMON_FUNCTIONS (fio)
static qse_ssize_t fio_input (int cmd, void* arg, void* buf, qse_size_t size); static qse_ssize_t fio_input (int cmd, void* arg, void* buf, qse_size_t size);
static qse_ssize_t fio_output (int cmd, void* arg, void* buf, qse_size_t size); static qse_ssize_t fio_output (int cmd, void* arg, void* buf, qse_size_t size);

View File

@ -19,6 +19,8 @@
#include <qse/cmn/lda.h> #include <qse/cmn/lda.h>
#include "mem.h" #include "mem.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (lda)
#define lda_t qse_lda_t #define lda_t qse_lda_t
#define node_t qse_lda_node_t #define node_t qse_lda_node_t
#define copier_t qse_lda_copier_t #define copier_t qse_lda_copier_t
@ -150,21 +152,6 @@ void qse_lda_fini (lda_t* lda)
} }
} }
void* qse_lda_getxtn (lda_t* lda)
{
return lda + 1;
}
mmgr_t* qse_lda_getmmgr (lda_t* lda)
{
return lda->mmgr;
}
void qse_lda_setmmgr (lda_t* lda, mmgr_t* mmgr)
{
lda->mmgr = mmgr;
}
int qse_lda_getscale (lda_t* lda) int qse_lda_getscale (lda_t* lda)
{ {
return lda->scale; return lda->scale;

View File

@ -19,6 +19,8 @@
#include <qse/cmn/map.h> #include <qse/cmn/map.h>
#include "mem.h" #include "mem.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (map)
#define map_t qse_map_t #define map_t qse_map_t
#define pair_t qse_map_pair_t #define pair_t qse_map_pair_t
#define copier_t qse_map_copier_t #define copier_t qse_map_copier_t
@ -286,21 +288,6 @@ void qse_map_fini (map_t* map)
QSE_MMGR_FREE (map->mmgr, map->bucket); QSE_MMGR_FREE (map->mmgr, map->bucket);
} }
void* qse_map_getxtn (map_t* map)
{
return map + 1;
}
mmgr_t* qse_map_getmmgr (map_t* map)
{
return map->mmgr;
}
void qse_map_setmmgr (map_t* map, mmgr_t* mmgr)
{
map->mmgr = mmgr;
}
int qse_map_getscale (map_t* map, qse_map_id_t id) int qse_map_getscale (map_t* map, qse_map_id_t id)
{ {
QSE_ASSERTX (id == QSE_MAP_KEY || id == QSE_MAP_VAL, QSE_ASSERTX (id == QSE_MAP_KEY || id == QSE_MAP_VAL,
@ -424,7 +411,7 @@ pair_t* qse_map_search (map_t* map, const void* kptr, size_t klen)
return QSE_NULL; return QSE_NULL;
} }
int qse_map_put ( static int map_put (
map_t* map, void* kptr, size_t klen, map_t* map, void* kptr, size_t klen,
void* vptr, size_t vlen, pair_t** px) void* vptr, size_t vlen, pair_t** px)
{ {
@ -487,7 +474,7 @@ pair_t* qse_map_upsert (
int n; int n;
pair_t* px; pair_t* px;
n = qse_map_put (map, kptr, klen, vptr, vlen, &px); n = map_put (map, kptr, klen, vptr, vlen, &px);
if (n < 0) return QSE_NULL; if (n < 0) return QSE_NULL;
return px; return px;
} }

View File

@ -29,7 +29,7 @@
# include <sys/wait.h> # include <sys/wait.h>
#endif #endif
QSE_IMPLEMENT_STD_FUNCTIONS (pio) QSE_IMPLEMENT_COMMON_FUNCTIONS (pio)
static qse_ssize_t pio_input (int cmd, void* arg, void* buf, qse_size_t size); static qse_ssize_t pio_input (int cmd, void* arg, void* buf, qse_size_t size);
static qse_ssize_t pio_output (int cmd, void* arg, void* buf, qse_size_t size); static qse_ssize_t pio_output (int cmd, void* arg, void* buf, qse_size_t size);
@ -420,6 +420,8 @@ qse_pio_err_t qse_pio_geterrnum (qse_pio_t* pio)
return pio->errnum; return pio->errnum;
} }
/* TODO: qse_pio_geterrmsg (qse_pio_t* pio) */
const qse_char_t* qse_pio_geterrstr (qse_pio_t* pio) const qse_char_t* qse_pio_geterrstr (qse_pio_t* pio)
{ {
static const qse_char_t* __errstr[] = static const qse_char_t* __errstr[] =

View File

@ -19,6 +19,8 @@
#include <qse/cmn/sll.h> #include <qse/cmn/sll.h>
#include "mem.h" #include "mem.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (sll)
#define sll_t qse_sll_t #define sll_t qse_sll_t
#define node_t qse_sll_node_t #define node_t qse_sll_node_t
#define copier_t qse_sll_copier_t #define copier_t qse_sll_copier_t
@ -137,21 +139,6 @@ void qse_sll_fini (sll_t* sll)
qse_sll_clear (sll); qse_sll_clear (sll);
} }
void* qse_sll_getxtn (sll_t* sll)
{
return sll + 1;
}
mmgr_t* qse_sll_getmmgr (sll_t* sll)
{
return sll->mmgr;
}
void qse_sll_setmmgr (sll_t* sll, mmgr_t* mmgr)
{
sll->mmgr = mmgr;
}
int qse_sll_getscale (sll_t* sll) int qse_sll_getscale (sll_t* sll)
{ {
return sll->scale; return sll->scale;

View File

@ -19,6 +19,8 @@
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
#include "mem.h" #include "mem.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (str)
qse_str_t* qse_str_open (qse_mmgr_t* mmgr, qse_size_t ext, qse_size_t capa) qse_str_t* qse_str_open (qse_mmgr_t* mmgr, qse_size_t ext, qse_size_t capa)
{ {
qse_str_t* str; qse_str_t* str;
@ -104,21 +106,6 @@ int qse_str_yield (qse_str_t* str, qse_xstr_t* buf, int new_capa)
return 0; return 0;
} }
void* qse_str_getxtn (qse_str_t* str)
{
return str + 1;
}
qse_mmgr_t* qse_str_getmmgr (qse_str_t* str)
{
return str->mmgr;
}
void qse_str_setmmgr (qse_str_t* str, qse_mmgr_t* mmgr)
{
str->mmgr = mmgr;
}
qse_str_sizer_t qse_str_getsizer (qse_str_t* str) qse_str_sizer_t qse_str_getsizer (qse_str_t* str)
{ {
return str->sizer; return str->sizer;

View File

@ -19,7 +19,7 @@
#include <qse/cmn/tio.h> #include <qse/cmn/tio.h>
#include "mem.h" #include "mem.h"
QSE_IMPLEMENT_STD_FUNCTIONS (tio) QSE_IMPLEMENT_COMMON_FUNCTIONS (tio)
qse_tio_t* qse_tio_open (qse_mmgr_t* mmgr, qse_size_t ext) qse_tio_t* qse_tio_open (qse_mmgr_t* mmgr, qse_size_t ext)
{ {
@ -90,9 +90,9 @@ qse_tio_err_t qse_tio_geterrnum (qse_tio_t* tio)
return tio->errnum; return tio->errnum;
} }
const qse_char_t* qse_tio_geterrstr (qse_tio_t* tio) const qse_char_t* qse_tio_geterrmsg (qse_tio_t* tio)
{ {
static const qse_char_t* __errstr[] = static const qse_char_t* __errmsg[] =
{ {
QSE_T("no error"), QSE_T("no error"),
QSE_T("out of memory"), QSE_T("out of memory"),
@ -111,9 +111,9 @@ const qse_char_t* qse_tio_geterrstr (qse_tio_t* tio)
QSE_T("unknown error") QSE_T("unknown error")
}; };
return __errstr[ return __errmsg[
(tio->errnum < 0 || tio->errnum >= QSE_COUNTOF(__errstr))? (tio->errnum < 0 || tio->errnum >= QSE_COUNTOF(__errmsg))?
QSE_COUNTOF(__errstr) - 1: tio->errnum]; QSE_COUNTOF(__errmsg) - 1: tio->errnum];
} }
int qse_tio_attachin (qse_tio_t* tio, qse_tio_io_t input, void* arg) int qse_tio_attachin (qse_tio_t* tio, qse_tio_io_t input, void* arg)