From: Guido Draheim Date: Sat, 14 May 2005 15:08:23 +0000 (+0000) Subject: zzip64 helpers X-Git-Tag: v0.13.48~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d968f17ebc0bb7b747ea8b5819519a261b972163;p=zziplib zzip64 helpers (.) --- diff --git a/ChangeLog b/ChangeLog index 0e540a3..725cb87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2005-02-17 + * adding that _GNU_SOURCE on __linux__ to get the strndup prototype + * cleaning a few warning messages on different platforms as well + as a bug for 64bit platforms + * updating docs/mksite.sh and adding docs/mksite.pl and going to + let VERSION be pasted directly instead of a makefile snippet + * adding docs/memdisk.htm documentation to the series which is + currently quite shallow. + * note: no tests for actual zip64 support are made, neither for a + large central directory (more than 64K files) nor for large + files (more than 2GB). This is all theoretic but I am quite + confident that it will work. + +2005-02-16 + * change zzip/zip disk_trailer implementation + * we do not anymore pass a copy of the file block around + * we do use a local helper structure now with off_t fields + * the parse_root_directory is now using off_t for all computatations + * make check succeeds - beware, this is a new implementation + * RANT: glibc bastards make for additinal warning messages, the fseeko + prototype is not exported by default, but as soon as we add some + define to make it available, some other prototypes are disabled, + including one of the most widespread: strndup(). The documentation + even says we have to say GNU to get prototype - if you have ever heard + of unix to diverge into something not quite but be alike, here it is, + what compiles on most platforms gives a warning on linux even that it + works fine afterwards because the libc does export all we need and + autoconf does find it - it is just not prototyped and that's all. + +2005-02-15 + * adding zzip/memdisk.* as cache variant for libzzipfseeko + * add macro support for zip64 extensions + * extend trailer routines with zip64 detection (and return 0) + * add memdisk bins + 2005-01-04 * remember TODO multithreading tests and hardening the code. http://www.idefense.com/application/poi/display?id=153&type=vulnerabilities diff --git a/acinclude.m4 b/acinclude.m4 index adeef66..5ab1bfb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,4 +1,4 @@ -dnl acinclude.m4 generated automatically by ac-archive's acinclude 0.5.60 +dnl acinclude.m4 generated automatically by ac-archive's acinclude 0.5.63 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -1060,7 +1060,7 @@ dnl copy the tarball from the builddir to the sourcedir (or $(PUB)) dnl for reason of convenience. dnl dnl @author Guido Draheim -dnl @version %Id: ax_enable_builddir.m4,v 1.14 2004/12/29 05:22:31 guidod Exp % +dnl @version %Id: ax_enable_builddir.m4,v 1.16 2005/01/16 17:29:48 guidod Exp % dnl AC_DEFUN([AX_ENABLE_BUILDDIR],[AC_REQUIRE([AC_CANONICAL_HOST])[]dnl AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl @@ -1107,6 +1107,12 @@ if test ".$srcdir" = ".." ; then fi fi dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec" AC_PATH_PROG(SED,gsed sed, sed) +AUX="$ac_aux_dir" ; test ".$AUX" = "." && AUX="." +echo "AUX=(1) $AUX" +echo "$AUX" : $SED -e "'s!$ac_top_srcdir!.!'" +AUX=`echo "$AUX" | $SED -e "s|$ac_top_srcdir|.|"` +test ".$AUX" = "." && AUX="." +echo "AUX=(2)=$AUX" AS_VAR_POPDEF([SED])dnl AS_VAR_POPDEF([AUX])dnl AS_VAR_POPDEF([SUB])dnl @@ -1180,7 +1186,7 @@ dnl dist-all exists... and would make for dist-all-all ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) ; done + ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) /dist[]_ALL *:/a\\ @ HOST="\$(HOST)\" \\\\\\ @@ -1191,8 +1197,8 @@ dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) ; if test "\$\$found" = "0" ; then : \\\\\\ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; test -f "\$\$i/\$(PACKAGE)-\$(VERSION).tar.gz" \\\\\\ - && mv "\$\$i/\$(PACKAGE)-\$(VERSION).tar.gz" \$(PUB). ; break ; done + ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ + ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done dnl special rule add-on: "distclean" removes all local builddirs completely /distclean[]_ALL *:/a\\ @ HOST="\$(HOST)\" \\\\\\ @@ -1694,9 +1700,10 @@ dnl that can read good initializers from the .spec file. In consequencd, most dnl of the generatable installable stuff can be made from information being dnl updated in a single place for the whole project. dnl -dnl @%Id: ax_create_pkgconfig_info.m4,v 1.1 2003/10/19 00:08:51 guidod Exp % +dnl @%Id: ax_create_pkgconfig_info.m4,v 1.2 2005/01/06 19:56:30 guidod Exp % AC_DEFUN([AX_CREATE_PKGCONFIG_INFO],[dnl +AS_VAR_PUSHDEF([PKGCONFIG_suffix],[ax_create_pkgconfig_suffix])dnl AS_VAR_PUSHDEF([PKGCONFIG_libdir],[ax_create_pkgconfig_libdir])dnl AS_VAR_PUSHDEF([PKGCONFIG_libfile],[ax_create_pkgconfig_libfile])dnl AS_VAR_PUSHDEF([PKGCONFIG_libname],[ax_create_pkgconfig_libname])dnl @@ -1753,6 +1760,11 @@ test "$pkgconfig_libfile" != "$PKGCONFIG_libfile" && ( AC_MSG_RESULT(expanded our pkgconfig_libfile... $PKGCONFIG_libfile)) AC_SUBST([pkgconfig_libfile]) +AC_MSG_CHECKING(our package / suffix) +PKGCONFIG_suffix="$program_suffix" +test ".$PKGCONFIG_suffix" != .NONE || PKGCONFIG_suffix="" +AC_MSG_RESULT(${PACKAGE_NAME} / ${PKGCONFIG_suffix}) + AC_MSG_CHECKING(our pkgconfig description) PKGCONFIG_description="ifelse($4,,$PACKAGE_SUMMARY,$4)" test ".$PKGCONFIG_description" != "." || \ @@ -1790,7 +1802,7 @@ AC_MSG_RESULT(generate the pkgconfig later... $PKGCONFIG_generate)) if test ".$PKGCONFIG_src_libdir" = "." ; then PKGCONFIG_src_libdir=`pwd` -PKGCONFIG_src_libdir=`AX_DIRNAME("$PKGCONFIG_src_libdir/$PKGCONFIG_generate")` +PKGCONFIG_src_libdir=`AS_DIRNAME("$PKGCONFIG_src_libdir/$PKGCONFIG_generate")` test ! -d $PKGCONFIG_src_libdir/src || \ PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/src" case ".$objdir" in @@ -1804,12 +1816,13 @@ v="$ac_top_srcdir" ; test ".$v" != "." || v="$ax_spec_dir" test ".$v" != "." || v="$srcdir" case "$v" in /*) PKG_CONFIG_src_headers="" ;; esac -PKGCONFIG_src_headers=`AX_DIRNAME("$PKGCONFIG_src_headers/$v/x")` +PKGCONFIG_src_headers=`AS_DIRNAME("$PKGCONFIG_src_headers/$v/x")` test ! -d $PKGCONFIG_src_headers/incl[]ude || \ PKGCONFIG_src_headers="$PKGCONFIG_src_headers/incl[]ude" AC_MSG_RESULT(noninstalled pkgconfig -I $PKGCONFIG_src_headers) fi + dnl AC_CONFIG_COMMANDS crap disallows to use $PKGCONFIG_libfile here... AC_CONFIG_COMMANDS([$ax_create_pkgconfig_generate],[ pkgconfig_generate="$ax_create_pkgconfig_generate" @@ -1821,12 +1834,17 @@ else generate="false"; fi if $generate ; then AC_MSG_NOTICE(creating $pkgconfig_generate.in) -cat > $pkgconfig_generate.in <<_EOF +cat > $pkgconfig_generate.in < $pkgconfig_generate +cat >conftest.sed < $pkgconfig_generate if test ! -s $pkgconfig_generate ; then AC_MSG_ERROR([$pkgconfig_generate is empty]) -fi # DONE generate $pkgconfig_generate +fi ; rm conftest.sed # DONE generate $pkgconfig_generate pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.pc/'` AC_MSG_NOTICE(creating $pkgconfig_uninstalled) -sed -e "s|@prefix@|${pkgconfig_prefix}|" \ - -e "s|@exec_prefix@|${pkgconfig_execprefix}|" \ - -e "s|@libdir@|${pkgconfig_src_libdir}|" \ - -e "s|@includedir@|${pkgconfig_src_headers}|" \ - -e "s|@PACKAGE_NAME@|${pkgconfig_libname}|" \ - -e "s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|" \ - -e "s|@PACKAGE_VERSION@|${pkgconfig_version}|" \ - -e "s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|" \ - -e "s|@LIBS@|${pkgconfig_libs}|" \ - -e "s|@CPPFLAGS@|${pkgconfig_cppflags}|" \ - $pkgconfig_generate.in > $pkgconfig_uninstalled +cat >conftest.sed < $pkgconfig_uninstalled if test ! -s $pkgconfig_uninstalled ; then AC_MSG_ERROR([$pkgconfig_uninstalled is empty]) -fi # DONE generate $pkgconfig_uninstalled +fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled + pkgconfig_requires_add=`echo ${pkgconfig_requires}` +if test ".$pkgconfig_requires_add" != "." ; then + pkgconfig_requires_add="pkg-config $pkgconfig_requires_add" + else pkgconfig_requires_add=":" ; fi +pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.sh/'` +AC_MSG_NOTICE(creating $pkgconfig_uninstalled) +cat >conftest.sed <Name:>for option\\; do case \"\$option\" in --list-all|--name) echo > +s>Description: *>\\;\\; --help) pkg-config --help \\; echo Buildscript Of > +s>Version: *>\\;\\; --modversion|--version) echo > +s>Requires:>\\;\\; --requires) echo $pkgconfig_requires_add> +s>Libs: *>\\;\\; --libs) echo > +s>Cflags: *>\\;\\; --cflags) echo > +/--libs)/a\\ + $pkgconfig_requires_add +/--cflags)/a\\ + $pkgconfig_requires_add\\ +;; --variable=*) eval echo '\$'\`echo \$option | sed -e 's/.*=//'\`\\ +;; --uninstalled) exit 0 \\ +;; *) ;; esac done +AXEOF +sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled +if test ! -s $pkgconfig_uninstalled ; then + AC_MSG_ERROR([$pkgconfig_uninstalled is empty]) +fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled ],[ dnl AC_CONFIG_COMMANDS crap, the AS_PUSHVAR defines are invalid here... ax_create_pkgconfig_generate="$ax_create_pkgconfig_generate" pkgconfig_prefix='$prefix' pkgconfig_execprefix='$exec_prefix' +pkgconfig_bindir='$bindir' pkgconfig_libdir='$libdir' pkgconfig_includedir='$includedir' +pkgconfig_datadir='$datadir' +pkgconfig_sysconfdir='$sysconfdir' +pkgconfig_suffix='$ax_create_pkgconfig_suffix' +pkgconfig_package='$PACKAGE_NAME' pkgconfig_libname='$ax_create_pkgconfig_libname' pkgconfig_description='$ax_create_pkgconfig_description' pkgconfig_version='$ax_create_pkgconfig_version' @@ -1883,6 +1960,7 @@ pkgconfig_cppflags='$ax_create_pkgconfig_cppflags' pkgconfig_src_libdir='$ax_create_pkgconfig_src_libdir' pkgconfig_src_headers='$ax_create_pkgconfig_src_headers' ])dnl +AS_VAR_POPDEF([PKGCONFIG_suffix])dnl AS_VAR_POPDEF([PKGCONFIG_libdir])dnl AS_VAR_POPDEF([PKGCONFIG_libfile])dnl AS_VAR_POPDEF([PKGCONFIG_libname])dnl @@ -2067,30 +2145,6 @@ AS_VAR_POPDEF([_DEF])dnl AS_VAR_POPDEF([_OUT])dnl ],[PACKAGE="$PACKAGE"])]) -dnl ______ /usr/share/aclocal/guidod/ax_dirname.m4 ______ -dnl @* AX_DIRNAME(PATHNAME) -dnl -dnl Parts of the implementation have been taken from AS_DIRNAME from the -dnl main autoconf package in generation 2.5x. However, we do only use -dnl "sed" to cut out the dirname, and we do additionally clean up some -dnl dir/.. parts in the resulting pattern. -dnl -dnl this macro may be used in autoconf 2.13 scripts as well. -dnl -dnl @%Id: ax_dirname.m4,v 1.1 2003/07/02 23:42:59 guidod Exp % - -AC_DEFUN([AX_DIRNAME], -[echo X[]$1 | - sed ['s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - /^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q']]) - dnl ______ /usr/share/aclocal/guidod/ax_not_enable_frame_pointer.m4 ______ dnl @* AX_NOT_ENABLE_FRAME_POINTER ([shellvar]) dnl diff --git a/bins/Makefile.am b/bins/Makefile.am index 84059e9..957ac84 100644 --- a/bins/Makefile.am +++ b/bins/Makefile.am @@ -4,7 +4,8 @@ DEFAULT_INCLUDES = # nothing - no default of -I. -I$(srcdir) DEFS = @DEFS@ -I$(top_builddir) -I$(top_srcdir) # also for automake 1.4 bin_PROGRAMS = zzcat zzdir zzxorcat zzxordir zzxorcopy \ - unzzip unzzipdir unzzipcat unzzipshow + unzzip unzzipdir unzzipcat unzzipcat-seeko \ + unzzipdir-mem unzzipcat-mem noinst_PROGRAMS = zziptest zzobfuscated zzip aclocaldir = $(datadir)/aclocal aclocal_DATA = zziplib.m4 @@ -41,9 +42,13 @@ unzzipdir_LDFLAGS = @ZZIPLIB_LDFLAGS@ unzzipdir_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz unzzipcat_LDFLAGS = @ZZIPLIB_LDFLAGS@ unzzipcat_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzipdir_mem_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipdir_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzipcat_mem_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipcat_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz # and this uses the simplified fseeko stdio version -unzzipshow_LDFLAGS = @ZZIPLIB_LDFLAGS@ -unzzipshow_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz +unzzipcat_seeko_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipcat_seeko_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz ../zzip/libzzip.la : @top_srcdir@/zzip/*.c (cd ../zzip && $(MAKE) `basename $@`) diff --git a/bins/Makefile.in b/bins/Makefile.in index b9d33bf..9bfd138 100644 --- a/bins/Makefile.in +++ b/bins/Makefile.in @@ -15,7 +15,7 @@ @SET_MAKE@ -SOURCES = unzzip.c unzzipcat.c unzzipdir.c unzzipshow.c zzcat.c zzdir.c zzip.c zziptest.c zzobfuscated.c zzxorcat.c zzxorcopy.c zzxordir.c +SOURCES = unzzip.c unzzipcat.c unzzipcat-mem.c unzzipcat-seeko.c unzzipdir.c unzzipdir-mem.c zzcat.c zzdir.c zzip.c zziptest.c zzobfuscated.c zzxorcat.c zzxorcopy.c zzxordir.c srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -42,7 +42,8 @@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = zzcat$(EXEEXT) zzdir$(EXEEXT) zzxorcat$(EXEEXT) \ zzxordir$(EXEEXT) zzxorcopy$(EXEEXT) unzzip$(EXEEXT) \ - unzzipdir$(EXEEXT) unzzipcat$(EXEEXT) unzzipshow$(EXEEXT) + unzzipdir$(EXEEXT) unzzipcat$(EXEEXT) unzzipcat-seeko$(EXEEXT) \ + unzzipdir-mem$(EXEEXT) unzzipcat-mem$(EXEEXT) noinst_PROGRAMS = zziptest$(EXEEXT) zzobfuscated$(EXEEXT) \ zzip$(EXEEXT) subdir = bins @@ -64,12 +65,18 @@ unzzip_DEPENDENCIES = ../zzip/libzzip.la unzzipcat_SOURCES = unzzipcat.c unzzipcat_OBJECTS = unzzipcat.$(OBJEXT) unzzipcat_DEPENDENCIES = ../zzip/libzzipmmapped.la +unzzipcat_mem_SOURCES = unzzipcat-mem.c +unzzipcat_mem_OBJECTS = unzzipcat-mem.$(OBJEXT) +unzzipcat_mem_DEPENDENCIES = ../zzip/libzzipmmapped.la +unzzipcat_seeko_SOURCES = unzzipcat-seeko.c +unzzipcat_seeko_OBJECTS = unzzipcat-seeko.$(OBJEXT) +unzzipcat_seeko_DEPENDENCIES = ../zzip/libzzipfseeko.la unzzipdir_SOURCES = unzzipdir.c unzzipdir_OBJECTS = unzzipdir.$(OBJEXT) unzzipdir_DEPENDENCIES = ../zzip/libzzipmmapped.la -unzzipshow_SOURCES = unzzipshow.c -unzzipshow_OBJECTS = unzzipshow.$(OBJEXT) -unzzipshow_DEPENDENCIES = ../zzip/libzzipfseeko.la +unzzipdir_mem_SOURCES = unzzipdir-mem.c +unzzipdir_mem_OBJECTS = unzzipdir-mem.$(OBJEXT) +unzzipdir_mem_DEPENDENCIES = ../zzip/libzzipmmapped.la zzcat_SOURCES = zzcat.c zzcat_OBJECTS = zzcat.$(OBJEXT) zzcat_DEPENDENCIES = ../zzip/libzzip.la @@ -104,12 +111,12 @@ LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = unzzip.c unzzipcat.c unzzipdir.c unzzipshow.c zzcat.c \ - zzdir.c zzip.c zziptest.c zzobfuscated.c zzxorcat.c \ - zzxorcopy.c zzxordir.c -DIST_SOURCES = unzzip.c unzzipcat.c unzzipdir.c unzzipshow.c zzcat.c \ - zzdir.c zzip.c zziptest.c zzobfuscated.c zzxorcat.c \ - zzxorcopy.c zzxordir.c +SOURCES = unzzip.c unzzipcat.c unzzipcat-mem.c unzzipcat-seeko.c \ + unzzipdir.c unzzipdir-mem.c zzcat.c zzdir.c zzip.c zziptest.c \ + zzobfuscated.c zzxorcat.c zzxorcopy.c zzxordir.c +DIST_SOURCES = unzzip.c unzzipcat.c unzzipcat-mem.c unzzipcat-seeko.c \ + unzzipdir.c unzzipdir-mem.c zzcat.c zzdir.c zzip.c zziptest.c \ + zzobfuscated.c zzxorcat.c zzxorcopy.c zzxordir.c am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -284,9 +291,13 @@ unzzipdir_LDFLAGS = @ZZIPLIB_LDFLAGS@ unzzipdir_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz unzzipcat_LDFLAGS = @ZZIPLIB_LDFLAGS@ unzzipcat_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzipdir_mem_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipdir_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzipcat_mem_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipcat_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz # and this uses the simplified fseeko stdio version -unzzipshow_LDFLAGS = @ZZIPLIB_LDFLAGS@ -unzzipshow_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz +unzzipcat_seeko_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzipcat_seeko_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz all: all-am .SUFFIXES: @@ -361,12 +372,18 @@ unzzip$(EXEEXT): $(unzzip_OBJECTS) $(unzzip_DEPENDENCIES) unzzipcat$(EXEEXT): $(unzzipcat_OBJECTS) $(unzzipcat_DEPENDENCIES) @rm -f unzzipcat$(EXEEXT) $(LINK) $(unzzipcat_LDFLAGS) $(unzzipcat_OBJECTS) $(unzzipcat_LDADD) $(LIBS) +unzzipcat-mem$(EXEEXT): $(unzzipcat_mem_OBJECTS) $(unzzipcat_mem_DEPENDENCIES) + @rm -f unzzipcat-mem$(EXEEXT) + $(LINK) $(unzzipcat_mem_LDFLAGS) $(unzzipcat_mem_OBJECTS) $(unzzipcat_mem_LDADD) $(LIBS) +unzzipcat-seeko$(EXEEXT): $(unzzipcat_seeko_OBJECTS) $(unzzipcat_seeko_DEPENDENCIES) + @rm -f unzzipcat-seeko$(EXEEXT) + $(LINK) $(unzzipcat_seeko_LDFLAGS) $(unzzipcat_seeko_OBJECTS) $(unzzipcat_seeko_LDADD) $(LIBS) unzzipdir$(EXEEXT): $(unzzipdir_OBJECTS) $(unzzipdir_DEPENDENCIES) @rm -f unzzipdir$(EXEEXT) $(LINK) $(unzzipdir_LDFLAGS) $(unzzipdir_OBJECTS) $(unzzipdir_LDADD) $(LIBS) -unzzipshow$(EXEEXT): $(unzzipshow_OBJECTS) $(unzzipshow_DEPENDENCIES) - @rm -f unzzipshow$(EXEEXT) - $(LINK) $(unzzipshow_LDFLAGS) $(unzzipshow_OBJECTS) $(unzzipshow_LDADD) $(LIBS) +unzzipdir-mem$(EXEEXT): $(unzzipdir_mem_OBJECTS) $(unzzipdir_mem_DEPENDENCIES) + @rm -f unzzipdir-mem$(EXEEXT) + $(LINK) $(unzzipdir_mem_LDFLAGS) $(unzzipdir_mem_OBJECTS) $(unzzipdir_mem_LDADD) $(LIBS) zzcat$(EXEEXT): $(zzcat_OBJECTS) $(zzcat_DEPENDENCIES) @rm -f zzcat$(EXEEXT) $(LINK) $(zzcat_LDFLAGS) $(zzcat_OBJECTS) $(zzcat_LDADD) $(LIBS) @@ -399,9 +416,11 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-mem.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-seeko.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir-mem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipshow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzcat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzip.Po@am__quote@ diff --git a/bins/zzxorcat.c b/bins/zzxorcat.c index 8ed49f6..97fcd51 100644 --- a/bins/zzxorcat.c +++ b/bins/zzxorcat.c @@ -44,7 +44,7 @@ static zzip_ssize_t xor_read (int f, void* p, zzip_size_t l) return r; } -static struct zzip_plugin_io xor_handlers; +static zzip_plugin_io_handlers xor_handlers; static zzip_strings_t xor_fileext[] = { ".dat", "", 0 }; int @@ -64,7 +64,7 @@ main (int argc, char ** argv) return 0; } - zzip_init_io (&xor_handlers, 0); xor_handlers.read = &xor_read; + zzip_init_io (&xor_handlers, 0); xor_handlers.fd.read = &xor_read; for (argn=1; argn < argc; argn++) { diff --git a/config.h.in b/config.h.in index 69b8986..2dcc0f2 100644 --- a/config.h.in +++ b/config.h.in @@ -43,6 +43,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H @@ -131,9 +134,14 @@ /* Define to empty if `const' does not conform to ANSI C. */ #undef const -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus #undef inline +#endif + +/* Define to `_zzip_off_t' if does not define. */ +#undef off64_t /* Define to `long' if does not define. */ #undef off_t diff --git a/configure b/configure index 7102b3a..456c6eb 100755 --- a/configure +++ b/configure @@ -1746,6 +1746,12 @@ else echo "${ECHO_T}no" >&6 fi +ax_enable_builddir_auxdir="$ac_aux_dir" ; test ".$ax_enable_builddir_auxdir" = "." && ax_enable_builddir_auxdir="." +echo "ax_enable_builddir_auxdir=(1) $ax_enable_builddir_auxdir" +echo "$ax_enable_builddir_auxdir" : $ax_enable_builddir_sed -e "'s!$ac_top_srcdir!.!'" +ax_enable_builddir_auxdir=`echo "$ax_enable_builddir_auxdir" | $ax_enable_builddir_sed -e "s|$ac_top_srcdir|.|"` +test ".$ax_enable_builddir_auxdir" = "." && ax_enable_builddir_auxdir="." +echo "ax_enable_builddir_auxdir=(2)=$ax_enable_builddir_auxdir" ac_config_commands="$ac_config_commands buildir" # -------------------------------------------- @@ -4376,7 +4382,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4379 "configure"' > conftest.$ac_ext + echo '#line 4385 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6190,7 +6196,7 @@ fi # Provide some information about the compiler. -echo "$as_me:6193:" \ +echo "$as_me:6199:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -7240,11 +7246,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7243: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7249: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7247: \$? = $ac_status" >&5 + echo "$as_me:7253: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7483,11 +7489,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7486: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7492: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7490: \$? = $ac_status" >&5 + echo "$as_me:7496: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7543,11 +7549,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7546: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7552: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7550: \$? = $ac_status" >&5 + echo "$as_me:7556: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9728,7 +9734,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12024: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12022: \$? = $ac_status" >&5 + echo "$as_me:12028: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -12075,11 +12081,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12078: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12084: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12082: \$? = $ac_status" >&5 + echo "$as_me:12088: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13436,7 +13442,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:14380: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14378: \$? = $ac_status" >&5 + echo "$as_me:14384: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14431,11 +14437,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14434: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14440: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14438: \$? = $ac_status" >&5 + echo "$as_me:14444: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16466,11 +16472,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16469: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16475: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16473: \$? = $ac_status" >&5 + echo "$as_me:16479: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16709,11 +16715,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16712: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16718: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16716: \$? = $ac_status" >&5 + echo "$as_me:16722: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16769,11 +16775,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16772: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16778: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16776: \$? = $ac_status" >&5 + echo "$as_me:16782: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18954,7 +18960,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&6) +echo "$as_me:$LINENO: checking our package / suffix" >&5 +echo $ECHO_N "checking our package / suffix... $ECHO_C" >&6 +ax_create_pkgconfig_suffix="$program_suffix" +test ".$ax_create_pkgconfig_suffix" != .NONE || ax_create_pkgconfig_suffix="" +echo "$as_me:$LINENO: result: ${PACKAGE_NAME} / ${ax_create_pkgconfig_suffix}" >&5 +echo "${ECHO_T}${PACKAGE_NAME} / ${ax_create_pkgconfig_suffix}" >&6 + echo "$as_me:$LINENO: checking our pkgconfig description" >&5 echo $ECHO_N "checking our pkgconfig description... $ECHO_C" >&6 ax_create_pkgconfig_description="$PACKAGE_SUMMARY" @@ -20227,16 +20240,18 @@ echo "${ECHO_T}generate the pkgconfig later... $ax_create_pkgconfig_generate" >& if test ".$ax_create_pkgconfig_src_libdir" = "." ; then ax_create_pkgconfig_src_libdir=`pwd` -ax_create_pkgconfig_src_libdir=`echo X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" | - sed 's/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - /^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` +ax_create_pkgconfig_src_libdir=`(dirname "$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate") 2>/dev/null || +$as_expr X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" : 'X\(//\)[^/]' \| \ + X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" : 'X\(//\)$' \| \ + X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ax_create_pkgconfig_src_libdir/$ax_create_pkgconfig_generate" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` test ! -d $ax_create_pkgconfig_src_libdir/src || \ ax_create_pkgconfig_src_libdir="$ax_create_pkgconfig_src_libdir/src" case ".$objdir" in @@ -20251,22 +20266,25 @@ v="$ac_top_srcdir" ; test ".$v" != "." || v="$ax_spec_dir" test ".$v" != "." || v="$srcdir" case "$v" in /*) PKG_CONFIG_src_headers="" ;; esac -ax_create_pkgconfig_src_headers=`echo X"$ax_create_pkgconfig_src_headers/$v/x" | - sed 's/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - s/\/[^\/:][^\/:]*\/..\//\//g - /^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` +ax_create_pkgconfig_src_headers=`(dirname "$ax_create_pkgconfig_src_headers/$v/x") 2>/dev/null || +$as_expr X"$ax_create_pkgconfig_src_headers/$v/x" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ax_create_pkgconfig_src_headers/$v/x" : 'X\(//\)[^/]' \| \ + X"$ax_create_pkgconfig_src_headers/$v/x" : 'X\(//\)$' \| \ + X"$ax_create_pkgconfig_src_headers/$v/x" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ax_create_pkgconfig_src_headers/$v/x" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` test ! -d $ax_create_pkgconfig_src_headers/include || \ ax_create_pkgconfig_src_headers="$ax_create_pkgconfig_src_headers/include" echo "$as_me:$LINENO: result: noninstalled pkgconfig -I $ax_create_pkgconfig_src_headers" >&5 echo "${ECHO_T}noninstalled pkgconfig -I $ax_create_pkgconfig_src_headers" >&6 fi + ac_config_commands="$ac_config_commands $ax_create_pkgconfig_generate" # ----------------------------------------------------------------------- @@ -22122,6 +22140,72 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for off64_t" >&5 +echo $ECHO_N "checking for off64_t... $ECHO_C" >&6 +if test "${ac_cv_type_off64_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((off64_t *) 0) + return 0; +if (sizeof (off64_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off64_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_off64_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off64_t" >&5 +echo "${ECHO_T}$ac_cv_type_off64_t" >&6 +if test $ac_cv_type_off64_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define off64_t _zzip_off_t +_ACEOF + +fi + echo "$as_me:$LINENO: checking size of short" >&5 echo $ECHO_N "checking size of short... $ECHO_C" >&6 if test "${ac_cv_sizeof_short+set}" = set; then @@ -24823,7 +24907,7 @@ cat >>$CONFIG_STATUS <<_ACEOF # ax_enable_builddir_srcdir="$srcdir" # $srcdir -ax_enable_builddir_target="$TARGET" # $TARGET / $target +ax_enable_builddir_host="$HOST" # $HOST / $host ax_enable_builddir_version="$VERSION" # $VERSION ax_enable_builddir_package="$PACKAGE" # $PACKAGE ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX @@ -24837,8 +24921,13 @@ PACKAGE="$PACKAGE" ax_create_pkgconfig_generate="$ax_create_pkgconfig_generate" pkgconfig_prefix='$prefix' pkgconfig_execprefix='$exec_prefix' +pkgconfig_bindir='$bindir' pkgconfig_libdir='$libdir' pkgconfig_includedir='$includedir' +pkgconfig_datadir='$datadir' +pkgconfig_sysconfdir='$sysconfdir' +pkgconfig_suffix='$ax_create_pkgconfig_suffix' +pkgconfig_package='$PACKAGE_NAME' pkgconfig_libname='$ax_create_pkgconfig_libname' pkgconfig_description='$ax_create_pkgconfig_description' pkgconfig_version='$ax_create_pkgconfig_version' @@ -25656,11 +25745,7 @@ esac { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in - buildir ) _SUB=`grep "continue configure in default builddir " config.log | - $ax_enable_builddir_sed -e "s/.*continue configure in default builddir //"` - ac_top_srcdir="$ax_enable_builddir_srcdir" - { echo "$as_me:$LINENO: checking $ac_top_srcdir/Makefile : $ax_enable_builddir" >&5 -echo "$as_me: checking $ac_top_srcdir/Makefile : $ax_enable_builddir" >&6;} + buildir ) ac_top_srcdir="$ax_enable_builddir_srcdir" if test ".$ax_enable_builddir" = "." ; then if test -f "$top_srcdir/Makefile" ; then { echo "$as_me:$LINENO: skipping top_srcdir/Makefile - left untouched" >&5 @@ -25715,33 +25800,33 @@ s/:.*/:/ all-configured : all-all /-all-all/d /^.*[=]/!a\\ - @ TARGET="\$(TARGET)\" \\\\\\ - ; test ".\$\$TARGET" = "." && TARGET=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$TARGET " Makefile | sed -e 's/.*|//' $x \\\\\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ + ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$TARGET : \$\$n * \$\@"; if test "\$\$n" = "0" ; then : \\\\\\ + ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" = "0" ; then : \\\\\\ ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) ; done + ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done /dist-all *:/a\\ - @ TARGET="\$(TARGET)\" \\\\\\ - ; test ".\$\$TARGET" = "." && TARGET=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$TARGET " Makefile | sed -e 's/.*|//' $x \\\\\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ + ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$TARGET : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ + ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ ; if test "\$\$found" = "0" ; then : \\\\\\ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; test -f "\$\$i/\$(PACKAGE)-\$(VERSION).tar.gz" \\\\\\ - && mv "\$\$i/\$(PACKAGE)-\$(VERSION).tar.gz" \$(PUB). ; break ; done + ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ + ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done /distclean-all *:/a\\ - @ TARGET="\$(TARGET)\" \\\\\\ - ; test ".\$\$TARGET" = "." && TARGET=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ ; BUILD=$x grep "^#### .*| *\\./" Makefile | sed -e 's/.*|//' $x \\\\\\ ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$TARGET : \$\$n * \$\@ (all local builds)" \\\\\\ + ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ @@ -25760,13 +25845,13 @@ echo "$as_me: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&6;} if grep '^; echo "MAKE ' $ac_top_srcdir/Makefile >/dev/null ; then { echo "$as_me:$LINENO: buggy sed found - it deletes tab in \"a\" text parts" >&5 echo "$as_me: buggy sed found - it deletes tab in \"a\" text parts" >&6;} - $ax_enable_builddir_sed -e '/^@ TARGET=/s/^/ /' -e '/^; /s/^/ /' $ac_top_srcdir/Makefile \ + $ax_enable_builddir_sed -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $ac_top_srcdir/Makefile \ >$ac_top_srcdir/Makefile~ (test -s $ac_top_srcdir/Makefile~ && mv $ac_top_srcdir/Makefile~ $ac_top_srcdir/Makefile) 2>/dev/null fi else xxxx="\\#\\#\\#\\#" - # echo "/^$xxxx *$ax_enable_builddir_target /d" >$tmp/conftemp.sed + # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed echo "s!^$xxxx [^|]* | *$ax_enable_builddir *\$!$xxxx ...... $ax_enable_builddir!" >$tmp/conftemp.sed $ax_enable_builddir_sed -f "$tmp/conftemp.sed" "$ac_top_srcdir/Makefile" >$tmp/mkfile.tmp cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~" ## DEBUGGING @@ -25781,10 +25866,10 @@ echo "$as_me: reusing top_srcdir/Makefile from earlier configure" >&6;} mv "$tmp/mkfile.tmp" "$ac_top_srcdir/Makefile" fi fi - { echo "$as_me:$LINENO: build in $ax_enable_builddir (TARGET=$ax_enable_builddir_target)" >&5 -echo "$as_me: build in $ax_enable_builddir (TARGET=$ax_enable_builddir_target)" >&6;} + { echo "$as_me:$LINENO: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&5 +echo "$as_me: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&6;} xxxx="####" - echo "$xxxx" "$ax_enable_builddir_target" "|$ax_enable_builddir" >>$ac_top_srcdir/Makefile + echo "$xxxx" "$ax_enable_builddir_host" "|$ax_enable_builddir" >>$ac_top_srcdir/Makefile fi ;; depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do @@ -26097,12 +26182,17 @@ fi if $generate ; then { echo "$as_me:$LINENO: creating $pkgconfig_generate.in" >&5 echo "$as_me: creating $pkgconfig_generate.in" >&6;} -cat > $pkgconfig_generate.in <<_EOF +cat > $pkgconfig_generate.in <&5 echo "$as_me: creating $pkgconfig_generate" >&6;} -sed -e "s|@prefix@|${pkgconfig_prefix}|" \ - -e "s|@exec_prefix@|${pkgconfig_execprefix}|" \ - -e "s|@libdir@|${pkgconfig_libdir}|" \ - -e "s|@includedir@|${pkgconfig_includedir}|" \ - -e "s|@PACKAGE_NAME@|${pkgconfig_libname}|" \ - -e "s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|" \ - -e "s|@PACKAGE_VERSION@|${pkgconfig_version}|" \ - -e "s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|" \ - -e "s|@LIBS@|${pkgconfig_libs}|" \ - -e "s|@CPPFLAGS@|${pkgconfig_cppflags}|" \ - $pkgconfig_generate.in > $pkgconfig_generate +cat >conftest.sed < $pkgconfig_generate if test ! -s $pkgconfig_generate ; then { { echo "$as_me:$LINENO: error: $pkgconfig_generate is empty" >&5 echo "$as_me: error: $pkgconfig_generate is empty" >&2;} { (exit 1); exit 1; }; } -fi # DONE generate $pkgconfig_generate +fi ; rm conftest.sed # DONE generate $pkgconfig_generate pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.pc/'` { echo "$as_me:$LINENO: creating $pkgconfig_uninstalled" >&5 echo "$as_me: creating $pkgconfig_uninstalled" >&6;} -sed -e "s|@prefix@|${pkgconfig_prefix}|" \ - -e "s|@exec_prefix@|${pkgconfig_execprefix}|" \ - -e "s|@libdir@|${pkgconfig_src_libdir}|" \ - -e "s|@includedir@|${pkgconfig_src_headers}|" \ - -e "s|@PACKAGE_NAME@|${pkgconfig_libname}|" \ - -e "s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|" \ - -e "s|@PACKAGE_VERSION@|${pkgconfig_version}|" \ - -e "s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|" \ - -e "s|@LIBS@|${pkgconfig_libs}|" \ - -e "s|@CPPFLAGS@|${pkgconfig_cppflags}|" \ - $pkgconfig_generate.in > $pkgconfig_uninstalled +cat >conftest.sed < $pkgconfig_uninstalled +if test ! -s $pkgconfig_uninstalled ; then + { { echo "$as_me:$LINENO: error: $pkgconfig_uninstalled is empty" >&5 +echo "$as_me: error: $pkgconfig_uninstalled is empty" >&2;} + { (exit 1); exit 1; }; } +fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled + pkgconfig_requires_add=`echo ${pkgconfig_requires}` +if test ".$pkgconfig_requires_add" != "." ; then + pkgconfig_requires_add="pkg-config $pkgconfig_requires_add" + else pkgconfig_requires_add=":" ; fi +pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.sh/'` +{ echo "$as_me:$LINENO: creating $pkgconfig_uninstalled" >&5 +echo "$as_me: creating $pkgconfig_uninstalled" >&6;} +cat >conftest.sed <Name:>for option\\; do case \"\$option\" in --list-all|--name) echo > +s>Description: *>\\;\\; --help) pkg-config --help \\; echo Buildscript Of > +s>Version: *>\\;\\; --modversion|--version) echo > +s>Requires:>\\;\\; --requires) echo $pkgconfig_requires_add> +s>Libs: *>\\;\\; --libs) echo > +s>Cflags: *>\\;\\; --cflags) echo > +/--libs)/a\\ + $pkgconfig_requires_add +/--cflags)/a\\ + $pkgconfig_requires_add\\ +;; --variable=*) eval echo '\$'\`echo \$option | sed -e 's/.*=//'\`\\ +;; --uninstalled) exit 0 \\ +;; *) ;; esac done +AXEOF +sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled if test ! -s $pkgconfig_uninstalled ; then { { echo "$as_me:$LINENO: error: $pkgconfig_uninstalled is empty" >&5 echo "$as_me: error: $pkgconfig_uninstalled is empty" >&2;} { (exit 1); exit 1; }; } -fi # DONE generate $pkgconfig_uninstalled +fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled ;; esac done diff --git a/configure.ac b/configure.ac index c056d98..c1bc1e3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(zziplib.spec) AC_PREREQ(2.49) AC_COPYRIGHT([Guido Draheim for ZZipLib.SF.net]) -AC_REVISION($Revision: 1.3 $) +AC_REVISION($Revision: 1.4 $) AC_CONFIG_AUX_DIR(uses) # ======================================================================= AC_CANONICAL_SYSTEM @@ -103,6 +103,7 @@ AC_TYPE_OFF_T AC_TYPE_SIZE_T dnl AC_TYPE_SSIZE_T AC_CHECK_TYPE(ssize_t,int) +AC_CHECK_TYPE(off64_t,_zzip_off_t) AC_COMPILE_CHECK_SIZEOF(short) AC_COMPILE_CHECK_SIZEOF(int) AC_COMPILE_CHECK_SIZEOF(long) diff --git a/docs/Makefile.am b/docs/Makefile.am index a6c7de7..ffe9871 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -6,7 +6,7 @@ doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB \ htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm \ zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm \ zzip-api.htm zzip-basics.htm zzip-extras.htm zzip-parse.htm \ - 64on32.htm future.htm fseeko.htm mmapped.htm \ + 64on32.htm future.htm fseeko.htm mmapped.htm memdisk.htm \ configs.htm sfx-make.htm developer.htm download.htm \ history.htm referentials.htm faq.htm copying.htm SDL = @top_srcdir@/SDL @@ -15,7 +15,7 @@ SDL_RWOPS = $(SDL)/SDL_rwops_zzcat.c \ changelog = @top_srcdir@/ChangeLog EXTRA_DIST = make-doc.py $(doc_FILES) $(htm_FILES) $(SDL_RWOPS) \ - make-doc.pl make-dbk.pl mksite.sh body.htm \ + make-doc.pl make-dbk.pl mksite.sh mksite.pl body.htm \ manpages.ar CLEANFILES = *.pc *.omf DISTCLEANFILES = zziplib.spec manpages.ar htmpages.ar *.html *.xml @@ -200,12 +200,11 @@ borderhead =
bordertail =
site.htm : body.htm - D=$(DATESPEC) ; cat $< \ - | sed -e "s//$(VERSION)/" \ - | sed -e "s//$$D/" \ - > $@ + cp $(srcdir)/body.htm site.htm +mksite_sh_args = --srcdir=$(srcdir) --VERSION=$(VERSION) site.html : site.htm mksite.sh $(htm_FILES) - $(SHELL) $(srcdir)/mksite.sh --srcdir=$(srcdir) site.htm + perl $(srcdir)/mksite.pl $(mksite_sh_args) site.htm || \ + $(SHELL) $(srcdir)/mksite.sh $(mksite_sh_args) site.htm x : $(htm_FILES:.htm=.htmls) $(htm_FILES:.htm=.htmls) : body.htm diff --git a/docs/Makefile.in b/docs/Makefile.in index e9203ef..b2e50ae 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -189,7 +189,7 @@ doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB \ htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm \ zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm \ zzip-api.htm zzip-basics.htm zzip-extras.htm zzip-parse.htm \ - 64on32.htm future.htm fseeko.htm mmapped.htm \ + 64on32.htm future.htm fseeko.htm mmapped.htm memdisk.htm \ configs.htm sfx-make.htm developer.htm download.htm \ history.htm referentials.htm faq.htm copying.htm @@ -198,7 +198,7 @@ SDL_RWOPS = $(SDL)/SDL_rwops_zzcat.c \ changelog = @top_srcdir@/ChangeLog EXTRA_DIST = make-doc.py $(doc_FILES) $(htm_FILES) $(SDL_RWOPS) \ - make-doc.pl make-dbk.pl mksite.sh body.htm \ + make-doc.pl make-dbk.pl mksite.sh mksite.pl body.htm \ manpages.ar CLEANFILES = *.pc *.omf @@ -235,6 +235,7 @@ datehead =
\ datetail =
borderhead =
bordertail =
+mksite_sh_args = --srcdir=$(srcdir) --VERSION=$(VERSION) all: all-am .SUFFIXES: @@ -547,12 +548,10 @@ install-omf : $(PACKAGE)-doc.omf $(PACKAGE)-man.omf $(PACKAGE).xml - test ".$(DESTDIR)" != "." || scrollkeeper-update -v site.htm : body.htm - D=$(DATESPEC) ; cat $< \ - | sed -e "s//$(VERSION)/" \ - | sed -e "s//$$D/" \ - > $@ + cp $(srcdir)/body.htm site.htm site.html : site.htm mksite.sh $(htm_FILES) - $(SHELL) $(srcdir)/mksite.sh --srcdir=$(srcdir) site.htm + perl $(srcdir)/mksite.pl $(mksite_sh_args) site.htm || \ + $(SHELL) $(srcdir)/mksite.sh $(mksite_sh_args) site.htm x : $(htm_FILES:.htm=.htmls) $(htm_FILES:.htm=.htmls) : body.htm diff --git a/docs/body.htm b/docs/body.htm index aaf38b5..dfb1603 100644 --- a/docs/body.htm +++ b/docs/body.htm @@ -27,7 +27,7 @@ ZZIPlib -
+

