untgz plugin for NSIS v2
untgz - unzip like replacement plugin, except for gzipped tarballs
KJD <jeremyd@computer.org>

  This software based on NSIS exDLL (example plugin) and zlib library.
  I personally add no additional copyright, so the license is
  the same as the NSIS example DLL and ZLIB license [combined].
  2002-2003

  To build, simply extract in the NSIS2 Contrib\ directory (along
  side the exDLL directory).  The zlib files are slightly modified
  and included in the zlib subdirectory of this untgz archive.
  Then either run the makefile or open the project file.
  The Release build will place untgz.dll in the ../../Plugins directory.

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

---
 * Please note: all material here other than those by KJD
 * have been taken from the respective author/copyright holder's
 * work, do not contact them regarding these [my] changes.
 * Corrections/additions/ or information to obtain original
 * versions, please contact me: jeremyd@computer.org
---

/*
 * This plugin largely based on untgz sample included with zlib:
 *
 * untgz.c -- Display contents and/or extract file from
 * a gzip'd TAR file
 * written by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
 * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
 */

--- Large Portions from ZLIB general purpose compression library ---
    version 1.1.4, March 11th, 2002
    Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  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.

--- Portions from NSIS, especially ExDLL (Example NSIS Plugin) ---
    Copyright (C) 1999-2002 Nullsoft, Inc.

  This software is provided 'as-is', without any express or implied
  warranty. In no event will the authors be held liable for any damages
  arising from the use of this software. 

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.

  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.

--- Portions from ExtractDLL v0.1 beta ---
    Copyright 2002 
    by Tim Kosse
    tim.kosse@gmx.de

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  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.

/****************************************************************************/

USAGE:
  untgz::extract [-j] [-d basedir] tarball.tgz
    extracts files from tarball.tgz
	if -j is specified then ignore paths in tarball (junkpaths)
	if -d is specified will extract relative to basedir
  untgz::extractV [-j] [-d basedir] tarball.tgz [-i {iList}] [-x {xList}] --
    extracts files from tarball.tgz
	if -j is specified then ignore paths in tarball (junkpaths)
	if -d is specified will extract relative to basedir
	if -i is specified will only extract files whose filename matches
	if -x is specified will NOT extract files whose filename matches
	the -- is required and marks the end of the file lists
  untgz::extractFile [-d basedir] tarball.tgz file
    extracts just the file specified
	path information is ignored, implictly -j is specified (may also be explicit)

TODO:
- without -j there is a security issue as no checking is done to directories
- change to better support -d option, presently we just chdir there

NOTES:
- presently tested with NSIS v2
- does not require a c runtime library (important if say you compile with MS VC 7 and don't
  want to require its runtime present during install [or Windows 95 and compiled with MS VC 5 or 6])
- Note the included zlib is slightly modified so as to use Win32 API and not c runtime library
  see below for exact patches, requires included miniclib.{h,c}

HISTORY:
- 20030101  KJD  1.0.0
  initial release (used for AbiWord v2 as a replacement for spawning unzip.exe)
- 20030103  KJD  1.0.1
  modified to not require c runtime library and added version resource
  (note still links with crt for some oddball VC functions stkchk, chkesp, & allmul)
- 20030109  KJD  1.0.2
  implemented extract (include) and don't extract (exclude) list parsing
  cleaned up compile some (no longer needs to link with MSVCRT for some static functions
  added MS VC 6 project file (makefile generated from this)
  moved extraction from tar.gz code (mostly untgz.c from zlib anyway) into separate file from plugin
- 20030115  KJD  1.0.3
  fixed stack bug, rearranged options so doesn't read past called options
  placed utility functions into separate file (so easier for others to reuse if wanted)
  added example/test files
- 20030920  KJD  1.0.4
  correct Makefile.abi, adjust source so doesn't use intrinsic memcpy/memset functions
  even when /Oi (enable intrinsics) is given (e.g. via /O2)
- 20040408  KJD  1.0.5
  patch by Tavella Gaston to correctly return an error 'status' when we fail
  to extract from the tarball
  updated example.nsi to demonstrate errors and added truncated examplecorrupt.tgz


KJD
20040408


Patches applied to zlib:
--- zutil.h.orig	Tue Mar 12 06:25:06 2002
+++ zutil.h	Sat Jan  4 05:00:56 2003
@@ -15,6 +15,10 @@
 
 #include "zlib.h"
 
+#if 1
+#include "miniclib.h"
+#else
+
 #ifdef STDC
 #  include <stddef.h>
 #  include <string.h>
@@ -26,6 +30,8 @@
 #   include <errno.h>
 #endif
 
+#endif /* 1 */
+
 #ifndef local
 #  define local static
 #endif

--- gzio.c.orig	Wed Jan  1 23:37:38 2003
+++ gzio.c	Sat Jan  4 06:14:20 2003
@@ -7,7 +7,9 @@
 
 /* @(#) $Id: README.TXT,v 1.1.2.6 2004/04/08 12:41:04 jeremyd Exp $ */
 
+#if 0
 #include <stdio.h>
+#endif
 
 #include "zutil.h"
 

