From cbc48145c45e0da6c58ccfe6bb679b1d2c7c906d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 29 Jun 2008 02:37:09 +0000 Subject: [PATCH] --- ase/cmd/awk/awk.c | 21 ++---- ase/cmd/tgp/tgp.c | 25 +------ ase/include/ase/utl/helper.h | 28 ++++++++ ase/include/ase/utl/makefile.am | 2 +- ase/lib/utl/helper.c | 117 ++++++++++++++++++++++++++++++++ ase/lib/utl/makefile.am | 2 +- ase/lib/utl/makefile.in | 7 +- 7 files changed, 157 insertions(+), 45 deletions(-) create mode 100644 ase/include/ase/utl/helper.h create mode 100644 ase/lib/utl/helper.c diff --git a/ase/cmd/awk/awk.c b/ase/cmd/awk/awk.c index c4a73408..ff78870f 100644 --- a/ase/cmd/awk/awk.c +++ b/ase/cmd/awk/awk.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -1145,27 +1145,16 @@ static int awk_main (int argc, ase_char_t* argv[]) prmfns.mmgr.custom_data = NULL; #endif - prmfns.ccls.is_upper = custom_awk_isupper; - prmfns.ccls.is_lower = custom_awk_islower; - prmfns.ccls.is_alpha = custom_awk_isalpha; - prmfns.ccls.is_digit = custom_awk_isdigit; - prmfns.ccls.is_xdigit = custom_awk_isxdigit; - prmfns.ccls.is_alnum = custom_awk_isalnum; - prmfns.ccls.is_space = custom_awk_isspace; - prmfns.ccls.is_print = custom_awk_isprint; - prmfns.ccls.is_graph = custom_awk_isgraph; - prmfns.ccls.is_cntrl = custom_awk_iscntrl; - prmfns.ccls.is_punct = custom_awk_ispunct; - prmfns.ccls.to_upper = custom_awk_toupper; - prmfns.ccls.to_lower = custom_awk_tolower; - prmfns.ccls.custom_data = NULL; + /*prmfns.mmgr = *ASE_GETMMGR();*/ + prmfns.ccls = *ASE_GETCCLS(); prmfns.misc.pow = custom_awk_pow; prmfns.misc.sprintf = custom_awk_sprintf; prmfns.misc.dprintf = custom_awk_dprintf; prmfns.misc.custom_data = NULL; - if ((awk = ase_awk_open(&prmfns, ASE_NULL)) == ASE_NULL) + awk = ase_awk_open(&prmfns, ASE_NULL); + if (awk == ASE_NULL) { #ifdef _WIN32 HeapDestroy (mmgr_data.heap); diff --git a/ase/cmd/tgp/tgp.c b/ase/cmd/tgp/tgp.c index 214ba6c7..bf3a7037 100644 --- a/ase/cmd/tgp/tgp.c +++ b/ase/cmd/tgp/tgp.c @@ -10,16 +10,8 @@ #include #include #include -//#include - -/* -#include -#include -#include -#include -*/ - +#include #include #include @@ -99,21 +91,6 @@ static ase_ssize_t put_output ( return -1; } -static void* custom_tgp_malloc (void* custom, ase_size_t n) -{ - return malloc (n); -} - -static void* custom_tgp_realloc (void* custom, void* ptr, ase_size_t n) -{ - return realloc (ptr, n); -} - -static void custom_tgp_free (void* custom, void* ptr) -{ - free (ptr); -} - #endif static void print_usage (const ase_char_t* argv0) diff --git a/ase/include/ase/utl/helper.h b/ase/include/ase/utl/helper.h new file mode 100644 index 00000000..4d2d23f2 --- /dev/null +++ b/ase/include/ase/utl/helper.h @@ -0,0 +1,28 @@ +/* + * $Id: helper.h 231 2008-06-28 08:37:09Z baconevi $ + */ + +#ifndef _ASE_UTL_HELPER_H_ +#define _ASE_UTL_HELPER_H_ + +#include +#include + +#define ASE_GETMMGR() (ase_mmgr) +#define ASE_SETMMGR(m) ((ase_mmgr) = (m)) + +#define ASE_GETCCLS() (ase_ccls) +#define ASE_SETCCLS(c) ((ase_ccls) = (c)) + +#ifdef __cplusplus +extern "C" { +#endif + +extern ase_mmgr_t* ase_mmgr; +extern ase_ccls_t* ase_ccls; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/include/ase/utl/makefile.am b/ase/include/ase/utl/makefile.am index 7b54b521..425dad32 100644 --- a/ase/include/ase/utl/makefile.am +++ b/ase/include/ase/utl/makefile.am @@ -1,5 +1,5 @@ -pkginclude_HEADERS = ctype.h getopt.h http.h main.h stdio.h +pkginclude_HEADERS = helper.h ctype.h getopt.h http.h main.h stdio.h pkgincludedir= $(includedir)/ase/utl diff --git a/ase/lib/utl/helper.c b/ase/lib/utl/helper.c new file mode 100644 index 00000000..5dd8cdd4 --- /dev/null +++ b/ase/lib/utl/helper.c @@ -0,0 +1,117 @@ + +/* + * $Id: helper.c 231 2008-06-28 08:37:09Z baconevi $ + */ + +#include +#include +#include + +static void* mmgr_malloc (void* custom, ase_size_t n) +{ + return malloc (n); +} + +static void* mmgr_realloc (void* custom, void* ptr, ase_size_t n) +{ + return realloc (ptr, n); +} + +static void mmgr_free (void* custom, void* ptr) +{ + free (ptr); +} + +static ase_bool_t ccls_isupper (void* custom, ase_cint_t c) +{ + return ase_isupper (c); +} + +static ase_bool_t ccls_islower (void* custom, ase_cint_t c) +{ + return ase_islower (c); +} + +static ase_bool_t ccls_isalpha (void* custom, ase_cint_t c) +{ + return ase_isalpha (c); +} + +static ase_bool_t ccls_isdigit (void* custom, ase_cint_t c) +{ + return ase_isdigit (c); +} + +static ase_bool_t ccls_isxdigit (void* custom, ase_cint_t c) +{ + return ase_isxdigit (c); +} + +static ase_bool_t ccls_isalnum (void* custom, ase_cint_t c) +{ + return ase_isalnum (c); +} + +static ase_bool_t ccls_isspace (void* custom, ase_cint_t c) +{ + return ase_isspace (c); +} + +static ase_bool_t ccls_isprint (void* custom, ase_cint_t c) +{ + return ase_isprint (c); +} + +static ase_bool_t ccls_isgraph (void* custom, ase_cint_t c) +{ + return ase_isgraph (c); +} + +static ase_bool_t ccls_iscntrl (void* custom, ase_cint_t c) +{ + return ase_iscntrl (c); +} + +static ase_bool_t ccls_ispunct (void* custom, ase_cint_t c) +{ + return ase_ispunct (c); +} + +static ase_cint_t ccls_toupper (void* custom, ase_cint_t c) +{ + return ase_toupper (c); +} + +static ase_cint_t ccls_tolower (void* custom, ase_cint_t c) +{ + return ase_tolower (c); +} + +static ase_mmgr_t mmgr = +{ + mmgr_malloc, + mmgr_realloc, + mmgr_free, + ASE_NULL +}; + +static ase_ccls_t ccls = +{ + ccls_isupper, + ccls_islower, + ccls_isalpha, + ccls_isdigit, + ccls_isxdigit, + ccls_isalnum, + ccls_isspace, + ccls_isprint, + ccls_isgraph, + ccls_iscntrl, + ccls_ispunct, + ccls_toupper, + ccls_tolower, + ASE_NULL +}; + +ase_mmgr_t* ase_mmgr = &mmgr; +ase_ccls_t* ase_ccls = &ccls; diff --git a/ase/lib/utl/makefile.am b/ase/lib/utl/makefile.am index 3ade971f..ca7e841e 100644 --- a/ase/lib/utl/makefile.am +++ b/ase/lib/utl/makefile.am @@ -2,5 +2,5 @@ AM_CFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libaseutl.la -libaseutl_la_SOURCES = assert.c ctype.c getopt.c http.c main.c stdio.c +libaseutl_la_SOURCES = helper.c assert.c ctype.c getopt.c http.c main.c stdio.c libaseutl_la_LDFLAGS = -release $(VERSION) diff --git a/ase/lib/utl/makefile.in b/ase/lib/utl/makefile.in index 1d1479c5..c82abd28 100644 --- a/ase/lib/utl/makefile.in +++ b/ase/lib/utl/makefile.in @@ -55,8 +55,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libaseutl_la_LIBADD = -am_libaseutl_la_OBJECTS = assert.lo ctype.lo getopt.lo http.lo main.lo \ - stdio.lo +am_libaseutl_la_OBJECTS = helper.lo assert.lo ctype.lo getopt.lo \ + http.lo main.lo stdio.lo libaseutl_la_OBJECTS = $(am_libaseutl_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/ase depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp @@ -191,7 +191,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_CFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libaseutl.la -libaseutl_la_SOURCES = assert.c ctype.c getopt.c http.c main.c stdio.c +libaseutl_la_SOURCES = helper.c assert.c ctype.c getopt.c http.c main.c stdio.c libaseutl_la_LDFLAGS = -release $(VERSION) all: all-am @@ -265,6 +265,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctype.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@