From 376594ac1d65cbb31165f5a74775d624c3fd2981 Mon Sep 17 00:00:00 2001 From: "admin@progandy.co.cc" Date: Mon, 13 Sep 2010 18:11:13 +0000 Subject: - added basic html conversion for receiving (maybe a bit too powerful) - some bugfixes git-svn-id: http://mirotr.googlecode.com/svn/trunk@12 eced67a3-f377-a0ae-92ae-d6de1850b05a --- ekhtml/src/.deps/ekhtml.Plo | 1 + ekhtml/src/.deps/ekhtml_comment.Plo | 1 + ekhtml/src/.deps/ekhtml_data.Plo | 1 + ekhtml/src/.deps/ekhtml_endtag.Plo | 1 + ekhtml/src/.deps/ekhtml_mktables.Po | 1 + ekhtml/src/.deps/ekhtml_special.Plo | 1 + ekhtml/src/.deps/ekhtml_starttag.Plo | 1 + ekhtml/src/.deps/ekhtml_util.Plo | 1 + ekhtml/src/.deps/hash.Plo | 1 + ekhtml/src/Makefile | 402 +++++++++++++ ekhtml/src/Makefile.am | 22 + ekhtml/src/Makefile.in | 402 +++++++++++++ ekhtml/src/ekhtml.c | 394 +++++++++++++ ekhtml/src/ekhtml_comment.c | 119 ++++ ekhtml/src/ekhtml_data.c | 61 ++ ekhtml/src/ekhtml_endtag.c | 129 +++++ ekhtml/src/ekhtml_mktables.c | 141 +++++ ekhtml/src/ekhtml_special.c | 72 +++ ekhtml/src/ekhtml_starttag.c | 390 +++++++++++++ ekhtml/src/ekhtml_util.c | 55 ++ ekhtml/src/hash.c | 1035 ++++++++++++++++++++++++++++++++++ 21 files changed, 3231 insertions(+) create mode 100644 ekhtml/src/.deps/ekhtml.Plo create mode 100644 ekhtml/src/.deps/ekhtml_comment.Plo create mode 100644 ekhtml/src/.deps/ekhtml_data.Plo create mode 100644 ekhtml/src/.deps/ekhtml_endtag.Plo create mode 100644 ekhtml/src/.deps/ekhtml_mktables.Po create mode 100644 ekhtml/src/.deps/ekhtml_special.Plo create mode 100644 ekhtml/src/.deps/ekhtml_starttag.Plo create mode 100644 ekhtml/src/.deps/ekhtml_util.Plo create mode 100644 ekhtml/src/.deps/hash.Plo create mode 100644 ekhtml/src/Makefile create mode 100644 ekhtml/src/Makefile.am create mode 100644 ekhtml/src/Makefile.in create mode 100644 ekhtml/src/ekhtml.c create mode 100644 ekhtml/src/ekhtml_comment.c create mode 100644 ekhtml/src/ekhtml_data.c create mode 100644 ekhtml/src/ekhtml_endtag.c create mode 100644 ekhtml/src/ekhtml_mktables.c create mode 100644 ekhtml/src/ekhtml_special.c create mode 100644 ekhtml/src/ekhtml_starttag.c create mode 100644 ekhtml/src/ekhtml_util.c create mode 100644 ekhtml/src/hash.c (limited to 'ekhtml/src') diff --git a/ekhtml/src/.deps/ekhtml.Plo b/ekhtml/src/.deps/ekhtml.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_comment.Plo b/ekhtml/src/.deps/ekhtml_comment.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_comment.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_data.Plo b/ekhtml/src/.deps/ekhtml_data.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_data.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_endtag.Plo b/ekhtml/src/.deps/ekhtml_endtag.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_endtag.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_mktables.Po b/ekhtml/src/.deps/ekhtml_mktables.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_mktables.Po @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_special.Plo b/ekhtml/src/.deps/ekhtml_special.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_special.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_starttag.Plo b/ekhtml/src/.deps/ekhtml_starttag.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_starttag.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/ekhtml_util.Plo b/ekhtml/src/.deps/ekhtml_util.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/ekhtml_util.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/.deps/hash.Plo b/ekhtml/src/.deps/hash.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/ekhtml/src/.deps/hash.Plo @@ -0,0 +1 @@ +# dummy diff --git a/ekhtml/src/Makefile b/ekhtml/src/Makefile new file mode 100644 index 0000000..3739820 --- /dev/null +++ b/ekhtml/src/Makefile @@ -0,0 +1,402 @@ +# Makefile.in generated by automake 1.6.3 from Makefile.am. +# Generated automatically from Makefile.in by configure. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# 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. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. + +prefix = /usr/local +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include +pkgdatadir = $(datadir)/ekhtml +pkglibdir = $(libdir)/ekhtml +pkgincludedir = $(includedir)/ekhtml +top_builddir = .. + +ACLOCAL = ${SHELL} /z/missing --run aclocal-1.6 +AUTOCONF = ${SHELL} /z/missing --run autoconf +AUTOMAKE = ${SHELL} /z/missing --run automake-1.6 +AUTOHEADER = ${SHELL} /z/missing --run autoheader + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = /bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = ${INSTALL} +INSTALL_HEADER = $(INSTALL_DATA) +transform = s,x,x, +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = +host_triplet = i686-pc-mingw32 + +EXEEXT = .exe +OBJEXT = o +PATH_SEPARATOR = : +AMTAR = ${SHELL} /z/missing --run tar +AS = @AS@ +AWK = gawk +CC = gcc +DEPDIR = .deps +DLLTOOL = @DLLTOOL@ +ECHO = echo +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +MAINT = # +OBJDUMP = @OBJDUMP@ +PACKAGE = ekhtml +RANLIB = ranlib +STRIP = strip +VERSION = 0.3.2 +am__include = include +am__quote = +install_sh = /z/install-sh +libekhtml_la_SOURCES = \ + ekhtml.c \ + ekhtml_comment.c \ + ekhtml_data.c \ + ekhtml_endtag.c \ + ekhtml_special.c \ + ekhtml_starttag.c \ + ekhtml_util.c \ + hash.c + + +libekhtml_la_DEPENDENCIES = ekhtml_tables.h +lib_LTLIBRARIES = libekhtml.la +noinst_PROGRAMS = ekhtml_mktables + +ekhtml_mktables_SOURCES = ekhtml_mktables.c + +CLEANFILES = ekhtml_tables.h +subdir = src +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/include/ekhtml_config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + +libekhtml_la_LDFLAGS = +libekhtml_la_LIBADD = +am_libekhtml_la_OBJECTS = ekhtml.lo ekhtml_comment.lo ekhtml_data.lo \ + ekhtml_endtag.lo ekhtml_special.lo ekhtml_starttag.lo \ + ekhtml_util.lo hash.lo +libekhtml_la_OBJECTS = $(am_libekhtml_la_OBJECTS) +noinst_PROGRAMS = ekhtml_mktables$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + +am_ekhtml_mktables_OBJECTS = ekhtml_mktables.$(OBJEXT) +ekhtml_mktables_OBJECTS = $(am_ekhtml_mktables_OBJECTS) +ekhtml_mktables_LDADD = $(LDADD) +ekhtml_mktables_DEPENDENCIES = +ekhtml_mktables_LDFLAGS = + +DEFS = -DHAVE_CONFIG_H +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +CPPFLAGS = +LDFLAGS = +LIBS = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +DEP_FILES = ./$(DEPDIR)/ekhtml.Plo \ + ./$(DEPDIR)/ekhtml_comment.Plo \ + ./$(DEPDIR)/ekhtml_data.Plo \ + ./$(DEPDIR)/ekhtml_endtag.Plo \ + ./$(DEPDIR)/ekhtml_mktables.Po \ + ./$(DEPDIR)/ekhtml_special.Plo \ + ./$(DEPDIR)/ekhtml_starttag.Plo \ + ./$(DEPDIR)/ekhtml_util.Plo ./$(DEPDIR)/hash.Plo +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = -g -O2 +DIST_SOURCES = $(libekhtml_la_SOURCES) $(ekhtml_mktables_SOURCES) +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libekhtml_la_SOURCES) $(ekhtml_mktables_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: # Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +Makefile: # $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +libLTLIBRARIES_INSTALL = $(INSTALL) +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test -z "$dir" && dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libekhtml.la: $(libekhtml_la_OBJECTS) $(libekhtml_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libekhtml_la_LDFLAGS) $(libekhtml_la_OBJECTS) $(libekhtml_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ekhtml_mktables$(EXEEXT): $(ekhtml_mktables_OBJECTS) $(ekhtml_mktables_DEPENDENCIES) + @rm -f ekhtml_mktables$(EXEEXT) + $(LINK) $(ekhtml_mktables_LDFLAGS) $(ekhtml_mktables_OBJECTS) $(ekhtml_mktables_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/ekhtml.Plo +include ./$(DEPDIR)/ekhtml_comment.Plo +include ./$(DEPDIR)/ekhtml_data.Plo +include ./$(DEPDIR)/ekhtml_endtag.Plo +include ./$(DEPDIR)/ekhtml_mktables.Po +include ./$(DEPDIR)/ekhtml_special.Plo +include ./$(DEPDIR)/ekhtml_starttag.Plo +include ./$(DEPDIR)/ekhtml_util.Plo +include ./$(DEPDIR)/hash.Plo + +distclean-depend: + -rm -rf ./$(DEPDIR) + +.c.o: + source='$<' object='$@' libtool=no \ + depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \ + $(CCDEPMODE) $(depcomp) \ + $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< + +.c.obj: + source='$<' object='$@' libtool=no \ + depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \ + $(CCDEPMODE) $(depcomp) \ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: + source='$<' object='$@' libtool=yes \ + depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' \ + $(CCDEPMODE) $(depcomp) \ + $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< +CCDEPMODE = depmode=gcc3 + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +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; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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 $(LTLIBRARIES) $(PROGRAMS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) + +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_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_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-libLTLIBRARIES clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-libLTLIBRARIES + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES + +.PHONY: GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ + distclean distclean-compile distclean-depend distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool tags uninstall \ + uninstall-am uninstall-info-am uninstall-libLTLIBRARIES + + +ekhtml.c: ekhtml_tables.h + +ekhtml_tables.h: ekhtml_mktables + ./ekhtml_mktables > $@ +# 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: diff --git a/ekhtml/src/Makefile.am b/ekhtml/src/Makefile.am new file mode 100644 index 0000000..6fcdaf8 --- /dev/null +++ b/ekhtml/src/Makefile.am @@ -0,0 +1,22 @@ +libekhtml_la_SOURCES = \ + ekhtml.c \ + ekhtml_comment.c \ + ekhtml_data.c \ + ekhtml_endtag.c \ + ekhtml_special.c \ + ekhtml_starttag.c \ + ekhtml_util.c \ + hash.c + +libekhtml_la_DEPENDENCIES = ekhtml_tables.h +lib_LTLIBRARIES = libekhtml.la +noinst_PROGRAMS = ekhtml_mktables + +ekhtml_mktables_SOURCES = ekhtml_mktables.c + +ekhtml.c: ekhtml_tables.h + +ekhtml_tables.h: ekhtml_mktables + ./ekhtml_mktables > $@ + +CLEANFILES = ekhtml_tables.h diff --git a/ekhtml/src/Makefile.in b/ekhtml/src/Makefile.in new file mode 100644 index 0000000..c5147f0 --- /dev/null +++ b/ekhtml/src/Makefile.in @@ -0,0 +1,402 @@ +# Makefile.in generated by automake 1.6.3 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# 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. + +@SET_MAKE@ +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ +libekhtml_la_SOURCES = \ + ekhtml.c \ + ekhtml_comment.c \ + ekhtml_data.c \ + ekhtml_endtag.c \ + ekhtml_special.c \ + ekhtml_starttag.c \ + ekhtml_util.c \ + hash.c + + +libekhtml_la_DEPENDENCIES = ekhtml_tables.h +lib_LTLIBRARIES = libekhtml.la +noinst_PROGRAMS = ekhtml_mktables + +ekhtml_mktables_SOURCES = ekhtml_mktables.c + +CLEANFILES = ekhtml_tables.h +subdir = src +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/include/ekhtml_config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + +libekhtml_la_LDFLAGS = +libekhtml_la_LIBADD = +am_libekhtml_la_OBJECTS = ekhtml.lo ekhtml_comment.lo ekhtml_data.lo \ + ekhtml_endtag.lo ekhtml_special.lo ekhtml_starttag.lo \ + ekhtml_util.lo hash.lo +libekhtml_la_OBJECTS = $(am_libekhtml_la_OBJECTS) +noinst_PROGRAMS = ekhtml_mktables$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + +am_ekhtml_mktables_OBJECTS = ekhtml_mktables.$(OBJEXT) +ekhtml_mktables_OBJECTS = $(am_ekhtml_mktables_OBJECTS) +ekhtml_mktables_LDADD = $(LDADD) +ekhtml_mktables_DEPENDENCIES = +ekhtml_mktables_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ekhtml.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_comment.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_data.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_endtag.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_mktables.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_special.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_starttag.Plo \ +@AMDEP_TRUE@ ./$(DEPDIR)/ekhtml_util.Plo ./$(DEPDIR)/hash.Plo +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libekhtml_la_SOURCES) $(ekhtml_mktables_SOURCES) +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libekhtml_la_SOURCES) $(ekhtml_mktables_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +libLTLIBRARIES_INSTALL = $(INSTALL) +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test -z "$dir" && dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libekhtml.la: $(libekhtml_la_OBJECTS) $(libekhtml_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libekhtml_la_LDFLAGS) $(libekhtml_la_OBJECTS) $(libekhtml_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ekhtml_mktables$(EXEEXT): $(ekhtml_mktables_OBJECTS) $(ekhtml_mktables_DEPENDENCIES) + @rm -f ekhtml_mktables$(EXEEXT) + $(LINK) $(ekhtml_mktables_LDFLAGS) $(ekhtml_mktables_OBJECTS) $(ekhtml_mktables_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_comment.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_data.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_endtag.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_mktables.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_special.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_starttag.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ekhtml_util.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Plo@am__quote@ + +distclean-depend: + -rm -rf ./$(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +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; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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 $(LTLIBRARIES) $(PROGRAMS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) + +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_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_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-libLTLIBRARIES clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-libLTLIBRARIES + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES + +.PHONY: GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ + distclean distclean-compile distclean-depend distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool tags uninstall \ + uninstall-am uninstall-info-am uninstall-libLTLIBRARIES + + +ekhtml.c: ekhtml_tables.h + +ekhtml_tables.h: ekhtml_mktables + ./ekhtml_mktables > $@ +# 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: diff --git a/ekhtml/src/ekhtml.c b/ekhtml/src/ekhtml.c new file mode 100644 index 0000000..f369746 --- /dev/null +++ b/ekhtml/src/ekhtml.c @@ -0,0 +1,394 @@ +/* + * Copyright (c) 2002, Jon Travis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ekhtml: The El-Kabong HTML parser + * by Jon Travis (jtravis@p00p.org) + * + * El-Kabong: A speedy, yet forgiving, SAX-stylee HTML parser. + * + * The idea behind this parser is for it to use very little memory, and still + * be very speedy, while forgiving poorly written HTML. + + * The internals of the parser consist of a small memory buffer which is able + * to grow when not enough information is known to correctly parse a tag. + * Given the typical layout of HTML, 4k should be plenty. + * + * The main state engine loops through this internal buffer, determining what + * the next state should be. Once this is known, it passes off a segment to + * the state handlers (starttag, endtag, etc.) to process. The segment + * handlers and the main state engine communicate via a few variables. These + * variables indicate whether or not the main engine should switch state, + * or successfully remove some data, etc. The segment handlers are + * guaranteed the same starting data (though not the same pointer) on each + * invocation until the state is changed. Thus, the segment handlers cannot + * use pointers into the main buffer -- they must use offsets. + * + * Some of the speed is gained from using character map data found in + * ekhtml_tables.h. I don't have any empirical data for this yet -- + * it only sounds like it would be faster.. ;-) + * + * I'm always looking for ways to clean && speed up this code. Feel free + * to give feedback -- JMT + */ + + +#include +#include +#include +#include +#include + +#include "ekhtml_config.h" +#include "ekhtml.h" +#define EKHTML_USE_TABLES +#include "ekhtml_tables.h" +#define EKHTML_USE_PRIVATE +#include "ekhtml_private.h" + +#ifndef MIN +#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#endif + + +/* + * ekhtml_buffer_grow: Grow the parser's internal buffer by a blocksize. + * NOTE: Calling the function has the potential to + * change the data buffer location. Do + * not rely on it's location! + * + * Arguments: Parser = Parser to grow + */ + +static void ekhtml_buffer_grow(ekhtml_parser_t *parser){ + size_t newsize; + char *newbuf; + + newsize = parser->nalloced + EKHTML_BLOCKSIZE; + + if((newbuf = realloc(parser->buf, newsize)) == NULL){ + fprintf(stderr, "BAD! Can't allocate %d bytes in ekhtml_buffer_grow\n", + newsize); + fflush(stderr); /* Just in case someone changes the buffering scheme */ + } + + parser->buf = newbuf; + parser->nalloced = newsize; +} + +/* + * parser_state_determine: Determine the next state that the main parser + * should have, by investigating up to the first + * 4 characters in the buffer. + * + * Arguments: startp = Starting data pointer + * endp = Pointer to first byte of 'out of range' data + * + * Return values: Returns one of EKHTML_STATE_* indicating the state that + * was found. + * + */ + +static inline +int parser_state_determine(const char *startp, const char *endp){ + const char *firstchar; + int newstate; + + assert(startp != endp); + + if(*startp != '<') + return EKHTML_STATE_INDATA; + + firstchar = startp + 1; + if(firstchar == endp) + return EKHTML_STATE_NONE; + + newstate = EKCMap_EKState[(unsigned char)*firstchar]; + if(newstate == EKHTML_STATE_NONE){ + if(firstchar + 2 >= endp) /* Not enough data to evaluate */ + return EKHTML_STATE_NONE; + if(*(firstchar + 1) == '-' && *(firstchar + 2) == '-') + return EKHTML_STATE_COMMENT; + else + return EKHTML_STATE_SPECIAL; + } else + return newstate; +} + + +int ekhtml_parser_flush(ekhtml_parser_t *parser, int flushall){ + void **state_data = &parser->state.state_data; + char *buf = parser->buf, *curp = buf, *endp = buf + parser->nbuf; + int badp = -1, tmpstate = parser->state.state, didsomething = 0; + + while(curp != endp){ + char *workp = curp; + + if(tmpstate == EKHTML_STATE_NONE){ + tmpstate = parser_state_determine(workp, endp); + if(tmpstate == EKHTML_STATE_NONE) /* Not enough data yet */ + break; + } + + if(tmpstate == EKHTML_STATE_INDATA || tmpstate == EKHTML_STATE_BADDATA) + curp = ekhtml_parse_data(parser, workp, endp, tmpstate); + else if(endp - workp > 2){ /* All tags fall under this catagory */ + switch(tmpstate){ + case EKHTML_STATE_ENDTAG: + curp = ekhtml_parse_endtag(parser, state_data, + workp, endp, &badp); + break; + case EKHTML_STATE_STARTTAG: + curp = ekhtml_parse_starttag(parser, state_data, + workp, endp, &badp); + break; + case EKHTML_STATE_COMMENT: + curp = ekhtml_parse_comment(parser, state_data, + workp, endp, &badp); + break; + case EKHTML_STATE_SPECIAL: + curp = ekhtml_parse_special(parser, state_data, + workp, endp, &badp); + break; + default: + assert(!"Unimplemented state"); + } + } else { + curp = NULL; /* Not enough data, keep going */ + } + + /* If one of the parsers said the data was bad, reset the state */ + if(badp != -1){ + tmpstate = badp; + badp = -1; + } + + if(curp == NULL){ /* State needed more data, so break out */ + curp = workp; + break; + } + + if(workp != curp){ /* state backend cleared up some data */ + didsomething = 1; + tmpstate = EKHTML_STATE_NONE; + assert(*state_data == NULL); + } + } + + if(flushall){ + /* Flush whatever we didn't use */ + if(parser->datacb){ + ekhtml_string_t str; + + str.str = curp; + str.len = endp - curp; + parser->datacb(parser->cbdata, &str); + } + curp = endp; + didsomething = 1; + tmpstate = EKHTML_STATE_NONE; /* Clean up to an unknown state */ + *state_data = NULL; + } + + parser->state.state = tmpstate; + + if(didsomething){ + /* Shuffle the data back, based on where we ended up */ + parser->nbuf -= curp - buf; + if(endp - curp){ /* If there's still any data to move */ + memmove(buf, curp, endp - curp); + } + } + return didsomething; +} + +void ekhtml_parser_feed(ekhtml_parser_t *parser, ekhtml_string_t *str){ + size_t nfed = 0; + + while(nfed != str->len){ + size_t tocopy; + + /* First see how much we can fill up our internal buffer */ + tocopy = MIN(parser->nalloced - parser->nbuf, str->len - nfed); + memcpy(parser->buf + parser->nbuf, str->str + nfed, tocopy); + nfed += tocopy; + parser->nbuf += tocopy; + if(parser->nalloced == parser->nbuf){ + /* Process the buffer */ + if(!ekhtml_parser_flush(parser, 0)){ + /* If we didn't actually process anything, grow our buffer */ + ekhtml_buffer_grow(parser); + } + } + } +} + +void ekhtml_parser_datacb_set(ekhtml_parser_t *parser, ekhtml_data_cb_t cb){ + parser->datacb = cb; +} + +void ekhtml_parser_commentcb_set(ekhtml_parser_t *parser, ekhtml_data_cb_t cb){ + parser->commentcb = cb; +} + +void ekhtml_parser_cbdata_set(ekhtml_parser_t *parser, void *cbdata){ + parser->cbdata = cbdata; +} + +static void +ekhtml_parser_startendcb_add(ekhtml_parser_t *parser, const char *tag, + ekhtml_starttag_cb_t startcb, + ekhtml_endtag_cb_t endcb, + int isStart) +{ + ekhtml_tag_container *cont; + ekhtml_string_t lookup_str; + char *newtag, *cp; + unsigned int taglen; + hnode_t *hn; + + if(!tag){ + if(isStart) + parser->startcb_unk = startcb; + else + parser->endcb_unk = endcb; + return; + } + + + newtag = _strdup(tag); + for(cp=newtag; *cp; cp++) + *cp = toupper(*cp); + + taglen = cp - newtag; + + /* First see if the container already exists */ + lookup_str.str = newtag; + lookup_str.len = taglen; + + if((hn = hash_lookup(parser->startendcb, &lookup_str))){ + cont = hnode_get(hn); + free(newtag); + if(isStart) + cont->startfunc = startcb; + else + cont->endfunc = endcb; + } else { + ekhtml_string_t *set_str; + + cont = malloc(sizeof(*cont)); + if(isStart){ + cont->startfunc = startcb; + cont->endfunc = NULL; + } else { + cont->startfunc = NULL; + cont->endfunc = endcb; + } + set_str = malloc(sizeof(*set_str)); + *set_str = lookup_str; + hash_alloc_insert(parser->startendcb, set_str, cont); + } +} + +void ekhtml_parser_startcb_add(ekhtml_parser_t *parser, const char *tag, + ekhtml_starttag_cb_t cback) +{ + ekhtml_parser_startendcb_add(parser, tag, cback, NULL, 1); +} + +void ekhtml_parser_endcb_add(ekhtml_parser_t *parser, const char *tag, + ekhtml_endtag_cb_t cback) +{ + ekhtml_parser_startendcb_add(parser, tag, NULL, cback, 0); +} + + +static hash_val_t ekhtml_string_hash(const void *key){ + const ekhtml_string_t *s = key; + hash_val_t res = 5381; + const char *str = s->str; + size_t len = s->len; + int c; + + while(len--){ + c = str[len]; + res = ((res << 5) + res) + c; /* res * 33 + c */ + } + return res; +} + +static int ekhtml_string_comp(const void *key1, const void *key2){ + const ekhtml_string_t *s1 = key1, *s2 = key2; + + if(s1->len == s2->len) + return memcmp(s1->str, s2->str, s1->len); + return 1; +} + +void ekhtml_parser_destroy(ekhtml_parser_t *ekparser){ + hnode_t *hn; + hscan_t hs; + + hash_scan_begin(&hs, ekparser->startendcb); + while((hn = hash_scan_next(&hs))){ + ekhtml_string_t *key = (ekhtml_string_t *)hnode_getkey(hn); + ekhtml_tag_container *cont = hnode_get(hn); + + hash_scan_delete(ekparser->startendcb, hn); + free((char *)key->str); + free(key); + free(cont); + } + + hash_destroy(ekparser->startendcb); + ekhtml_parser_starttag_cleanup(ekparser); + free(ekparser->buf); + free(ekparser); +} + +ekhtml_parser_t *ekhtml_parser_new(void *cbdata){ + ekhtml_parser_t *res; + + res = malloc(sizeof(*res)); + res->datacb = NULL; + res->startendcb = hash_create(HASHCOUNT_T_MAX, ekhtml_string_comp, + ekhtml_string_hash); + res->cbdata = cbdata; + res->startcb_unk = NULL; + res->endcb_unk = NULL; + res->commentcb = NULL; + res->buf = NULL; + res->nalloced = 0; + res->nbuf = 0; + res->freeattrs = NULL; + res->state.state = EKHTML_STATE_NONE; + res->state.state_data = NULL; + + /* Start out with a buffer of 1 block size */ + ekhtml_buffer_grow(res); + return res; +} + diff --git a/ekhtml/src/ekhtml_comment.c b/ekhtml/src/ekhtml_comment.c new file mode 100644 index 0000000..e37cc48 --- /dev/null +++ b/ekhtml/src/ekhtml_comment.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2002, Jon Travis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ekhtml_comment.c: Comment tag processor for El-Kabong. + * + * The comment processor is a pretty simple piece of machinery. It + * relies that the first 4 characters are '