enhanced resizing of qse_lda_t and qse_str_t

This commit is contained in:
hyung-hwan 2010-10-22 07:29:12 +00:00
parent a5f99ece99
commit 299852beaa
11 changed files with 317 additions and 560 deletions

View File

@ -1,478 +0,0 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# include/qse/scm/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
pkgdatadir = $(datadir)/qse
pkglibdir = $(libdir)/qse
pkglibexecdir = $(libexecdir)/qse
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = x86_64-unknown-linux-gnu
host_triplet = x86_64-unknown-linux-gnu
subdir = include/qse/scm
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/libtool.m4 \
$(top_srcdir)/ac/m4/ltoptions.m4 \
$(top_srcdir)/ac/m4/ltsugar.m4 \
$(top_srcdir)/ac/m4/ltversion.m4 \
$(top_srcdir)/ac/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(pkgincludedir)"
HEADERS = $(pkginclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgincludedir = $(includedir)/qse/scm
ACLOCAL = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run aclocal-1.11
AMTAR = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run tar
AR = ar
AUTOCONF = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run autoconf
AUTOHEADER = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run autoheader
AUTOMAKE = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run automake-1.11
AWK = gawk
BUILD_MODE = debug
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -Wall -O2 -g -DQSE_HAVE_CONFIG_H -D_LARGEFILE64_SOURCE -g -D_DEBUG -UNDEBUG -DQSE_BUILD_DEBUG -D_REENTRANT -D_THREAD_SAFE
CHAR_MODE = QSE_CHAR_IS_WCHAR
CPP = gcc -E
CPPFLAGS =
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -Wall -O2 -g -DQSE_HAVE_CONFIG_H -D_LARGEFILE64_SOURCE -g -D_DEBUG -UNDEBUG -DQSE_BUILD_DEBUG -D_REENTRANT -D_THREAD_SAFE
CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps
DSYMUTIL =
DUMPBIN =
ECHO_C =
ECHO_N = -n
ECHO_T =
EGREP = grep -E
EXEEXT =
FGREP = grep -F
GREP = grep
HAVE_CXX = yes
HAVE_OBJC = yes
INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
LD = ld -m elf_x86_64
LDFLAGS =
LIBM = -lm
LIBOBJS =
LIBS =
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LIBTOOL_DEPS = ac/au/ltmain.sh
LIPO =
LN_S = ln -s
LTLIBOBJS =
MAKEINFO = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/missing --run makeinfo
MKDIR_P = /bin/mkdir -p
NM = nm
NMEDIT =
OBJC = gcc
OBJCDEPMODE = depmode=gcc3
OBJCFLAGS = -DQSE_HAVE_CONFIG_H -D_LARGEFILE64_SOURCE -g -D_DEBUG -UNDEBUG -DQSE_BUILD_DEBUG -D_REENTRANT -D_THREAD_SAFE
OBJDUMP = objdump
OBJEXT = o
OTOOL =
OTOOL64 =
PACKAGE = qse
PACKAGE_BUGREPORT = Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)
PACKAGE_NAME = qse
PACKAGE_STRING = qse 0.5.5
PACKAGE_TARNAME = qse
PACKAGE_URL = http://qse.googlecode.com
PACKAGE_VERSION = 0.5.5
PATH_SEPARATOR = :
QSE_PROJECT_AUTHOR = Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)
QSE_PROJECT_URL = http://qse.googlecode.com
QSE_SIZEOF_CHAR = 1
QSE_SIZEOF_DOUBLE = 8
QSE_SIZEOF_FLOAT = 4
QSE_SIZEOF_INT = 4
QSE_SIZEOF_LONG = 8
QSE_SIZEOF_LONG_DOUBLE = 16
QSE_SIZEOF_LONG_LONG = 8
QSE_SIZEOF_SHORT = 2
QSE_SIZEOF_VOID_P = 8
QSE_SIZEOF_WCHAR_T = 4
RANLIB = ranlib
RM = rm -f
SED = sed
SET_MAKE =
SHELL = /bin/bash
STRIP = strip
VERSION = 0.5.5
abs_builddir = /home/hyung-hwan/workspace/qse/include/qse/scm
abs_srcdir = /home/hyung-hwan/workspace/qse/include/qse/scm
abs_top_builddir = /home/hyung-hwan/workspace/qse
abs_top_srcdir = /home/hyung-hwan/workspace/qse
ac_ct_CC = gcc
ac_ct_CXX = g++
ac_ct_DUMPBIN =
ac_ct_OBJC = gcc
am__include = include
am__leading_dot = .
am__quote =
am__tar = ${AMTAR} chof - "$$tardir"
am__untar = ${AMTAR} xf -
bindir = ${exec_prefix}/bin
build = x86_64-unknown-linux-gnu
build_alias =
build_cpu = x86_64
build_os = linux-gnu
build_vendor = unknown
builddir = .
datadir = ${datarootdir}
datarootdir = ${prefix}/share
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
dvidir = ${docdir}
exec_prefix = ${prefix}
host = x86_64-unknown-linux-gnu
host_alias =
host_cpu = x86_64
host_os = linux-gnu
host_vendor = unknown
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = ${SHELL} /home/hyung-hwan/workspace/qse/ac/au/install-sh
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
localstatedir = ${prefix}/var
lt_ECHO = echo
mandir = ${datarootdir}/man
mkdir_p = /bin/mkdir -p
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /home/hyung-hwan/xxx
program_transform_name = s,x,x,
psdir = ${docdir}
sbindir = ${exec_prefix}/sbin
sharedstatedir = ${prefix}/com
srcdir = .
sysconfdir = ${prefix}/etc
target_alias =
top_build_prefix = ../../../
top_builddir = ../../..
top_srcdir = ../../..
pkginclude_HEADERS = scm.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/scm/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign include/qse/scm/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \
done
uninstall-pkgincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(pkgincludedir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(pkgincludedir)" && rm -f $$files
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(pkgincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-pkgincludeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-pkgincludeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-pkgincludeHEADERS install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-pkgincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h 349 2010-08-27 11:47:48Z hyunghwan.chung $
* $Id: types.h 360 2010-10-21 13:29:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -108,7 +108,11 @@ typedef enum qse_tri_t qse_tri_t;
/** @typedef qse_ulong_t
* The qse_ulong_t type defines the largest unsigned integer type supported
*/
#if QSE_SIZEOF_LONG_LONG > 0
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
typedef long qse_long_t;
typedef unsigned long qse_ulong_t;
#define QSE_SIZEOF_LONG_T QSE_SIZEOF_LONG
#elif QSE_SIZEOF_LONG_LONG > 0
typedef long long qse_long_t;
typedef unsigned long long qse_ulong_t;
#define QSE_SIZEOF_LONG_T QSE_SIZEOF_LONG_LONG

View File

@ -1,4 +1,4 @@
pkgincludedir= $(includedir)/qse/utl
pkginclude_HEADERS = http.h tgp.h
pkginclude_HEADERS = http.h

View File

@ -216,7 +216,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = http.h tgp.h
pkginclude_HEADERS = http.h
all: all-am
.SUFFIXES:

View File

@ -8,6 +8,55 @@
#include <qse/types.h>
#include <qse/macros.h>
typedef struct qse_http_buf_t qse_http_buf_t;
struct qse_http_buf_t
{
qse_size_t capa;
qse_size_t size;
qse_char_t* data;
};
enum qse_http_errnum_t
{
QSE_HTTP_ENOERR,
QSE_HTTP_ENOMEM
};
typedef enum qse_http_errnum_t qse_http_errnum_t;
/*
struct qse_http_req_t
{
enum
{
QSE_HTTP_REQ_HEAD,
QSE_HTTP_REQ_GET,
QSE_HTTP_REQ_POST
} method;
qse_char_t path[];
};
*/
typedef struct qse_http_t qse_http_t;
struct qse_http_t
{
QSE_DEFINE_COMMON_FIELDS (http)
qse_http_errnum_t errnum;
struct
{
qse_http_buf_t buf;
int no;
} state;
};
/* returns the type of http method */
typedef struct qse_http_req_t qse_http_req_t;
typedef struct qse_http_hdr_t qse_http_hdr_t;
@ -48,6 +97,32 @@ extern "C" {
qse_char_t* qse_parsehttpreq (qse_char_t* buf, qse_http_req_t* req);
qse_char_t* qse_parsehttphdr (qse_char_t* buf, qse_http_hdr_t* hdr);
QSE_DEFINE_COMMON_FUNCTIONS (http)
/**
* The qse_http_open() function creates a http processor.
*/
qse_http_t* qse_http_open (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t xtnsize /**< extension size in bytes */
);
/**
* The qse_http_close() function destroys a http processor.
*/
void qse_http_close (
qse_http_t* http
);
qse_http_t* qse_http_init (
qse_http_t* http,
qse_mmgr_t* mmgr
);
void qse_http_fini (
qse_http_t* http
);
#ifdef __cplusplus
}
#endif

View File

@ -1,52 +0,0 @@
/*
* $Id: tgp.h 235 2008-07-05 07:25:54Z baconevi $
*/
#ifndef _QSE_UTL_TGP_H_
#define _QSE_UTL_TGP_H_
#include <qse/types.h>
#include <qse/macros.h>
typedef struct qse_tgp_t qse_tgp_t;
enum qse_tgp_iocmd_t
{
QSE_TGP_IO_OPEN = 0,
QSE_TGP_IO_CLOSE = 1,
QSE_TGP_IO_READ = 2,
QSE_TGP_IO_WRITE = 3
};
typedef qse_ssize_t (*qse_tgp_io_t) (
int cmd, void* arg, qse_char_t* data, qse_size_t count);
#ifdef __cplusplus
extern "C" {
#endif
QSE_DEFINE_COMMON_FUNCTIONS (tgp)
qse_tgp_t* qse_tgp_open (
qse_mmgr_t* mmgr,
qse_size_t xtn
);
void qse_tgp_close (
qse_tgp_t* tgp
);
qse_tgp_t* qse_tgp_init (
qse_tgp_t* tgp,
qse_mmgr_t* mmgr
);
void qse_tgp_fini (
qse_tgp_t* tgp
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: lda.c 354 2010-09-03 12:50:08Z hyunghwan.chung $
* $Id: lda.c 360 2010-10-21 13:29:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -347,12 +347,14 @@ size_t qse_lda_insert (lda_t* lda, size_t pos, void* dptr, size_t dlen)
* doesn't modify lda on any errors */
if (pos >= lda->capa || lda->size >= lda->capa)
{
size_t capa;
size_t capa, mincapa;
/* get the minimum capacity needed */
mincapa = (pos >= lda->size)? (pos + 1): (lda->size + 1);
if (lda->sizer)
{
capa = (pos >= lda->size)? (pos + 1): (lda->size + 1);
capa = lda->sizer (lda, capa);
capa = lda->sizer (lda, mincapa);
}
else
{
@ -368,13 +370,21 @@ size_t qse_lda_insert (lda_t* lda, size_t pos, void* dptr, size_t dlen)
}
}
if (qse_lda_setcapa(lda,capa) == QSE_NULL)
do
{
if (lda->freeer)
lda->freeer (lda, DPTR(node), DLEN(node));
QSE_MMGR_FREE (lda->mmgr, node);
return QSE_LDA_NIL;
}
if (qse_lda_setcapa(lda,capa) != QSE_NULL) break;
if (capa <= mincapa)
{
if (lda->freeer)
lda->freeer (lda, DPTR(node), DLEN(node));
QSE_MMGR_FREE (lda->mmgr, node);
return QSE_LDA_NIL;
}
capa--; /* let it retry after lowering the capacity */
}
while (1);
}
if (pos >= lda->capa || lda->size >= lda->capa)

View File

@ -1,5 +1,5 @@
/*
* $Id: str_dyn.c 348 2010-08-26 06:26:28Z hyunghwan.chung $
* $Id: str_dyn.c 360 2010-10-21 13:29:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -256,12 +256,16 @@ qse_size_t qse_str_ncat (qse_str_t* str, const qse_char_t* s, qse_size_t len)
{
if (len > str->capa - str->len)
{
qse_size_t ncapa;
qse_size_t ncapa, mincapa;
/* let the minimum capacity be as large as
* to fit in the new substring */
mincapa = str->len + len;
if (str->sizer == QSE_NULL)
{
/* increase the capacity by the length to add */
ncapa = str->len + len;
ncapa = mincapa;
/* if the new capacity is less than the double,
* just double it */
if (ncapa < str->capa * 2) ncapa = str->capa * 2;
@ -270,15 +274,19 @@ qse_size_t qse_str_ncat (qse_str_t* str, const qse_char_t* s, qse_size_t len)
{
/* let the user determine the new capacity.
* pass the minimum capacity required as a hint */
ncapa = str->sizer (str, str->len + len);
ncapa = str->sizer (str, mincapa);
/* if no change in capacity, return current length */
if (ncapa == str->capa) return str->len;
}
if (qse_str_setcapa (str, ncapa) == (qse_size_t)-1)
/* change the capacity */
do
{
return (qse_size_t)-1;
if (qse_str_setcapa (str, ncapa) != (qse_size_t)-1) break;
if (ncapa <= mincapa) return (qse_size_t)-1;
ncapa--;
}
while (1);
}
if (len > str->capa - str->len)

View File

@ -705,24 +705,39 @@ void qse_xma_free (qse_xma_t* xma, void* b)
void qse_xma_dump (qse_xma_t* xma, qse_xma_dumper_t dumper, void* target)
{
qse_xma_blk_t* tmp;
unsigned long long fsum, asum;
qse_ulong_t fsum, asum;
#ifdef QSE_XMA_ENABLE_STAT
unsigned long long isum;
qse_ulong_t isum;
#endif
dumper (target, QSE_T("<XMA DUMP>\n"));
#ifdef QSE_XMA_ENABLE_STAT
dumper (target, QSE_T("== statistics ==\n"));
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
dumper (target, QSE_T("total = %lu\n"), (unsigned long)xma->stat.total);
dumper (target, QSE_T("alloc = %lu\n"), (unsigned long)xma->stat.alloc);
dumper (target, QSE_T("avail = %lu\n"), (unsigned long)xma->stat.avail);
#else
dumper (target, QSE_T("total = %llu\n"), (unsigned long long)xma->stat.total);
dumper (target, QSE_T("alloc = %llu\n"), (unsigned long long)xma->stat.alloc);
dumper (target, QSE_T("avail = %llu\n"), (unsigned long long)xma->stat.avail);
#endif
#endif
dumper (target, QSE_T("== blocks ==\n"));
dumper (target, QSE_T(" size avail address\n"));
for (tmp = xma->head, fsum = 0, asum = 0; tmp; tmp = tmp->b.next)
{
dumper (target, QSE_T(" %-18llu %-5d %p\n"), (unsigned long long)tmp->size, tmp->avail, tmp);
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
dumper (target, QSE_T(" %-18lu %-5d %p\n"),
(unsigned long)tmp->size, tmp->avail, tmp
);
#else
dumper (target, QSE_T(" %-18llu %-5d %p\n"),
(unsigned long long)tmp->size, tmp->avail, tmp
);
#endif
if (tmp->avail) fsum += tmp->size;
else asum += tmp->size;
}
@ -732,11 +747,22 @@ void qse_xma_dump (qse_xma_t* xma, qse_xma_dumper_t dumper, void* target)
#endif
dumper (target, QSE_T("---------------------------------------\n"));
dumper (target, QSE_T("Allocated blocks: %18llu bytes\n"), asum);
dumper (target, QSE_T("Available blocks: %18llu bytes\n"), fsum);
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
dumper (target, QSE_T("Allocated blocks: %18lu bytes\n"), (unsigned long)asum);
dumper (target, QSE_T("Available blocks: %18lu bytes\n"), (unsigned long)fsum);
#else
dumper (target, QSE_T("Allocated blocks: %18llu bytes\n"), (unsigned long long)asum);
dumper (target, QSE_T("Available blocks: %18llu bytes\n"), (unsigned long long)fsum);
#endif
#ifdef QSE_XMA_ENABLE_STAT
dumper (target, QSE_T("Internal use : %18llu bytes\n"), isum);
dumper (target, QSE_T("Total : %18llu bytes\n"), asum + fsum + isum);
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
dumper (target, QSE_T("Internal use : %18lu bytes\n"), (unsigned long)isum);
dumper (target, QSE_T("Total : %18lu bytes\n"), (unsigned long)(asum + fsum + isum));
#else
dumper (target, QSE_T("Internal use : %18llu bytes\n"), (unsigned long long)isum);
dumper (target, QSE_T("Total : %18llu bytes\n"), (unsigned long long)(asum + fsum + isum));
#endif
#endif
QSE_ASSERT (asum == xma->stat.alloc);

View File

@ -1,5 +1,5 @@
/*
* $Id: sed.c 348 2010-08-26 06:26:28Z hyunghwan.chung $
* $Id: sed.c 360 2010-10-21 13:29:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -41,7 +41,7 @@ do { \
qse_sed_seterror (sed, num, &__ea__, loc); \
} while (0)
qse_sed_t* qse_sed_open (qse_mmgr_t* mmgr, qse_size_t xtn)
qse_sed_t* qse_sed_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
{
qse_sed_t* sed;
@ -55,7 +55,7 @@ qse_sed_t* qse_sed_open (qse_mmgr_t* mmgr, qse_size_t xtn)
if (mmgr == QSE_NULL) return QSE_NULL;
}
sed = (qse_sed_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_sed_t) + xtn);
sed = (qse_sed_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_sed_t) + xtnsize);
if (sed == QSE_NULL) return QSE_NULL;
if (qse_sed_init (sed, mmgr) == QSE_NULL)

View File

@ -22,6 +22,8 @@
#include <qse/cmn/chr.h>
#include "../cmn/mem.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (http)
static int is_http_space (qse_char_t c)
{
return QSE_ISSPACE(c) && c != QSE_T('\r') && c != QSE_T('\n');
@ -205,3 +207,165 @@ ok:
*last = QSE_T('\0');
return p;
}
static QSE_INLINE void init_buffer (qse_http_t* http, qse_http_buf_t* buf)
{
buf->size = 0;
buf->capa = 0;
buf->data = QSE_NULL;
}
static QSE_INLINE void fini_buffer (qse_http_t* http, qse_http_buf_t* buf)
{
if (buf->data)
{
QSE_MMGR_FREE (http->mmgr, buf->data);
buf->capa = 0;
buf->size = 0;
buf->data = QSE_NULL;
}
}
static QSE_INLINE_ALWAYS void clear_buffer (qse_http_t* http, qse_http_buf_t* buf)
{
buf->size = 0;
}
static QSE_INLINE int push_to_buffer (
qse_http_t* http, qse_http_buf_t* buf,
const qse_char_t* ptr, qse_size_t len)
{
qse_size_t nsize = (buf)->size + len;
const qse_char_t* end = ptr + len;
if (nsize > (buf)->capa)
{
qse_size_t ncapa = (nsize > (buf)->capa * 2)? nsize: ((buf)->capa * 2);
do
{
void* tmp = QSE_MMGR_REALLOC ((http)->mmgr, (buf)->data, ncapa * QSE_SIZEOF(*ptr));
if (tmp)
{
(buf)->capa = ncapa;
(buf)->data = tmp;
break;
}
if (ncapa <= nsize)
{
(http)->errnum = QSE_HTTP_ENOMEM;
return -1;
}
/* retry with a smaller size */
ncapa--;
}
while (1);
}
while (ptr < end) (buf)->data[(buf)->size++] = *ptr++;
return 0;
}
#define QSE_HTTP_STATE_REQ 1
#define QSE_HTTP_STATE_HDR 2
#define QSE_HTTP_STATE_POST 3
qse_http_t* qse_http_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
{
qse_http_t* http;
if (mmgr == QSE_NULL)
{
mmgr = QSE_MMGR_GETDFL();
QSE_ASSERTX (mmgr != QSE_NULL,
"Set the memory manager with QSE_MMGR_SETDFL()");
if (mmgr == QSE_NULL) return QSE_NULL;
}
http = (qse_http_t*) QSE_MMGR_ALLOC (
mmgr, QSE_SIZEOF(qse_http_t) + xtnsize
);
if (http == QSE_NULL) return QSE_NULL;
if (qse_http_init (http, mmgr) == QSE_NULL)
{
QSE_MMGR_FREE (http->mmgr, http);
return QSE_NULL;
}
return http;
}
void qse_http_close (qse_http_t* http)
{
qse_http_fini (http);
QSE_MMGR_FREE (http->mmgr, http);
}
qse_http_t* qse_http_init (qse_http_t* http, qse_mmgr_t* mmgr)
{
if (mmgr == QSE_NULL) mmgr = QSE_MMGR_GETDFL();
QSE_MEMSET (http, 0, QSE_SIZEOF(*http));
http->mmgr = mmgr;
init_buffer (http, &http->state.buf);
http->state.no = QSE_HTTP_STATE_REQ;
return http;
}
void qse_http_fini (qse_http_t* http)
{
fini_buffer (http, &http->state.buf);
}
/* feed the percent encoded string */
int qse_http_feed (qse_http_t* http, const qse_char_t* ptr, qse_size_t len)
{
const qse_char_t* end = ptr + len;
const qse_char_t* blk = ptr;
while (ptr < end)
{
if (*ptr++ == '\n')
{
if (push_to_buffer (http, &http->state.buf, blk, ptr - blk) <= -1) return -1;
blk = ptr; /* let ptr point to the next character to '\n' */
if (http->state.no == QSE_HTTP_STATE_REQ)
{
/*
if (parse_http_req (http, &http->state.buf) <= -1)
{
return -1;
}
*/
}
else
{
/*
if (parse_http_hdr (http, &http->state.buf) <= -1)
{
return -1;
}
*/
}
qse_printf (QSE_T("[%.*s]\n"), (int)http->state.buf.size, http->state.buf.data);
clear_buffer (http, &http->state.buf);
}
}
/* enbuffer the unfinished data */
if (push_to_buffer (http, &http->state.buf, blk, ptr - blk) <= -1) return -1;
qse_printf (QSE_T("UNFINISHED [%.*s]\n"), (int)http->state.buf.size, http->state.buf.data);
return 0;
}