Library
- ZIP Access @@ -42,9 +42,10 @@ <> extras
=Parsing ZIPs
- 64on32 extras -
- Next To Come -
<> fseeko -<> mmapped +
- Next To Come
<> + fseeko + mmapped + memdisk
- Config Helpers
- Making a zip/exe
=Hints And Links @@ -76,7 +77,7 @@

-generated +generated
(C) Guido Draheim
guidod@gmx.de diff --git a/docs/mksite.sh b/docs/mksite.sh index b4f25be..2c5a786 100644 --- a/docs/mksite.sh +++ b/docs/mksite.sh @@ -20,11 +20,18 @@ # 2. Altered source versions must be plainly marked as such, and must not # be misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. -# $Id: mksite.sh,v 1.3 2004-05-11 17:58:03 guidod Exp $ +# $Id: mksite.sh,v 1.4 2005-05-14 15:08:23 guidod Exp $ + +# Zsh is not Bourne compatible without the following: (seen in autobook) +if test -n "$ZSH_VERSION"; then + emulate sh + NULLCMD=: +fi # initialize some defaults -test ".$SITEFILE" = "." && test -f site.htm && SITEFILE=site.htm -test ".$SITEFILE" = "." && test -f site.html && SITEFILE=site.html +test ".$SITEFILE" = "." && test -f "site.htm" && SITEFILE="site.htm" +test ".$SITEFILE" = "." && test -f "site.html" && SITEFILE="site.html" +test ".$SITEFILE" = "." && SITEFILE="site.htm" MK="-mksite" # note the "-" at the start SED="sed" CAT="cat" # "sed -e n" would be okay too @@ -38,6 +45,7 @@ INFO="~~" # extension for meta data files HEAD="~head~" # extension for head sed script BODY="~body~" # extension for body sed script FOOT="~foot~" # append to body text (non sed) +FAST="~move~" # extension for printer friendly sed NULL="/dev/null" # to divert stdout/stderr CATNULL="$CAT $NULL" # to create 0-byte files @@ -66,9 +74,11 @@ export LANG LANGUAGE LC_COLLATE # lowercasing as some collate # ========================================================================== # reading options from the command line GETOPT +opt_variables="files" opt_fileseparator="?" opt_files="" opt_main_file="" +opt_formatter="$0" opt="" for arg in "$@" # this variant should allow to embed spaces in $arg do if test ".$opt" != "." ; then @@ -83,6 +93,7 @@ do if test ".$opt" != "." ; then else arg=`echo "$arg" | $SED -e "s/^[^=]*=//"` eval "export opt_$opt='$arg'" + opt_variables="$opt_variables $opt" fi opt="" ;; -*-*) @@ -102,13 +113,16 @@ do if test ".$opt" != "." ; then eval "export opt_$opt=' '" fi opt="" ;; - *) test ".$opt_main_file" = "." && opt_main_file="$arg" + *) if test ".$opt_main_file" = "." ; then opt_main_file="$arg" ; else test ".$opt_files" != "." && opt_files="$opt_files$opt_fileseparator" - opt_files="$opt_files$arg" + opt_files="$opt_files$arg" ; fi opt="" ;; esac fi -done +done ; if test ".$opt" != "." ; then + eval "export opt_$opt='$arg'" + opt="" +fi ### env | grep ^opt test ".$opt_main_file" != "." && test -f "$opt_main_file" && \ @@ -116,6 +130,22 @@ SITEFILE="$opt_main_file" test ".$opt_site_file" != "." && test -f "$opt_site_file" && \ SITEFILE="$opt_site_file" +if test ".$opt_help" != "." ; then + F="$SITEFILE" + echo "$0 [sitefile]"; + echo " default sitefile = $F"; + echo "options:"; + echo " --filelist : show list of target files as ectracted from $F" + echo " --src-dir xx : if source files are not where mksite is executed" + echo " --tmp-dir xx : use temp instead of local directory" + echo " --tmp : use automatic temp directory in ${TEMP-/tmp}/mksite.*" + exit; + echo " internal:" + echo "--fileseparator=x : for building the internal filelist (default '?')" + echo "--files xx : for list of additional files to be processed" + echo "--main-file xx : for the main sitefile to take file list from" +fi + if test ".$SITEFILE" = "." ; then echo "error: no SITEFILE found (default would be 'site.htm')" exit 1 @@ -123,45 +153,222 @@ else echo "NOTE: sitefile: `ls -s $SITEFILE`" fi +if "${SHELL-/bin/sh}" -c 'foo () { exit 0; }; foo' 2>$NULL ; then : ; else +echo "!! sorry, this shell '$SHELL' does not support shell functions"; exit 1 +fi + +tmp="." ; if test ".$opt_tmp_dir" != "." ; then tmp="$opt_tmp_dir" ; fi +if test ".$opt_tmp_dir" = "." && test ".$opt_tmp" != "." ; then +tmp="${TEMP-/tmp}/mksite.$$" ; fi + +# we use external files to store mappings - kind of relational tables +MK_TAGS="$tmp/$MK.tags.tmp" +MK_VARS="$tmp/$MK.vars.tmp" +MK_META="$tmp/$MK.meta.tmp" +MK_METT="$tmp/$MK.mett.tmp" +MK_TEST="$tmp/$MK.test.tmp" +MK_FAST="$tmp/$MK.fast.tmp" +MK_GETS="$tmp/$MK.gets.tmp" +MK_PUTS="$tmp/$MK.puts.tmp" +MK_OLDS="$tmp/$MK.olds.tmp" +MK_SITE="$tmp/$MK.site.tmp" +MK_SECT1="$tmp/$MK.sect1.tmp" +MK_SECT2="$tmp/$MK.sect2.tmp" +MK_SECT3="$tmp/$MK.sect3.tmp" +MK_STYLE="$tmp/$MK.style.tmp" +MK_INFO="$tmp/$MK.$INFO" + +# ======================================================================== +# ======================================================================== +# ======================================================================== +# MAGIC VARS +# IN $SITEFILE +printerfriendly="" +sectionlayout="list" +sitemaplayout="list" +simplevars="warn" # default +attribvars=" " # +updatevars=" " # default +expandvars=" " # +commentvars=" " # $updatevars && $expandsvars && $simplevars +sectiontab=" " # highlight ^...href="$section" +currenttab=" " # highlight ^
.. +headsection="no" +tailsection="no" +sectioninfo="no" # using

