diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index cbd477d4..63599bef 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h 78 2009-02-23 14:03:28Z hyunghwan.chung $ + * $Id: awk.h 79 2009-02-24 03:57:28Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -49,14 +49,142 @@ 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 */ /******/ +/* this is not a value. it is just a value holder */ +typedef struct qse_awk_val_chunk_t qse_awk_val_chunk_t; + +#if QSE_SIZEOF_INT == 2 +# define QSE_AWK_VAL_HDR \ + unsigned int type: 3; \ + unsigned int ref: 13 +#else +# define QSE_AWK_VAL_HDR \ + unsigned int type: 3; \ + unsigned int ref: 29 +#endif + +#define QSE_AWK_VAL_TYPE(x) ((x)->type) + +/****s* AWK/qse_awk_val_t + * NAME + * qse_awk_val_t - define an abstract value type + * SYNOPSIS + */ +struct qse_awk_val_t +{ + QSE_AWK_VAL_HDR; +}; typedef struct qse_awk_val_t qse_awk_val_t; +/******/ + +/****s* AWK/qse_awk_val_nil_t + * NAME + * qse_awk_val_nil_t - define a nil value type + * DESCRIPTION + * The type field is QSE_AWK_VAL_NIL. + * SYNOPSIS + */ +struct qse_awk_val_nil_t +{ + QSE_AWK_VAL_HDR; +}; +typedef struct qse_awk_val_nil_t qse_awk_val_nil_t; +/******/ + +/****s* AWK/qse_awk_val_int_t + * NAME + * qse_awk_val_int_t - define an integer number type + * DESCRIPTION + * The type field is QSE_AWK_VAL_INT. + * SYNOPSIS + */ +struct qse_awk_val_int_t +{ + QSE_AWK_VAL_HDR; + qse_long_t val; + void* nde; +}; +typedef struct qse_awk_val_int_t qse_awk_val_int_t; +/******/ + +/****s* AWK/qse_awk_val_real_t + * NAME + * qse_awk_val_real_t - define a floating-point number type + * DESCRIPTION + * The type field is QSE_AWK_VAL_REAL. + * SYNOPSIS + */ +struct qse_awk_val_real_t +{ + QSE_AWK_VAL_HDR; + qse_real_t val; + void* nde; +}; +typedef struct qse_awk_val_real_t qse_awk_val_real_t; +/******/ + +/****s* AWK/qse_awk_val_str_t + * NAME + * qse_awk_val_str_t - define a string type + * DESCRIPTION + * The type field is QSE_AWK_VAL_STR. + * SYNOPSIS + */ +struct qse_awk_val_str_t +{ + QSE_AWK_VAL_HDR; + qse_char_t* ptr; + qse_size_t len; +}; +typedef struct qse_awk_val_str_t qse_awk_val_str_t; +/******/ + +/****s* AWK/qse_awk_val_rex_t + * NAME + * qse_awk_val_rex_t - define a regular expression type + * DESCRIPTION + * The type field is QSE_AWK_VAL_REX. + * SYNOPSIS + */ +struct qse_awk_val_rex_t +{ + QSE_AWK_VAL_HDR; + qse_char_t* ptr; + qse_size_t len; + void* code; +}; +typedef struct qse_awk_val_rex_t qse_awk_val_rex_t; +/******/ + +/* QSE_AWK_VAL_MAP */ +struct qse_awk_val_map_t +{ + QSE_AWK_VAL_HDR; + + /* TODO: make val_map to array if the indices used are all + * integers switch to map dynamically once the + * non-integral index is seen. + */ + qse_map_t* map; +}; +typedef struct qse_awk_val_map_t qse_awk_val_map_t; + +/* QSE_AWK_VAL_REF */ +struct qse_awk_val_ref_t +{ + QSE_AWK_VAL_HDR; + + int id; + /* if id is QSE_AWK_VAL_REF_POS, adr holds an index of the + * positional variable. Otherwise, adr points to the value + * directly. */ + qse_awk_val_t** adr; +}; +typedef struct qse_awk_val_ref_t qse_awk_val_ref_t; typedef struct qse_awk_prm_t qse_awk_prm_t; typedef struct qse_awk_sio_t qse_awk_sio_t; - typedef struct qse_awk_rio_t qse_awk_rio_t; typedef struct qse_awk_riod_t qse_awk_riod_t; - typedef struct qse_awk_rcb_t qse_awk_rcb_t; typedef qse_real_t (*qse_awk_pow_t) ( @@ -582,131 +710,6 @@ struct qse_awk_valtostr_out_t typedef struct qse_awk_valtostr_out_t qse_awk_valtostr_out_t; #endif -typedef struct qse_awk_val_nil_t qse_awk_val_nil_t; -typedef struct qse_awk_val_rex_t qse_awk_val_rex_t; -typedef struct qse_awk_val_map_t qse_awk_val_map_t; -typedef struct qse_awk_val_ref_t qse_awk_val_ref_t; - -/* this is not a value. it is just a value holder */ -typedef struct qse_awk_val_chunk_t qse_awk_val_chunk_t; - -#if QSE_SIZEOF_INT == 2 -# define QSE_AWK_VAL_HDR \ - unsigned int type: 3; \ - unsigned int ref: 13 -#else -# define QSE_AWK_VAL_HDR \ - unsigned int type: 3; \ - unsigned int ref: 29 -#endif - -#define QSE_AWK_VAL_TYPE(x) ((x)->type) - -/****s* AWK/qse_awk_val_t - * NAME - * qse_awk_val_t - define an abstract value type - * SYNOPSIS - */ -struct qse_awk_val_t -{ - QSE_AWK_VAL_HDR; -}; -/******/ - -/****s* AWK/qse_awk_val_nil_t - * NAME - * qse_awk_val_nil_t - define a nil value type - * DESCRIPTION - * The type field is QSE_AWK_VAL_NIL. - * SYNOPSIS - */ -struct qse_awk_val_nil_t -{ - QSE_AWK_VAL_HDR; -}; -/******/ - -/****s* AWK/qse_awk_val_int_t - * NAME - * qse_awk_val_int_t - define an integer number type - * DESCRIPTION - * The type field is QSE_AWK_VAL_INT. - * SYNOPSIS - */ -struct qse_awk_val_int_t -{ - QSE_AWK_VAL_HDR; - qse_long_t val; - void* nde; -}; -typedef struct qse_awk_val_int_t qse_awk_val_int_t; -/******/ - -/****s* AWK/qse_awk_val_real_t - * NAME - * qse_awk_val_real_t - define a floating-point number type - * DESCRIPTION - * The type field is QSE_AWK_VAL_REAL. - * SYNOPSIS - */ -struct qse_awk_val_real_t -{ - QSE_AWK_VAL_HDR; - qse_real_t val; - void* nde; -}; -typedef struct qse_awk_val_real_t qse_awk_val_real_t; -/******/ - -/****s* AWK/qse_awk_val_str_t - * NAME - * qse_awk_val_str_t - define a string type - * DESCRIPTION - * The type field is QSE_AWK_VAL_STR. - * SYNOPSIS - */ -struct qse_awk_val_str_t -{ - QSE_AWK_VAL_HDR; - qse_char_t* ptr; - qse_size_t len; -}; -typedef struct qse_awk_val_str_t qse_awk_val_str_t; -/******/ - -/* QSE_AWK_VAL_REX */ -struct qse_awk_val_rex_t -{ - QSE_AWK_VAL_HDR; - qse_char_t* ptr; - qse_size_t len; - void* code; -}; - -/* QSE_AWK_VAL_MAP */ -struct qse_awk_val_map_t -{ - QSE_AWK_VAL_HDR; - - /* TODO: make val_map to array if the indices used are all - * integers switch to map dynamically once the - * non-integral index is seen. - */ - qse_map_t* map; -}; - -/* QSE_AWK_VAL_REF */ -struct qse_awk_val_ref_t -{ - QSE_AWK_VAL_HDR; - - int id; - /* if id is QSE_AWK_VAL_REF_POS, adr holds an index of the - * positional variable. Otherwise, adr points to the value - * directly. */ - qse_awk_val_t** adr; -}; - #ifdef __cplusplus extern "C" { #endif @@ -1492,7 +1495,7 @@ qse_awk_val_t* qse_awk_rtx_makerealval ( ); qse_awk_val_t* qse_awk_rtx_makestrval0 ( - qse_awk_rtx_t* rtx, + qse_awk_rtx_t* rtx, const qse_char_t* str ); diff --git a/qse/include/qse/utl/Makefile.am b/qse/include/qse/utl/Makefile.am index 8cbdfb13..3341bcbc 100644 --- a/qse/include/qse/utl/Makefile.am +++ b/qse/include/qse/utl/Makefile.am @@ -1,5 +1,5 @@ -pkginclude_HEADERS = http.h main.h stdio.h +pkginclude_HEADERS = http.h main.h stdio.h sed.h tgp.h pkgincludedir= $(includedir)/qse/utl diff --git a/qse/include/qse/utl/Makefile.in b/qse/include/qse/utl/Makefile.in index 72236959..bdc6b90c 100644 --- a/qse/include/qse/utl/Makefile.in +++ b/qse/include/qse/utl/Makefile.in @@ -177,7 +177,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -pkginclude_HEADERS = http.h main.h stdio.h +pkginclude_HEADERS = http.h main.h stdio.h sed.h tgp.h CLEANFILES = *dist all: all-am diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index a08a11b2..4eee794a 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -3,7 +3,8 @@ AUTOMAKE_OPTIONS = nostdinc AM_CFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsecmn.la -libqsecmn_la_SOURCES = mem.h chr.h \ +libqsecmn_la_SOURCES = \ + syscall.h mem.h chr.h \ mem.c chr.c chr_cnv.c rex.c \ str_bas.c str_cnv.c str_dyn.c str_utl.c \ lda.c map.c sll.c dll.c opt.c \ diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index 671d8e8f..faaff329 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -200,7 +200,8 @@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = nostdinc AM_CFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsecmn.la -libqsecmn_la_SOURCES = mem.h chr.h \ +libqsecmn_la_SOURCES = \ + syscall.h mem.h chr.h \ mem.c chr.c chr_cnv.c rex.c \ str_bas.c str_cnv.c str_dyn.c str_utl.c \ lda.c map.c sll.c dll.c opt.c \ diff --git a/qse/lib/cmn/syscall.h b/qse/lib/cmn/syscall.h index 4acfbff2..84c8e728 100644 --- a/qse/lib/cmn/syscall.h +++ b/qse/lib/cmn/syscall.h @@ -4,171 +4,165 @@ /* This file defines unix/linux system calls */ #ifdef HAVE_SYS_TYPES_H -#include +# include #endif #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_SYS_WAIT_H -#include +# include #endif #ifdef HAVE_SIGNAL_H -#include +# include #endif #ifdef HAVE_ERRNO_H -#include +# include #endif #if defined(QSE_USE_SYSCALL) && defined(HAVE_SYS_SYSCALL_H) -#include +# include #endif #ifdef SYS_open - #define QSE_OPEN(path,flags,mode) syscall(SYS_open,path,flags,mode) +# define QSE_OPEN(path,flags,mode) syscall(SYS_open,path,flags,mode) #else - #define QSE_OPEN(path,flags,mode) open(path,flags,mode) +# define QSE_OPEN(path,flags,mode) open(path,flags,mode) #endif #ifdef SYS_close - #define QSE_CLOSE(handle) syscall(SYS_close,handle) +# define QSE_CLOSE(handle) syscall(SYS_close,handle) #else - #define QSE_CLOSE(handle) close(handle) +# define QSE_CLOSE(handle) close(handle) #endif #ifdef SYS_read - #define QSE_READ(handle,buf,size) syscall(SYS_read,handle,buf,size) +# define QSE_READ(handle,buf,size) syscall(SYS_read,handle,buf,size) #else - #define QSE_READ(handle,buf,size) read(handle,buf,size) +# define QSE_READ(handle,buf,size) read(handle,buf,size) #endif #ifdef SYS_write - #define QSE_WRITE(handle,buf,size) syscall(SYS_write,handle,buf,size) +# define QSE_WRITE(handle,buf,size) syscall(SYS_write,handle,buf,size) #else - #define QSE_WRITE(handle,buf,size) write(handle,buf,size) +# define QSE_WRITE(handle,buf,size) write(handle,buf,size) #endif #if !defined(_LP64) && defined(SYS__llseek) - #define QSE_LLSEEK(handle,hoffset,loffset,out,whence) \ - syscall(SYS__llseek,handle,hoffset,loffset,out,whence) +# define QSE_LLSEEK(handle,hoffset,loffset,out,whence) syscall(SYS__llseek,handle,hoffset,loffset,out,whence) #elif !defined(_LP64) && defined(HAVE__LLSEEK) - #define QSE_LLSEEK(handle,hoffset,loffset,out,whence) \ - _llseek(handle,hoffset,loffset,out,whence) +# define QSE_LLSEEK(handle,hoffset,loffset,out,whence) _llseek(handle,hoffset,loffset,out,whence) #endif #if defined(SYS_lseek65) - #define QSE_LSEEK64(handle,offset,whence) \ - syscall(SYS_lseek64,handle,offset,whence) +# define QSE_LSEEK64(handle,offset,whence) syscall(SYS_lseek64,handle,offset,whence) #elif defined(HAVE_lseek64) - #define QSE_LSEEK64(handle,offset,whence) \ - lseek64(handle,offset,whence) +# define QSE_LSEEK64(handle,offset,whence) lseek64(handle,offset,whence) #endif #if defined(SYS_lseek) - #define QSE_LSEEK(handle,offset,whence) \ - syscall(SYS_lseek,handle,offset,whence) +# define QSE_LSEEK(handle,offset,whence) syscall(SYS_lseek,handle,offset,whence) #else - #define QSE_LSEEK(handle,offset,whence) \ - lseek(handle,offset,whence) +# define QSE_LSEEK(handle,offset,whence) lseek(handle,offset,whence) #endif #if !defined(_LP64) && defined(SYS_ftruncate64) - #define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate64,handle,size) +# define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate64,handle,size) #elif defined(SYS_ftruncate) - #define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate,handle,size) +# define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate,handle,size) #elif !defined(_LP64) && defined(HAVE_FTRUNCATE64) - #define QSE_FTRUNCATE(handle,size) ftruncate64(handle,size) +# define QSE_FTRUNCATE(handle,size) ftruncate64(handle,size) #else - #define QSE_FTRUNCATE(handle,size) ftruncate(handle,size) +# define QSE_FTRUNCATE(handle,size) ftruncate(handle,size) #endif #if defined(SYS_fchmod) - #define QSE_FCHMOD(handle,mode) syscall(SYS_fchmod,handle,mode) +# define QSE_FCHMOD(handle,mode) syscall(SYS_fchmod,handle,mode) #else - #define QSE_FCHMOD(handle,mode) fchmod(handle,mode) +# define QSE_FCHMOD(handle,mode) fchmod(handle,mode) #endif #if defined(SYS_fsync) - #define QSE_FSYNC(handle) syscall(SYS_fsync,handle) +# define QSE_FSYNC(handle) syscall(SYS_fsync,handle) #else - #define QSE_FSYNC(handle) fsync(handle) +# define QSE_FSYNC(handle) fsync(handle) #endif #if defined(SYS_fcntl) - #define QSE_FCNTL(handle,cmd,arg) syscall(SYS_fcntl,handle,cmd,arg) +# define QSE_FCNTL(handle,cmd,arg) syscall(SYS_fcntl,handle,cmd,arg) #else - #define QSE_FCNTL(handle,cmd,arg) fcntl(handle,cmd,arg) +# define QSE_FCNTL(handle,cmd,arg) fcntl(handle,cmd,arg) #endif #ifdef SYS_dup2 - #define QSE_DUP2(ofd,nfd) syscall(SYS_dup2,ofd,nfd) +# define QSE_DUP2(ofd,nfd) syscall(SYS_dup2,ofd,nfd) #else - #define QSE_DUP2(ofd,nfd) dup2(ofd,nfd) +# define QSE_DUP2(ofd,nfd) dup2(ofd,nfd) #endif #ifdef SYS_pipe - #define QSE_PIPE(pfds) syscall(SYS_pipe,pfds) +# define QSE_PIPE(pfds) syscall(SYS_pipe,pfds) #else - #define QSE_PIPE(pfds) pipe(pfds) +# define QSE_PIPE(pfds) pipe(pfds) #endif #ifdef SYS_exit - #define QSE_EXIT(code) syscall(SYS_exit,code) +# define QSE_EXIT(code) syscall(SYS_exit,code) #else - #define QSE_EXIT(code) _exit(code) +# define QSE_EXIT(code) _exit(code) #endif #ifdef SYS_fork - #define QSE_FORK() syscall(SYS_fork) +# define QSE_FORK() syscall(SYS_fork) #else - #define QSE_FORK() fork() +# define QSE_FORK() fork() #endif #ifdef SYS_execve - #define QSE_EXECVE(path,argv,envp) syscall(SYS_execve,path,argv,envp) +# define QSE_EXECVE(path,argv,envp) syscall(SYS_execve,path,argv,envp) #else - #define QSE_EXECVE(path,argv,envp) execve(path,argv,envp) +# define QSE_EXECVE(path,argv,envp) execve(path,argv,envp) #endif #ifdef SYS_waitpid - #define QSE_WAITPID(pid,status,options) syscall(SYS_waitpid,pid,status,options) +# define QSE_WAITPID(pid,status,options) syscall(SYS_waitpid,pid,status,options) #else - #define QSE_WAITPID(pid,status,options) waitpid(pid,status,options) +# define QSE_WAITPID(pid,status,options) waitpid(pid,status,options) #endif #ifdef SYS_kill - #define QSE_KILL(pid,sig) syscall(SYS_kill,pid,sig) +# define QSE_KILL(pid,sig) syscall(SYS_kill,pid,sig) #else - #define QSE_KILL(pid,sig) kill(pid,sig) +# define QSE_KILL(pid,sig) kill(pid,sig) #endif #ifdef SYS_getpid - #define QSE_GETPID() syscall(SYS_getpid) +# define QSE_GETPID() syscall(SYS_getpid) #else - #define QSE_GETPID() getpid() +# define QSE_GETPID() getpid() #endif #ifdef SYS_getuid - #define QSE_GETUID() syscall(SYS_getuid) +# define QSE_GETUID() syscall(SYS_getuid) #else - #define QSE_GETUID() getuid() +# define QSE_GETUID() getuid() #endif #ifdef SYS_geteuid - #define QSE_GETEUID() syscall(SYS_geteuid) +# define QSE_GETEUID() syscall(SYS_geteuid) #else - #define QSE_GETEUID() geteuid() +# define QSE_GETEUID() geteuid() #endif #ifdef SYS_getgid - #define QSE_GETGID() syscall(SYS_getgid) +# define QSE_GETGID() syscall(SYS_getgid) #else - #define QSE_GETGID() getgid() +# define QSE_GETGID() getgid() #endif #ifdef SYS_getegid - #define QSE_GETEGID() syscall(SYS_getegid) +# define QSE_GETEGID() syscall(SYS_getegid) #else - #define QSE_GETEGID() getegid() +# define QSE_GETEGID() getegid() #endif #endif