title

= info text +emailfooter="no" + +if $GREP "" $SITEFILE >$NULL ; then +echo \ +"WARNING: do not use , change to " "$SITEFILE" +echo \ +"warning: or " +sectionlayout="multi" +sitemaplayout="multi" +fi +if $GREP "" $SITEFILE >$NULL ; then +sectionlayout="multi" +sitemaplayout="multi" +fi +if $GREP "" $SITEFILE >$NULL ; then +sectionlayout="multi" +sitemaplayout="multi" +fi + +mksite_magic_option () +{ + # $1 is word/option to check for + INP="$2" ; test ".$INP" = "." && INP="$SITEFILE" + $SED \ + -e "s/\\(/\\1\\2: -->/g" \ + -e "s/\\(/\\1\\3:\\2-->/g" \ + -e "/.*/\\1/" \ + -e "s/.*.*/\\1/" \ + -e "/||g" >>$MK.tags.tmp - echo "s|||g" >>$MK.tags.tmp - echo "s|||g" >>$MK.tags.tmp - echo "s|||g" >>$MK.tags.tmp - echo "s|\\(<[^<>]*\\)\\\${[$AX]*:[?=]\\([^<{}>]*\\)}\\([^<>]*>\\)|\\1\\2\\3|g" >>$MK.tags.tmp - + echo "s|||g" >> "$MK_TAGS" + echo "s|||g" >> "$MK_TAGS" + echo "s|||g" >> "$MK_TAGS" + echo "s|||g" >> "$MK_TAGS" + echo "s|\\(<[^<>]*\\)\\\${[$AX]*:[?=]\\([^<{}>]*\\)}\\([^<>]*>\\)|\\1\\2\\3|g" >>$MK_TAGS + +# see overview at www.metatab.de - http-equivs are +# 5; url=target or target +# text/html; charset=koi8-r iso-8859-1/UTF-8 +# de UTF-8 +# text/javascript /jscript/vbscript +# text/css +# no-cache + +trimm () +{ + echo "$1" | $SED -e "s:^ *::" -e "s: *\$::"; +} +trimmm () +{ + echo "$1" | $SED -e "s:^ *::" -e "s: *\$::" -e "s:[ ][ ]*: :g"; +} -TRIMM=" -e 's:^ *::' -e 's: *\$::'" # trimm away leading/trailing spaces +timezone () +{ + # +%z is an extension while +%Z is supposed to be posix + _timezone=`$DATE_NOW +%z` + case "$_timezone" in + *+*) echo "$_timezone" ;; + *-*) echo "$_timezone" ;; + *) $DATE_NOW +%Z + esac +} +timetoday () +{ + $DATE_NOW +%Y-%m-%d +} +timetodays () +{ + $DATE_NOW +%Y-%m%d +} + # ====================================================================== # FUNCS @@ -189,8 +396,6 @@ sed_piped_key () # helper to escape chars special in s|anchor|| regex { # currently escaping "|" "[" "]" "." echo "$1" | $SED -e "s/[.|[-]/\\\\&/g" -e "s/\\]/\\\\&/g" } -SLASH_VALUE="s:[&/]:\\\\&:g" -PIPED_VALUE="s:[&/]:\\\\&:g" back_path () # helper to get the series of "../" for a given path { @@ -202,10 +407,9 @@ dir_name () echo "$1" | $SED -e "s:/[^/][^/]*\$::" } -info2test () # cut out all old-style usages +info2test_sed () # cut out all old-style usages { - OUT="$1" ; test ".$OUT" = "." && OUT="./$MK.test.tmp" - INP="$2" ; test ".$INP" = "." && INP="./$F.$INFO" + INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" V8=" *\\([^ ][^ ]*\\) \\(.*\\)" V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" q="\\\$" @@ -213,8 +417,8 @@ info2test () # cut out all old-style usages _y_="WARNING: assumed simplevar changed to " _X_="WARNING: assumed tailvar changed to " _Y_="WARNING: assumed tailvar changed to " - echo "s/^/ /" > $OUT - $SED -e "/=....=formatter /d" \ + echo "s/^/ /" # $++ + $SED -e "/^=....=formatter /d" \ -e "/=text=/s%=text=$V9%s|.*.*|$_x_|%" \ -e "/=Text=/s%=Text=$V9%s|.*.*|$_x_|%" \ -e "/=name=/s%=name=$V9%s|.*.*|$_y_|%" \ @@ -223,8 +427,8 @@ info2test () # cut out all old-style usages -e "/=Text=/s%=Text=$V8%s|.*.*|$_x_|%" \ -e "/=name=/s%=name=$V8%s|.*.*|$_y_|%" \ -e "/=Name=/s%=Name=$V8%s|.*.*|$_y_|%" \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT - $SED -e "/=....=formatter /d" \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $SED -e "/^=....=formatter /d" \ -e "/=text=/s%=text=$V9%s|.*.*|$_X_|%" \ -e "/=Text=/s%=Text=$V9%s|.*.*|$_X_|%" \ -e "/=name=/s%=name=$V9%s|.*.*|$_Y_|%" \ @@ -233,14 +437,13 @@ info2test () # cut out all old-style usages -e "/=Text=/s%=Text=$V8%s|.*.*|$_X_|%" \ -e "/=name=/s%=name=$V8%s|.*.*|$_Y_|%" \ -e "/=Name=/s%=Name=$V8%s|.*.*|$_Y_|%" \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT - echo "/^WARNING:/!d" >> $OUT + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + echo "/^WARNING:/!d" # $++ } -info2vars () # generate substition sed addon script +info2vars_sed () # generate substition sed addon script { - OUT="$1" ; test ".$OUT" = "." && OUT="./$MK.vars.tmp" - INP="$2" ; test ".$INP" = "." && INP="./$F.$INFO" + INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" V8=" *\\([^ ][^ ]*\\) \\(.*\\)" V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" N8=" *\\([^ ][^ ]*\\) \\([$NN].*\\)" @@ -254,152 +457,194 @@ info2vars () # generate substition sed addon script test ".$commentvars" = ".no" && expandvars="no" # option handling test ".$commentvars" = ".no" && simplevars="no" # tests below test ".$expandvars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=name=/s,=name=$V9,s||- \\2|," \ - -e "/=Name=/s,=Name=$V9,s||(\\2)|," \ - -e "/=name=/s,=name=$V8,s||- \\2|," \ - -e "/=Name=/s,=Name=$V8,s||(\\2)|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP > $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=name=/s,=name=$V9,s||- \\2|," \ + -e "/^=Name=/s,=Name=$V9,s||(\\2)|," \ + -e "/^=name=/s,=name=$V8,s||- \\2|," \ + -e "/^=Name=/s,=Name=$V8,s||(\\2)|," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$expandvars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=text=/s,=text=$V9,s||\\\\1$SS\\2|," \ - -e "/=Text=/s,=Text=$V9,s||\\\\1$SS\\2|," \ - -e "/=name=/s,=name=$V9,s||\\\\1$SS\\2|," \ - -e "/=Name=/s,=Name=$V9,s||\\\\1$SS\\2|," \ - -e "/=text=/s,=text=$V8,s||\\\\1$SS\\2|," \ - -e "/=Text=/s,=Text=$V8,s||\\\\1$SS\\2|," \ - -e "/=name=/s,=name=$V8,s||\\\\1$SS\\2|," \ - -e "/=Name=/s,=Name=$V8,s||\\\\1$SS\\2|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=text=/s,=text=$V9,s||\\\\1$SS\\2|," \ + -e "/^=Text=/s,=Text=$V9,s||\\\\1$SS\\2|," \ + -e "/^=name=/s,=name=$V9,s||\\\\1$SS\\2|," \ + -e "/^=Name=/s,=Name=$V9,s||\\\\1$SS\\2|," \ + -e "/^=text=/s,=text=$V8,s||\\\\1$SS\\2|," \ + -e "/^=Text=/s,=Text=$V8,s||\\\\1$SS\\2|," \ + -e "/^=name=/s,=name=$V8,s||\\\\1$SS\\2|," \ + -e "/^=Name=/s,=Name=$V8,s||\\\\1$SS\\2|," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$simplevars" != ".no" && test ".$updatevars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=text=/s,=text=$V9,s|[$AX]*|\\2|," \ - -e "/=Text=/s,=Text=$V9,s|[$AX]*|\\2|," \ - -e "/=name=/s,=name=$V9,s|[$AX]*|- \\2|," \ - -e "/=Name=/s,=Name=$V9,s|[$AX]*| (\\2) |," \ - -e "/=text=/s,=text=$V8,s|[$AX]*|\\2|," \ - -e "/=Text=/s,=Text=$V8,s|[$AX]*|\\2|," \ - -e "/=name=/s,=name=$V8,s|[$AX]*|- \\2|," \ - -e "/=Name=/s,=Name=$V8,s|[$AX]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=text=/s,=text=$V9,s|[$AX]*|\\2|," \ + -e "/^=Text=/s,=Text=$V9,s|[$AX]*|\\2|," \ + -e "/^=name=/s,=name=$V9,s|[$AX]*|- \\2|," \ + -e "/^=Name=/s,=Name=$V9,s|[$AX]*| (\\2) |," \ + -e "/^=text=/s,=text=$V8,s|[$AX]*|\\2|," \ + -e "/^=Text=/s,=Text=$V8,s|[$AX]*|\\2|," \ + -e "/^=name=/s,=name=$V8,s|[$AX]*|- \\2|," \ + -e "/^=Name=/s,=Name=$V8,s|[$AX]*| (\\2) |," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$updatevars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=name=/s,=name=$V9,s|[^<>]*|- \\2|," \ - -e "/=Name=/s,=Name=$V9,s|[^<>]*| (\\2) |," \ - -e "/=name=/s,=name=$V8,s|[^<>]*|- \\2|," \ - -e "/=Name=/s,=Name=$V8,s|[^<>]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=name=/s,=name=$V9,s|[^<>]*|- \\2|," \ + -e "/^=Name=/s,=Name=$V9,s|[^<>]*| (\\2) |," \ + -e "/^=name=/s,=name=$V8,s|[^<>]*|- \\2|," \ + -e "/^=Name=/s,=Name=$V8,s|[^<>]*| (\\2) |," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$updatevars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=text=/s,=text=$V9,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=Text=/s,=Text=$V9,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=name=/s,=name=$V9,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=Name=/s,=Name=$V9,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=text=/s,=text=$V8,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=Text=/s,=Text=$V8,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=name=/s,=name=$V8,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/=Name=/s,=Name=$V8,s|[^<>]*|\\\\1$SS\\2|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=text=/s,=text=$V9,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=Text=/s,=Text=$V9,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=name=/s,=name=$V9,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=Name=/s,=Name=$V9,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=text=/s,=text=$V8,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=Text=/s,=Text=$V8,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=name=/s,=name=$V8,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=Name=/s,=Name=$V8,s|[^<>]*|\\\\1$SS\\2|," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$attribvars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=text=/s,=text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=Text=/s,=Text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=name=/s,=name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=Name=/s,=Name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=text=/s,=text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=Text=/s,=Text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=name=/s,=name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/=Name=/s,=Name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=text=/s,=text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=Text=/s,=Text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=name=/s,=name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=Name=/s,=Name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=text=/s,=text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=Text=/s,=Text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=name=/s,=name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=Name=/s,=Name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ test ".$simplevars" != ".no" && \ - $SED -e "/=....=formatter /d" \ - -e "/=text=/s,=text=$V9,s|[$AX]*|\\2|," \ - -e "/=Text=/s,=Text=$V9,s|[$AX]*|\\2|," \ - -e "/=name=/s,=name=$V9,s|[$AX]*| - \\2|," \ - -e "/=Name=/s,=Name=$V9,s|[$AX]*| (\\2) |," \ - -e "/=text=/s,=text=$V8,s|[$AX]*|\\2|," \ - -e "/=Text=/s,=Text=$V8,s|[$AX]*|\\2|," \ - -e "/=name=/s,=name=$V8,s|[$AX]*| - \\2|," \ - -e "/=Name=/s,=Name=$V8,s|[$AX]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP >> $OUT + $SED -e "/^=....=formatter /d" \ + -e "/^=text=/s,=text=$V9,s|[$AX]*|\\2|," \ + -e "/^=Text=/s,=Text=$V9,s|[$AX]*|\\2|," \ + -e "/^=name=/s,=name=$V9,s|[$AX]*| - \\2|," \ + -e "/^=Name=/s,=Name=$V9,s|[$AX]*| (\\2) |," \ + -e "/^=text=/s,=text=$V8,s|[$AX]*|\\2|," \ + -e "/^=Text=/s,=Text=$V8,s|[$AX]*|\\2|," \ + -e "/^=name=/s,=name=$V8,s|[$AX]*| - \\2|," \ + -e "/^=Name=/s,=Name=$V8,s|[$AX]*| (\\2) |," \ + -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ # if value="2004" then generated sed might be "\\12004" which is bad # instead we generate an edited value of "\\1$SS$value" and cut out # the spacer now after expanding the variable values: - echo "s|$SS||g" >> $OUT + echo "s|$SS||g" # $++ } -info2meta () # generate text portion +info2meta_sed () # generate text portion { # http://www.metatab.de/meta_tags/DC_type.htm - OUT="$1" ; test ".$OUT" = "." && OUT="./$MK.meta.tmp" - INP="$2" ; test ".$INP" = "." && INP="./$F.$INFO" - V8=" *\\([^ ][^ ]*\\) \\(.*\\)" ; SCHEME="scheme=\"\\1\"" - V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" + INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" + V6=" *HTTP[.]\\([^ ][^ ]*\\) \\(.*\\)" + V7=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" + V8=" *\\([^ ][^ ]*\\) \\(.*\\)" INFO_META_TYPE_SCHEME="name=\"DC.type\" content=\"\\2\" scheme=\"\\1\"" - INFO_META_TYPEDCMI="name=\"\\1\" content=\"\\2\" scheme=\"DCMIType\"" + INFO_META_DCMI="name=\"\\1\" content=\"\\2\" scheme=\"DCMIType\"" + INFO_META_NAME_TZ="name=\"\\1\" content=\"\\2 `timezone`\"" INFO_META_NAME="name=\"\\1\" content=\"\\2\"" - INFO_META_NAME_TZ="name=\"\\1\" content=\"\\2 `$DATE_NOW +%z`\"" + INFO_META_HTTP="http-equiv=\"\\1\" content=\"\\2\"" $SED -e "/=....=today /d" \ - -e "/=meta=DC[.]DCMIType /s,=meta=$V9,," \ - -e "/=meta=DC[.]type Collection$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Dataset$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Event$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Image$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Service$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Software$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Sound$/s,=meta=$V8,," \ - -e "/=meta=DC[.]type Text$/s,=meta=$V8,," \ - -e "/=meta=DC[.]date[.].*[+]/s,=meta=$V8,," \ - -e "/=meta=DC[.]date[.].*[:]/s,=meta=$V8,," \ - -e "/=meta=/s,=meta=$V8,," \ + -e "/=meta=HTTP[.]/s,=meta=$V6, ," \ + -e "/=meta=DC[.]DCMIType /s,=meta=$V7, ," \ + -e "/=meta=DC[.]type Collection$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Dataset$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Event$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Image$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Service$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Software$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Sound$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]type Text$/s,=meta=$V8, ," \ + -e "/=meta=DC[.]date[.].*[+]/s,=meta=$V8, ," \ + -e "/=meta=DC[.]date[.].*[:]/s,=meta=$V8, ," \ + -e "/=meta=/s,=meta=$V8, ," \ -e "/ $OUT + -e "/ value known so far { TXT="$1" ; test ".$TXT" = "." && TXT="sect" - INP="$2" ; test ".$INP" = "." && INP="./$F.$INFO" - $SED -e "/=text=$TXT /!d" -e "s/=text=$TXT //" -e "q" $INP # to stdout + INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" + $SED -e "/=text=$TXT /!d" -e "s/=text=$TXT //" -e "q" $INP # $++ } info1grep () # test for a substition to be already present { TXT="$1" ; test ".$TXT" = "." && TXT="sect" - INP="$2" ; test ".$INP" = "." && INP="./$F.$INFO" + INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" $GREP "^=text=$TXT " $INP >$NULL return $? } +dx_init() +{ + mkpathdir "$tmp" + dx_meta formatter `basename $opt_formatter` > "$tmp/$F.$INFO" + for opt in $opt_variables ; do case "$opt" in # commandline --def=value + *_*) op_=`echo "$opt" | sed -e "y/_/-/"` # makes for + dx_meta "$op_" `eval echo "\\\$opt_$opt"` ;; + *) dx_text "$opt" `eval echo "\\\$opt_$opt"` ;; + esac ; done +} + +dx_line () +{ + echo "$1$2 "`trimmm "$3"` >> "$tmp/$F.$INFO" +} + +DX_line () +{ + dx_val_=`echo "$3" | sed -e "s/<[^<>]*>//g"` + dx_line "$1" "$2" "$dx_val_" +} + +dx_text () +{ + dx_line "=text=" "$1" "$2" +} + DX_text () # add a substition includings format variants { - N="$1" ; T="$2" + N=`trimm "$1"` ; T=`trimm "$2"` if test ".$N" != "." ; then if test ".$T" != "." ; then text=`echo "$T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"` - echo "=text=$N $T" >> $F.$INFO - echo "=name=$N $text" >> $F.$INFO + dx_line "=text=" "$N" "$T" + dx_line "=name=" "$N" "$text" varname=`echo "$N" | $SED -e 's/.*[.]//'` # cut out front part if test ".$N" != ".$varname" ; then text=`echo "$varname $T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"` - echo "=Text=$varname $T" >> $F.$INFO - echo "=Name=$varname $text" >> $F.$INFO + dx_line "=Text=" "$varname" "$T" + dx_line "=Name=" "$varname" "$text" fi fi fi } +dx_meta () +{ + DX_line "=meta=" "$1" "$2" +} + DX_meta () # add simple meta entry and its subsitution { - echo "=meta=$1 $2" >> $F.$INFO - DX_text "$1" "$2" + DX_line "=meta=" "$1" "$2" + DX_text "$1" "$2" } DC_meta () # add new DC.meta entry plus two substitutions { - echo "=meta=DC.$1 $2" >> $F.$INFO - DX_text "DC.$1" "$2" - DX_text "$1" "$2" + DX_line "=meta=" "DC.$1" "$2" + DX_text "DC.$1" "$2" + DX_text "$1" "$2" +} + +HTTP_meta () # add new HTTP.meta entry plus two substitutions +{ + DX_line "=meta=" "HTTP.$1" "$2" + DX_text "HTTP.$1" "$2" + DX_text "$1" "$2" } DC_VARS_Of () # check DC vars as listed in $DC_VARS global and generate DC_meta @@ -407,9 +652,11 @@ DC_VARS_Of () # check DC vars as listed in $DC_VARS global and generate DC_meta FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE" for M in $DC_VARS title ; do # scan for a of this name - term="-e '/<$M>/!d' -e 's|.*<$M>||' -e 's|.*||'" - part=`eval $SED $term $TRIMM -e q $FILENAME` - text=`echo "$part" | eval $SED -e "'s|^[$AA]*:||'" $TRIMM` + part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|.*||" -e q $FILENAME` + part=`trimm "$part"` + text=`echo "$part" | $SED -e "s|^[$AA]*:||"` + text=`trimm "$text"` + test ".$text" = "." && continue # will be if test ".$text" != ".$part" ; then N=`echo "$part" | $SED -e "s/:.*//"` @@ -422,6 +669,26 @@ DC_VARS_Of () # check DC vars as listed in $DC_VARS global and generate DC_meta done } +HTTP_VARS_Of () # check HTTP-EQUIVs as listed in $_EQUIV global then +{ # generate meta tags that are http-equiv= instead of name= + FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE" + for M in $_EQUIVS ; do + # scan for a of this name + part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|.*||" -e q $FILENAME` + part=`trimm "$part"` + text=`echo "$part" | $SED -e "s|^[$AA]*:||"` + text=`trimm "$text"` + test ".$text" = "." && continue + if test ".$M" = ".redirect" ; then + HTTP_meta "refresh" "5; url=$text" ; DX_text "$M" "$text" + elif test ".$M" = ".charset" ; then + HTTP_meta "content-type" "text/html; charset=$text" + else + HTTP_meta "$M" "$text" + fi + done +} + DC_isFormatOf () # make sure there is this DC.relation.isFormatOf tag { # choose argument for a fallback (usually $SOURCEFILE) NAME="$1" ; test ".$NAME" = "." && NAME="$SOURCEFILE" @@ -437,18 +704,19 @@ DC_publisher () # make sure there is this DC.publisher meta tag DC_modified () # make sure there is a DC.date.modified meta tag { # maybe choose from filesystem dates if possible Q="$1" # target file - if info1grep DC.date.modified - then : - else meta='$NULL | $SED -e '/odify:/!d' -e 's|.*fy:||' -e q` - modified=`echo "$modified" | eval $SED -e "'s/:..[.][$NN]*//'" $TRIMM` - test ".$modified" = "." && \ - modified=`$DATE_R "$Q" +%Y-%m-%d 2>$NULL` # GNU sed - test ".$modified" = "." && - modified=`$LS_L "$Q" | $SED -e "$cut_42_55" -e "s/^ *//g" -e "q"` - DC_meta date.modified "$modified" + text=`$STAT_R $Q 2>$NULL | $SED -e '/odify:/!d' -e 's|.*fy:||' -e q` + text=`echo "$text" | $SED -e "s/:..[.][$NN]*//"` + text=`trimm "$text"` + test ".$text" = "." && \ + text=`$DATE_R "$Q" +%Y-%m-%d 2>$NULL` # GNU sed + test ".$text" = "." && + text=`$LS_L "$Q" | $SED -e "$cut_42_55" -e "s/^ *//g" -e "q"` + text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds + DC_meta date.modified `trimm "$text"` fi } @@ -466,16 +734,17 @@ DC_date () # make sure there is this DC.date meta tag done if test ".$text" = "." ; then M="date" - term="-e '/<$M>/!d' -e 's|.*<$M>||' -e 's|.*||'" - part=`eval $SED $term $TRIMM -e q $Q` - text=`echo "$part" | eval $SED -e "'s|^[$AA]*:||'" $TRIMM` + part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|.*||" -e q $Q` + part=`trimm "$part"` + text=`echo "$part" | $SED -e "s|^[$AA]*:||"` + text=`trimm "$text"` fi if test ".$text" = "." ; then - # this should be rewritten.... ugly way to parse out a date: - CLEAN=" -e '/^%%%%%/!d' -e 's:^%*::' -e 's:::'" - EDATE=" -e 's:.*:%%%%%%:' -e 's:.*:%%%%%%:' $CLEAN" - text=`eval $SED $EDATE $TRIMM -e "'s|^ *[$AA]*:||'" -e q $Q` - text=`echo "$text" | $SED -e 's|\\&.*||'` + M="!--date:*=*--" # takeover updateable variable... + part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|/!d' -e 's|.*<$M>||' -e 's|.*||'" - text=`eval $SED $term $TRIMM -e q $Q` - test ".$text" != "." && break - term="-e '/<$M [^<>]*>/!d' -e 's|.*<$M [^<>]*>||' -e 's|.*||'" - text=`eval $SED $term $TRIMM -e q $Q` - test ".$text" != "." && break + text=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|.*||" -e q $Q` + text=`trimm "$text"` ; test ".$text" != "." && break + MM="$M [^<>]*" + text=`$SED -e "/<$MM>/!d" -e "s|.*<$MM>||" -e "s|.*||" -e q $Q` + text=`trimm "$text"` ; test ".$text" != "." && break done if test ".text" = "." ; then - text=`basename $Q .html | $SED -e 'y/_/ /' -e "s/\\$/ info/"` + text=`basename $Q .html` + text=`basename $text .htm | $SED -e 'y/_/ /' -e "s/\\$/ info/"` fi term=`echo "$text" | $SED -e 's/.*[(]//' -e 's/[)].*//'` text=`echo "$text" | $SED -e 's/[(][^()]*[)]//'` @@ -528,7 +797,7 @@ DC_title () site_get_section () # return parent section page of given page { _F_=`sed_slash_key "$1"` - $SED -e "/^=sect=$_F_ /!d" -e "s/^=sect=$_F_ //" -e q ./$MK.$INFO + $SED -e "/^=sect=$_F_ /!d" -e "s/^=sect=$_F_ //" -e q "$MK_INFO" # $++ } DC_section () # not really a DC relation (shall we use isPartOf ?) @@ -539,10 +808,15 @@ DC_section () # not really a DC relation (shall we use isPartOf ?) fi } +info_get_entry_section() +{ + info_get_entry DC.relation.section # $++ +} + site_get_selected () # return section of given page { _F_=`sed_slash_key "$1"` - $SED -e "/=use.=$_F_ /!d" -e "s/=use.=[^ ]* //" -e q ./$MK.$INFO + $SED -e "/=use.=$_F_ /!d" -e "s/=use.=[^ ]* //" -e q "$MK_INFO" # $++ } DC_selected () # not really a DC title (shall we use alternative ?) @@ -554,40 +828,34 @@ DC_selected () # not really a DC title (shall we use alternative ?) fi } +info_get_entry_selected () +{ + info_get_entry DC.title.selected # $++ +} + site_get_rootsections () # return all sections from root of nav tree { - $SED -e "/=use1=/!d" -e "s/=use.=\\([^ ]*\\) .*/\\1/" ./$MK.$INFO + $SED -e "/=use1=/!d" -e "s/=use.=\\([^ ]*\\) .*/\\1/" "$MK_INFO" # $++ } site_get_sectionpages () # return all children pages in the given section { _F_=`sed_slash_key "$1"` - $SED -e "/^=sect=[^ ]* $_F_\$/!d" -e "s/^=sect=//" -e "s/ .*//" ./$MK.$INFO + $SED -e "/^=sect=[^ ]* $_F_\$/!d" -e "s/^=sect=//" \ + -e "s/ .*//" "$MK_INFO" # $++ } site_get_subpages () # return all page children of given page { _F_=`sed_slash_key "$1"` - $SED -e "/^=node=[^ ]* $_F_\$/!d" -e "s/^=node=//" -e "s/ .*//" ./$MK.$INFO + $SED -e "/^=node=[^ ]* $_F_\$/!d" -e "s/^=node=//" -e "s/ .*//" "$MK_INFO" + # $++ } site_get_parentpage () # return parent page for given page (".." for sections) { _F_=`sed_slash_key "$1"` - $SED -e "/^=node=$_F_ /!d" -e "s/^=node=[^ ]* //" -e "q" ./$MK.$INFO -} - -mksite_magic_option () -{ - # $1 is word/option to check for - INP="$2" ; test ".$INP" = "." && INP="$SITEFILE" - $SED \ - -e "s/\\(/\\1\\2: -->/g" \ - -e "s/\\(/\\1\\3:\\2-->/g" \ - -e "/.*/\\1/" \ - -e "s/.*.*/\\1/" \ - -e "//{" >> $OUT - echo "s//\\1/" >> $OUT - echo "q" >> $OUT ; echo "}" >> $OUT + echo "//{" # $++ + echo "s//\\1/" # $++ + echo "q" # $++ + echo "}" # $++ fi } -info2body_append () # append alternative handling script to $BODY +info2body_sed () # append alternative handling script to $BODY { - OUT="$1" ; test ".$OUT" = "." && OUT="$F.$HEAD" have=`info_get_entry alternative` if test ".$have" != "." ; then - _replace_="s//\\1/" - echo "//$_replace_" >> $OUT + echo "s//\\1/" # $++ fi } @@ -623,52 +889,80 @@ bodymaker_for_sectioninfo () test ".$sectioninfo" = ".no" && return _x_="" _q_="\\([^<>]*[$AX][^<>]*\\)" - test ".$sectioninfo" != ". " && _q_="[ ][ ]*$sectioninfo\\([ ]\\)" - echo "s|\\(^<[hH][$NN][ >].*\\)$_q_|\\1$_x_\\2|" - echo "/$_x_/s|^|
|" - echo "/$_x_/s||&|" - echo "/$_x_/s|\$|
|" - echo "s|$_x_||" + test ".$sectioninfo" != ". " && _q_="[ ][ ]*$sectioninfo\\([ ]\\)" + echo "s|\\(^<[hH][$NN][ >].*\\)$_q_|\\1$_x_\\2|" # $++ + echo "/$_x_/s|^|
|" # $++ + echo "/$_x_/s||&|" # $++ + echo "/$_x_/s|\$|
|" # $++ + echo "s|$_x_||" # $++ } -moved_href () # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F" +fast_href () # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F" { # prints path to $FILETOREFERENCE href-clickable in $FROMCURRENTFILE # if no subdirectoy then output is the same as input $FILETOREFERENCE R="$2" ; test ".$R" = "." && R="$F" S=`back_path "$R"` if test ".$S" = "." - then echo "$1" + then echo "$1" # $++ else _1_=`echo "$1" | \ $SED -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" ` if test ".$_1_" = "." # don't move any in the pattern above - then echo "$1" - else echo "$S$1" + then echo "$1" # $++ + else echo "$S$1" # $++ prefixed with backpath fi fi } -make_move () # experimental - make a ~move~ file that can be applied +make_fast () # experimental - make a FAST file that can be applied { # to htm sourcefiles in a subdirectory of the sitefile. # R="$1" ; test ".$R" = "." && R="$F" S=`back_path "$F"` if test ".$S" = "" ; then # echo "backpath '$F' = none needed" - $CATNULL > $F.~move~ + $CATNULL # $++ else # echo "backpath '$F' -> '$S'" $SED -e "/href=\"[^\"]*\"/!d" -e "s/.*href=\"//" -e "s/\".*//" \ -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" \ - $SITEFILE $SOURCEFILE | sort | uniq \ - | $SED -e "s,.*,s|href=\"&\"|href=\"$S&\"|," > $F.~move~ + $SITEFILE $SOURCEFILE | sort | uniq \ + | $SED -e "s,.*,s|href=\"&\"|href=\"$S&\"|," # $++ fi } +# ============================================================== SITE MAP INFO +# each entry needs atleast a list-title, a long-title, and a list-date +# these are the basic information to be printed in the sitemap file +# where it is bound the hierarchy of sect/subsect of the entries. + +site_map_list_title() # $file $text +{ + echo "=list=$1 $2" >> "$MK_INFO" +} +info_map_list_title() # $file $text +{ + echo "=list=$2" >> "$tmp/$1.$INFO" +} +site_map_long_title() # $file $text +{ + echo "=long=$1 $2" >> "$MK_INFO" +} +info_map_long_title() # $file $text +{ + echo "=long=$2" >> "$tmp/$1.$INFO" +} +site_map_list_date() # $file $text +{ + echo "=date=$1 $2" >> "$MK_INFO" +} +info_map_list_date() # $file $text +{ + echo "=date=$2" >> "$tmp/$1.$INFO" +} siteinfo2sitemap () # generate addon sed scriptlet { # the resulting script will act on each item/line # containing and expand any following # reference of or or - OUT="$1" ; test ".$OUT" = "." && OUT="./$MK.site.tmp" - INP="$2" ; test ".$INP" = "." && INP="./$MK.$INFO" + INP="$1" ; test ".$INP" = "." && INP="$MK_INFO" _list_="s|.*|\\&\\2|" _date_="s|.*|\\&\\2|" _long_="s|.*|\\&\\2|" @@ -676,21 +970,20 @@ siteinfo2sitemap () # generate addon sed scriptlet -e "s:=list=\\([^ ]*\\) \\(.*\\):$_list_:" \ -e "s:=date=\\([^ ]*\\) \\(.*\\):$_date_:" \ -e "s:=long=\\([^ ]*\\) \\(.*\\):$_long_:" \ - -e "/^s|/!d" $INP > $OUT + -e "/^s|/!d" $INP # $++ } make_multisitemap () { # each category gets its own column along with the usual entries - OUTPUT="$1" ; test ".$OUTPUT" = "." && OUTPUT="./$F.$BODY" - INPUTS="$2" ; test ".$INPUTS" = "." && INPUTS="./$MK.$INFO" - siteinfo2sitemap ./$MK.site.tmp # have addon-sed + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO" + siteinfo2sitemap > "$MK_SITE" # have addon-sed _form_="" _form_="$_form_
" _tiny_="small> " > $OUTPUT + echo "
" # $++ $SED -e "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \ - -f ./$MK.site.tmp -e "/||" \ -e "s|||" \ -e "s||
|" \ @@ -698,205 +991,242 @@ make_multisitemap () -e "s|||" -e "s|||" \ -e "s|||" \ -e "s|| |" -e "s||
|" \ - $INPUTS >> $OUTPUT - echo "
" >> $OUTPUT + $INPUTS # $++ + echo "" # $++ } make_listsitemap () { # traditional - the body contains a list with date and title extras - OUTPUT="$1" ; test ".$OUTPUT" = "." && OUTPUT="$F.$BODY" - INPUTS="$2" ; test ".$INPUTS" = "." && INPUTS="./$MK.$INFO" - siteinfo2sitemap ./$MK.site.tmp # have addon-sed + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO" + siteinfo2sitemap > "$MK_SITE" # have addon-sed _form_="" _tabb_="\\ \\;" - echo "" > $OUTPUT + echo "
" # $++ $SED -e "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \ - -f ./$MK.site.tmp -e "/||" \ - -e "s|||" \ - -e "//s|]*>|&- |" \ - -e "s|||" -e "s// /g" \ + -f "$MK_SITE" -e "/||" \ + -e "s|||" \ + -e "s|||" \ + -e "//s|]*>|&- |" \ + -e "s|| |g" \ + -e "s||$_tabb_|" \ -e "s||$_tabb_|" \ -e "s|||" \ - $INPUTS >> $OUTPUT - echo "
*
-
*
-
|" -e "s|||" -e "s||
" >> $OUTPUT + $INPUTS # $++ + for xx in `grep "=use.=name:sitemap:" $INPUTS` ; do + xx=`echo $xx | sed -e "s/=use.=name:sitemap://"` + if test -f "$xx" ; then + grep "" $xx # $++ + fi + done + echo "" # $++ } print_extension () { ARG="$1" ; test ".$ARG" = "." && ARG="$opt_print" case "$ARG" in - -*|.*) echo "$ARG" ;; - *) echo ".print" ;; + -*|.*) echo "$ARG" ;; # $++ + *) echo ".print" ;; # $++ esac } html_sourcefile () # generally just cut away the trailing "l" (ell) { # making "page.html" argument into "page.htm" return _SRCFILE_=`echo "$1" | $SED -e "s/l\\$//"` - if test -f "$_SRCFILE_" ; then echo "$_SRCFILE_" - elif test -f "$opt_srcdir/$_SRCFILE_" ; then echo "$opt_srcdir/$_SRCFILE_" - else echo ".//$_SRCFILE_" + if test -f "$_SRCFILE_" ; then echo "$_SRCFILE_" # $++ + elif test -f "$opt_src_dir/$_SRCFILE_" + then echo "$opt_src_dir/$_SRCFILE_" # $++ + else echo ".//$_SRCFILE_" # $++ fi } html_printerfile_sourcefile () { if test ".$printerfriendly" = "." then - echo "$1" | sed -e "s/l\$//" + echo "$1" | sed -e "s/l\$//" # $++ else _ext_=`print_extension "$printerfriendly"` _ext_=`sed_slash_key "$_ext_"` - echo "$1" | sed -e "s/l\$//" -e "s/$_ext_\\([.][$AA]*\\)\$/\\1/" + echo "$1" | sed -e "s/l\$//" -e "s/$_ext_\\([.][$AA]*\\)\$/\\1/" # $++ fi } -moved_html_printerfile () { - x=`html_printerfile "$1"` ; moved_href "$x" $2 +fast_html_printerfile () { + x=`html_printerfile "$1"` ; basename "$x" # $++ +# x=`html_printerfile "$1"` ; fast_href "$x" $2 # $++ } html_printerfile () # generate the printerfile for a given normal output { _ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"` - echo "$1" | sed -e "s/\\([.][$AA]*\\)\$/$_ext_\\1/" + echo "$1" | sed -e "s/\\([.][$AA]*\\)\$/$_ext_\\1/" # $++ } -make_printerfile_move () # generate s/file.html/file.print.html/ for hrefs +make_printerfile_fast () # generate s/file.html/file.print.html/ for hrefs { # we do that only for the $FILELIST - OUTPUT="$1" ; test ".$OUTPUT" = "." && OUTPUT="$MK.move.tmp" - ALLPAGES="$2" ; test ".$ALLPAGES" = "." && ALLPAGES="$FILELIST" - $CATNULL > $OUTPUT + ALLPAGES="$1" ; # ="$FILELIST" for p in $ALLPAGES ; do a=`sed_slash_key "$p"` b=`html_printerfile "$p"` if test "$b" != "$p" ; then b=`html_printerfile "$p" | sed -e "s:&:\\\\&:g" -e "s:/:\\\\\\/:g"` - echo "s///" >> $OUTPUT + echo "s///" # $++ + echo "s/" # $+++ + echo " a:link { $_bold_ color : #000060 ; }" # $+++ + echo " a:visited { $_bold_ color : #000040 ; }" # $+++ + echo " body { background-color : white ; }" # $+++ + echo " " # $+++ +} + +make_printsitefile_head() # $sitefile +{ + echo_printsitefile_style > "$MK_STYLE" + $SED -e "//p" -e "/<title>/d" \ + -e "/<head>/p" -e "/<head>/d" \ + -e "/<\/head>/p" -e "/<\/head>/d" \ + -e "/<body>/p" -e "/<body>/d" \ + -e "/^.*<link [^<>]*rel=\"shortcut icon\"[^<>]*>.*\$/p" \ + -e "d" $SITEFILE | $SED -e "/<head>/r $MK_STYLE" # $+++ +} + + +# ------------------------------------------------------------------------ +# The printsitefile is a long text containing html href markups where +# each of the href lines in the file is being prefixed with the section +# relation. During a secondary call the printsitefile can grepp'ed for +# those lines that match a given output fast-file. The result is a +# navigation header with 1...3 lines matching the nesting level + # these alt-texts will be only visible in with a text-mode browser: printsitefile_square="width=\"8\" height=\"8\" border=\"0\"" printsitefile_img_1="<img alt=\"|go text:\" $printsitefile_square />" printsitefile_img_2="<img alt=\"||topics:\" $printsitefile_square />" printsitefile_img_3="<img alt=\"|||pages:\" $printsitefile_square />" +_SECT="mksite:sect:" + +echo_current_line () # $sect $extra +{ + echo "<!--$_SECT\"$1\"-->$2" # $++ +} +make_current_entry () # $sect $file ## requires $MK_SITE +{ + S="$1" ; R="$2" + SSS=`sed_slash_key "$S"` + sep=" - " ; _left_=" [ " ; _right_=" ] " + echo_current_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \ + | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ + -e "/<a href=\"$SSS\"/s/<a href/$_left_&/" \ + -e "/<a href=\"$SSS\"/s/<\\/a>/&$_right_/" \ + -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++ +} +echo_subpage_line () # $sect $extra +{ + echo "<!--$_SECT*:\"$1\"-->$2" # $++ +} + +make_subpage_entry () +{ + S="$1" ; R="$2" + RR=`sed_slash_key "$R"` + sep=" - " ; + echo_subpage_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \ + | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ + -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++ +} + make_printsitefile () { - OUTPUT="$1" ; test ".$OUTPUT" = "." && OUTPUT="$SITEFILE.print.html" - INPUTS="$2" ; test ".$INPUTS" = "." && INPUTS="./$MK.$INFO" - _bold_="text-decoration : none ; font-weight : bold ; " - echo " <style>" > $MK.style.tmp - echo " a:link { $_bold_ color : #000060 ; }" >> $MK.style.tmp - echo " a:visited { $_bold_ color : #000040 ; }" >> $MK.style.tmp - echo " body { background-color : white ; }" >> $MK.style.tmp - echo " </style>" >> $MK.style.tmp - siteinfo2sitemap ./$MK.site.tmp # have <name><long><date> addon-sed - _form_="<!--\"\\2\"--><!--use\\1--><!--name--><!--date--><!--long-->" - _tabb_="<td>\\ \\;</td>" - $SED -e "/<title>/p" -e "/<title>/d" \ - -e "/<head>/p" -e "/<head>/d" \ - -e "/<\/head>/p" -e "/<\/head>/d" \ - -e "/<body>/p" -e "/<body>/d" \ - -e "/^.*<link [^<>]*rel=\"shortcut icon\"[^<>]*>.*\$/p" \ - -e "d" $SITEFILE | $SED -e "/<head>/r ./$MK.style.tmp" > $OUTPUT + # building the printsitefile looks big but its really a loop over sects + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO" + siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed + make_printsitefile_head $SITEFILE # $++ - sep=" - " ; _left_=" [ " ; _right_=" ] " + sep=" - " _sect1="<a href=\"#.\" title=\"section\">$printsitefile_img_1</a> ||$sep" _sect2="<a href=\"#.\" title=\"topics\">$printsitefile_img_2</a> ||$sep" _sect3="<a href=\"#.\" title=\"pages\">$printsitefile_img_3</a> ||$sep" - site_get_rootsections > ./$MK.sect1.tmp - test -d DEBUG && echo "# rootsections" > DEBUG/printsitemap.txt - test -d DEBUG && cat ./$MK.sect1.tmp >> DEBUG/printsitemap.txt - for r in `cat ./$MK.sect1.tmp` ; do - echo "<!--mksite:sect:\"$r\"--><!--mksite:sect1:A--><br>$_sect1" >> $OUTPUT - for s in `cat ./$MK.sect1.tmp` ; do - rr=`sed_slash_key "$r"` - echo "<!--mksite:sect:\"$r\"--><a href=\"$s\"><!--\"$s\"--><!--name--></a>$sep" \ - | $SED -f ./$MK.site.tmp -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "/<a href=\"$rr\"/s/<a href/$_left_&/" \ - -e "/<a href=\"$rr\"/s/<\\/a>/&$_right_/" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" >> $OUTPUT - done - echo "<!--mksite:sect:\"$s\"--><!--mksite:sect1:Z-->" >> $OUTPUT - -# site_get_sectionpages "$r" > ./$MK.sect2.tmp - site_get_subpages "$r" > ./$MK.sect2.tmp - test -d DEBUG && echo "# subsections $r" >> DEBUG/printsitemap.txt - test -d DEBUG && cat ./$MK.sect2.tmp >> DEBUG/printsitemap.txt - for s in `cat ./$MK.sect2.tmp` ; do test "$r" = "$s" && continue - echo "<!--mksite:sect:\"$s\"--><!--mksite:sect2:A--><br>$_sect2" >> $OUTPUT - for t in `cat ./$MK.sect2.tmp` ; do test "$r" = "$t" && continue - ss=`sed_slash_key "$s"` - echo "<!--mksite:sect:\"$s\"--><a href=\"$t\"><!--\"$t\"--><!--name--></a>$sep" \ - | $SED -f ./$MK.site.tmp -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "/<a href=\"$ss\"/s/<a href/$_left_&/" \ - -e "/<a href=\"$ss\"/s/<\\/a>/&$_right_/" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" >> $OUTPUT - done # "$t" - echo "<!--mksite:sect:\"$s\"--><!--mksite:sect2:Z-->" >> $OUTPUT - - -# site_get_sectionpages "$s" > ./$MK.sect3.tmp - site_get_subpages "$s" > ./$MK.sect3.tmp - test -d DEBUG && echo "# subsubsections $s" >> DEBUG/printsitemap.txt - test -d DEBUG && cat ./$MK.sect3.tmp >> DEBUG/printsitemap.txt - for t in `cat ./$MK.sect3.tmp` ; do test "$s" = "$t" && continue - echo "<!--mksite:sect:\"$t\"--><!--mksite:sect3:A--><br>$_sect3" >> $OUTPUT - for u in `cat ./$MK.sect3.tmp` ; do test "$s" = "$u" && continue - tt=`sed_slash_key "$t"` - echo "<!--mksite:sect:\"$t\"--><a href=\"$u\"><!--\"$u\"--><!--name--></a>$sep" \ - | $SED -f ./$MK.site.tmp -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "/<a href=\"$tt\"/s/<a href/$_left_&/" \ - -e "/<a href=\"$tt\"/s/<\\/a>/&$_right_/" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" >> $OUTPUT - done # "$u" - echo "<!--mksite:sect:\"$t\"--><!--mksite:sect3:Z-->" >> $OUTPUT - done # "$t" + site_get_rootsections > "$MK_SECT1" + # round one - for each root section print a current menu + for r in `cat "$MK_SECT1"` ; do + echo_current_line "$r" "<!--mksite:sect1:A--><br>$_sect1" # $++ + for s in `cat "$MK_SECT1"` ; do + make_current_entry "$r" "$s" # $++ + done + echo_current_line "$r" "<!--mksite:sect1:Z-->" # $++ + done # "$r" - _have_children_="0" - for u in `cat ./$MK.sect3.tmp` ; do test "$r" = "$t" && continue - test "$_have_children_" = "0" && _have_children_="1" && \ - echo "<!--mksite:sect:*:\"$s\"--><!--mksite:sect3:A--><br>$_sect3" >> $OUTPUT - echo "<!--mksite:sect:*:\"$s\"--><a href=\"$u\"><!--\"$u\"--><!--name--></a>$sep" \ - | $SED -f ./$MK.site.tmp -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" >> $OUTPUT - done # "$u" - test "$_have_children_" = "1" && \ - echo "<!--mksite:sect:*:\"$s\"--><!--mksite:sect3:Z-->" >> $OUTPUT + # round two - for each subsection print a current and subpage menu + for r in `cat "$MK_SECT1"` ; do + site_get_subpages "$r" > "$MK_SECT2" + for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue + echo_current_line "$s" "<!--mksite:sect2:A--><br>$_sect2" # $++ + for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue + make_current_entry "$s" "$t" # $++ + done # "$t" + echo_current_line "$s" "<!--mksite:sect2:Z-->" # $++ done # "$s" + _have_children_="0" + for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue + test "$_have_children_" = "0" && _have_children_="1" && \ + echo_subpage_line "$r" "<!--mksite:sect2:A--><br>$_sect2" # $++ + make_subpage_entry "$r" "$t" # $++ + done # "$t" + test "$_have_children_" = "1" && \ + echo_subpage_line "$r" "<!--mksite:sect2:Z-->" # $++ + done # "$r" - _have_children_="0" - for t in `cat ./$MK.sect2.tmp` ; do test "$r" = "$t" && continue - test "$_have_children_" = "0" && _have_children_="1" && \ - echo "<!--mksite:sect:*:\"$r\"--><!--mksite:sect2:A--><br>$_sect2" >> $OUTPUT - echo "<!--mksite:sect:*:\"$r\"--><a href=\"$t\"><!--\"$t\"--><!--name--></a>$sep" \ - | $SED -f ./$MK.site.tmp -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" >> $OUTPUT + # round three - for each subsubsection print a current and subpage menu + for r in `cat "$MK_SECT1"` ; do + site_get_subpages "$r" > "$MK_SECT2" + for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue + site_get_subpages "$s" > "$MK_SECT3" + for t in `cat "$MK_SECT3"` ; do test "$s" = "$t" && continue + echo_current_line "$t" "<!--mksite:sect3:A--><br>$_sect3" # $++ + for u in `cat "$MK_SECT3"` ; do test "$s" = "$u" && continue + make_current_entry "$t" "$u" # $++ + done # "$u" + echo_current_line "$t" "<!--mksite:sect3:Z-->" # $++ done # "$t" - test "$_have_children_" = "1" && \ - echo "<!--mksite:sect:*:\"$r\"--><!--mksite:sect2:Z-->" >> $OUTPUT + _have_children_="0" + for u in `cat "$MK_SECT3"` ; do test "$u" = "$s" && continue + test "$_have_children_" = "0" && _have_children_="1" && \ + echo_subpage_line "$s" "<!--mksite:sect3:A--><br>$_sect3" # $++ + make_subpage_entry "$s" "$u" # $++ + done # "$u" + test "$_have_children_" = "1" && \ + echo_subpage_line "$s" "<!--mksite:sect3:Z-->" # $++ + done # "$s" done # "$r" - echo "<a name=\".\"></a>" >> $OUTPUT - echo "</body></html>" >> $OUTPUT + echo "<a name=\".\"></a>" # $++ + echo "</body></html>" # $++ } +# create a selector that can grep a printsitefile for the matching entries select_in_printsitefile () # arg = "page" : return to stdout >> $P.$HEAD { _selected_="$1" ; test ".$_selected_" = "." && _selected_="$F" _section_=`sed_slash_key "$_selected_"` - echo "s/^<!--mksite:sect:\"$_section_\"-->//" # sect3 - echo "s/^<!--mksite:sect:[*]:\"$_section_\"-->//" # children + echo "s/^<!--$_SECT\"$_section_\"-->//" # sect3 + echo "s/^<!--$_SECT[*]:\"$_section_\"-->//" # children _selected_=`site_get_parentpage "$_selected_"` _section_=`sed_slash_key "$_selected_"` - echo "s/^<!--mksite:sect:\"$_section_\"-->//" # sect2 + echo "s/^<!--$_SECT\"$_section_\"-->//" # sect2 _selected_=`site_get_parentpage "$_selected_"` _section_=`sed_slash_key "$_selected_"` - echo "s/^<!--mksite:sect:\"$_section_\"-->//" # sect1 - echo "/^<!--mksite:sect:\"[^\"]*\"-->/d" - echo "/^<!--mksite:sect:[*]:\"[^\"]*\"-->/d" - echo "s/^<!--mksite:sect[$NN]:[$AZ]-->//" + echo "s/^<!--$_SECT\"$_section_\"-->//" # sect1 + echo "/^<!--$_SECT\"[^\"]*\"-->/d" + echo "/^<!--$_SECT[*]:\"[^\"]*\"-->/d" + echo "s/^<!--mksite:sect[$NN]:[$AZ]-->//" } body_for_emailfooter () @@ -981,145 +1311,107 @@ echo_sp_PP () echo "/^$1$S*<a href=/s/^/$2/" } -h1="[-|[]" -b1="[*=]" -b2="[-|[]" -b3="[\\/:]" -q3="[\\/:,[]" -echo_HR_PP "<hr>" "$h1" "<!--sect1-->" > $MK.gets.tmp -echo_HR_EM_PP "<hr>" "<em>" "$h1" "<!--sect1-->" >> $MK.gets.tmp -echo_HR_EM_PP "<hr>" "<strong>" "$h1" "<!--sect1-->" >> $MK.gets.tmp -echo_HR_PP "<br>" "$b1$b1" "<!--sect1-->" >> $MK.gets.tmp -echo_HR_PP "<br>" "$b2$b2" "<!--sect2-->" >> $MK.gets.tmp -echo_HR_PP "<br>" "$b3$b3" "<!--sect3-->" >> $MK.gets.tmp -echo_br_PP "<br>" "$b2$b2" "<!--sect2-->" >> $MK.gets.tmp -echo_br_PP "<br>" "$b3$b3" "<!--sect3-->" >> $MK.gets.tmp -echo_br_EM_PP "<br>" "<small>" "$q3" "<!--sect3-->" >> $MK.gets.tmp -echo_br_EM_PP "<br>" "<em>" "$q3" "<!--sect3-->" >> $MK.gets.tmp -echo_br_EM_PP "<br>" "<u>" "$q3" "<!--sect3-->" >> $MK.gets.tmp -echo_HR_PP "<br>" "$q3" "<!--sect3-->" >> $MK.gets.tmp -echo_sp_PP "$q3" "<!--sect3-->" >> $MK.gets.tmp -$SED -e "s/>\\[/> *[/" ./$MK.gets.tmp > $MK.puts.tmp -# the .puts.tmp variant is used to <b><a href=..></b> some hrefs which -# shall not be used otherwise for being generated - this is nice for -# some quicklinks somewhere. The difference: a whitspace "<hr> <a...>" - -# scan sitefile for references pages - store as =use+= relation -_uses_="=use\\1=\\2 \\3" ; -_getX_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*" -_getY_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*<[^<>]*>[^<>]*" -$SED -f $MK.gets.tmp -e "/^<!--sect[$NN]-->/!d" \ - -e "s:^$_getX_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*:$_uses_:" \ - -e "s:^$_getY_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*:$_uses_:" \ - -e "/^=....=/!d" $SITEFILE > $MK.$INFO -# scan used pages and store relation =sect= pointing to section group -$SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "s/=use.=\\([^ ]*\\) .*/=sect=\\1/" \ - -e G -e "s:\\n: :" ./$MK.$INFO >> $MK.$INFO -$SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use1=/d" \ - -e "/=use3=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ - -e G -e "s:\\n: :" ./$MK.$INFO >> $MK.$INFO -# scan used pages and store relation =page= pointing to topic group -$SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use1=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=page=\\1/" \ - -e G -e "s:\\n: :" ./$MK.$INFO >> $MK.$INFO -$SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use1=/d" \ - -e "/=use2=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ - -e G -e "s:\\n: :" ./$MK.$INFO >> $MK.$INFO -# and for the root sections we register ".." as the parenting group -$SED -e "/=use1=/!d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1 ../" ./$MK.$INFO >> $MK.$INFO - -FILELIST=`$SED -e "/=use.=/!d" -e "s/=use.=//" -e "s/ .*//" ./$MK.$INFO` +echo_sp_sp () +{ + echo "/^$1*<a name=/s/^/$2/" + echo "/^<>$1*<a name=/s/^/$2/" + echo "/^$S$1*<a name=/s/^/$2/" + echo "/^<><>$1*<a name=/s/^/$2/" + echo "/^$S$S$1*<a name=/s/^/$2/" + echo "/^<>$1<>*<a name=/s/^/$2/" + echo "/^$S$1$S*<a name=/s/^/$2/" + echo "/^$1<><>*<a name=/s/^/$2/" + echo "/^$1$S$S*<a name=/s/^/$2/" + echo "/^$1<>*<a name=/s/^/$2/" + echo "/^$1$S*<a name=/s/^/$2/" +} +make_sitemap_init() +{ + # build a list of detectors that map site.htm entries to a section table + # note that the resulting .gets.tmp / .puts.tmp are real sed-script + h1="[-|[]" + b1="[*=]" + b2="[-|[]" + b3="[\\/:]" + q3="[\\/:,[]" + echo_HR_PP "<hr>" "$h1" "<!--sect1-->" > "$MK_GETS" + echo_HR_EM_PP "<hr>" "<em>" "$h1" "<!--sect1-->" >> "$MK_GETS" + echo_HR_EM_PP "<hr>" "<strong>" "$h1" "<!--sect1-->" >> "$MK_GETS" + echo_HR_PP "<br>" "$b1$b1" "<!--sect1-->" >> "$MK_GETS" + echo_HR_PP "<br>" "$b2$b2" "<!--sect2-->" >> "$MK_GETS" + echo_HR_PP "<br>" "$b3$b3" "<!--sect3-->" >> "$MK_GETS" + echo_br_PP "<br>" "$b2$b2" "<!--sect2-->" >> "$MK_GETS" + echo_br_PP "<br>" "$b3$b3" "<!--sect3-->" >> "$MK_GETS" + echo_br_EM_PP "<br>" "<small>" "$q3" "<!--sect3-->" >> "$MK_GETS" + echo_br_EM_PP "<br>" "<em>" "$q3" "<!--sect3-->" >> "$MK_GETS" + echo_br_EM_PP "<br>" "<u>" "$q3" "<!--sect3-->" >> "$MK_GETS" + echo_HR_PP "<br>" "$q3" "<!--sect3-->" >> "$MK_GETS" + echo_sp_PP "$q3" "<!--sect3-->" >> "$MK_GETS" + echo_sp_sp "$q3" "<!--sect9-->" >> "$MK_GETS" + $SED -e "s/\\(>\\)\\(\\[\\)/\\1 *\\2/" "$MK_GETS" > "$MK_PUTS" + # the .puts.tmp variant is used to <b><a href=..></b> some hrefs which + # shall not be used otherwise for being generated - this is nice for + # some quicklinks somewhere. The difference: a whitspace "<hr> <a...>" +} -# ========================================================================== -# MAGIC VARS -# IN $SITEFILE -printerfriendly="" -sectionlayout="list" -sitemaplayout="list" -simplevars="warn" # <!--varname-->default -attribvars=" " # <x ref="${varname:=default}"> -updatevars=" " # <!--$varname:=-->default -expandvars=" " # <!--$varname--> -commentvars=" " # $updatevars && $expandsvars && $simplevars -sectiontab=" " # highlight ^<td class=...>...href="$section" -currenttab=" " # highlight ^<br>..<a href="$topic"> -headsection="no" -tailsection="no" -sectioninfo="no" # using <h2> title <h2> = info text -emailfooter="no" +_uses_="=use\\1=\\2 \\3" ; _name_="=use\\1=name:\\2 \\3" ; +_getW_="<!--sect\\([$NN]\\)-->" +_getX_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*" +_getY_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*<[^<>]*>[^<>]*" -if $GREP "<!--multi-->" $SITEFILE >$NULL ; then -echo \ -"WARNING: do not use <!--multi-->, change to <!--mksite:multi--> " "$SITEFILE" -echo \ -"warning: or <!--mksite:multisectionlayout--> <!--mksite:multisitemaplayout-->" -sectionlayout="multi" -sitemaplayout="multi" -fi -if $GREP "<!--mksite:multi-->" $SITEFILE >$NULL ; then -sectionlayout="multi" -sitemaplayout="multi" -fi -if $GREP "<!--mksite:multilayout-->" $SITEFILE >$NULL ; then -sectionlayout="multi" -sitemaplayout="multi" -fi -x=`mksite_magic_option sectionlayout` ; case "$x" in - "list"|"multi") sectionlayout="$x" ;; esac -x=`mksite_magic_option sitemaplayout` ; case "$x" in - "list"|"multi") sitemaplayout="$x" ;; esac -x=`mksite_magic_option simplevars` ; case "$x" in - " "|"no"|"warn") simplevars="$x" ;; esac -x=`mksite_magic_option attribvars` ; case "$x" in - " "|"no"|"warn") attribvars="$x" ;; esac -x=`mksite_magic_option updatevars` ; case "$x" in - " "|"no"|"warn") updatevars="$x" ;; esac -x=`mksite_magic_option expandvars` ; case "$x" in - " "|"no"|"warn") expandvars="$x" ;; esac -x=`mksite_magic_option commentvars` ; case "$x" in - " "|"no"|"warn") commentvars="$x" ;; esac -x=`mksite_magic_option printerfriendly` ; case "$x" in - " "|".*"|"-*") printerfriendly="$x" ;; esac -x=`mksite_magic_option sectiontab` ; case "$x" in - " "|"no"|"warn") sectiontab="$x" ;; esac -x=`mksite_magic_option currenttab` ; case "$x" in - " "|"no"|"warn") currenttab="$x" ;; esac -x=`mksite_magic_option sectioninfo` ; case "$x" in - " "|"no"|"[=-:]") sectioninfo="$x" ;; esac -x=`mksite_magic_option emailfooter` - test ".$x" != "." && emailfooter="$x" +make_sitemap_list() +{ + # scan sitefile for references pages - store as "=use+=href+ anchortext" + $SED -f $MK_GETS -e "/^<!--sect[$NN]-->/!d" \ + -e "s|^$_getX_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_uses_|" \ + -e "s|^$_getY_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_uses_|" \ + -e "s|^$_getW_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \ + -e "s|^$_getX_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \ + -e "s|^$_getY_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \ + -e "/^=....=/!d" "$SITEFILE" > "$MK_INFO" +} -test ".$opt_print" != "." && printerfriendly="$opt_print" -test ".$commentvars" = ".no" && updatevars="no" # duplicated into -test ".$commentvars" = ".no" && expandvars="no" # info2vars () -test ".$commentvars" = ".no" && simplevars="no" # function above +make_sitemap_sect() +{ + # scan used pages and store prime section group relation =sect= and =node= + # (A) each "use1" creates "=sect=href+ href1" for all following non-"use1" + # (B) each "use1" creates "=node=href2 href1" for all following "use2" + $SED -e "/=use.=/!d" \ + -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "s/=use.=\\([^ ]*\\) .*/=sect=\\1/" \ + -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" + $SED -e "/=use.=/!d" \ + -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "/=use[13456789]=/d" \ + -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ + -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" +} -test -d DEBUG && \ -echo "NOTE: '$sectionlayout'sectionlayout '$sitemaplayout'sitemaplayout" -test -d DEBUG && \ -echo "NOTE: '$simplevars'simplevars '$printerfriendly'printerfriendly" -test -d DEBUG && \ -echo "NOTE: '$attribvars'attribvars '$updatevars'updatevars" -test -d DEBUG && \ -echo "NOTE: '$expandvars'expandvars '$commentvars'commentvars " -test -d DEBUG && \ -echo "NOTE: '$currenttab'currenttab '$sectiontab'sectiontab" -test -d DEBUG && \ -echo "NOTE: '$headsection'headsection '$tailsection'tailsection" +make_sitemap_page() +{ + # scan used pages and store secondary group relation =page= and =node= + # the parenting =node= for use3 is usually a use2 (or use1 if none there) + $SED -e "/=use.=/!d" \ + -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "/=use[1]=/d" \ + -e "s/=use.=\\([^ ]*\\) .*/=page=\\1/" \ + -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" + $SED -e "/=use.=/!d" \ + -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ + -e "/=use[12456789]=/d" \ + -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ + -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" + # and for the root sections we register ".." as the parenting group + $SED -e "/=use1=/!d" \ + -e "s/=use.=\\([^ ]*\\) .*/=node=\\1 ../" "$MK_INFO" >> "$MK_INFO" +} +echo_site_filelist() +{ + $SED -e "/=use.=/!d" -e "s/=use.=//" -e "s/ .*//" "$MK_INFO" +} # ========================================================================== # originally this was a one-pass compiler but the more information @@ -1128,249 +1420,355 @@ echo "NOTE: '$headsection'headsection '$tailsection'tailsection" # we scan the files first for global information. # 1.PASS -for F in $FILELIST ; do case "$F" in -http:*|*://*) ;; # skip -${SITEFILE}|${SITEFILE}l) SOURCEFILE=`html_sourcefile "$F"` -if test "$SOURCEFILE" != "$F" ; then - echo "=text=today `$DATE_NOW +%Y-%m-%d`" > $F.$INFO - echo "=meta=formatter `basename $0`" >> $F.$INFO - short=`echo "$F" | $SED -e "s:.*/::" -e "s:[.].*::"` - short="$short *" +scan_sitefile () # $F +{ + SOURCEFILE=`html_sourcefile "$F"` + if test "$SOURCEFILE" != "$F" ; then + dx_init "$F" + dx_text today "`timetoday`" + short=`echo "$F" | $SED -e "s:.*/::" -e "s:[.].*::"` # basename for all exts + short="$short ~" DC_meta title "$short" - DC_meta date.available `$DATE_NOW +%Y-%m-%d` + DC_meta date.available "`timetoday`" DC_meta subject sitemap DC_meta DCMIType Collection - DC_VARS_Of $SOURCEFILE - DC_modified $SOURCEFILE ; DC_date $SOURCEFILE + DC_VARS_Of "$SOURCEFILE" ; HTTP_VARS_Of "$SOURCEFILE" + DC_modified "$SOURCEFILE" ; DC_date "$SOURCEFILE" DC_section "$F" - DX_text date.formatted `$DATE_NOW +%Y-%m-%d` + DX_text date.formatted `timetoday` test ".$printerfriendly" != "." && \ - DX_text printerfriendly `moved_html_printerfile "$F"` + DX_text "printerfriendly" `fast_html_printerfile "$F"` test ".$USER" != "." && DC_publisher "$USER" echo "'$SOURCEFILE': $short (sitemap)" - echo "=list=$F $short" >> $MK.$INFO - echo "=date=$F `$DATE_NOW +%Y-%m-%d`" >> $MK.$INFO - echo "=long=$F generated sitemap index" >> $MK.$INFO -fi ;; -../*) - echo "!! -> '$F' (skipping topdir build)" - ;; -# */*.html) -# make_move # try for later subdir build -# echo "!! -> '$F' (skipping subdir build)" -# ;; -# */*/*/|*/*/|*/|*/index.htm|*/index.html) -# echo "!! -> '$F' (skipping subdir index.html)" -# ;; -*.html) SOURCEFILE=`html_sourcefile "$F"` # SCAN : -if test "$SOURCEFILE" != "$F" ; then : # HTML : -if test -f "$SOURCEFILE" ; then make_move "$F" - echo "=text=today `$DATE_NOW +%Y-%m-%d`" > $F.$INFO - echo "=text=todays `$DATE_NOW +%Y-%m%d`" >> $F.$INFO - echo "=meta=formatter `basename $0`" >> $F.$INFO - DC_VARS_Of "$SOURCEFILE" + site_map_list_title "$F" "$short" + site_map_long_title "$F" "generated sitemap index" + site_map_list_date "$F" "`timetoday`" + fi +} + +scan_htmlfile() # "$F" +{ + SOURCEFILE=`html_sourcefile "$F"` # SCAN : + if test "$SOURCEFILE" != "$F" ; then : # HTML : + if test -f "$SOURCEFILE" ; then make_fast "$F" > "$tmp/$F.$FAST" + dx_init "$F" + dx_text today "`timetoday`" + dx_text todays "`timetodays`" + DC_VARS_Of "$SOURCEFILE" ; HTTP_VARS_Of "$SOURCEFILE" DC_title "$SOURCEFILE" DC_isFormatOf "$SOURCEFILE" DC_modified "$SOURCEFILE" ; DC_date "$SOURCEFILE" ; DC_date "$SITEFILE" DC_section "$F" ; DC_selected "$F" ; DX_alternative "$SOURCEFILE" test ".$USER" != "." && DC_publisher "$USER" - DX_text date.formatted `$DATE_NOW +%Y-%m-%d` + DX_text date.formatted "`timetoday`" test ".$printerfriendly" != "." && \ - DX_text printerfriendly `moved_html_printerfile "$F"` + DX_text "printerfriendly" `fast_html_printerfile "$F"` sectn=`info_get_entry DC.relation.section` short=`info_get_entry DC.title.selected` - echo "=list=$short" >> $F.$INFO ; echo "=list=$F $short" >> $MK.$INFO + site_map_list_title "$F" "$short" + info_map_list_title "$F" "$short" title=`info_get_entry DC.title` - echo "=long=$title" >> $F.$INFO ; echo "=long=$F $title" >> $MK.$INFO + site_map_long_title "$F" "$title" + info_map_long_title "$F" "$title" edate=`info_get_entry DC.date` issue=`info_get_entry issue` - echo "=date=$edate" >> $F.$INFO ; echo "=date=$F $edate" >> $MK.$INFO + site_map_list_date "$F" "$edate" + info_map_list_date "$F" "$edate" echo "'$SOURCEFILE': '$title' ('$short') @ '$issue' ('$sectn')" -else + else echo "'$SOURCEFILE': does not exist" - echo "=list=$F $F" >> $MK.$INFO - echo "=long=$F (no source)" >> $MK.$INFO -fi ; else + site_map_list_title "$F" "$F" + site_map_long_title "$F" "$F (no source)" + fi ; else echo "<$F> - skipped" -fi ;; -*/) echo "'$F' : directory - skipped" - echo "=list=$F `sed_slash_key $F`" >> $MK.$INFO - echo "=long=$F (directory)" >> $MK.$INFO - ;; -*) echo "?? -> '$F'" - ;; -esac done + fi +} -if test ".$simplevars" = ". " ; then -$CATNULL > $MK.olds.tmp -fi +scan_namespec () +{ + # nothing so far + case "$1" in + name:sitemap:*) + short=`echo "$F" | $SED -e "s:.*/::" -e "s:[.].*::"` + short=`echo "$short ~" | $SED -e "s/name:sitemap://"` + site_map_list_title "$F" "$short" + site_map_long_title "$F" "external sitemap index" + site_map_list_date "$F" "`timetoday`" + echo "'$F' external sitemap index$n" + ;; + esac +} +scan_httpspec () +{ + # nothing so far + return; +} -# ========================================================================== -if test ".$printerfriendly" != "." ; then # PRINT -_ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"` # VERSION -PRINTSITEFILE=`echo "$SITEFILE" | sed -e "s/\\.[$AA]*\$/$_ext_&/"` -echo "NOTE: going to create printer-friendly sitefile $PRINTSITEFILE" -make_printsitefile "$PRINTSITEFILE" -fi +skip_namespec () +{ + # nothing so far + return; +} +skip_httpspec () +{ + # nothing so far + return; +} # ========================================================================== # and now generate the output pages # 2.PASS -for F in $FILELIST ; do case "$F" in -http:*|*://*) : ;; # skip -# .............................................................. SITE FILE -${SITEFILE}|${SITEFILE}l) SOURCEFILE=`html_sourcefile "$F"` -if test "$SOURCEFILE" != "$F" ; then -if test -f "$SOURCEFILE" ; then - # remember that in this case "${SITEFILE}l" = "$F" = "${SOURCEFILE}l" - test ".$simplevars" = ".warn" && \ - info2test $MK.test.tmp # check <!--title--> vars old-style - info2vars $MK.vars.tmp # have <!--title--> vars substituted - info2meta $MK.meta.tmp # add <meta name="DC.title"> values - test ".$simplevars" = ".warn" && \ - $SED_LONGSCRIPT ./$MK.test.tmp $SOURCEFILE | tee -a ./$MK.olds.tmp +head_sed_sitemap() # $filename $section +{ + FF="$1" + SECTION=`sed_slash_key "$2"` SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs - CURRENT_SECTION=`info_get_entry DC.relation.section` - SECTION=`sed_slash_key "$CURRENT_SECTION"` - $CAT ./$MK.puts.tmp > $F.$HEAD - echo "/^$SECTS.*<a href=\"$F\">/s|</a>|</a></b>|" >> $F.$HEAD - echo "/^$SECTS.*<a href=\"$F\">/s|<a href=|<b><a href=|" >> $F.$HEAD + echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|" # $++ + echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|" # $++ test ".$sectiontab" != ".no" && \ - echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" >> $F.$HEAD - echo "/<head>/r $MK.meta.tmp" >> $F.$HEAD - $CAT ./$MK.vars.tmp ./$MK.tags.tmp >> $F.$HEAD - echo "/<\\/body>/d" >> $F.$HEAD + echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" # $++ +} + +head_sed_listsection() # $filename $section +{ + # traditional.... the sitefile is the full navigation bar + FF=`sed_slash_key "$1"` + SECTION=`sed_slash_key "$2"` + SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs + echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|" # $++ + echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|" # $++ + test ".$sectiontab" != ".no" && \ + echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" # $++ +} + +head_sed_multisection() # $filename $section +{ + # sitefile navigation bar is split into sections + FF=`sed_slash_key "$1"` + SECTION=`sed_slash_key "$2"` + SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs + # grep all pages with a =sect= relation to current $SECTION and + # build foreach an sed line "s|$SECTS\(<a href=$F>\)|<!--sectX-->\1|" + # after that all the (still) numeric SECTNs are deactivated / killed. + for section in $SECTION $headsection $tailsection ; do + test ".$section" = ".no" && continue + $SED -e "/^=sect=[^ ]* $section/!d" \ + -e "s, .*,\"\\\\)|<!--sectX-->\\\\1|," \ + -e "s,^=sect=,s|^$SECTS\\\\(.*<a href=\"," "$MK_INFO" # $++ + done + echo "s|^$SECTN[^ ]*\\(<a href=[^<>]*>\\).*|<!-- \\1 -->|" # $++ + echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|" # $++ + echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|" # $++ + test ".$sectiontab" != ".no" && \ + echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" # $++ +} + +make_sitefile () # "$F" +{ + SOURCEFILE=`html_sourcefile "$F"` + if test "$SOURCEFILE" != "$F" ; then + if test -f "$SOURCEFILE" ; then + # remember that in this case "${SITEFILE}l" = "$F" = "${SOURCEFILE}l" + info2vars_sed > $MK_VARS # have <!--title--> vars substituted + info2meta_sed > $MK_META # add <meta name="DC.title"> values + if test ".$simplevars" = ".warn" ; then + info2test_sed > $MK_TEST # check <!--title--> vars old-style + $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi + F_HEAD="$tmp/$F.$HEAD" ; F_FOOT="$tmp/$F.$FOOT" + $CAT "$MK_PUTS" > "$F_HEAD" + head_sed_sitemap "$F" "`info_get_entry_section`" >> "$F_HEAD" + echo "/<head>/r $MK_META" >> "$F_HEAD" + $CAT "$MK_VARS" "$MK_TAGS" >> "$F_HEAD" + echo "/<\\/body>/d" >> "$F_HEAD" case "$sitemaplayout" in - multi) make_multisitemap $F.$BODY ;; # here we use ~body~ as - *) make_listsitemap $F.$BODY ;; # a plain text file + multi) make_multisitemap > "$F_FOOT" ;; # here we use ~foot~ to + *) make_listsitemap > "$F_FOOT" ;; # hold the main text esac - $SED_LONGSCRIPT $F.$HEAD $SITEFILE > $F # ~head~ - $CAT $F.$BODY >> $F # ~body~ - $SED -e "/<\\/body>/!d" -f ./$MK.vars.tmp $SITEFILE >> $F #</body> - echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` "->" `ls -s $F` "(sitemap)" -else + + mkpathfile "$F" + $SED_LONGSCRIPT "$F_HEAD" "$SITEFILE" > $F # ~head~ + $CAT "$F_FOOT" >> $F # ~body~ + $SED -e "/<\\/body>/!d" -f "$MK_VARS" "$SITEFILE" >> $F #</body> + echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` ">->" `ls -s $F` "(sitemap)" + else echo "'$SOURCEFILE': does not exist" -fi fi ;; -../*) - echo "!! -> '$F' (skipping topdir build)" - ;; -# */*.html) -# echo "!! -> '$F' (skipping subdir build)" -# ;; -# */*/*/|*/*/|*/|*/index.htm|*/index.html) -# echo "!! -> '$F' (skipping subdir index.html)" -# ;; -# ............................................................... HTML FILES -*.html) SOURCEFILE=`html_sourcefile "$F"` # 2.PASS -if test "$SOURCEFILE" != "$F" ; then -if test -f "$SOURCEFILE" ; then - test ".$simplevars" = ".warn" && \ - info2test $MK.test.tmp # check <!--title--> vars old-style - info2vars $MK.vars.tmp # have <!--$title--> vars substituted - info2meta $MK.meta.tmp # add <meta name="DC.title"> values - test ".$simplevars" = ".warn" && \ - $SED_LONGSCRIPT ./$MK.test.tmp $SOURCEFILE | tee -a ./$MK.olds.tmp - SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs - CURRENT_SECTION=`info_get_entry DC.relation.section` - SECTION=`sed_slash_key "$CURRENT_SECTION"` - FF=`sed_slash_key "$F"` + fi fi +} + +make_htmlfile() # "$F" +{ + SOURCEFILE=`html_sourcefile "$F"` # 2.PASS + if test "$SOURCEFILE" != "$F" ; then + if test -f "$SOURCEFILE" ; then + if grep '<meta name="formatter"' "$SOURCEFILE" >/dev/null ; then + echo "$SOURCEFILE: SKIP, this sourcefile looks like a formatted file" + echo "$SOURCEFILE: (may be a sourcefile in place of a targetfile?)" + return + fi + info2vars_sed > $MK_VARS # have <!--$title--> vars substituted + info2meta_sed > $MK_META # add <meta name="DC.title"> values + if test ".$simplevars" = ".warn" ; then + info2test_sed > $MK_TEST # check <!--title--> vars old-style + $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi + F_HEAD="$tmp/$F.$HEAD" ; F_BODY="$tmp/$F.$BODY" ; F_FOOT="$tmp/$F.$FOOT" + $CAT "$MK_PUTS" > "$F_HEAD" case "$sectionlayout" in - multi) # sitefile navigation bar is split into sections - $CAT ./$MK.puts.tmp > $F.$HEAD - # grep all pages with a =sect= relation to current $SECTION and - # build foreach an sed line "s|$SECTS\(<a href=$F>\)|<!--sectX-->\1|" - # after that all the (still) numeric SECTNs are deactivated / killed. - for i in $SECTION $headsection $tailsection ; do - $SED -e "/^=sect=[^ ]* $SECTION/!d" \ - -e "s, .*,\"\\\\)|<!--sectX-->\\\\1|," \ - -e "s,^=sect=,s|^$SECTS\\\\(.*<a href=\"," ./$MK.$INFO >> $F.$HEAD - done - echo "s|^$SECTN[^ ]*\\(<a href=[^<>]*>\\).*|<!-- \\1 -->|" >> $F.$HEAD - echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|" >> $F.$HEAD - echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|" >> $F.$HEAD - test ".$sectiontab" != ".no" && \ - echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" >> $F.$HEAD - $CAT ./$MK.vars.tmp ./$MK.tags.tmp >> $F.$HEAD #tag and vars - echo "/<\\/body>/d" >> $F.$HEAD #cut lastline - echo "/<head>/r $MK.meta.tmp" >> $F.$HEAD #add metatags - ;; - *) # traditional.... the sitefile is the full navigation bar - $CAT ./$MK.puts.tmp > $F.$HEAD - echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|" >> $F.$HEAD - echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|" >> $F.$HEAD - test ".$sectiontab" != ".no" && \ - echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |" >> $F.$HEAD - $CAT ./$MK.vars.tmp ./$MK.tags.tmp >> $F.$HEAD #tag and vars - echo "/<\\/body>/d" >> $F.$HEAD #cut lastline - echo "/<head>/r $MK.meta.tmp" >> $F.$HEAD #add metatags - ;; esac - echo "/<title>/d" > $F.$BODY #not that line - $CAT ./$MK.vars.tmp ./$MK.tags.tmp >> $F.$BODY #tag and vars - bodymaker_for_sectioninfo >> $F.$BODY #if sectioninfo - info2body_append $F.$BODY #cut early - info2head_append $F.$HEAD - $CAT ./$F.~move~ >> $F.$HEAD + multi) head_sed_multisection "$F" "`info_get_entry_section`" >> "$F_HEAD" ;; + *) head_sed_listsection "$F" "`info_get_entry_section`" >> "$F_HEAD" ;; + esac + $CAT "$MK_VARS" "$MK_TAGS" >> "$F_HEAD" #tag and vars + echo "/<\\/body>/d" >> "$F_HEAD" #cut lastline + echo "/<head>/r $MK_META" >> "$F_HEAD" #add metatags + echo "/<title>/d" > "$F_BODY" #not that line + $CAT "$MK_VARS" "$MK_TAGS" >> "$F_BODY" #tag and vars + bodymaker_for_sectioninfo >> "$F_BODY" #if sectioninfo + info2body_sed >> "$F_BODY" #cut early + info2head_sed >> "$F_HEAD" + $CAT "$tmp/$F.$FAST" >> "$F_HEAD" test ".$emailfooter" != ".no" && \ - body_for_emailfooter > $F.$FOOT - $SED_LONGSCRIPT ./$F.$HEAD $SITEFILE > $F # ~head~ - $SED_LONGSCRIPT ./$F.$BODY $SOURCEFILE >> $F # ~body~ - test -f ./$F.$FOOT && $CAT ./$F.$FOOT >> $F # ~foot~ - $SED -e "/<\\/body>/!d" -f $MK.vars.tmp $SITEFILE >> $F #</body> + body_for_emailfooter > "$F_FOOT" + + mkpathfile "$F" + $SED_LONGSCRIPT "$F_HEAD" $SITEFILE > $F # ~head~ + $SED_LONGSCRIPT "$F_BODY" $SOURCEFILE >> $F # ~body~ + test -f "$F_FOOT" && $CAT "$F_FOOT" >> $F # ~foot~ + $SED -e "/<\\/body>/!d" -f "$MK_VARS" "$SITEFILE" >> $F #</body> echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` "->" `ls -s $F` -else + else # test -f $SOURDEFILE echo "'$SOURCEFILE': does not exist" -fi ; else + fi ; else echo "<$F> - skipped" -fi ;; -*/) echo "'$F' : directory - skipped" - ;; -*) echo "?? -> '$F'" - ;; -esac - # ....................................................................... -if test ".$printerfriendly" != "." ; then # PRINTER + fi +} + +make_printerfriendly () # "$F" +{ # PRINTER printsitefile="0" # FRIENDLY + P=`html_printerfile "$F"` + F_FAST="$tmp/$F.$FAST" + P_HEAD="$tmp/$P.$HEAD" + P_BODY="$tmp/$P.$BODY" case "$F" in - ${SITEFILE}|${SITEFILE}l) make_move "$F" - printsitefile="*>" ; BODY_TXT="./$F.$BODY" ; BODY_SED="./$P.$HEAD";; - *.html) printsitefile="=>" ; BODY_TXT="$SOURCEFILE"; BODY_SED="./$F.$BODY";; + ${SITEFILE}|${SITEFILE}l) make_fast "$F" > "$F_FAST" + printsitefile=">=>" ; BODY_TXT="$tmp/$F.$FOOT" ;; + *.html) printsitefile="=>" ; BODY_TXT="$SOURCEFILE" ;; esac + if grep '<meta name="formatter"' "$BODY_TXT" >/dev/null ; then return; fi if test ".$printsitefile" != ".0" && test -f "$SOURCEFILE" ; then - make_printerfile_move ./$MK.move.tmp - P=`html_printerfile "$F"` - $CAT ./$MK.vars.tmp ./$MK.tags.tmp ./$MK.move.tmp > ./$P.$HEAD + make_printerfile_fast "$FILELIST" > ./$MK_FAST + $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST" > "$P_HEAD" $SED -e "/DC.relation.isFormatOf/s|content=\"[^\"]*\"|content=\"$F\"|" \ - ./$MK.meta.tmp > ./$MK.mett.tmp - echo "/<head>/r $MK.mett.tmp" >> ./$P.$HEAD # meta - echo "/<\\/body>/d" >> ./$P.$HEAD - select_in_printsitefile "$F" >> ./$P.$HEAD + "$MK_META" > "$MK_METT" + echo "/<head>/r $MK_METT" >> "$P_HEAD" # meta + echo "/<\\/body>/d" >> "$P_HEAD" + select_in_printsitefile "$F" >> "$P_HEAD" _ext_=`print_extension "$printerfriendly"` # head- - $SED -e "s/[.]html\"|/$_ext_&/g" ./$F.~move~ >> ./$P.$HEAD # hrefs - line_=`sed_slash_key "$printsitefile_img_2"` # back- - echo "/$line_/s| href=\"[#][.]\"| href=\"$F\"|" >> ./$P.$HEAD # link. - $CAT ./$F.~move~ >> ./$P.$HEAD # subdir - $CAT ./$MK.vars.tmp ./$MK.tags.tmp ./$MK.move.tmp > ./$P.$BODY - $SED -e "s/[.]html\"|/$_ext_&/g" ./$F.~move~ >> ./$P.$BODY # body- - $CAT ./$F.~move~ >> ./$P.$BODY # hrefs -# $CAT $BODY_SED >> ./$P.$BODY # ORIG - $SED_LONGSCRIPT ./$P.$HEAD $PRINTSITEFILE > $P # ~head~ - $SED_LONGSCRIPT ./$P.$BODY $BODY_TXT >> $P # ~body~ - $SED -e "/<\\/body>/!d" -f $MK.vars.tmp $PRINTSITEFILE >> $P #</body> + $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST" >> "$P_HEAD" # hrefs + # line_=`sed_slash_key "$printsitefile_img_2"` # back- + echo "/||topics:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD" + echo "/|||pages:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD" + $CAT "$F_FAST" >> "$P_HEAD" # subdir + $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST" > "$P_BODY" + $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST" >> "$P_BODY" # body- + $CAT "$F_FAST" >> "$P_BODY" # hrefs + + mkpathfile "$P" + $SED_LONGSCRIPT "$P_HEAD" $PRINTSITEFILE > $P # ~head~ + $SED_LONGSCRIPT "$P_BODY" $BODY_TXT >> $P # ~body~ + $SED -e "/<\\/body>/!d" -f $MK_VARS $PRINTSITEFILE >> $P #</body> echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` "$printsitefile" `ls -s $P` fi +} + + +# ======================================================================== +# ======================================================================== +# ======================================================================== + +# ======================================================================== +# #### 0. INIT +make_sitemap_init +make_sitemap_list +make_sitemap_sect +make_sitemap_page + +FILELIST=`echo_site_filelist` +if test ".$opt_filelist" != "." || test ".$opt_list" = ".file"; then + for F in $FILELIST; do echo "$F" ; done ; exit # --filelist +fi +if test ".$opt_files" != "." ; then FILELIST="$opt_files" ; fi # --files +if test ".$FILELIST" = "."; then echo "nothing to do" >&2 ; fi +if test ".$FILELIST" = ".SITEFILE" ; then echo "only '$SITEFILE'?!" >&2 ; fi + +for F in $FILELIST ; do case "$F" in #### 1. PASS +name:*) scan_namespec "$F" ;; +http:*|*://*) scan_httpspec "$F" ;; +${SITEFILE}|${SITEFILE}l) scan_sitefile "$F" ;; # ........... SCAN SITE +../*) + echo "!! -> '$F' (skipping topdir build)" + ;; +# */*.html) +# make_fast > $F.$FAST # try for later subdir build +# echo "!! -> '$F' (skipping subdir build)" +# ;; +# */*/*/|*/*/|*/|*/index.htm|*/index.html) +# echo "!! -> '$F' (skipping subdir index.html)" +# ;; +*.html) scan_htmlfile "$F" ;; # ........... SCAN HTML +*/) echo "'$F' : directory - skipped" + site_map_list_title "$F" "`sed_slash_key $F`" + site_map_long_title "$F" "(directory)" + ;; +*) echo "?? -> '$F'" + ;; +esac done + +if test ".$printerfriendly" != "." ; then # .......... PRINT VERSION + _ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"` + PRINTSITEFILE=`echo "$SITEFILE" | sed -e "s/\\.[$AA]*\$/$_ext_&/"` + echo "NOTE: going to create printer-friendly sitefile $PRINTSITEFILE" + make_printsitefile > "$PRINTSITEFILE" +fi + +if test ".$simplevars" = ". " ; then +mknewfile $MK_OLDS fi + +for F in $FILELIST ; do case "$F" in #### 2. PASS +name:*) skip_namespec "$F" ;; +http:*|*://*) skip_httpspec "$F" ;; +${SITEFILE}|${SITEFILE}l) make_sitefile "$F" # ........ SITE FILE + if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;; +../*) + echo "!! -> '$F' (skipping topdir build)" + ;; +# */*.html) +# echo "!! -> '$F' (skipping subdir build)" +# ;; +# */*/*/|*/*/|*/|*/index.htm|*/index.html) +# echo "!! -> '$F' (skipping subdir index.html)" +# ;; +*.html) make_htmlfile "$F" # .................. HTML FILES + if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;; +*/) echo "'$F' : directory - skipped" + ;; +*) echo "?? -> '$F'" + ;; +esac # .............. debug .................... if test -d DEBUG && test -f "./$F" ; then - cp ./$F.$INFO DEBUG/$F.info.TMP + FFFF=`echo "$F" | sed -e s,/,:,g` + cp "$tmp/$F.$INFO" DEBUG/$FFFF.info.TMP for P in tags vars meta page date list html sect info ; do - test -f ./$MK.$P.tmp && cp ./$MK.$P.tmp DEBUG/$F.$P.tmp - test -f ./$MK.$P.TMP && cp ./$MK.$P.TMP DEBUG/$F.$P.TMP + test -f $tmp/$MK.$P.tmp && cp $tmp/$MK.$P.tmp DEBUG/$FFFF.$P.tmp + test -f $tmp/$MK.$P.TMP && cp $tmp/$MK.$P.TMP DEBUG/$FFFF.$P.TMP done fi done -if test ".$simplevars" = ".warn" ; then -oldvars=`cat ./$MK.olds.tmp | wc -l | $SED -e "s/ *//g"` + +if test ".$simplevars" = ".warn" ; then if test -f "$MK_OLDS" ; then +oldvars=`cat "$MK_OLDS" | wc -l | $SED -e "s/ *//g"` if test "$oldvars" = "0" ; then echo "HINT: you have no simplevars in your htm sources, so you may want to" echo "hint: set the magic <!--mksite:nosimplevars--> in your $SITEFILE" @@ -1384,7 +1782,8 @@ echo "hint: <!--mksite:simplevars--> somewhere to suppress this warning" echo "note: simplevars expansion will be an explicit option in the future." echo "note: errornous simplevar detection can be suppressed with a magic" echo "note: hint of <!--mksite:nosimplevars--> in the $SITEFILE for now." -fi fi +fi fi fi -rm ./$MK.*.tmp +rm $tmp/$MK.*.tmp +if test ".$tmp_dir_was_created" != ".no" ; then rm $tmp/* ; rmdir $tmp ; fi exit 0 diff --git a/zzip/Makefile.am b/zzip/Makefile.am index a0044e0..3533dba 100644 --- a/zzip/Makefile.am +++ b/zzip/Makefile.am @@ -43,8 +43,8 @@ libzzip_la_LDFLAGS= @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \ $(THREAD_SAFE) libzzip_la_LIBADD= -lz @RESOLVES@ -libzzipmmapped_la_SOURCES = mmapped.c fetch.c -libzzipmmapped_la_headers = mmapped.h fetch.h +libzzipmmapped_la_SOURCES = mmapped.c memdisk.c fetch.c +libzzipmmapped_la_headers = mmapped.h memdisk.h fetch.h libzzipmmapped_la_LDFLAGS= @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \ $(THREAD_SAFE) libzzipmmapped_la_LIBADD= -lz @RESOLVES@ @@ -134,3 +134,7 @@ __zziplib.pc : Makefile echo 'Requires: zzip-zlib-config' >>$@ echo 'Libs: -L$${libdir} -lzzip' >>$@ echo 'Cflags: $${largefile} -I$${includedir}' >>$@ + +# ---------------------------------------------------------------------- +.c.i : + $(COMPILE) -E $< >$@ diff --git a/zzip/Makefile.in b/zzip/Makefile.in index 4585524..11ac9ec 100644 --- a/zzip/Makefile.in +++ b/zzip/Makefile.in @@ -68,7 +68,7 @@ libzzipfseeko_la_DEPENDENCIES = am_libzzipfseeko_la_OBJECTS = fseeko.lo fetch.lo libzzipfseeko_la_OBJECTS = $(am_libzzipfseeko_la_OBJECTS) libzzipmmapped_la_DEPENDENCIES = -am_libzzipmmapped_la_OBJECTS = mmapped.lo fetch.lo +am_libzzipmmapped_la_OBJECTS = mmapped.lo memdisk.lo fetch.lo libzzipmmapped_la_OBJECTS = $(am_libzzipmmapped_la_OBJECTS) depcomp = $(SHELL) $(top_srcdir)/uses/depcomp am__depfiles_maybe = depfiles @@ -266,8 +266,8 @@ libzzip_la_LDFLAGS = @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \ $(THREAD_SAFE) libzzip_la_LIBADD = -lz @RESOLVES@ -libzzipmmapped_la_SOURCES = mmapped.c fetch.c -libzzipmmapped_la_headers = mmapped.h fetch.h +libzzipmmapped_la_SOURCES = mmapped.c memdisk.c fetch.c +libzzipmmapped_la_headers = mmapped.h memdisk.h fetch.h libzzipmmapped_la_LDFLAGS = @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \ $(THREAD_SAFE) @@ -290,7 +290,7 @@ pkgconfig_HEADERS = zzip-zlib-config.pc zziplib.pc \ all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .i .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -366,6 +366,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseeko.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memdisk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmapped.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Plo@am__quote@ @@ -681,6 +682,10 @@ __zziplib.pc : Makefile echo 'Requires: zzip-zlib-config' >>$@ echo 'Libs: -L$${libdir} -lzzip' >>$@ echo 'Cflags: $${largefile} -I$${includedir}' >>$@ + +# ---------------------------------------------------------------------- +.c.i : + $(COMPILE) -E $< >$@ # 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/zzip/conf.h b/zzip/conf.h index ccf0a3b..4825390 100644 --- a/zzip/conf.h +++ b/zzip/conf.h @@ -48,6 +48,14 @@ #endif #endif +#ifndef _zzip_off64_t +#ifdef ZZIP_off64_t +#define _zzip_off64_t ZZIP_off64_t +#else +#define _zzip_off64_t off64_t +#endif +#endif + /* currently unused, all current zziplib-users do have ansi-C94 compilers. */ #ifndef _zzip_const #ifdef ZZIP_const @@ -70,6 +78,12 @@ #define _zzip_restrict restrict #endif #endif +#ifdef __linux__ +#define _zzip_new _zzip_restrict +#else +#define _zzip_new +#endif + #ifndef _zzip_size_t #ifdef ZZIP_size_t #define _zzip_size_t ZZIP_size_t diff --git a/zzip/dir.c b/zzip/dir.c index 4f87b71..a84a130 100644 --- a/zzip/dir.c +++ b/zzip/dir.c @@ -179,6 +179,11 @@ zzip_seekdir(ZZIP_DIR* dir, zzip_off_t offset) #undef zzip_seekdir /* zzip_seekdir64 */ #undef zzip_telldir /* zzip_telldir64 */ +long zzip_telldir(ZZIP_DIR* dir); +void zzip_seekdir(ZZIP_DIR* dir, long offset); + +/* DLL compatibility layer - so that 32bit code can link with this lib too */ + long zzip_telldir(ZZIP_DIR* dir) { off_t off = zzip_telldir64 (dir); diff --git a/zzip/err.c b/zzip/err.c index 299c44e..2b6140b 100644 --- a/zzip/err.c +++ b/zzip/err.c @@ -22,19 +22,21 @@ static struct errlistentry { int code; const char* mesg; } errlist[] = { - { ZZIP_NO_ERROR, "No error" }, - { ZZIP_OUTOFMEM, "could not get temporary memory for internal structures" }, - { ZZIP_DIR_OPEN, "Failed to open zip-file %s" }, - { ZZIP_DIR_STAT, "Failed to fstat zip-file %s" }, - { ZZIP_DIR_SEEK, "Failed to lseek zip-file %s" }, - { ZZIP_DIR_READ, "Failed to read zip-file %s"}, + { ZZIP_NO_ERROR, "No error" }, + { ZZIP_OUTOFMEM, + "could not get temporary memory for internal structures" }, + { ZZIP_DIR_OPEN, "Failed to open zip-file %s" }, + { ZZIP_DIR_STAT, "Failed to fstat zip-file %s" }, + { ZZIP_DIR_SEEK, "Failed to lseek zip-file %s" }, + { ZZIP_DIR_READ, "Failed to read zip-file %s"}, { ZZIP_DIR_TOO_SHORT, "zip-file %s too short" }, { ZZIP_DIR_EDH_MISSING, "zip-file central directory not found" }, - { ZZIP_DIRSIZE, "Directory size too big..." }, - { ZZIP_ENOENT, "No such file found in zip-file %s" }, - { ZZIP_UNSUPP_COMPR, "Unsupported compression format" }, - { ZZIP_CORRUPTED, "Zipfile corrupted" }, - { ZZIP_UNDEF, "Some undefined error occurred" }, + { ZZIP_DIRSIZE, "Directory size too big..." }, + { ZZIP_ENOENT, "No such file found in zip-file %s" }, + { ZZIP_UNSUPP_COMPR, "Unsupported compression format" }, + { ZZIP_CORRUPTED, "Zipfile corrupted" }, + { ZZIP_UNDEF, "Some undefined error occurred" }, + { ZZIP_DIR_LARGEFILE, "Directory is largefile variant" }, { 0, 0 }, }; diff --git a/zzip/fetch.c b/zzip/fetch.c index 6cb745f..2bbc783 100644 --- a/zzip/fetch.c +++ b/zzip/fetch.c @@ -1,10 +1,14 @@ #include <zzip/fetch.h> -#if defined ZZIP_WORDS_BIGENDIAN && defined bswap_16 && defined bswap_32 +#if defined ZZIP_WORDS_BIGENDIAN && \ + defined bswap_16 && defined bswap_32 && defined bswap_64 # define __ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) # define __ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) # define __ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) # define __ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x))) +# define __ZZIP_GET64(__p) bswap_64(*(zzip_off64_t*)(__p)) +# define __ZZIP_SET64(__p,__x) \ + (*(zzip_off64_t*)(__p) = bswap_64((zzip_off64_t)(__x))) #endif /* ------------------------- fetch helpers --------------------------------- */ @@ -19,7 +23,7 @@ uint32_t __zzip_get32(unsigned char * s) return __ZZIP_GET32(s); #else return ((uint32_t)s[3] << 24) | ((uint32_t)s[2] << 16) - | ((uint32_t)s[1] << 8) | (uint32_t)s[0]; + | ((uint32_t)s[1] << 8) | ((uint32_t)s[0]); #endif } @@ -31,7 +35,30 @@ uint16_t __zzip_get16(unsigned char * s) #if defined __ZZIP_GET16 return __ZZIP_GET16(s); #else - return ((uint16_t)s[1] << 8) | (uint16_t)s[0]; + return ((uint16_t)s[1] << 8) | ((uint16_t)s[0]); +#endif +} + +/** => __zzip_get32 + * This function does the same for an off64_t value. + */ +zzip_off64_t __zzip_get64(unsigned char * s) +{ +#if __GNUC__+0 >= 3 + register zzip_off64_t v + = s[7]; v <<= 8; + v |= s[6]; v <<= 8; + v |= s[5]; v <<= 8; + v |= s[4]; v <<= 8; + v |= s[3]; v <<= 8; + v |= s[2]; v <<= 8; + v |= s[1]; v <<= 8; + v |= s[0]; return v; +#else + return ((zzip_off64_t)s[7] << 56) | ((zzip_off64_t)s[6] << 48) + | ((zzip_off64_t)s[5] << 40) | ((zzip_off64_t)s[4] << 32) + | ((zzip_off64_t)s[3] << 24) | ((zzip_off64_t)s[2] << 16) + | ((zzip_off64_t)s[1] << 8) | ((zzip_off64_t)s[0]); #endif } @@ -66,3 +93,25 @@ void __zzip_set16(unsigned char * s, uint16_t v) s[1] = (unsigned char) (v); #endif } + +/** => __zzip_get32 + * This function pushes a off64_t value at the specified address + */ +void __zzip_set64(unsigned char * s, zzip_off64_t v) +{ + s[0] = (unsigned char) (v); + v >>= 8; + s[1] = (unsigned char) (v); + v >>= 8; + s[2] = (unsigned char) (v); + v >>= 8; + s[3] = (unsigned char) (v); + v >>= 8; + s[4] = (unsigned char) (v); + v >>= 8; + s[5] = (unsigned char) (v); + v >>= 8; + s[6] = (unsigned char) (v); + v >>= 8; + s[7] = (unsigned char) (v); +} diff --git a/zzip/fetch.h b/zzip/fetch.h index f655166..7e2777c 100644 --- a/zzip/fetch.h +++ b/zzip/fetch.h @@ -15,23 +15,32 @@ extern uint16_t __zzip_get16(unsigned char * s) __attribute__((const)); extern void __zzip_set32(unsigned char * s, uint32_t v); extern void __zzip_set16(unsigned char * s, uint16_t v); +extern zzip_off64_t __zzip_get64(unsigned char * s) __attribute__((const)); +extern void __zzip_set64(unsigned char * s, zzip_off64_t v); + #ifdef ZZIP_WORDS_BIGENDIAN -# if defined bswap_16 && defined bswap_32 /* a.k.a. linux */ +# if defined bswap_16 && defined bswap_32 && defined bswap_64 /* i.e. linux */ # define ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) # define ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) +# define ZZIP_GET64(__p) bswap_64(*(uint64_t*)(__p)) # define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) # define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x))) +# define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = bswap_64((uint64_t)(__x))) # else +# define ZZIP_GET64(__p) (__zzip_get64((__p))) # define ZZIP_GET32(__p) (__zzip_get32((__p))) # define ZZIP_GET16(__p) (__zzip_get16((__p))) +# define ZZIP_SET64(__p,__x) (__zzip_set64((__p),(__x))) # define ZZIP_SET32(__p,__x) (__zzip_set32((__p),(__x))) # define ZZIP_SET16(__p,__x) (__zzip_set16((__p),(__x))) # endif #else /* little endian is the original zip format byteorder */ # define ZZIP_GET16(__p) (*(uint16_t*)(__p)) # define ZZIP_GET32(__p) (*(uint32_t*)(__p)) +# define ZZIP_GET64(__p) (*(uint64_t*)(__p)) # define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = (uint16_t)(__x)) # define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = (uint32_t)(__x)) +# define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = (uint64_t)(__x)) #endif /* ..................... bitcorrect physical access .................... */ @@ -126,6 +135,25 @@ extern void __zzip_set16(unsigned char * s, uint16_t v); #define zzip_extra_block_get_datasize(__p) ZZIP_GET16((char*)(__p)+2) #define zzip_extra_block_set_datasize(__p,__x) ZZIP_SET16((char*)(__p)+2,__x) +/* zzip64_disk_trailer - the zip64 archive entry point */ +#define zzip_disk64_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic) +#define zzip_disk64_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) +#define zzip_disk64_trailer_get_size(__p) ZZIP_GET64((__p)->z_size) +#define zzip_disk64_trailer_set_size(__p,__x) ZZIP_SET64((__p)->z_size,(__x)) +#define zzip_disk64_trailer_get_disk(__p) ZZIP_GET32((__p)->z_disk) +#define zzip_disk64_trailer_set_disk(__p,__x) ZZIP_SET32((__p)->z_disk,(__x)) +#define zzip_disk64_trailer_get_finaldisk(__p) ZZIP_GET32((__p)->z_finaldisk) +#define zzip_disk64_trailer_set_finaldisk(__p,__x) ZZIP_SET32((__p)->z_finaldisk,(__x)) +#define zzip_disk64_trailer_get_entries(__p) ZZIP_GET64((__p)->z_entries) +#define zzip_disk64_trailer_set_entries(__p,__x) ZZIP_SET64((__p)->z_entries,(__x)) +#define zzip_disk64_trailer_get_finalentries(__p) ZZIP_GET64((__p)->z_finalentries) +#define zzip_disk64_trailer_set_finalentries(__p,__x) ZZIP_SET64((__p)->z_finalentries,(__x)) +#define zzip_disk64_trailer_get_rootsize(__p) ZZIP_GET64((__p)->z_rootsize) +#define zzip_disk64_trailer_set_rootsize(__p,__x) ZZIP_SET64((__p)->z_rootsize,(__x)) +#define zzip_disk64_trailer_get_rootseek(__p) ZZIP_GET64((__p)->z_rootseek) +#define zzip_disk64_trailer_set_rootseek(__p,__x) ZZIP_SET64((__p)->z_rootseek,(__x)) +#define zzip_disk64_trailer_check_magic(__p) ZZIP_DISK64_TRAILER_CHECKMAGIC((__p)) + /* .............. some logical typed access wrappers ....................... */ /* zzip_file_header - the local file header */ @@ -227,9 +255,29 @@ extern void __zzip_set16(unsigned char * s, uint16_t v); #define zzip_disk_trailer_to_endoffile(__p) ((char*) \ (zzip_disk_trailer_to_comment(__p) + zzip_disk_trailer_comment(__p))) +/* zzip_disk64_trailer - the zip archive entry point */ +#define zzip_disk64_trailer_localdisk(__p) ((int) \ + zzip_disk64_trailer_get_disk(__p)) +#define zzip_disk64_trailer_finaldisk(__p) ((int) \ + zzip_disk64_trailer_get_finaldisk(__p)) +#define zzip_disk64_trailer_localentries(__p) ((int) \ + zzip_disk64_trailer_get_entries(__p)) +#define zzip_disk64_trailer_finalentries(__p) ((int) \ + zzip_disk64_trailer_get_finalentries(__p)) +#define zzip_disk64_trailer_rootsize(__p) ((zzip_off64_t) \ + zzip_disk64_trailer_get_rootsize(__p)) +#define zzip_disk64_trailer_rootseek(__p) ((zzip_off64_t) \ + zzip_disk64_trailer_get_rootseek(__p)) +#define zzip_disk64_trailer_sizeof_tail(__p) ((zzip_size_t) \ + zzip_disk64_trailer_get_size(__p) - zzip_disk64_trailer_headerlength) +#define zzip_disk64_trailer_sizeto_end(__p) ((zzip_size_t) \ + zzip_disk64_trailer_get_size(__p)) +#define zzip_disk64_trailer_skipto_end(__p) ((char*) \ + ((char*)(__p) + zzip_disk64_sizeto_end(__p))) + /* extra field should be type + size + data + type + size + data ... */ #define zzip_extra_block_sizeof_tail(__p) ((zzip_size_t) \ - (zzip_extra_block_get_datasize(__p)) + (zzip_extra_block_get_datasize(__p))) #define zzip_extra_block_sizeto_end(__p) ((zzip_size_t) \ (zzip_extra_block_sizeof_tail(__p) + zzip_extra_block_headerlength)) #define zzip_extra_block_skipto_end(__p) ((char*) (__p) \ diff --git a/zzip/file.c b/zzip/file.c index 2ca6883..86713af 100644 --- a/zzip/file.c +++ b/zzip/file.c @@ -762,6 +762,19 @@ zzip_open_shared_io (ZZIP_FILE* stream, #undef zzip_open_ext_io /* zzip_open_ext_io64 */ #undef zzip_opendir_ext_io /* zzip_opendir_ext_io64 */ +_zzip_export +ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream, + zzip_char_t* name, int o_flags, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); +_zzip_export +ZZIP_FILE * zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); +_zzip_export +ZZIP_DIR * zzip_opendir_ext_io(zzip_char_t* name, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); + +/* DLL compatibility layer - so that 32bit code can link with this lib too */ + _zzip_export ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream, zzip_char_t* name, int o_flags, int o_modes, diff --git a/zzip/format.h b/zzip/format.h index 03ead9b..83dbf2e 100644 --- a/zzip/format.h +++ b/zzip/format.h @@ -168,6 +168,26 @@ struct zzip_extra_block } __zzip_attribute__((packed)); #define zzip_extra_block_headerlength (2+2) +/* Zip64 end of central dir record */ +struct zzip_disk64_trailer +{ +# define ZZIP_DISK64_TRAILER_MAGIC 0x06064b50 +# define ZZIP_DISK64_TRAILER_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\6','\6') + char z_magic[4]; /* end of central dir signature (0x06054b50) */ + char z_size[8]; /* size of this central directory record */ + zzip_version_t z_encoder; /* version made by */ + zzip_version_t z_extract; /* version need to extract */ + char z_disk[4]; /* number of this disk */ + char z_finaldisk[4]; /* number of the disk with the start of the central dir */ + char z_entries[8]; /* total number of entries in the central dir on this disk */ + char z_finalentries[8]; /* total number of entries in the central dir */ + char z_rootsize[8]; /* size of the central directory */ + char z_rootseek[8]; /* offset of start of central directory with respect to * + * the starting disk number */ + /* followed by zip64 extensible data sector (of variable size) */ +} __zzip_attribute__((packed)); +#define zzip_disk64_trailer_headerlength (4+8+2+2+4+4+8+8+8+8) + /* z_flags */ #define ZZIP_IS_ENCRYPTED(p) ((*(unsigned char*)p)&1) #define ZZIP_IS_COMPRLEVEL(p) (((*(unsigned char*)p)>>1)&3) diff --git a/zzip/fseeko.c b/zzip/fseeko.c index 4c78afc..6b48af9 100644 --- a/zzip/fseeko.c +++ b/zzip/fseeko.c @@ -82,6 +82,10 @@ struct zzip_entry : public struct zzip_disk_entry FILE* diskfile; /* a file reference */ zzip_off_t disksize; /* the size of the file */ zzip_off_t headseek; /* the offset within the file */ + zzip_off_t zz_usize; + zzip_off_t zz_csize; /* items scanned from header */ + zzip_off_t zz_offset; /* or zip64 extension block */ + int zz_diskstart; }; #else struct zzip_entry /* : struct zzip_disk_entry */ @@ -92,6 +96,10 @@ struct zzip_entry /* : struct zzip_disk_entry */ FILE* diskfile; /* a file reference */ zzip_off_t disksize; /* the size of the file */ zzip_off_t headseek; /* the offset within the file */ + zzip_off_t zz_usize; + zzip_off_t zz_csize; /* items scanned from header */ + zzip_off_t zz_offset; /* or zip64 extension block */ + int zz_diskstart; }; #endif @@ -148,7 +156,7 @@ zzip_entry_data_offset(ZZIP_ENTRY* entry) * in the zip central directory but if not then we fallback to the filename * given in the file_header of each compressed data portion. */ -char* _zzip_restrict +char* _zzip_new zzip_entry_strdup_name(ZZIP_ENTRY* entry) { if (! entry) return 0; @@ -176,6 +184,29 @@ zzip_entry_strdup_name(ZZIP_ENTRY* entry) ____;____; } +static int +prescan_entry(ZZIP_ENTRY* entry) +{ + zzip_off_t tailsize = zzip_disk_entry_sizeof_tails (disk_(entry)); + if (tailsize+1 > entry->tailalloc) + { + char* newtail = realloc (entry->tail, tailsize+1); + if (! newtail) return ENOMEM; + entry->tail = newtail; + entry->tailalloc = tailsize+1; + } + fread (entry->tail, 1, tailsize, entry->diskfile); + /* name + comment + extras */ + return 0; +} + +static void +prescan_clear(ZZIP_ENTRY* entry) +{ + if (entry->tail) free (entry->tail); + entry->tail = 0; entry->tailalloc = 0; +} + /* ====================================================================== */ /** => zzip_entry_findfile @@ -205,7 +236,7 @@ zzip_entry_strdup_name(ZZIP_ENTRY* entry) * catch a common brokeness with zip archives that still allows us to find * the start of the zip central directory. */ -ZZIP_ENTRY* _zzip_restrict +ZZIP_ENTRY* _zzip_new zzip_entry_findfirst(FILE* disk) { if (! disk) return 0; @@ -231,18 +262,24 @@ zzip_entry_findfirst(FILE* disk) ___ char* p = buffer + mapsize - sizeof(struct zzip_disk_trailer); for (; p >= buffer ; p--) { - if (! zzip_disk_trailer_check_magic(p)) continue; - ___ zzip_off_t root = - zzip_disk_trailer_rootseek ((struct zzip_disk_trailer*)p); - if ((char*) root > p) - { /* the first disk_entry is after the disk_trailer? can't be! */ - zzip_off_t rootsize = - zzip_disk_trailer_rootsize ((struct zzip_disk_trailer*)p); - if (rootsize > mapoffs) continue; - /* a common brokeness that can be fixed: we just assume that - * the central directory was written directly before : */ - root = mapoffs - rootsize; - } + zzip_off_t root; /* (struct zzip_disk_entry*) */ + if (zzip_disk_trailer_check_magic(p)) { + root = zzip_disk_trailer_rootseek ( + (struct zzip_disk_trailer*)p); + if (root > disksize - (long) sizeof(struct zzip_disk_trailer)) + { /* first disk_entry is after the disk_trailer? can't be! */ + zzip_off_t rootsize = zzip_disk_trailer_rootsize ( + (struct zzip_disk_trailer*)p); + if (rootsize > mapoffs) continue; + /* a common brokeness that can be fixed: we just assume the + * central directory was written directly before : */ + root = mapoffs - rootsize; + } + } else if (zzip_disk64_trailer_check_magic(p)) { + if (sizeof(zzip_off_t) < 8) return 0; + root = zzip_disk64_trailer_rootseek ( + (struct zzip_disk64_trailer*)p); + } else continue; assert (0 <= root && root < mapsize); fseeko (disk, root, SEEK_SET); fread (disk_(entry), 1, sizeof(*disk_(entry)), disk); @@ -252,14 +289,9 @@ zzip_entry_findfirst(FILE* disk) entry->headseek = root; entry->diskfile = disk; entry->disksize = disksize; - ___ zzip_size_t tailsize = - zzip_disk_entry_sizeof_tails (disk_(entry)); - if (!( entry->tail = malloc (tailsize+1) )) goto nomem; - fread (entry->tail, 1, tailsize, disk); - entry->tailalloc = tailsize+1; - return entry; ____; + if (prescan_entry(entry)) goto nomem; + return entry; } - ____; } ____; if (! mapoffs) break; assert (mapsize >= pagesize/2); mapoffs -= pagesize/2; /* mapsize += pagesize/2; */ @@ -281,26 +313,20 @@ zzip_entry_findfirst(FILE* disk) * to stop searching for matches before that case then please call * => zzip_entry_free on the cursor struct ZZIP_ENTRY. */ -ZZIP_ENTRY* _zzip_restrict +ZZIP_ENTRY* _zzip_new zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry) { if (! entry) return entry; + if (! zzip_disk_entry_check_magic (entry)) goto err; ___ zzip_off_t seek = entry->headseek + zzip_disk_entry_sizeto_end (disk_(entry)); if (seek + (zzip_off_t) sizeof(*disk_(entry)) > entry->disksize) goto err; fseeko (entry->diskfile, seek, SEEK_SET); fread (disk_(entry), 1, sizeof(*disk_(entry)), entry->diskfile); entry->headseek = seek; - ___ zzip_off_t tailsize = zzip_disk_entry_sizeof_tails (disk_(entry)); - if (tailsize+1 > entry->tailalloc) - { - char* newtail = realloc (entry->tail, tailsize+1); - if (! newtail) goto err; - entry->tail = newtail; - entry->tailalloc = tailsize+1; - } - fread (entry->tail, 1, tailsize, entry->diskfile); - return entry; ____; + if (! zzip_disk_entry_check_magic (entry)) goto err; + if (prescan_entry(entry)) goto err; + return entry; err: zzip_entry_free (entry); return 0; ____; @@ -315,7 +341,7 @@ int zzip_entry_free(ZZIP_ENTRY* entry) { if (! entry) return 0; - free (entry->tail); + prescan_clear (entry); free (entry); return 1; } @@ -331,7 +357,7 @@ zzip_entry_free(ZZIP_ENTRY* entry) * is rather useless with this variant of _findfile). If no further entry is * found then null is returned and any "old"-entry gets already free()d. */ -ZZIP_ENTRY* _zzip_restrict +ZZIP_ENTRY* _zzip_new zzip_entry_findfile(FILE* disk, char* filename, ZZIP_ENTRY* _zzip_restrict entry, zzip_strcmp_fn_t compare) @@ -386,7 +412,7 @@ static int _zzip_fnmatch(char* pattern, char* string, int flags) * next entry matching the given filespec. If no further entry is * found then null is returned and any "old"-entry gets already free()d. */ -ZZIP_ENTRY* _zzip_restrict +ZZIP_ENTRY* _zzip_new zzip_entry_findmatch(FILE* disk, char* filespec, ZZIP_ENTRY* _zzip_restrict entry, zzip_fnmatch_fn_t compare, int flags) @@ -439,7 +465,7 @@ struct zzip_entry_file /* : zzip_file_header */ * the size of the internal readahead buffer. If an error occurs then null * is returned. */ -ZZIP_ENTRY_FILE* _zzip_restrict +ZZIP_ENTRY_FILE* _zzip_new zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover) { if (! entry) return 0; @@ -447,7 +473,7 @@ zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover) { ZZIP_ENTRY* found = malloc (sizeof(*entry)); if (! found) return 0; - memcpy (found, entry, sizeof(*entry)); + memcpy (found, entry, sizeof(*entry)); /* prescan_copy */ found->tail = malloc (found->tailalloc); if (! found->tail) { free (found); return 0; } memcpy (found->tail, entry->tail, entry->tailalloc); @@ -496,7 +522,7 @@ zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover) * the zip central directory with => zzip_entry_findfile and whatever * is found first is given to => zzip_entry_fopen */ -ZZIP_ENTRY_FILE* _zzip_restrict +ZZIP_ENTRY_FILE* _zzip_new zzip_entry_ffile (FILE* disk, char* filename) { ZZIP_ENTRY* entry = zzip_entry_findfile (disk, filename, 0, 0); diff --git a/zzip/fseeko.h b/zzip/fseeko.h index 0a6f58e..83c9e20 100644 --- a/zzip/fseeko.h +++ b/zzip/fseeko.h @@ -24,19 +24,17 @@ typedef struct zzip_entry_file ZZIP_ENTRY_FILE; typedef int (*zzip_strcmp_fn_t)(char*, char*); typedef int (*zzip_fnmatch_fn_t)(char*, char*, int); +#ifndef zzip_entry_extern #define zzip_entry_extern extern +#endif -zzip_off_t +zzip_entry_extern zzip_off_t zzip_entry_data_offset(ZZIP_ENTRY* entry); -char* _zzip_restrict -zzip_entry_strdup_name(ZZIP_ENTRY* entry); - - -zzip_entry_extern ZZIP_ENTRY* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY* _zzip_new zzip_entry_findfirst(FILE* file); -zzip_entry_extern ZZIP_ENTRY* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY* _zzip_new zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry); #define zzip_entry_findlast zzip_entry_free @@ -46,24 +44,24 @@ zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry); zzip_entry_extern int zzip_entry_free(ZZIP_ENTRY* entry); -char* _zzip_restrict +zzip_entry_extern char* _zzip_new zzip_entry_strdup_name(ZZIP_ENTRY* entry); -char* +zzip_entry_extern char* zzip_entry_to_data(ZZIP_ENTRY* entry); -zzip_entry_extern ZZIP_ENTRY* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY* _zzip_new zzip_entry_findfile(FILE* disk, char* filename, ZZIP_ENTRY* _zzip_restrict old, zzip_strcmp_fn_t compare); -zzip_entry_extern ZZIP_ENTRY* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY* _zzip_new zzip_entry_findmatch(FILE* disk, char* filespec, ZZIP_ENTRY* _zzip_restrict old, zzip_fnmatch_fn_t compare, int flags); -zzip_entry_extern ZZIP_ENTRY_FILE* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY_FILE* _zzip_new zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover); -zzip_entry_extern ZZIP_ENTRY_FILE* _zzip_restrict +zzip_entry_extern ZZIP_ENTRY_FILE* _zzip_new zzip_entry_ffile (FILE* disk, char* filename); zzip_entry_extern _zzip_size_t diff --git a/zzip/mmapped.c b/zzip/mmapped.c index 6a7f4f1..35679ac 100644 --- a/zzip/mmapped.c +++ b/zzip/mmapped.c @@ -22,6 +22,10 @@ * of the Mozilla Public License 1.1 */ +#ifdef __linux__ +#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_this_gnu_specific_ +#endif + #include <zzip/mmapped.h> #include <stdlib.h> #include <sys/stat.h> @@ -258,6 +262,27 @@ zzip_disk_entry_strdup_name(ZZIP_DISK* disk, struct zzip_disk_entry* entry) return _zzip_strndup (name, len); ____; } +/** => zzip_disk_entry_to_data + * This function is similar creating a reference to a zero terminated + * string but it can only exist in the zip central directory entry. + */ +char* _zzip_restrict +zzip_disk_entry_strdup_comment(ZZIP_DISK* disk, struct zzip_disk_entry* entry) +{ + if (! disk || ! entry) return 0; + + ___ char* text; zzip_size_t len; + if ((len = zzip_disk_entry_comment (entry))) + text = zzip_disk_entry_to_comment (entry); + else + return 0; + + if (disk->buffer > text || text+len > disk->endbuf) + return 0; + + return _zzip_strndup (text, len); ____; +} + /* ====================================================================== */ /** => zzip_disk_findfile @@ -295,22 +320,29 @@ zzip_disk_findfirst(ZZIP_DISK* disk) ___ char* p = disk->endbuf-sizeof(struct zzip_disk_trailer); for (; p >= disk->buffer ; p--) { - if (! zzip_disk_trailer_check_magic(p)) continue; - ___ char* root = /* (struct zzip_disk_entry*) */ disk->buffer + - zzip_disk_trailer_get_rootseek ((struct zzip_disk_trailer*)p); - if (root > p) - { /* the first disk_entry is after the disk_trailer? can't be! */ - zzip_size_t rootsize = - zzip_disk_trailer_get_rootsize ((struct zzip_disk_trailer*)p); - if (disk->buffer+rootsize > p) continue; - /* a common brokeness that can be fixed: we just assume that the - * central directory was written directly before the trailer: */ - root = p - rootsize; - } + char* root; /* (struct zzip_disk_entry*) */ + if (zzip_disk_trailer_check_magic(p)) { + root = disk->buffer + zzip_disk_trailer_get_rootseek ( + (struct zzip_disk_trailer*)p); + if (root > p) + { /* the first disk_entry is after the disk_trailer? can't be! */ + zzip_size_t rootsize = zzip_disk_trailer_get_rootsize ( + (struct zzip_disk_trailer*)p); + if (disk->buffer+rootsize > p) continue; + /* a common brokeness that can be fixed: we just assume the + * central directory was written directly before the trailer:*/ + root = p - rootsize; + } + } else if (zzip_disk64_trailer_check_magic(p)) { + if (sizeof(void*) < 8) return 0; /* EOVERFLOW */ + root = disk->buffer + zzip_disk64_trailer_get_rootseek ( + (struct zzip_disk64_trailer*)p); + if (root > p) continue; + } else continue; + if (root < disk->buffer) continue; if (zzip_disk_entry_check_magic(root)) return (struct zzip_disk_entry*) root; - ____; }____; return 0; } @@ -326,10 +358,12 @@ zzip_disk_findnext(ZZIP_DISK* disk, struct zzip_disk_entry* entry) { if ((char*)entry < disk->buffer || (char*)entry > disk->endbuf-sizeof(entry) || + ! zzip_disk_entry_check_magic (entry) || zzip_disk_entry_sizeto_end (entry) > 64*1024) return 0; entry = zzip_disk_entry_to_next_entry (entry); if ((char*)entry > disk->endbuf-sizeof(entry) || + ! zzip_disk_entry_check_magic (entry) || zzip_disk_entry_sizeto_end (entry) > 64*1024 || zzip_disk_entry_skipto_end (entry) + sizeof(entry) > disk->endbuf) return 0; diff --git a/zzip/mmapped.h b/zzip/mmapped.h index e9d543f..cd7c738 100644 --- a/zzip/mmapped.h +++ b/zzip/mmapped.h @@ -61,9 +61,6 @@ zzip_disk_extern int zzip_disk_close(ZZIP_DISK* disk); -zzip_disk_extern int -zzip_disk_init (ZZIP_DISK* disk, char* buffer, _zzip_size_t buflen); - zzip_disk_extern ZZIP_DISK_ENTRY* zzip_disk_findfirst(ZZIP_DISK* disk); @@ -72,6 +69,8 @@ zzip_disk_findnext(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); char* _zzip_restrict zzip_disk_entry_strdup_name(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); +char* _zzip_restrict +zzip_disk_entry_strdup_comment(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); struct zzip_file_header* zzip_disk_entry_to_file_header(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); char* diff --git a/zzip/types.h b/zzip/types.h index 18d12e8..dc92984 100644 --- a/zzip/types.h +++ b/zzip/types.h @@ -27,6 +27,7 @@ /* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */ +typedef _zzip_off64_t zzip_off64_t; typedef _zzip_off_t zzip_off_t; typedef _zzip_size_t zzip_size_t; typedef _zzip_ssize_t zzip_ssize_t; diff --git a/zzip/zip.c b/zzip/zip.c index 9053cc2..d6932ec 100644 --- a/zzip/zip.c +++ b/zzip/zip.c @@ -42,17 +42,45 @@ #define _255 255 #endif +#define ZZIP_DISK64_TRAILER + +#ifdef ZZIP_DISK64_TRAILER +struct _disk_trailer { + void* zz_tail; + zzip_off64_t zz_entries; + zzip_off64_t zz_finalentries; + zzip_off64_t zz_rootseek; + zzip_off64_t zz_rootsize; +}; +#define _disk_trailer_entries(__p) ((__p)->zz_entries) +#define _disk_trailer_localentries(__p) ((__p)->zz_entries) +#define _disk_trailer_finalentries(__p) ((__p)->zz_entries) +#define _disk_trailer_rootseek(__p) ((__p)->zz_rootseek) +#define _disk_trailer_rootsize(__p) ((__p)->zz_rootsize) +#define _disk_trailer_set_rootseek(__p,__v) ((__p)->rootseek = (__v)) + +#else +#define _disk_trailer zzip_disk_trailer +#define _disk_trailer_entries zzip_disk_trailer_entries +#define _disk_trailer_localentries zzip_disk_trailer_localentries +#define _disk_trailer_finalentries zzip_disk_trailer_finalentries +#define _disk_trailer_rootseek zzip_disk_trailer_rootseek +#define _disk_trailer_rootsize zzip_disk_trailer_rootsize +#define _disk_trailer_set_rootseek zzip_disk_trailer_set_rootseek +#define __zzip_fetch_disk_trailer __zzip_find_disk_trailer +#endif + /* --------------------------- internals -------------------------------- */ /* internal functions of zziplib, avoid at all cost, changes w/o warning. * we do export them for debugging purpose and special external tools * which know what they do and which can adapt from version to version */ -int __zzip_find_disk_trailer( int fd, zzip_off_t filesize, - struct zzip_disk_trailer * trailer, +int __zzip_fetch_disk_trailer( int fd, zzip_off_t filesize, + struct _disk_trailer * _zzip_restrict trailer, zzip_plugin_io_t io); int __zzip_parse_root_directory( int fd, - struct zzip_disk_trailer * trailer, + struct _disk_trailer * trailer, struct zzip_dir_hdr ** hdr_return, zzip_plugin_io_t io); @@ -68,16 +96,16 @@ _zzip_inline char* __zzip_aligned4(char* p); */ _zzip_inline static void __fixup_rootseek( zzip_off_t offset_of_trailer, - struct zzip_disk_trailer* trailer) + struct _disk_trailer* trailer) { - if ( zzip_disk_trailer_rootseek (trailer) > - offset_of_trailer - zzip_disk_trailer_rootsize (trailer) && - offset_of_trailer > zzip_disk_trailer_rootsize (trailer)) + if ( _disk_trailer_rootseek (trailer) > + offset_of_trailer - _disk_trailer_rootsize (trailer) && + offset_of_trailer > _disk_trailer_rootsize (trailer)) { register zzip_off_t offset; - offset = offset_of_trailer - zzip_disk_trailer_rootsize (trailer); - zzip_disk_trailer_set_rootseek (trailer, offset); - HINT2("new rootseek=%li", (long) zzip_disk_trailer_rootseek (trailer)); + offset = offset_of_trailer - _disk_trailer_rootsize (trailer); + _disk_trailer_set_rootseek (trailer, offset); + HINT2("new rootseek=%li", (long) _disk_trailer_rootseek (trailer)); } } #define __correct_rootseek(A,B,C) @@ -108,7 +136,7 @@ _zzip_inline static void __debug_dir_hdr (struct zzip_dir_hdr* hdr) * (as long as the following assertion holds...) */ - if (((unsigned)hdr)&3) + if (((zzip_off_t)hdr)&3) { NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); } /* we assume that if this machine's malloc has returned a non-aligned * memory block, then it is actually safe to access misaligned data, and @@ -139,9 +167,9 @@ _zzip_inline static void __debug_dir_hdr (struct zzip_dir_hdr* hdr) * bytes off the end of the file. */ int -__zzip_find_disk_trailer(int fd, zzip_off_t filesize, - struct zzip_disk_trailer * trailer, - zzip_plugin_io_t io) +__zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, + struct _disk_trailer * _zzip_restrict trailer, + zzip_plugin_io_t io) { #ifdef DEBUG #define return(val) { e=val; HINT2("%s", zzip_strerror(e)); goto cleanup; } @@ -241,9 +269,10 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, for (tail = end-1; (tail >= mapped); tail--) { if ((*tail == 'P') && /* quick pre-check for trailer magic */ - end-tail >= __sizeof(*trailer)-2 && - ZZIP_DISK_TRAILER_CHECKMAGIC(tail)) + end-tail >= __sizeof(struct zzip_disk_trailer)-2 && + zzip_disk_trailer_check_magic(tail)) { +# ifndef ZZIP_DISK64_TRAILER /* if the file-comment is not present, it happens that the z_comment field often isn't either */ if (end-tail >= __sizeof(*trailer)) @@ -254,9 +283,31 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, trailer->z_comment[0] = 0; trailer->z_comment[1] = 0; } +# else + struct zzip_disk_trailer* orig = (struct zzip_disk_trailer*) tail; + trailer->zz_tail = tail; + trailer->zz_entries = zzip_disk_trailer_localentries (orig); + trailer->zz_finalentries = zzip_disk_trailer_finalentries (orig); + trailer->zz_rootseek = zzip_disk_trailer_rootseek (orig); + trailer->zz_rootsize = zzip_disk_trailer_rootsize (orig); +# endif __fixup_rootseek (offset + tail-mapped, trailer); { return(0); } + } else if ((*tail == 'P') && + end-tail >= __sizeof(struct zzip_disk64_trailer)-2 && + zzip_disk64_trailer_check_magic(tail)) + { +# ifndef ZZIP_DISK64_TRAILER + return(ZZIP_DIR_LARGEFILE); +# else + struct zzip_disk64_trailer* orig = (struct zzip_disk64_trailer*) tail; + trailer->zz_tail = tail; + trailer->zz_entries = zzip_disk64_trailer_localentries (orig); + trailer->zz_finalentries = zzip_disk64_trailer_finalentries (orig); + trailer->zz_rootseek = zzip_disk64_trailer_rootseek (orig); + trailer->zz_rootsize = zzip_disk64_trailer_rootsize (orig); +# endif } } } @@ -305,7 +356,7 @@ _zzip_inline char* __zzip_aligned4(char* p) */ int __zzip_parse_root_directory(int fd, - struct zzip_disk_trailer * trailer, + struct _disk_trailer * trailer, struct zzip_dir_hdr ** hdr_return, zzip_plugin_io_t io) { @@ -313,54 +364,56 @@ __zzip_parse_root_directory(int fd, struct zzip_dir_hdr * hdr; struct zzip_dir_hdr * hdr0; uint16_t * p_reclen = 0; - short entries; - long offset; /* offset from start of root directory */ + unsigned long entries; /* 32bit is enough */ + zzip_off64_t zz_offset; /* offset from start of root directory */ char* fd_map = 0; - int32_t fd_gap = 0; - uint16_t u_entries = zzip_disk_trailer_get_entries (trailer); - uint32_t u_rootsize = zzip_disk_trailer_get_rootsize (trailer); - uint32_t u_rootseek = zzip_disk_trailer_get_rootseek (trailer); - __correct_rootseek (u_rootseek, u_rootsize, trailer); + zzip_off64_t zz_fd_gap = 0; + zzip_off64_t zz_entries = _disk_trailer_localentries (trailer); + zzip_off64_t zz_rootsize = _disk_trailer_rootsize (trailer); + zzip_off64_t zz_rootseek = _disk_trailer_rootseek (trailer); + __correct_rootseek (zz_rootseek, zz_rootsize, trailer); - hdr0 = (struct zzip_dir_hdr*) malloc(u_rootsize); + hdr0 = (struct zzip_dir_hdr*) malloc(zz_rootsize); if (!hdr0) return ZZIP_DIRSIZE; hdr = hdr0; __debug_dir_hdr (hdr); if (USE_MMAP && io->fd.sys) { - fd_gap = u_rootseek & (_zzip_getpagesize(io->fd.sys)-1) ; - HINT4(" mapseek=0x%x, maplen=%d, fd_gap=%d", - u_rootseek-fd_gap, u_rootsize+fd_gap, fd_gap); + zz_fd_gap = zz_rootseek & (_zzip_getpagesize(io->fd.sys)-1) ; + HINT4(" fd_gap=%ld, mapseek=0x%lx, maplen=%ld", (long)(zz_fd_gap), + (long)(zz_rootseek-zz_fd_gap), (long)(zz_rootsize+zz_fd_gap)); fd_map = _zzip_mmap(io->fd.sys, fd, - u_rootseek-fd_gap, u_rootsize+fd_gap); + zz_rootseek-zz_fd_gap, zz_rootsize+zz_fd_gap); /* if mmap failed we will fallback to seek/read mode */ if (fd_map == MAP_FAILED) { NOTE2("map failed: %s",strerror(errno)); fd_map=0; }else{ - HINT3("mapped *%p len=%i", fd_map, u_rootsize+fd_gap); + HINT3("mapped *%p len=%li", fd_map, (long)(zz_rootsize+zz_fd_gap)); } } - for (entries=u_entries, offset=0; entries > 0; entries--) + for (entries=zz_entries, zz_offset=0; entries; entries--) { register struct zzip_disk_entry * d; uint16_t u_extras, u_comment, u_namlen; if (fd_map) - { d = (void*)(fd_map+fd_gap+offset); } /* fd_map+fd_gap==u_rootseek */ + { d = (void*)(fd_map+zz_fd_gap+zz_offset); } /* fd_map+fd_gap==u_rootseek */ else { - if (io->fd.seeks(fd, u_rootseek+offset, SEEK_SET) < 0) + if (io->fd.seeks(fd, zz_rootseek+zz_offset, SEEK_SET) < 0) return ZZIP_DIR_SEEK; if (io->fd.read(fd, &dirent, sizeof(dirent)) < __sizeof(dirent)) return ZZIP_DIR_READ; d = &dirent; } - if (offset+sizeof(*d) > u_rootsize) - { FAIL2("%i's entry stretches beyond root directory", entries); break;} + if ((zzip_off64_t)(zz_offset+sizeof(*d)) > zz_rootsize || + (zzip_off64_t)(zz_offset+sizeof(*d)) < 0) + { FAIL4("%li's entry stretches beyond root directory (O:%li R:%li)", + (long)entries, (long)(zz_offset), (long)zz_rootsize); break;} # if 0 && defined DEBUG zzip_debug_xbuf ((unsigned char*) d, sizeof(*d) + 8); @@ -370,7 +423,7 @@ __zzip_parse_root_directory(int fd, u_comment = zzip_disk_entry_get_comment (d); u_namlen = zzip_disk_entry_get_namlen (d); HINT5("offset=0x%lx, size %ld, dirent *%p, hdr %p\n", - offset+u_rootseek, (long)u_rootsize, d, hdr); + (long)(zz_offset+zz_rootseek), (long)zz_rootsize, d, hdr); /* writes over the read buffer, Since the structure where data is copied is smaller than the data in buffer this can be done. @@ -386,23 +439,26 @@ __zzip_parse_root_directory(int fd, hdr->d_compr = zzip_disk_entry_get_compr (d); if (hdr->d_compr > _255) hdr->d_compr = 255; - if (offset+sizeof(*d) + u_namlen > u_rootsize) - { FAIL2("%i's name stretches beyond root directory", entries); break;} + if ((zzip_off64_t)(zz_offset+sizeof(*d) + u_namlen) > zz_rootsize || + (zzip_off64_t)(zz_offset+sizeof(*d) + u_namlen) < 0) + { FAIL4("%li's name stretches beyond root directory (O:%li N:%li)", + (long)entries, (long)(zz_offset), (long)(u_namlen)); break; } if (fd_map) - { memcpy(hdr->d_name, fd_map+fd_gap + offset+sizeof(*d), u_namlen); } + { memcpy(hdr->d_name, fd_map+zz_fd_gap + zz_offset+sizeof(*d), u_namlen); } else { io->fd.read(fd, hdr->d_name, u_namlen); } hdr->d_name[u_namlen] = '\0'; hdr->d_namlen = u_namlen; /* update offset by the total length of this entry -> next entry */ - offset += sizeof(*d) + u_namlen + u_extras + u_comment; + zz_offset += sizeof(*d) + u_namlen + u_extras + u_comment; - if (offset > (long)u_rootsize) - { FAIL2("%i's end beyond root directory", entries); entries--; break;} + if (zz_offset > zz_rootsize) + { FAIL3("%li's entry stretches beyond root directory (O:%li)", + (long)entries, (long)(zz_offset)); entries--; break; } - HINT5("file %d { compr=%d crc32=$%x offset=%d", - entries, hdr->d_compr, hdr->d_crc32, hdr->d_off); + HINT5("file %ld { compr=%d crc32=$%x offset=%d", + (long)entries, hdr->d_compr, hdr->d_crc32, hdr->d_off); HINT5("csize=%d usize=%d namlen=%d extras=%d", hdr->d_csize, hdr->d_usize, u_namlen, u_extras); HINT5("comment=%d name='%s' %s <sizeof %d> } ", @@ -419,8 +475,8 @@ __zzip_parse_root_directory(int fd, if (USE_MMAP && fd_map) { - HINT3("unmap *%p len=%i", fd_map, u_rootsize+fd_gap); - _zzip_munmap(io->fd.sys, fd_map, u_rootsize+fd_gap); + HINT3("unmap *%p len=%li", fd_map, (long)(zz_rootsize+zz_fd_gap)); + _zzip_munmap(io->fd.sys, fd_map, zz_rootsize+zz_fd_gap); } if (p_reclen) @@ -575,7 +631,7 @@ __zzip_dir_parse (ZZIP_DIR* dir) { zzip_error_t rv; zzip_off_t filesize; - struct zzip_disk_trailer trailer; + struct _disk_trailer trailer; /* if (! dir || dir->fd < 0) * { rv = EINVAL; goto error; } */ @@ -585,15 +641,15 @@ __zzip_dir_parse (ZZIP_DIR* dir) { rv = ZZIP_DIR_STAT; goto error; } HINT2("------------------ filesize=%ld", (long) filesize); - if ((rv = __zzip_find_disk_trailer(dir->fd, filesize, &trailer, + if ((rv = __zzip_fetch_disk_trailer(dir->fd, filesize, &trailer, dir->io)) != 0) { goto error; } HINT5("directory = { entries= %ld/%ld, size= %ld, seek= %ld } ", - (long) zzip_disk_trailer_localentries (&trailer), - (long) zzip_disk_trailer_finalentries (&trailer), - (long) zzip_disk_trailer_rootsize (&trailer), - (long) zzip_disk_trailer_rootseek (&trailer)); + (long) _disk_trailer_localentries (&trailer), + (long) _disk_trailer_finalentries (&trailer), + (long) _disk_trailer_rootsize (&trailer), + (long) _disk_trailer_rootseek (&trailer)); if ( (rv = __zzip_parse_root_directory(dir->fd, &trailer, &dir->hdr0, dir->io)) != 0) diff --git a/zzip/zzip.h b/zzip/zzip.h index e69f03a..eecc473 100644 --- a/zzip/zzip.h +++ b/zzip/zzip.h @@ -31,18 +31,19 @@ extern "C" { typedef enum { ZZIP_NO_ERROR = 0, /* no error, may be used if user sets it. */ - ZZIP_OUTOFMEM = ZZIP_ERROR-20, /* out of memory */ + ZZIP_OUTOFMEM = ZZIP_ERROR-20, /* out of memory */ ZZIP_DIR_OPEN = ZZIP_ERROR-21, /* failed to open zipfile, see errno for details */ ZZIP_DIR_STAT = ZZIP_ERROR-22, /* failed to fstat zipfile, see errno for details */ ZZIP_DIR_SEEK = ZZIP_ERROR-23, /* failed to lseek zipfile, see errno for details */ ZZIP_DIR_READ = ZZIP_ERROR-24, /* failed to read zipfile, see errno for details */ ZZIP_DIR_TOO_SHORT = ZZIP_ERROR-25, ZZIP_DIR_EDH_MISSING = ZZIP_ERROR-26, - ZZIP_DIRSIZE = ZZIP_ERROR-27, - ZZIP_ENOENT = ZZIP_ERROR-28, - ZZIP_UNSUPP_COMPR = ZZIP_ERROR-29, - ZZIP_CORRUPTED = ZZIP_ERROR-31, - ZZIP_UNDEF = ZZIP_ERROR-32 + ZZIP_DIRSIZE = ZZIP_ERROR-27, + ZZIP_ENOENT = ZZIP_ERROR-28, + ZZIP_UNSUPP_COMPR = ZZIP_ERROR-29, + ZZIP_CORRUPTED = ZZIP_ERROR-31, + ZZIP_UNDEF = ZZIP_ERROR-32, + ZZIP_DIR_LARGEFILE = ZZIP_ERROR-33 } zzip_error_t; /* diff --git a/zziplib.spec b/zziplib.spec index 66b8691..9d9e841 100644 --- a/zziplib.spec +++ b/zziplib.spec @@ -1,7 +1,7 @@ %define lib lib010 Summary: ZZipLib - libZ-based ZIP-access Library Name: zziplib -Version: 0.13.38 +Version: 0.13.43 Release: 1.suse92 Serial: 1 Copyright: LGPL