delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2001/11/11/02:13:15

Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-apps-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/lists.html#faqs>
Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com
Message-ID: <019d01c16a7f$ab3ee060$0200a8c0@lifelesswks>
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
To: <cygwin-patches AT cygwin DOT com>
Cc: <cygwin-apps AT sources DOT redhat DOT com>
Subject: setup streams work..
Date: Sun, 11 Nov 2001 18:08:29 +1100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-OriginalArrivalTime: 11 Nov 2001 07:14:24.0702 (UTC) FILETIME=[7E1925E0:01C16A80]

This is a multi-part message in MIME format.

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Cross-posted for review...

Ok, I've now got file magic fairly complete.

The NIO and bz classes still need refactoring and expanding.

There's a still a chunk of code to be migrated over to the io_streams
class.

Is there any objection to this being checked into HEAD (with a little
more tidyup, but I won't bother having that reviewed :})?

Overview of changes:
* File magic detection for bz2, gz and tar file types. (I.e. you can
install from a local .tar file, as well as a local .tar.gz - once one
line in choose.cc is changed).
* io_stream hierarchy based on the classes Warren came up with, with my
single uniting class at the top.
* tar logic is stream based, not fd based, so can install directly from
http/ftp(once nio is refactored).
* Compiler warnings pushed up and all warnings bar autoload.c and the
bison system files addressed.

The file magic code here is federated across each - to overload an MS
term - class class. I.e. archive.cc knows about all archive types,
compress.cc knows all compression formats.

There's plenty more in this project I'm working on, but with the
successful install of lynx.tar.gz via a setup with this code in it, I
feel that the class hierarchy is shown to meet our needs. It's probably
able to be tweaked - for instance some instantion helper calls for the
io_stream class perhaps belong in a lower level between io_stream and
io_stream_ file|cygfile|http|ftp...

So given that the class layout works, and somethings are already
becoming easier to do, I plan to commit this to HEAD.

Any objections?

Rob

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="streams.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="streams.patch"

Index: Makefile.in=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/Makefile.in,v=0A=
retrieving revision 2.24=0A=
diff -u -p -r2.24 Makefile.in=0A=
--- Makefile.in	2001/11/02 04:03:55	2.24=0A=
+++ Makefile.in	2001/11/11 06:54:53=0A=
@@ -35,7 +35,9 @@ CC		:=3D @CC@=0A=
 CC_FOR_TARGET	:=3D $(CC)=0A=
 CXX		:=3D @CXX@=0A=
 =0A=
-CFLAGS		:=3D @CFLAGS@=0A=
+CFLAGS		:=3D @CFLAGS@ -Werror -Winline -Wall -Wpointer-arith =
-Wcast-align\=0A=
+	-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \=0A=
+	-Wmissing-declarations -Wcomments=0A=
 CXXFLAGS	:=3D @CXXFLAGS@ $(CFLAGS) -fno-exceptions -fno-rtti=0A=
 CXX		:=3D @CXX@=0A=
 =0A=
@@ -48,6 +50,11 @@ MINGW_INCLUDES	:=3D -I. -I$(srcdir) -I$(mi=0A=
 =0A=
 MINGW_CXXFLAGS	:=3D -MMD $(CXXFLAGS) -mno-cygwin $(MINGW_INCLUDES) =
-mwindows=0A=
 MINGW_CFLAGS	:=3D -MMD $(CFLAGS) -mno-cygwin $(MINGW_INCLUDES) -mwindows=0A=
+# to avoid false errors that assembly generates=0A=
+WARNONLY_CFLAGS :=3D -MMD @CFLAGS@ -Winline -Wall -Wpointer-arith =
-Wcast-align \=0A=
+	-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \=0A=
+	-Wmissing-declarations -Wcomments \=0A=
+	 -mno-cygwin $(MINGW_INCLUDES) -mwindows=0A=
 =0A=
 ZLIB		:=3D zlib/libzcygw.a=0A=
 BZ2LIB		:=3D $(bupdir)/bz2lib/libbz2.a=0A=
@@ -73,8 +80,13 @@ ALL_LDFLAGS	:=3D ${filter-out -I%, \=0A=
 PROGS	:=3D setup$(EXEEXT)=0A=
 =0A=
 OBJS =3D \=0A=
+	archive.o \=0A=
+	archive_tar_file.o \=0A=
 	autoload.o \=0A=
 	choose.o \=0A=
+	compress.o \=0A=
+	compress_bz.o \=0A=
+	compress_gz.o \=0A=
 	concat.o \=0A=
 	desktop.o \=0A=
 	dialog.o \=0A=
@@ -88,6 +100,9 @@ OBJS =3D \=0A=
 	inilex.o \=0A=
 	iniparse.o \=0A=
 	install.o \=0A=
+	io_stream.o \=0A=
+	io_stream_cygfile.o \=0A=
+	io_stream_file.o \=0A=
 	localdir.o \=0A=
 	log.o \=0A=
 	main.o \=0A=
@@ -166,8 +181,7 @@ version.c : $(srcdir)/ChangeLog Makefile=0A=
 	V=3D`grep '^\$$Revision.*' $(srcdir)/ChangeLog \=0A=
 	| sed -e 's/\$$Revision:* *//' \=0A=
 	  -e 's/ *$$.*//'` ;\=0A=
-	echo "char *version =3D \"$$V\";" > version.tmp ;\=0A=
-	echo "static char *id =3D \"\\n%%% setup-version $$V\\n\";" >> =
version.tmp=0A=
+	echo "const char *version =3D \"$$V\";" > version.tmp ;\=0A=
 	mv version.tmp version.c=0A=
 =0A=
 %.o: %.rc=0A=
@@ -196,11 +210,29 @@ endif=0A=
 =0A=
 autoload.o: autoload.c=0A=
 ifdef VERBOSE=0A=
-	$(CC) $(MINGW_CFLAGS) -c -o $@ $< -fno-inline-functions=0A=
+	$(CC) $(WARNONLY_CFLAGS) -c -o $@ $< -fno-inline-functions=0A=
 else=0A=
-	@echo $(CC) -c $(CFLAGS) ... $(<F) -fno-inline-functions=0A=
-	@$(CC) $(MINGW_CFLAGS) -c -o $@ $< -fno-inline-functions=0A=
+	@echo $(CC) -c $(WARNONLY_CFLAGS) ... $(<F) -fno-inline-functions=0A=
+	@$(CC) $(WARNONLY_CFLAGS) -c -o $@ $< -fno-inline-functions=0A=
 endif=0A=
+=0A=
+inilex.o: inilex.c=0A=
+ifdef VERBOSE=0A=
+	$(CC) $(WARNONLY_CFLAGS) -c -o $@ $<=0A=
+else=0A=
+	@echo $(CC) -c $(WARNONLY_CFLAGS) ... $(<F)=0A=
+	@$(CC) $(WARNONLY_CFLAGS) -c -o $@ $< =0A=
+endif=0A=
+=0A=
+iniparse.o: iniparse.cc=0A=
+ifdef VERBOSE=0A=
+	$(CXX) @CXXFLAGS@ $(WARNONLY_CFLAGS) -fno-exceptions -fno-rtti -c -o =
$@ $< =0A=
+else=0A=
+	@echo $(CXX) -c @CXXFLAGS@ $(WARNONLY_CFLAGS) ... $(<F) =
-fno-exceptions -fno-rtti=0A=
+	@$(CXX) @CXXFLAGS@ $(WARNONLY_CFLAGS) -c -o $@ $< -fno-exceptions =
-fno-rtti=0A=
+endif=0A=
+=0A=
+=0A=
 =0A=
 iniparse.cc iniparse.h : iniparse.y=0A=
 	bison -d -o iniparse.cc $(srcdir)/iniparse.y=0A=
Index: autoload.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/autoload.c,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 autoload.c=0A=
--- autoload.c	2001/08/07 08:00:58	2.2=0A=
+++ autoload.c	2001/11/11 06:54:53=0A=
@@ -12,8 +12,9 @@=0A=
  * Written by DJ Delorie <dj AT cygnus DOT com>=0A=
  *=0A=
  */=0A=
-=0A=
-static char *cvsid =3D "\n%%% $Id: autoload.c,v 2.2 2001/08/07 08:00:58 =
corinna Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D "\n%%% $Id: autoload.c,v 2.2 2001/08/07 =
08:00:58 corinna Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
Index: choose.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/choose.cc,v=0A=
retrieving revision 2.65=0A=
diff -u -p -r2.65 choose.cc=0A=
--- choose.cc	2001/11/09 23:37:22	2.65=0A=
+++ choose.cc	2001/11/11 06:54:55=0A=
@@ -27,7 +27,7 @@=0A=
 =0A=
 #if 0=0A=
 static const char *cvsid =3D=0A=
-  "\n%%% $Id: choose.cc,v 2.65 2001/11/09 23:37:22 rbcollins Exp $\n";=0A=
+  "\n%%% $Id: choose.cc,v 2.63 2001/11/09 14:12:00 rbcollins Exp $\n";=0A=
 #endif=0A=
 =0A=
 #include "win32.h"=0A=
@@ -45,7 +45,7 @@ static const char *cvsid =3D=0A=
 #include "log.h"=0A=
 #include "find.h"=0A=
 #include "filemanip.h"=0A=
-#include "mount.h"=0A=
+#include "io_stream.h"=0A=
 #include "choose.h"=0A=
 =0A=
 #include "port.h"=0A=
@@ -140,10 +140,9 @@ set_action (Package * pkg, bool preinc)=0A=
 	    return;=0A=
 	  }=0A=
 	/* the passed in trust level is missing... */=0A=
-	if (!preinc /* auto set */=0A=
-	    && pkg->installed =0A=
-	    && pkg->action > ACTION_CURR) /* There is no current version */=0A=
-	    (int)pkg->action =3D ACTION_SAME_CURR;=0A=
+	if (!preinc		/* auto set */=0A=
+	    && pkg->installed && pkg->action > ACTION_CURR)	/* There is no =
current version */=0A=
+	  (int) pkg->action =3D ACTION_SAME_CURR;=0A=
 	break;=0A=
 	/* ACTION_SAME_* are used when the installed version is the same=0A=
 	   as the given action. */=0A=
@@ -963,8 +962,8 @@ _view::insert_under (int linen, pick_lin=0A=
     {=0A=
       if (lines[n].get_category () || (lines[n].get_pkg ()=0A=
 				       && strcasecmp (line.get_pkg ()->name,=0A=
-						      lines[n].get_pkg ()->=0A=
-						      name) < 0))=0A=
+						      lines[n].=0A=
+						      get_pkg ()->name) < 0))=0A=
 	{=0A=
 	  insert_at (n, line);=0A=
 	  n =3D nlines;=0A=
@@ -1032,9 +1031,10 @@ _view::click (int row, int x)=0A=
 		{=0A=
 		  if (lines[n].get_category () || (lines[n].get_pkg ()=0A=
 						   && strcasecmp (pkg->name,=0A=
-								  lines[n].=0A=
-								  get_pkg ()->=0A=
-								  name) < 0))=0A=
+								  lines=0A=
+								  [n].get_pkg=0A=
+								  ()->name) <=0A=
+						   0))=0A=
 		    {=0A=
 		      insert_at (n, line);=0A=
 		      n =3D nlines;=0A=
@@ -1158,7 +1158,8 @@ create_listview (HWND dlg, RECT * r)=0A=
   default_trust (lv, TRUST_CURR);=0A=
   set_view_mode (lv, VIEW_CATEGORY);=0A=
   if (!SetDlgItemText (dlg, IDC_CHOOSE_VIEWCAPTION, =
chooser->mode_caption ()))=0A=
-    log (LOG_BABBLE, "Failed to set View button caption %ld", =
GetLastError ());=0A=
+    log (LOG_BABBLE, "Failed to set View button caption %ld",=0A=
+	 GetLastError ());=0A=
   for (Package * foo =3D package; foo->name; foo++)=0A=
     add_required (foo);=0A=
   static int ta[] =3D { IDC_CHOOSE_CURR, 0 };=0A=
@@ -1520,17 +1521,16 @@ _Info::_Info (const char *_install, cons=0A=
 static void=0A=
 read_installed_db ()=0A=
 {=0A=
-  if (!get_root_dir ())=0A=
-    return;=0A=
-=0A=
   char line[1000], pkgname[1000], inst[1000], src[1000];=0A=
   int instsz, srcsz;=0A=
 =0A=
-  FILE *db =3D fopen (cygpath ("/etc/setup/installed.db", 0), "rt");=0A=
+  io_stream *db =3D=0A=
+    io_stream::open (concat ("cygfile://", "/etc/setup/installed.db", =
0),=0A=
+		     "rt");=0A=
   if (!db)=0A=
     return;=0A=
 =0A=
-  while (fgets (line, 1000, db))=0A=
+  while (db->gets (line, 1000))=0A=
     {=0A=
       int parseable;=0A=
       src[0] =3D 0;=0A=
@@ -1570,7 +1570,7 @@ read_installed_db ()=0A=
 	      break;=0A=
 	    }=0A=
     }=0A=
-  fclose (db);=0A=
+  delete db;=0A=
 }=0A=
 =0A=
 int=0A=
Index: choose.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/choose.h,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 choose.h=0A=
--- choose.h	2001/11/09 14:12:00	2.3=0A=
+++ choose.h	2001/11/11 06:54:55=0A=
@@ -45,7 +45,8 @@ typedef enum=0A=
   ACTION_SAME_TEST =3D ACTION_TEST + ACTION_SAME,=0A=
   /* Last action. */=0A=
   ACTION_SAME_LAST=0A=
-} actions;=0A=
+}=0A=
+actions;=0A=
 =0A=
 typedef enum=0A=
 {=0A=
@@ -54,7 +55,8 @@ typedef enum=0A=
   VIEW_PACKAGE,=0A=
   VIEW_CATEGORY,=0A=
   NVIEW=0A=
-} views;=0A=
+}=0A=
+views;=0A=
 =0A=
 struct _header=0A=
 {=0A=
@@ -70,46 +72,55 @@ typedef class _view view;=0A=
 =0A=
 class pick_line=0A=
 {=0A=
-  public:=0A=
-    void set_line (Package *_pkg);=0A=
-    void set_line (Category *_cat);=0A=
-    void paint (HDC hdc, int x, int y, int row, int show_cat);=0A=
-    Package *get_pkg (void) { return pkg; };=0A=
-    Category *get_category (void) { return cat; };=0A=
-    int click (int x);=0A=
-  private:=0A=
-    Package *pkg;=0A=
-    Category *cat;=0A=
+public:=0A=
+  void set_line (Package * _pkg);=0A=
+  void set_line (Category * _cat);=0A=
+  void paint (HDC hdc, int x, int y, int row, int show_cat);=0A=
+  Package *get_pkg (void)=0A=
+  {=0A=
+    return pkg;=0A=
+  };=0A=
+  Category *get_category (void)=0A=
+  {=0A=
+    return cat;=0A=
+  };=0A=
+  int click (int x);=0A=
+private:=0A=
+    Package * pkg;=0A=
+  Category *cat;=0A=
 };=0A=
 =0A=
 class _view=0A=
 {=0A=
-  public:=0A=
-    int num_columns;=0A=
-    views get_view_mode () { return view_mode; };=0A=
-    void set_view_mode(views _mode);=0A=
-    struct _header *headers;=0A=
+public:=0A=
+  int num_columns;=0A=
+  views get_view_mode ()=0A=
+  {=0A=
+    return view_mode;=0A=
+  };=0A=
+  void set_view_mode (views _mode);=0A=
+  struct _header *headers;=0A=
     _view (views mode, HDC dc);=0A=
-    const char *mode_caption ();=0A=
-    void insert_pkg (Package *);=0A=
-    void insert_category (Category *, int);=0A=
-    void clear_view (void);=0A=
-    int click (int row, int x);=0A=
-    int current_col;=0A=
-    int new_col;=0A=
-    int src_col;=0A=
-    int cat_col;=0A=
-    int pkg_col;=0A=
-    int last_col;=0A=
-    pick_line * lines;=0A=
-    int nlines;=0A=
+  const char *mode_caption ();=0A=
+  void insert_pkg (Package *);=0A=
+  void insert_category (Category *, int);=0A=
+  void clear_view (void);=0A=
+  int click (int row, int x);=0A=
+  int current_col;=0A=
+  int new_col;=0A=
+  int src_col;=0A=
+  int cat_col;=0A=
+  int pkg_col;=0A=
+  int last_col;=0A=
+  pick_line *lines;=0A=
+  int nlines;=0A=
 =0A=
-  private:=0A=
+private:=0A=
     views view_mode;=0A=
-    void set_headers (void);=0A=
-    void init_headers (HDC dc);=0A=
-    void insert_at (int, pick_line);=0A=
-    void insert_under (int linen, pick_line line); =0A=
+  void set_headers (void);=0A=
+  void init_headers (HDC dc);=0A=
+  void insert_at (int, pick_line);=0A=
+  void insert_under (int linen, pick_line line);=0A=
 =0A=
 };=0A=
 #endif /* __cplusplus */=0A=
Index: concat.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/concat.cc,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 concat.cc=0A=
--- concat.cc	2001/05/27 07:05:09	2.2=0A=
+++ concat.cc	2001/11/11 06:54:55=0A=
@@ -16,8 +16,12 @@=0A=
 /* See concat.h.  Note that we canonicalize the result, this avoids=0A=
    multiple slashes being interpreted as UNCs. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: concat.cc,v 2.2 2001/05/27 07:05:09 =
cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: concat.cc,v 2.2 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
+=0A=
 #include <stdarg.h>=0A=
 #include <stdlib.h>=0A=
 #include <string.h>=0A=
@@ -61,12 +65,12 @@ vconcat (const char *s, va_list v)=0A=
   strcpy (rv, s);=0A=
   v =3D save_v;=0A=
   while (1)=0A=
-  {=0A=
-    arg =3D va_arg (v, char *);=0A=
-    if (arg =3D=3D 0)=0A=
-      break;=0A=
-    strcat (rv, arg);=0A=
-  }=0A=
+    {=0A=
+      arg =3D va_arg (v, char *);=0A=
+      if (arg =3D=3D 0)=0A=
+	break;=0A=
+      strcat (rv, arg);=0A=
+    }=0A=
   va_end (v);=0A=
 =0A=
   char *d, *p;=0A=
Index: concat.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/concat.h,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 concat.h=0A=
--- concat.h	2001/05/11 01:40:36	2.1=0A=
+++ concat.h	2001/11/11 06:54:55=0A=
@@ -20,12 +20,12 @@=0A=
    name or URL, and will canonicalize the result accordingly=0A=
    (i.e. replace \ with /, collapse multiple /// to a single /, etc.)  =
*/=0A=
 =0A=
-char * concat (const char *s, ...);=0A=
-char * vconcat (const char *, va_list);=0A=
+char *concat (const char *s, ...);=0A=
+char *vconcat (const char *, va_list);=0A=
 =0A=
 /* convert slashes to backslashes */=0A=
 =0A=
-char * backslash (char *s);=0A=
+char *backslash (char *s);=0A=
 =0A=
 /* Used when treating / and \ as equivalent. */=0A=
 #define SLASH_P(ch) \=0A=
Index: desktop.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/desktop.cc,v=0A=
retrieving revision 2.13=0A=
diff -u -p -r2.13 desktop.cc=0A=
--- desktop.cc	2001/10/27 15:56:46	2.13=0A=
+++ desktop.cc	2001/11/11 06:54:55=0A=
@@ -18,7 +18,10 @@=0A=
    that unlike other do_* functions, this one is called directly from=0A=
    install.cc */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: desktop.cc,v 2.13 2001/10/27 =
15:56:46 cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: desktop.cc,v 2.13 2001/10/27 15:56:46 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <shlobj.h>=0A=
@@ -39,9 +42,7 @@ static char *cvsid =3D "\n%%% $Id: desktop=0A=
 =0A=
 #include "port.h"=0A=
 =0A=
-extern "C" {=0A=
-  void make_link_2 (char *exepath, char *args, char *icon, char *lname);=0A=
-};=0A=
+#include "mklink2.h"=0A=
 =0A=
 static OSVERSIONINFO verinfo;=0A=
 =0A=
@@ -53,7 +54,7 @@ static OSVERSIONINFO verinfo;=0A=
 	@*=0A=
    */=0A=
 =0A=
-static char *etc_profile[] =3D {=0A=
+static const char *etc_profile[] =3D {=0A=
   "PATH=3D\"/usr/local/bin:/usr/bin:/bin:$PATH\"",=0A=
   "",=0A=
   "USER=3D\"`id -un`\"",=0A=
@@ -93,79 +94,83 @@ static char *batname;=0A=
 static char *iconname;=0A=
 =0A=
 static void=0A=
-make_link (char *linkpath, char *title, char *target)=0A=
+make_link (const char *linkpath, const char *title, const char *target)=0A=
 {=0A=
   char argbuf[_MAX_PATH];=0A=
   char *fname =3D concat (linkpath, "/", title, ".lnk", 0);=0A=
 =0A=
   if (_access (fname, 0) =3D=3D 0)=0A=
-    return; /* already exists */=0A=
+    return;			/* already exists */=0A=
 =0A=
   msg ("make_link %s, %s, %s\n", fname, title, target);=0A=
 =0A=
   mkdir_p (0, fname);=0A=
 =0A=
-  char *exepath, *args;=0A=
+  char *exepath;=0A=
 =0A=
   /* If we are running Win9x, build a command line. */=0A=
   if (verinfo.dwPlatformId =3D=3D VER_PLATFORM_WIN32_NT)=0A=
     {=0A=
-      exepath =3D target;=0A=
-      args =3D "";=0A=
+      exepath =3D concat (target, 0);=0A=
+      sprintf (argbuf, " ");=0A=
     }=0A=
   else=0A=
     {=0A=
-      char *pccmd;=0A=
       char windir[MAX_PATH];=0A=
 =0A=
       GetWindowsDirectory (windir, sizeof (windir));=0A=
       exepath =3D concat (windir, COMMAND9XEXE, 0);=0A=
       sprintf (argbuf, "%s %s", COMMAND9XARGS, target);=0A=
-      args =3D argbuf;=0A=
     }=0A=
 =0A=
-  msg ("make_link_2 (%s, %s, %s, %s)", exepath, args, iconname, fname);=0A=
-  make_link_2 (exepath, args, iconname, fname);=0A=
+  msg ("make_link_2 (%s, %s, %s, %s)", exepath, argbuf, iconname, =
fname);=0A=
+  make_link_2 (exepath, argbuf, iconname, fname);=0A=
 }=0A=
 =0A=
 static void=0A=
-start_menu (char *title, char *target)=0A=
+start_menu (const char *title, const char *target)=0A=
 {=0A=
   char path[_MAX_PATH];=0A=
   LPITEMIDLIST id;=0A=
   int issystem =3D (root_scope =3D=3D IDC_ROOT_SYSTEM) ? 1 : 0;=0A=
-  SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_COMMON_PROGRAMS : =
CSIDL_PROGRAMS, &id);=0A=
+  SHGetSpecialFolderLocation (NULL,=0A=
+			      issystem ? CSIDL_COMMON_PROGRAMS :=0A=
+			      CSIDL_PROGRAMS, &id);=0A=
   SHGetPathFromIDList (id, path);=0A=
 // following lines added because it appears Win95 does not use common =
programs=0A=
 // unless it comes into play when multiple users for Win95 is enabled=0A=
-  msg("Program directory for program link: %s",path);=0A=
-  if ( strlen(path) =3D=3D 0) {=0A=
-     SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);=0A=
-     SHGetPathFromIDList (id, path);=0A=
-     msg("Program directory for program link changed to: %s",path);=0A=
-  }=0A=
+  msg ("Program directory for program link: %s", path);=0A=
+  if (strlen (path) =3D=3D 0)=0A=
+    {=0A=
+      SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);=0A=
+      SHGetPathFromIDList (id, path);=0A=
+      msg ("Program directory for program link changed to: %s", path);=0A=
+    }=0A=
 // end of Win95 addition=0A=
   strcat (path, "/Cygnus Solutions");=0A=
   make_link (path, title, target);=0A=
 }=0A=
 =0A=
 static void=0A=
-desktop_icon (char *title, char *target)=0A=
+desktop_icon (const char *title, const char *target)=0A=
 {=0A=
   char path[_MAX_PATH];=0A=
   LPITEMIDLIST id;=0A=
   int issystem =3D (root_scope =3D=3D IDC_ROOT_SYSTEM) ? 1 : 0;=0A=
   //SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_DESKTOP : =
CSIDL_COMMON_DESKTOPDIRECTORY, &id);=0A=
-  SHGetSpecialFolderLocation (NULL, issystem ? =
CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY, &id);=0A=
+  SHGetSpecialFolderLocation (NULL,=0A=
+			      issystem ? CSIDL_COMMON_DESKTOPDIRECTORY :=0A=
+			      CSIDL_DESKTOPDIRECTORY, &id);=0A=
   SHGetPathFromIDList (id, path);=0A=
 // following lines added because it appears Win95 does not use common =
programs=0A=
 // unless it comes into play when multiple users for Win95 is enabled=0A=
-  msg("Desktop directory for desktop link: %s",path);=0A=
-  if ( strlen(path) =3D=3D 0) {=0A=
-     SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);=0A=
-     SHGetPathFromIDList (id, path);=0A=
-     msg("Desktop directory for deskop link changed to: %s",path);=0A=
-  }=0A=
+  msg ("Desktop directory for desktop link: %s", path);=0A=
+  if (strlen (path) =3D=3D 0)=0A=
+    {=0A=
+      SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);=0A=
+      SHGetPathFromIDList (id, path);=0A=
+      msg ("Desktop directory for deskop link changed to: %s", path);=0A=
+    }=0A=
 // end of Win95 addition=0A=
   make_link (path, title, target);=0A=
 }=0A=
@@ -186,7 +191,8 @@ make_cygwin_bat ()=0A=
   fprintf (bat, "@echo off\n\n");=0A=
 =0A=
   fprintf (bat, "%.2s\n", get_root_dir ());=0A=
-  fprintf (bat, "chdir %s\n\n", backslash (concat (get_root_dir () + 2, =
"/bin", 0)));=0A=
+  fprintf (bat, "chdir %s\n\n",=0A=
+	   backslash (concat (get_root_dir () + 2, "/bin", 0)));=0A=
 =0A=
   fprintf (bat, "bash --login -i\n");=0A=
 =0A=
@@ -205,18 +211,18 @@ make_etc_profile ()=0A=
   char os;=0A=
   switch (verinfo.dwPlatformId)=0A=
     {=0A=
-      case VER_PLATFORM_WIN32_NT:=0A=
-	os =3D 'N';=0A=
-	break;=0A=
-      case VER_PLATFORM_WIN32_WINDOWS:=0A=
-	if (verinfo.dwMinorVersion =3D=3D 0)=0A=
-	  os =3D '5';=0A=
-	else=0A=
-	  os =3D '8';=0A=
-	break;=0A=
-      default:=0A=
-	os =3D '?';=0A=
-	break;=0A=
+    case VER_PLATFORM_WIN32_NT:=0A=
+      os =3D 'N';=0A=
+      break;=0A=
+    case VER_PLATFORM_WIN32_WINDOWS:=0A=
+      if (verinfo.dwMinorVersion =3D=3D 0)=0A=
+	os =3D '5';=0A=
+      else=0A=
+	os =3D '8';=0A=
+      break;=0A=
+    default:=0A=
+      os =3D '?';=0A=
+      break;=0A=
     }=0A=
   msg ("os is %c", os);=0A=
 =0A=
@@ -224,14 +230,14 @@ make_etc_profile ()=0A=
   if (!p)=0A=
     return;=0A=
 =0A=
-  int i, allow=3D1;=0A=
-  for (i=3D0; etc_profile[i]; i++)=0A=
+  int i, allow =3D 1;=0A=
+  for (i =3D 0; etc_profile[i]; i++)=0A=
     {=0A=
       if (etc_profile[i][0] =3D=3D '@')=0A=
 	{=0A=
 	  allow =3D 0;=0A=
 	  msg ("profile: %s", etc_profile[i]);=0A=
-	  for (char *cp =3D etc_profile[i]+1; *cp; cp++)=0A=
+	  for (const char *cp =3D etc_profile[i] + 1; *cp; cp++)=0A=
 	    if (*cp =3D=3D os || *cp =3D=3D '*')=0A=
 	      allow =3D 1;=0A=
 	  msg ("allow is %d\n", allow);=0A=
@@ -244,7 +250,7 @@ make_etc_profile ()=0A=
 }=0A=
 =0A=
 static int=0A=
-uexists (char *path)=0A=
+uexists (const char *path)=0A=
 {=0A=
   char *f =3D cygpath (path, 0);=0A=
   int a =3D _access (f, 0);=0A=
@@ -266,12 +272,12 @@ make_passwd_group ()=0A=
   if (verinfo.dwPlatformId !=3D VER_PLATFORM_WIN32_NT)=0A=
     {=0A=
       Package *pkg =3D getpkgbyname ("cygwin");=0A=
-      if (pkg && is_download_action (pkg) &&=0A=
-	  pkg->action !=3D ACTION_SRC_ONLY)=0A=
+      if (pkg && is_download_action (pkg) && pkg->action !=3D =
ACTION_SRC_ONLY)=0A=
 	{=0A=
 	  /* mkpasswd and mkgroup are not working on 9x/ME up to 1.1.5-4 */=0A=
 	  char *border_version =3D canonicalize_version ("1.1.5-4");=0A=
-	  char *inst_version =3D canonicalize_version =
(pkg->info[pkg->trust].version);=0A=
+	  char *inst_version =3D=0A=
+	    canonicalize_version (pkg->info[pkg->trust].version);=0A=
 	  if (strcmp (inst_version, border_version) <=3D 0)=0A=
 	    goto out;=0A=
 	}=0A=
@@ -285,7 +291,7 @@ make_passwd_group ()=0A=
   if (!uexists ("/etc/group"))=0A=
     fprintf (p, "bin\\mkgroup -l > etc\\group\n");=0A=
 =0A=
- out:=0A=
+out:=0A=
   fclose (p);=0A=
 }=0A=
 =0A=
@@ -312,21 +318,23 @@ save_icon ()=0A=
 }=0A=
 =0A=
 static void=0A=
-do_desktop_setup()=0A=
+do_desktop_setup ()=0A=
 {=0A=
   save_icon ();=0A=
 =0A=
   make_cygwin_bat ();=0A=
   make_etc_profile ();=0A=
   make_passwd_group ();=0A=
+=0A=
+  if (root_menu)=0A=
+    {=0A=
+      start_menu ("Cygwin Bash Shell", batname);=0A=
+    }=0A=
 =0A=
-  if (root_menu) {=0A=
-    start_menu ("Cygwin Bash Shell", batname);=0A=
-  }=0A=
-=0A=
-  if (root_desktop) {=0A=
-    desktop_icon ("Cygwin", batname);=0A=
-  }=0A=
+  if (root_desktop)=0A=
+    {=0A=
+      desktop_icon ("Cygwin", batname);=0A=
+    }=0A=
 }=0A=
 =0A=
 static int da[] =3D { IDC_ROOT_DESKTOP, 0 };=0A=
@@ -346,61 +354,69 @@ load_dialog (HWND h)=0A=
   check_if_enable_next (h);=0A=
 }=0A=
 =0A=
-static int check_desktop (char *title, char *target)=0A=
+static int=0A=
+check_desktop (const char *title, const char *target)=0A=
 {=0A=
   char path[_MAX_PATH];=0A=
   LPITEMIDLIST id;=0A=
   int issystem =3D (root_scope =3D=3D IDC_ROOT_SYSTEM) ? 1 : 0;=0A=
-  SHGetSpecialFolderLocation (NULL, issystem ? =
CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY, &id);=0A=
+  SHGetSpecialFolderLocation (NULL,=0A=
+			      issystem ? CSIDL_COMMON_DESKTOPDIRECTORY :=0A=
+			      CSIDL_DESKTOPDIRECTORY, &id);=0A=
   SHGetPathFromIDList (id, path);=0A=
   // following lines added because it appears Win95 does not use common =
programs=0A=
   // unless it comes into play when multiple users for Win95 is enabled=0A=
-  msg ("Desktop directory for desktop link: %s",path);=0A=
-  if (strlen (path) =3D=3D 0) {=0A=
-     SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);=0A=
-     SHGetPathFromIDList (id, path);=0A=
-     msg ("Desktop directory for deskop link changed to: %s",path);=0A=
-  }=0A=
+  msg ("Desktop directory for desktop link: %s", path);=0A=
+  if (strlen (path) =3D=3D 0)=0A=
+    {=0A=
+      SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);=0A=
+      SHGetPathFromIDList (id, path);=0A=
+      msg ("Desktop directory for deskop link changed to: %s", path);=0A=
+    }=0A=
   // end of Win95 addition=0A=
   char *fname =3D concat (path, "/", title, ".lnk", 0);=0A=
 =0A=
   if (_access (fname, 0) =3D=3D 0)=0A=
-    return 0; /* already exists */=0A=
+    return 0;			/* already exists */=0A=
 =0A=
-  fname =3D concat (path, "/", title, ".pif", 0); /* check for a pif as =
well */=0A=
+  fname =3D concat (path, "/", title, ".pif", 0);	/* check for a pif as =
well */=0A=
 =0A=
   if (_access (fname, 0) =3D=3D 0)=0A=
-    return 0; /* already exists */=0A=
+    return 0;			/* already exists */=0A=
 =0A=
   return IDC_ROOT_DESKTOP;=0A=
 }=0A=
 =0A=
-static int check_startmenu (char *title, char *target)=0A=
+static int=0A=
+check_startmenu (const char *title, const char *target)=0A=
 {=0A=
   char path[_MAX_PATH];=0A=
   LPITEMIDLIST id;=0A=
   int issystem =3D (root_scope =3D=3D IDC_ROOT_SYSTEM) ? 1 : 0;=0A=
-  SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_COMMON_PROGRAMS : =
CSIDL_PROGRAMS, &id);=0A=
+  SHGetSpecialFolderLocation (NULL,=0A=
+			      issystem ? CSIDL_COMMON_PROGRAMS :=0A=
+			      CSIDL_PROGRAMS, &id);=0A=
   SHGetPathFromIDList (id, path);=0A=
   // following lines added because it appears Win95 does not use common =
programs=0A=
   // unless it comes into play when multiple users for Win95 is enabled=0A=
-  msg ("Program directory for program link: %s",path);=0A=
-  if (strlen (path) =3D=3D 0) {=0A=
-     SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);=0A=
-     SHGetPathFromIDList (id, path);=0A=
-     msg ("Program directory for program link changed to: %s",path);=0A=
-  }=0A=
+  msg ("Program directory for program link: %s", path);=0A=
+  if (strlen (path) =3D=3D 0)=0A=
+    {=0A=
+      SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);=0A=
+      SHGetPathFromIDList (id, path);=0A=
+      msg ("Program directory for program link changed to: %s", path);=0A=
+    }=0A=
   // end of Win95 addition=0A=
   strcat (path, "/Cygnus Solutions");=0A=
   char *fname =3D concat (path, "/", title, ".lnk", 0);=0A=
 =0A=
   if (_access (fname, 0) =3D=3D 0)=0A=
-    return 0; /* already exists */=0A=
+    return 0;			/* already exists */=0A=
 =0A=
-  fname =3D concat (path, "/", title, ".pif", 0); /* check for a pif as =
well */=0A=
+  fname =3D concat (path, "/", title, ".pif", 0);	/* check for a pif as =
well */=0A=
 =0A=
   if (_access (fname, 0) =3D=3D 0)=0A=
-    return 0; /* already exists */=0A=
+    return 0;			/* already exists */=0A=
 =0A=
   return IDC_ROOT_MENU;=0A=
 }=0A=
@@ -408,7 +424,7 @@ static int check_startmenu (char *title,=0A=
 static void=0A=
 save_dialog (HWND h)=0A=
 {=0A=
-  root_desktop=3D rbget (h, da);=0A=
+  root_desktop =3D rbget (h, da);=0A=
   root_menu =3D rbget (h, ma);=0A=
 }=0A=
 =0A=
@@ -426,7 +442,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
 =0A=
     case IDOK:=0A=
       save_dialog (h);=0A=
-      do_desktop_setup();=0A=
+      do_desktop_setup ();=0A=
       NEXT (IDD_S_POSTINSTALL);=0A=
       break;=0A=
 =0A=
@@ -439,6 +455,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -463,8 +480,11 @@ do_desktop (HINSTANCE h)=0A=
   verinfo.dwOSVersionInfoSize =3D sizeof (verinfo);=0A=
   GetVersionEx (&verinfo);=0A=
 =0A=
-  root_desktop =3D check_desktop("Cygwin",backslash (cygpath =
("/cygwin.bat", 0)));=0A=
-  root_menu =3D check_startmenu("Cygwin Bash Shell",backslash (cygpath =
("/cygwin.bat", 0)));=0A=
+  root_desktop =3D=0A=
+    check_desktop ("Cygwin", backslash (cygpath ("/cygwin.bat", 0)));=0A=
+  root_menu =3D=0A=
+    check_startmenu ("Cygwin Bash Shell",=0A=
+		     backslash (cygpath ("/cygwin.bat", 0)));=0A=
 =0A=
   int rv =3D 0;=0A=
 =0A=
Index: dialog.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/dialog.cc,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 dialog.cc=0A=
--- dialog.cc	2001/05/27 07:05:09	2.3=0A=
+++ dialog.cc	2001/11/11 06:54:55=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to provide common functionality for=0A=
    all the dialogs in the program. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: dialog.cc,v 2.3 2001/05/27 07:05:09 =
cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: dialog.cc,v 2.3 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -60,14 +63,14 @@ eset (HWND h, int id, const char *val)=0A=
 void=0A=
 eset (HWND h, int id, int val)=0A=
 {=0A=
-  SetDlgItemInt (h, id, (UINT)val, TRUE);=0A=
+  SetDlgItemInt (h, id, (UINT) val, TRUE);=0A=
 }=0A=
 =0A=
 int=0A=
 rbget (HWND h, int *ids)=0A=
 {=0A=
   int i;=0A=
-  for (i=3D0; ids[i]; i++)=0A=
+  for (i =3D 0; ids[i]; i++)=0A=
     if (IsDlgButtonChecked (h, ids[i]) =3D=3D BST_CHECKED)=0A=
       return ids[i];=0A=
   return 0;=0A=
@@ -77,22 +80,17 @@ void=0A=
 rbset (HWND h, int *ids, int id)=0A=
 {=0A=
   int i;=0A=
-  for (i=3D0; ids[i]; i++)=0A=
-    CheckDlgButton (h, ids[i], id=3D=3Dids[i] ? BST_CHECKED : =
BST_UNCHECKED);=0A=
+  for (i =3D 0; ids[i]; i++)=0A=
+    CheckDlgButton (h, ids[i], id =3D=3D ids[i] ? BST_CHECKED : =
BST_UNCHECKED);=0A=
 }=0A=
 =0A=
 void=0A=
-fatal (char *msg)=0A=
+fatal (const char *msg)=0A=
 {=0A=
   DWORD e =3D GetLastError ();=0A=
   char *buf;=0A=
   FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | =
FORMAT_MESSAGE_FROM_SYSTEM,=0A=
-		 0,=0A=
-		 e,=0A=
-		 0,=0A=
-		 (CHAR *)&buf,=0A=
-		 0,=0A=
-		 0);=0A=
+		 0, e, 0, (CHAR *) & buf, 0, 0);=0A=
   MessageBox (0, buf, msg, 0);=0A=
   exit_setup (1);=0A=
 }=0A=
Index: dialog.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/dialog.h,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 dialog.h=0A=
--- dialog.h	2001/05/27 07:05:09	2.3=0A=
+++ dialog.h	2001/11/11 06:54:55=0A=
@@ -26,20 +26,20 @@ extern int exit_msg;=0A=
 =0A=
 /* prototypes for all the do_* functions (most called by main.cc) */=0A=
 =0A=
-D(do_choose);=0A=
-D(do_desktop);=0A=
-D(do_download);=0A=
-D(do_fromcwd);=0A=
-D(do_ini);=0A=
-D(do_install);=0A=
-D(do_local_dir);=0A=
-D(do_net);=0A=
-D(do_other);=0A=
-D(do_postinstall);=0A=
-D(do_root);=0A=
-D(do_site);=0A=
-D(do_source);=0A=
-D(do_splash);=0A=
+D (do_choose);=0A=
+D (do_desktop);=0A=
+D (do_download);=0A=
+D (do_fromcwd);=0A=
+D (do_ini);=0A=
+D (do_install);=0A=
+D (do_local_dir);=0A=
+D (do_net);=0A=
+D (do_other);=0A=
+D (do_postinstall);=0A=
+D (do_root);=0A=
+D (do_site);=0A=
+D (do_source);=0A=
+D (do_splash);=0A=
 =0A=
 #undef D=0A=
 =0A=
@@ -48,25 +48,25 @@ D(do_splash);=0A=
 =0A=
 /* Get the value of an EditText control.  Pass the previously stored=0A=
    value and it will free the memory if needed. */=0A=
- =0A=
+=0A=
 char *eget (HWND h, int id, char *var);=0A=
 =0A=
 /* Same, but convert the value to an integer */=0A=
 =0A=
-int   eget (HWND h, int id);=0A=
+int eget (HWND h, int id);=0A=
 =0A=
 /* Set the EditText control to the given string or integer */=0A=
 =0A=
-void  eset (HWND h, int id, const char *var);=0A=
-void  eset (HWND h, int id, int var);=0A=
+void eset (HWND h, int id, const char *var);=0A=
+void eset (HWND h, int id, int var);=0A=
 =0A=
 /* RadioButtons.  ids is a null-terminated list of IDs.  Get=0A=
    returns the selected ID (or zero), pass an ID to set */=0A=
 =0A=
-int   rbget (HWND h, int *ids);=0A=
-void  rbset (HWND h, int *ids, int id);=0A=
+int rbget (HWND h, int *ids);=0A=
+void rbset (HWND h, int *ids, int id);=0A=
 =0A=
 /* *This* version of fatal (compare with msg.h) uses GetLastError() to=0A=
    format a suitable error message.  Similar to perror() */=0A=
 =0A=
-void fatal (char *msg);=0A=
+void fatal (const char *msg) __attribute__ ((noreturn));=0A=
Index: diskfull.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/diskfull.cc,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 diskfull.cc=0A=
--- diskfull.cc	2001/05/27 07:05:09	2.1=0A=
+++ diskfull.cc	2001/11/11 06:54:55=0A=
@@ -18,14 +18,17 @@=0A=
    handle disks bigger than 2G, and a new API that isn't always=0A=
    available. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: diskfull.cc,v 2.1 2001/05/27 =
07:05:09 cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: diskfull.cc,v 2.1 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
 #include "diskfull.h"=0A=
 =0A=
-typedef   BOOL WINAPI (*GDFS)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER,=0A=
-			      PULARGE_INTEGER);=0A=
+typedef BOOL WINAPI (*GDFS) (LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER,=0A=
+			     PULARGE_INTEGER);=0A=
 =0A=
 int=0A=
 diskfull (const char *path)=0A=
@@ -43,7 +46,7 @@ diskfull (const char *path)=0A=
 	  if (gdfs (path, &avail, &total, &free))=0A=
 	    {=0A=
 	      int perc =3D avail.QuadPart * 100 / total.QuadPart;=0A=
-	      return 100-perc;=0A=
+	      return 100 - perc;=0A=
 	    }=0A=
 	}=0A=
     }=0A=
@@ -62,7 +65,7 @@ diskfull (const char *path)=0A=
   if (GetDiskFreeSpace (root, &junk, &junk, &free_clusters, =
&total_clusters))=0A=
     {=0A=
       int perc =3D free_clusters * 100 / total_clusters;=0A=
-      return 100-perc;=0A=
+      return 100 - perc;=0A=
     }=0A=
 =0A=
   return 0;=0A=
Index: download.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/download.cc,v=0A=
retrieving revision 2.12=0A=
diff -u -p -r2.12 download.cc=0A=
--- download.cc	2001/06/13 16:11:01	2.12=0A=
+++ download.cc	2001/11/11 06:54:55=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to download all the files we need to=0A=
    do the installation. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: download.cc,v 2.12 2001/06/13 =
16:11:01 cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: download.cc,v 2.12 2001/06/13 16:11:01 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -34,8 +37,7 @@ static char *cvsid =3D "\n%%% $Id: downloa=0A=
 #include "log.h"=0A=
 #include "port.h"=0A=
 =0A=
-DWORD=0A=
-get_file_size (const char *name)=0A=
+DWORD get_file_size (const char *name)=0A=
 {=0A=
   HANDLE h;=0A=
   WIN32_FIND_DATA buf;=0A=
@@ -52,22 +54,20 @@ get_file_size (const char *name)=0A=
 }=0A=
 =0A=
 static int=0A=
-download_one (char *name, int expected_size, int action)=0A=
+download_one (char *name, unsigned int expected_size, int action)=0A=
 {=0A=
   char *local =3D name;=0A=
-  int errors =3D 0;=0A=
 =0A=
   DWORD size;=0A=
   if ((size =3D get_file_size (local)) > 0)=0A=
     if (size =3D=3D expected_size && action !=3D ACTION_SRC_ONLY=0A=
-  && action !=3D ACTION_REDO )=0A=
+	&& action !=3D ACTION_REDO)=0A=
       return 0;=0A=
 =0A=
   mkdir_p (0, local);=0A=
 =0A=
   if (get_url_to_file (concat (MIRROR_SITE, "/", name, 0),=0A=
-		       concat (local, ".tmp", 0),=0A=
-		       expected_size))=0A=
+		       concat (local, ".tmp", 0), expected_size))=0A=
     {=0A=
       note (IDS_DOWNLOAD_FAILED, name);=0A=
       return 1;=0A=
@@ -78,13 +78,13 @@ download_one (char *name, int expected_s=0A=
       if (size =3D=3D expected_size)=0A=
 	{=0A=
 	  log (0, "Downloaded %s", local);=0A=
-    if ( _access (local , 0) =3D=3D 0)=0A=
-       remove ( local );=0A=
+	  if (_access (local, 0) =3D=3D 0)=0A=
+	    remove (local);=0A=
 	  rename (concat (local, ".tmp", 0), local);=0A=
 	}=0A=
       else=0A=
 	{=0A=
-	  log (0, "Download %s wrong size (%d actual vs %d expected)",=0A=
+	  log (0, "Download %s wrong size (%ld actual vs %d expected)",=0A=
 	       local, size, expected_size);=0A=
 	  note (IDS_DOWNLOAD_SHORT, local, size, expected_size);=0A=
 	  return 1;=0A=
@@ -97,30 +97,27 @@ download_one (char *name, int expected_s=0A=
 void=0A=
 do_download (HINSTANCE h)=0A=
 {=0A=
-  int i;=0A=
   int errors =3D 0;=0A=
   total_download_bytes =3D 0;=0A=
   total_download_bytes_sofar =3D 0;=0A=
 =0A=
-  for (Package *pkg =3D package; pkg->name; pkg++)=0A=
+  for (Package * pkg =3D package; pkg->name; pkg++)=0A=
     if (is_download_action (pkg))=0A=
       {=0A=
 	Info *pi =3D pkg->info + pkg->trust;=0A=
 	DWORD size =3D get_file_size (pi->install);=0A=
 	char *local =3D pi->install;=0A=
 	if (pkg->action !=3D ACTION_SRC_ONLY &&=0A=
-	    (pkg->action =3D=3D ACTION_REDO ||=0A=
-	     size !=3D pi->install_size))=0A=
+	    (pkg->action =3D=3D ACTION_REDO || size !=3D pi->install_size))=0A=
 	  total_download_bytes +=3D pi->install_size;=0A=
 	local =3D pi->source;=0A=
 	size =3D get_file_size (pi->source);=0A=
 	if (pkg->srcpicked &&=0A=
-	    (pkg->action =3D=3D ACTION_SRC_ONLY ||=0A=
-	     size !=3D pi->source_size))=0A=
+	    (pkg->action =3D=3D ACTION_SRC_ONLY || size !=3D pi->source_size))=0A=
 	  total_download_bytes +=3D pi->source_size;=0A=
       }=0A=
 =0A=
-  for (Package *pkg =3D package; pkg->name; pkg++)=0A=
+  for (Package * pkg =3D package; pkg->name; pkg++)=0A=
     if (is_download_action (pkg))=0A=
       {=0A=
 	int e =3D 0;=0A=
Index: filemanip.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/filemanip.h,v=0A=
retrieving revision 1.3=0A=
diff -u -p -r1.3 filemanip.h=0A=
--- filemanip.h	2001/06/13 16:11:01	1.3=0A=
+++ filemanip.h	2001/11/11 06:54:55=0A=
@@ -22,8 +22,9 @@ typedef struct=0A=
   char ver[MAX_PATH + 1];=0A=
   char tail[MAX_PATH + 1];=0A=
   char what[16];=0A=
-} fileparse;=0A=
+}=0A=
+fileparse;=0A=
 =0A=
-int parse_filename (const char *in_fn, fileparse& f);=0A=
+int parse_filename (const char *in_fn, fileparse & f);=0A=
 char *base (const char *name);=0A=
 DWORD get_file_size (const char *name);=0A=
Index: find.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/find.cc,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 find.cc=0A=
--- find.cc	2001/04/18 20:11:58	2.1=0A=
+++ find.cc	2001/11/11 06:54:55=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to doa recursive find on a given=0A=
    directory, calling a given function for each file found. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: find.cc,v 2.1 2001/04/18 20:11:58 =
cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: find.cc,v 2.1 2001/04/18 20:11:58 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -24,7 +27,7 @@ static char *cvsid =3D "\n%%% $Id: find.cc=0A=
 =0A=
 #include "port.h"=0A=
 =0A=
-static void (*for_each)(char *, unsigned int);=0A=
+static void (*for_each) (char *, unsigned int);=0A=
 static char dir[_MAX_PATH], *found_part;=0A=
 =0A=
 static int=0A=
@@ -43,29 +46,31 @@ find_sub ()=0A=
   if (h =3D=3D INVALID_HANDLE_VALUE)=0A=
     return 0;=0A=
 =0A=
-  do {=0A=
-    if (strcmp (wfd.cFileName, ".") =3D=3D 0=0A=
-	|| strcmp (wfd.cFileName, "..") =3D=3D 0)=0A=
-      continue;=0A=
-=0A=
-    strcpy (end, wfd.cFileName);=0A=
-=0A=
-    if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)=0A=
-      find_sub ();=0A=
-    else=0A=
-      {=0A=
-	for_each (found_part, wfd.nFileSizeLow);=0A=
-	rv++;=0A=
-      }=0A=
+  do=0A=
+    {=0A=
+      if (strcmp (wfd.cFileName, ".") =3D=3D 0=0A=
+	  || strcmp (wfd.cFileName, "..") =3D=3D 0)=0A=
+	continue;=0A=
+=0A=
+      strcpy (end, wfd.cFileName);=0A=
+=0A=
+      if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)=0A=
+	find_sub ();=0A=
+      else=0A=
+	{=0A=
+	  for_each (found_part, wfd.nFileSizeLow);=0A=
+	  rv++;=0A=
+	}=0A=
 =0A=
-  } while (FindNextFile (h, &wfd));=0A=
+    }=0A=
+  while (FindNextFile (h, &wfd));=0A=
 =0A=
   FindClose (h);=0A=
   return rv;=0A=
 }=0A=
 =0A=
 int=0A=
-find (char *starting_dir, void (*_for_each)(char *, unsigned int))=0A=
+find (const char *starting_dir, void (*_for_each) (char *, unsigned =
int))=0A=
 {=0A=
   strcpy (dir, starting_dir);=0A=
   for_each =3D _for_each;=0A=
Index: find.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/find.h,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 find.h=0A=
--- find.h	2000/08/08 00:27:54	2.0=0A=
+++ find.h	2001/11/11 06:54:55=0A=
@@ -19,4 +19,5 @@=0A=
    (bytes).  find() returns the number of files found.  Directories=0A=
    are scanned but not included in the "found" files. */=0A=
 =0A=
-extern int find (char *starting_dir, void (*for_each)(char *, unsigned =
int));=0A=
+extern int find (const char *starting_dir,=0A=
+		 void (*for_each) (char *, unsigned int));=0A=
Index: fromcwd.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/fromcwd.cc,v=0A=
retrieving revision 2.10=0A=
diff -u -p -r2.10 fromcwd.cc=0A=
--- fromcwd.cc	2001/11/05 13:00:36	2.10=0A=
+++ fromcwd.cc	2001/11/11 06:54:55=0A=
@@ -26,7 +26,8 @@=0A=
    that we search recursively. */=0A=
 =0A=
 #if 0=0A=
-static const char *cvsid =3D "\n%%% $Id: fromcwd.cc,v 2.10 2001/11/05 =
13:00:36 rbcollins Exp $\n";=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: fromcwd.cc,v 2.10 2001/11/05 13:00:36 rbcollins Exp $\n";=0A=
 #endif=0A=
 =0A=
 #include "win32.h"=0A=
@@ -53,7 +54,7 @@ static int=0A=
 is_test_version (char *v)=0A=
 {=0A=
   int i;=0A=
-  for (i=3D0; v[i] && isdigit (v[i]); i++) ;=0A=
+  for (i =3D 0; v[i] && isdigit (v[i]); i++);=0A=
   return (i >=3D 6) ? 1 : 0;=0A=
 }=0A=
 =0A=
@@ -62,19 +63,19 @@ canonicalize_version (const char *v)=0A=
 {=0A=
   static char nv[3][100];=0A=
   static int idx =3D 0;=0A=
-  char *np ;=0A=
+  char *np;=0A=
   const char *dp;=0A=
   int i;=0A=
 =0A=
-  idx =3D (idx+1) % 3;=0A=
+  idx =3D (idx + 1) % 3;=0A=
   np =3D nv[idx];=0A=
 =0A=
   while (*v)=0A=
     {=0A=
       if (isdigit (*v))=0A=
 	{=0A=
-	  for (dp=3Dv; *dp && isdigit (*dp); dp++) ;=0A=
-	  for (i=3Ddp-v; i<12; i++)=0A=
+	  for (dp =3D v; *dp && isdigit (*dp); dp++);=0A=
+	  for (i =3D dp - v; i < 12; i++)=0A=
 	    *np++ =3D '0';=0A=
 	  while (v < dp)=0A=
 	    *np++ =3D *v++;=0A=
@@ -106,7 +107,7 @@ found_file (char *path, unsigned int fsi=0A=
       }=0A=
 =0A=
   if (p =3D=3D NULL)=0A=
-      p =3D new_package (f.pkg);=0A=
+    p =3D new_package (f.pkg);=0A=
 =0A=
   int trust =3D is_test_version (f.ver) ? TRUST_TEST : TRUST_CURR;=0A=
 =0A=
@@ -120,11 +121,11 @@ found_file (char *path, unsigned int fsi=0A=
     }=0A=
 =0A=
   if (p->info[trust].version)=0A=
-    free(p->info[trust].version);=0A=
+    free (p->info[trust].version);=0A=
   p->info[trust].version =3D _strdup (f.ver);=0A=
 =0A=
   if (p->info[trust].install)=0A=
-    free(p->info[trust].install);=0A=
+    free (p->info[trust].install);=0A=
   p->info[trust].install =3D _strdup (path);=0A=
 =0A=
   p->info[trust].install_size =3D fsize;=0A=
@@ -150,7 +151,7 @@ do_fromcwd (HINSTANCE h)=0A=
   char srcpath[_MAX_PATH];=0A=
   for (i =3D 0; i < npackages; i++)=0A=
     {=0A=
-      p =3D package+i;=0A=
+      p =3D package + i;=0A=
       for (t =3D TRUST_PREV; t <=3D TRUST_TEST; t++)=0A=
 	if (p->info[t].install)=0A=
 	  {=0A=
@@ -168,7 +169,7 @@ do_fromcwd (HINSTANCE h)=0A=
 	      }=0A=
 	    if (h !=3D INVALID_HANDLE_VALUE)=0A=
 	      {=0A=
-		msg("-- got it");=0A=
+		msg ("-- got it");=0A=
 		FindClose (h);=0A=
 		p->info[t].source =3D _strdup (srcpath);=0A=
 		p->info[t].source_size =3D wfd.nFileSizeLow;=0A=
Index: geturl.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/geturl.cc,v=0A=
retrieving revision 2.11=0A=
diff -u -p -r2.11 geturl.cc=0A=
--- geturl.cc	2001/11/07 00:09:04	2.11=0A=
+++ geturl.cc	2001/11/11 06:54:55=0A=
@@ -17,7 +17,10 @@=0A=
    netio.cc.  We add a progress dialog and some convenience functions=0A=
    (like collect to string or file */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: geturl.cc,v 2.11 2001/11/07 00:09:04 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: geturl.cc,v 2.10 2001/11/02 00:50:19 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include "commctrl.h"=0A=
@@ -60,13 +63,12 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
     case IDCANCEL:=0A=
       exit_setup (0);=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)=0A=
 {=0A=
-  int i, j;=0A=
-  HWND listbox;=0A=
   switch (message)=0A=
     {=0A=
     case WM_INITDIALOG:=0A=
@@ -90,16 +92,18 @@ dialog_proc (HWND h, UINT message, WPARA=0A=
 static WINAPI DWORD=0A=
 dialog (void *)=0A=
 {=0A=
-  int rv =3D 0;=0A=
   MSG m;=0A=
-  HWND local_gw_dialog =3D CreateDialog (hinstance, MAKEINTRESOURCE =
(IDD_DLSTATUS),=0A=
-				   0, dialog_proc);=0A=
+  HWND local_gw_dialog =3D=0A=
+    CreateDialog (hinstance, MAKEINTRESOURCE (IDD_DLSTATUS),=0A=
+		  0, dialog_proc);=0A=
   ShowWindow (local_gw_dialog, SW_SHOWNORMAL);=0A=
   UpdateWindow (local_gw_dialog);=0A=
-  while (GetMessage (&m, 0, 0, 0) > 0) {=0A=
-    TranslateMessage (&m);=0A=
-    DispatchMessage (&m);=0A=
-  }=0A=
+  while (GetMessage (&m, 0, 0, 0) > 0)=0A=
+    {=0A=
+      TranslateMessage (&m);=0A=
+      DispatchMessage (&m);=0A=
+    }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static DWORD start_tics;=0A=
@@ -121,16 +125,16 @@ init_dialog (char *url, int length)=0A=
       SendMessage (gw_pprogress, PBM_SETRANGE, 0, MAKELPARAM (0, 100));=0A=
       SendMessage (gw_iprogress, PBM_SETRANGE, 0, MAKELPARAM (0, 100));=0A=
     }=0A=
-  char *sl=3Durl, *cp;=0A=
-  for (cp=3Durl; *cp; cp++)=0A=
+  char *sl =3D url, *cp;=0A=
+  for (cp =3D url; *cp; cp++)=0A=
     if (*cp =3D=3D '/' || *cp =3D=3D '\\' || *cp =3D=3D ':')=0A=
-      sl =3D cp+1;=0A=
+      sl =3D cp + 1;=0A=
   max_bytes =3D length;=0A=
   SetWindowText (gw_url, sl);=0A=
   SetWindowText (gw_rate, "Connecting...");=0A=
   SendMessage (gw_progress, PBM_SETPOS, (WPARAM) 0, 0);=0A=
   ShowWindow (gw_progress, (length > 0) ? SW_SHOW : SW_HIDE);=0A=
-  if (length > 0 )=0A=
+  if (length > 0)=0A=
     SetWindowText (gw_progress_text, "Package");=0A=
   else=0A=
     SetWindowText (gw_progress_text, "       ");=0A=
@@ -160,9 +164,9 @@ progress (int bytes)=0A=
   int kbps;=0A=
   static unsigned int last_tics =3D 0;=0A=
   DWORD tics =3D GetTickCount ();=0A=
-  if (tics =3D=3D start_tics) // to prevent division by zero=0A=
+  if (tics =3D=3D start_tics)	// to prevent division by zero=0A=
     return;=0A=
-  if (tics < last_tics + 200) // to prevent flickering updates=0A=
+  if (tics < last_tics + 200)	// to prevent flickering updates=0A=
     return;=0A=
   last_tics =3D tics;=0A=
 =0A=
@@ -175,13 +179,14 @@ progress (int bytes)=0A=
       int perc =3D bytes / (max_bytes / 100);=0A=
       SendMessage (gw_progress, PBM_SETPOS, (WPARAM) perc, 0);=0A=
       sprintf (buf, "%3d %%  (%dk/%dk)  %d kb/s\n",=0A=
-	       perc, bytes/1000, max_bytes/1000, kbps);=0A=
+	       perc, bytes / 1000, max_bytes / 1000, kbps);=0A=
       if (total_download_bytes > 0)=0A=
-        {=0A=
-          int totalperc =3D (total_download_bytes_sofar + bytes) / (=0A=
-                    total_download_bytes / 100);=0A=
-          SendMessage (gw_pprogress, PBM_SETPOS, (WPARAM) totalperc, 0);=0A=
-        }=0A=
+	{=0A=
+	  int totalperc =3D=0A=
+	    (total_download_bytes_sofar +=0A=
+	     bytes) / (total_download_bytes / 100);=0A=
+	  SendMessage (gw_pprogress, PBM_SETPOS, (WPARAM) totalperc, 0);=0A=
+	}=0A=
     }=0A=
   else=0A=
     sprintf (buf, "%d  %d kb/s\n", bytes, kbps);=0A=
@@ -189,7 +194,8 @@ progress (int bytes)=0A=
   SetWindowText (gw_rate, buf);=0A=
 }=0A=
 =0A=
-struct GUBuf {=0A=
+struct GUBuf=0A=
+{=0A=
   GUBuf *next;=0A=
   int count;=0A=
   char buf[2000];=0A=
@@ -214,7 +220,7 @@ get_url_to_string (char *_url)=0A=
 =0A=
   GUBuf *bufs =3D 0;=0A=
   GUBuf **nextp =3D &bufs;=0A=
-  int total_bytes =3D 1; /* for the NUL */=0A=
+  int total_bytes =3D 1;		/* for the NUL */=0A=
   progress (0);=0A=
   while (1)=0A=
     {=0A=
@@ -265,7 +271,7 @@ get_url_to_file (char *_url, char *_file=0A=
     }=0A=
   init_dialog (_url, expected_length);=0A=
 =0A=
-  remove (_filename); /* but ignore errors */=0A=
+  remove (_filename);		/* but ignore errors */=0A=
 =0A=
   NetIO *n =3D NetIO::open (_url, allow_ftp_auth);=0A=
   if (!n || !n->ok ())=0A=
@@ -278,7 +284,7 @@ get_url_to_file (char *_url, char *_file=0A=
   FILE *f =3D fopen (_filename, "wb");=0A=
   if (!f)=0A=
     {=0A=
-      char *err =3D strerror (errno);=0A=
+      const char *err =3D strerror (errno);=0A=
       if (!err)=0A=
 	err =3D "(unknown error)";=0A=
       fatal (IDS_ERR_OPEN_WRITE, _filename, err);=0A=
Index: geturl.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/geturl.h,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 geturl.h=0A=
--- geturl.h	2001/05/28 08:31:02	2.2=0A=
+++ geturl.h	2001/11/11 06:54:55=0A=
@@ -19,7 +19,7 @@=0A=
 extern int total_download_bytes;=0A=
 extern int total_download_bytes_sofar;=0A=
 =0A=
-char  *get_url_to_string (char *_url);=0A=
-int    get_url_to_file (char *_url, char *_filename, int expected_size,=0A=
-			BOOL allow_ftp_auth =3D FALSE);=0A=
-void   dismiss_url_status_dialog ();=0A=
+char *get_url_to_string (char *_url);=0A=
+int get_url_to_file (char *_url, char *_filename, int expected_size,=0A=
+		     BOOL allow_ftp_auth =3D FALSE);=0A=
+void dismiss_url_status_dialog ();=0A=
Index: hash.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/hash.cc,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 hash.cc=0A=
--- hash.cc	2000/08/30 01:07:51	2.2=0A=
+++ hash.cc	2001/11/11 06:54:55=0A=
@@ -15,14 +15,18 @@=0A=
 =0A=
 /* Simple hash class for install.cc */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: hash.cc,v 2.2 2000/08/30 01:07:51 dj =
Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: hash.cc,v 2.2 2000/08/30 01:07:51 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include <stdlib.h>=0A=
 #include <string.h>=0A=
 =0A=
 #include "hash.h"=0A=
 =0A=
-class hash_internals {=0A=
+class hash_internals=0A=
+{=0A=
 public:=0A=
   char **keys;=0A=
   int numkeys;=0A=
@@ -50,7 +54,7 @@ void=0A=
 hash::add (char *string)=0A=
 {=0A=
   int i;=0A=
-  for (i=3D0; i<h->numkeys; i++)=0A=
+  for (i =3D 0; i < h->numkeys; i++)=0A=
     if (strcmp (h->keys[i], string) =3D=3D 0)=0A=
       return;=0A=
   if (h->numkeys >=3D h->maxkeys)=0A=
@@ -60,7 +64,7 @@ hash::add (char *string)=0A=
     }=0A=
 =0A=
   h->keys[h->numkeys] =3D _strdup (string);=0A=
-  h->numkeys ++;=0A=
+  h->numkeys++;=0A=
 }=0A=
 =0A=
 =0A=
@@ -68,7 +72,7 @@ int=0A=
 hash::has (char *string)=0A=
 {=0A=
   int i;=0A=
-  for (i=3D0; i<h->numkeys; i++)=0A=
+  for (i =3D 0; i < h->numkeys; i++)=0A=
     if (strcmp (h->keys[i], string) =3D=3D 0)=0A=
       return 1;=0A=
   return 0;=0A=
@@ -79,7 +83,7 @@ hash::enumerate (char *prev)=0A=
 {=0A=
   if (prev =3D=3D 0)=0A=
     h->prev_index =3D -1;=0A=
-  h->prev_index ++;=0A=
+  h->prev_index++;=0A=
   if (h->prev_index >=3D h->numkeys)=0A=
     return 0;=0A=
   return h->keys[h->prev_index];=0A=
@@ -88,8 +92,8 @@ hash::enumerate (char *prev)=0A=
 static int=0A=
 rev_len (const void *va, const void *vb)=0A=
 {=0A=
-  char *a =3D *(char **)va;=0A=
-  char *b =3D *(char **)vb;=0A=
+  char *a =3D *(char **) va;=0A=
+  char *b =3D *(char **) vb;=0A=
   return strcmp (b, a);=0A=
 }=0A=
 =0A=
Index: hash.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/hash.h,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 hash.h=0A=
--- hash.h	2000/08/30 01:05:42	2.1=0A=
+++ hash.h	2001/11/11 06:54:55=0A=
@@ -17,11 +17,12 @@=0A=
 =0A=
 class hash_internals;=0A=
 =0A=
-class hash {=0A=
+class hash=0A=
+{=0A=
   hash_internals *h;=0A=
- public:=0A=
-  hash ();=0A=
-  ~hash ();=0A=
+public:=0A=
+    hash ();=0A=
+   ~hash ();=0A=
 =0A=
   void add (char *string);=0A=
   int has (char *string);=0A=
@@ -30,5 +31,5 @@ class hash {=0A=
   void add_subdirs (char *path);=0A=
   void reverse_sort ();=0A=
 =0A=
-  char *enumerate (char *prev=3D0);=0A=
+  char *enumerate (char *prev =3D 0);=0A=
 };=0A=
Index: ini.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/ini.cc,v=0A=
retrieving revision 2.9=0A=
diff -u -p -r2.9 ini.cc=0A=
--- ini.cc	2001/06/13 16:11:01	2.9=0A=
+++ ini.cc	2001/11/11 06:54:55=0A=
@@ -18,7 +18,10 @@=0A=
    flex parsers are provided also.  We check to see if this setup.ini=0A=
    is older than the one we used last time, and if so, warn the user. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: ini.cc,v 2.9 2001/06/13 16:11:01 cgf =
Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: ini.cc,v 2.9 2001/06/13 16:11:01 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -33,11 +36,12 @@ static char *cvsid =3D "\n%%% $Id: ini.cc,=0A=
 #include "geturl.h"=0A=
 #include "dialog.h"=0A=
 #include "msg.h"=0A=
-#include "mkdir.h"=0A=
 #include "log.h"=0A=
 #include "version.h"=0A=
 #include "mount.h"=0A=
 =0A=
+#include "io_stream.h"=0A=
+=0A=
 unsigned int setup_timestamp =3D 0;=0A=
 char *setup_version =3D 0;=0A=
 =0A=
@@ -68,7 +72,7 @@ do_ini (HINSTANCE h)=0A=
   ini_init (ini_file);=0A=
 =0A=
   setup_timestamp =3D 0;=0A=
-  /*yydebug =3D 1;*/=0A=
+  /*yydebug =3D 1; */=0A=
 =0A=
   if (yyparse () || error_count > 0)=0A=
     {=0A=
@@ -80,24 +84,28 @@ do_ini (HINSTANCE h)=0A=
   else=0A=
     {=0A=
       /* save known-good setup.ini locally */=0A=
-      FILE *inif =3D fopen ("setup.ini", "wb");=0A=
-      if (inif)=0A=
+      io_stream *inistream =3D io_stream::open ("file://setup.ini", =
"wb");=0A=
+      if (inistream)=0A=
 	{=0A=
-	  fwrite (ini_file, 1, strlen (ini_file), inif);=0A=
-	  fclose (inif);=0A=
+	  inistream->write (ini_file, strlen (ini_file));=0A=
+	  delete inistream;=0A=
 	}=0A=
     }=0A=
 =0A=
   if (get_root_dir ())=0A=
     {=0A=
-      mkdir_p (1, cygpath ("/etc/setup", 0));=0A=
+      io_stream::mkpath_p (PATH_TO_DIR, "cygfile:///etc/setup");=0A=
 =0A=
       unsigned int old_timestamp =3D 0;=0A=
-      FILE *ots =3D fopen (cygpath ("/etc/setup/timestamp", 0), "rt");=0A=
+      io_stream *ots =3D=0A=
+	io_stream::open ("cygfile:///etc/setup/timestamp", "rt");=0A=
       if (ots)=0A=
 	{=0A=
-	  fscanf (ots, "%u", &old_timestamp);=0A=
-	  fclose (ots);=0A=
+	  char temp[20];=0A=
+	  memset (temp, '\0', 20);=0A=
+	  if (ots->read (temp, 19))=0A=
+	    sscanf (temp, "%u", &old_timestamp);=0A=
+	  delete ots;=0A=
 	  if (old_timestamp && setup_timestamp=0A=
 	      && (old_timestamp > setup_timestamp))=0A=
 	    {=0A=
@@ -108,16 +116,20 @@ do_ini (HINSTANCE h)=0A=
 	}=0A=
       if (setup_timestamp)=0A=
 	{=0A=
-	  FILE *nts =3D fopen (cygpath ("/etc/setup/timestamp", 0), "wt");=0A=
+	  io_stream *nts =3D=0A=
+	    io_stream::open ("cygfile:///etc/setup/timestamp", "wt");=0A=
 	  if (nts)=0A=
 	    {=0A=
-	      fprintf (nts, "%u", setup_timestamp);=0A=
-	      fclose (nts);=0A=
+	      char temp[20];=0A=
+	      sprintf (temp, "%u", setup_timestamp);=0A=
+	      nts->write (temp, strlen (temp));=0A=
+	      delete nts;=0A=
 	    }=0A=
 	}=0A=
     }=0A=
 =0A=
-  msg ("setup_version is %s, our_version is %s", =
setup_version?:"(null)", version);=0A=
+  msg ("setup_version is %s, our_version is %s", setup_version ? : =
"(null)",=0A=
+       version);=0A=
   if (setup_version)=0A=
     {=0A=
       char *ini_version =3D canonicalize_version (setup_version);=0A=
@@ -131,7 +143,8 @@ do_ini (HINSTANCE h)=0A=
 =0A=
 extern int yylineno;=0A=
 =0A=
-extern "C" int yyerror (char *s, ...)=0A=
+extern "C" int=0A=
+yyerror (char *s, ...)=0A=
 {=0A=
   char buf[1000];=0A=
   int len;=0A=
@@ -154,14 +167,16 @@ extern "C" int yyerror (char *s, ...)=0A=
       strcpy (error_buf, buf);=0A=
     }=0A=
   error_count++;=0A=
+  /* TODO: is return 0 correct? */=0A=
+  return 0;=0A=
 }=0A=
 =0A=
-extern "C" int fprintf (FILE *f, const char *s, ...);=0A=
+extern "C" int fprintf (FILE * f, const char *s, ...);=0A=
 =0A=
 static char stderrbuf[1000];=0A=
 =0A=
 int=0A=
-fprintf (FILE *f, const char *fmt, ...)=0A=
+fprintf (FILE * f, const char *fmt, ...)=0A=
 {=0A=
   char buf[1000];=0A=
   int rv;=0A=
@@ -174,7 +189,7 @@ fprintf (FILE *f, const char *fmt, ...)=0A=
       if (char *nl =3D strchr (stderrbuf, '\n'))=0A=
 	{=0A=
 	  *nl =3D 0;=0A=
-	  /*OutputDebugString (stderrbuf);*/=0A=
+	  /*OutputDebugString (stderrbuf); */=0A=
 	  MessageBox (0, buf, "Cygwin Setup", 0);=0A=
 	  stderrbuf[0] =3D 0;=0A=
 	}=0A=
Index: ini.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/ini.h,v=0A=
retrieving revision 2.19=0A=
diff -u -p -r2.19 ini.h=0A=
--- ini.h	2001/11/09 14:12:00	2.19=0A=
+++ ini.h	2001/11/11 06:54:56=0A=
@@ -41,14 +41,16 @@ typedef enum=0A=
   TRUST_CURR,=0A=
   TRUST_TEST,=0A=
   NTRUST=0A=
-} trusts;=0A=
+}=0A=
+trusts;=0A=
 =0A=
 typedef enum=0A=
 {=0A=
   EXCLUDE_NONE =3D 0,=0A=
   EXCLUDE_BY_SETUP,=0A=
   EXCLUDE_NOT_FOUND=0A=
-} excludes;=0A=
+}=0A=
+excludes;=0A=
 =0A=
 #define is_download_action(pkg) \=0A=
   ((pkg)->action =3D=3D ACTION_PREV || \=0A=
@@ -75,55 +77,58 @@ typedef enum=0A=
 #define SRCACTION_YES		1=0A=
 typedef struct _Info=0A=
 {=0A=
-  char *version;	/* version part of filename */=0A=
-  char *install;	/* file name to install */=0A=
+  char *version;		/* version part of filename */=0A=
+  char *install;		/* file name to install */=0A=
   unsigned int install_size;	/* in bytes */=0A=
-  int install_exists;	/* install file exists on disk */=0A=
-  int derived;		/* True if we "figured out" that this version should=0A=
-			   go here but it was not in setup.ini */=0A=
-  char *source;		/* sources for installed binaries */=0A=
+  int install_exists;		/* install file exists on disk */=0A=
+  int derived;			/* True if we "figured out" that this version should=0A=
+				   go here but it was not in setup.ini */=0A=
+  char *source;			/* sources for installed binaries */=0A=
   unsigned int source_size;	/* in bytes */=0A=
-  int source_exists;	/* source file exists on disk */=0A=
+  int source_exists;		/* source file exists on disk */=0A=
 #ifdef __cplusplus=0A=
-  _Info (const char *_install, const char *_version,=0A=
-	 int _install_size, const char *_source =3D NULL,=0A=
-	 int _source_size =3D 0);=0A=
+    _Info (const char *_install, const char *_version,=0A=
+	   int _install_size, const char *_source =3D NULL,=0A=
+	   int _source_size =3D 0);=0A=
 #endif=0A=
-} Info;			/* +1 for TRUST_UNKNOWN */=0A=
+}=0A=
+Info;				/* +1 for TRUST_UNKNOWN */=0A=
 =0A=
 typedef struct _CategoryPackage=0A=
 {=0A=
-  struct _CategoryPackage *next;  /* The next package pointer in the =
list */=0A=
-  char *pkgname;		  /* This should be Package *, but the packages can =
move*/=0A=
-} CategoryPackage;=0A=
+  struct _CategoryPackage *next;	/* The next package pointer in the =
list */=0A=
+  char *pkgname;		/* This should be Package *, but the packages can =
move */=0A=
+}=0A=
+CategoryPackage;=0A=
 =0A=
 struct _Category=0A=
 {=0A=
-  struct _Category *next; /* the next category in the list */=0A=
-  char *name;		  /* the category */=0A=
-  CategoryPackage *packages; /* the packages in this category */=0A=
+  struct _Category *next;	/* the next category in the list */=0A=
+  char *name;			/* the category */=0A=
+  CategoryPackage *packages;	/* the packages in this category */=0A=
 };=0A=
 =0A=
 typedef struct _Dependency=0A=
 {=0A=
-  struct _Dependency *next; /* the next package in this dependency list =
*/=0A=
-  char *package;	/* the name of the package that is depended on */=0A=
-} Dependency; 		/* Dependencies can be used for=0A=
-			   recommended/required/related... */=0A=
+  struct _Dependency *next;	/* the next package in this dependency list =
*/=0A=
+  char *package;		/* the name of the package that is depended on */=0A=
+}=0A=
+Dependency;			/* Dependencies can be used for=0A=
+				   recommended/required/related... */=0A=
 struct _Package=0A=
 {=0A=
-  char *name;		/* package name, like "cygwin" */=0A=
-  char *sdesc;		/* short description (replaces "name" if provided) */=0A=
-  char *ldesc;		/* long description (multi-line) */=0A=
-  Category *category;   /* the categories the package belongs to */ =0A=
-  Dependency *required; /* the packages required for this package to =
work */=0A=
-  actions action;	/* A range of states applicable to this package */=0A=
-  trusts trust;		/* Selects among info[] below, a subset of action */=0A=
-  int srcpicked;	/* True if source is required */=0A=
-=0A=
-  Info *installed;	/* Info on installed package */=0A=
-  trusts installed_ix;	/* Index into info array for currently installed =
package */=0A=
-  excludes exclude;	/* true if this package should be excluded */=0A=
+  char *name;			/* package name, like "cygwin" */=0A=
+  char *sdesc;			/* short description (replaces "name" if provided) */=0A=
+  char *ldesc;			/* long description (multi-line) */=0A=
+  Category *category;		/* the categories the package belongs to */=0A=
+  Dependency *required;		/* the packages required for this package to =
work */=0A=
+  actions action;		/* A range of states applicable to this package */=0A=
+  trusts trust;			/* Selects among info[] below, a subset of action */=0A=
+  int srcpicked;		/* True if source is required */=0A=
+=0A=
+  Info *installed;		/* Info on installed package */=0A=
+  trusts installed_ix;		/* Index into info array for currently =
installed package */=0A=
+  excludes exclude;		/* true if this package should be excluded */=0A=
 =0A=
   /* The reason for this weird layout is to allow for loops that scan =
either=0A=
      the info array, based on trust value or the infoscan array based =
on a pointer,=0A=
@@ -140,20 +145,22 @@ extern Category *category;=0A=
 extern int ncategories;=0A=
 =0A=
 #ifdef __cplusplus=0A=
-extern "C" {=0A=
+extern "C"=0A=
+{=0A=
 #endif=0A=
 =0A=
-Package *new_package (char *name);=0A=
-void	ini_init (char *string);=0A=
-Package *getpkgbyname (const char *pkgname);=0A=
-void    new_requirement (Package *package, char *dependson);=0A=
-Category *getcategorybyname (const char *categoryname);=0A=
-Category *getpackagecategorybyname (Package *pkg, const char =
*categoryname); =0A=
-Category *register_category (const char *name);=0A=
-void    add_category (Package *package, Category *cat);=0A=
+  Package *new_package (char *name);=0A=
+  void ini_init (char *string);=0A=
+  Package *getpkgbyname (const char *pkgname);=0A=
+  void new_requirement (Package * package, char *dependson);=0A=
+  Category *getcategorybyname (const char *categoryname);=0A=
+  Category *getpackagecategorybyname (Package * pkg,=0A=
+				      const char *categoryname);=0A=
+  Category *register_category (const char *name);=0A=
+  void add_category (Package * package, Category * cat);=0A=
 =0A=
 #ifdef __cplusplus=0A=
 }=0A=
 #endif=0A=
 =0A=
-#endif /* _INI_H_ */=0A=
+#endif				/* _INI_H_ */=0A=
Index: inilex.l=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/inilex.l,v=0A=
retrieving revision 2.5=0A=
diff -u -p -r2.5 inilex.l=0A=
--- inilex.l	2001/09/21 17:57:52	2.5=0A=
+++ inilex.l	2001/11/11 06:54:56=0A=
@@ -27,7 +27,7 @@=0A=
 #define YY_INPUT(buf,result,max_size) { result =3D ini_getchar(buf, =
max_size); }=0A=
 =0A=
 static int ini_getchar(char *buf, int max_size);=0A=
-static void ignore_line ();=0A=
+static void ignore_line (void);=0A=
 =0A=
 %}=0A=
 =0A=
@@ -119,7 +119,7 @@ static void=0A=
 ignore_line ()=0A=
 {=0A=
   char c;=0A=
-  while (c =3D input ())=0A=
+  while ((c =3D input ()))=0A=
     {=0A=
       if (c =3D=3D EOF)=0A=
 	return;=0A=
Index: install.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/install.cc,v=0A=
retrieving revision 2.21=0A=
diff -u -p -r2.21 install.cc=0A=
--- install.cc	2001/11/02 00:50:19	2.21=0A=
+++ install.cc	2001/11/11 06:54:56=0A=
@@ -17,9 +17,12 @@=0A=
    the install list (in ini.h).  Note that we use a separate thread to=0A=
    maintain the progress dialog, so we avoid the complexity of=0A=
    handling two tasks in one thread.  We also create or update all the=0A=
-   files in /etc/setup/* and create the mount points. */=0A=
+   files in /etc/setup/\* and create the mount points. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: install.cc,v 2.21 2001/11/02 =
00:50:19 rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: install.cc,v 2.21 2001/11/02 00:50:19 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include "commctrl.h"=0A=
@@ -39,7 +42,6 @@ static char *cvsid =3D "\n%%% $Id: install=0A=
 #include "geturl.h"=0A=
 #include "mkdir.h"=0A=
 #include "state.h"=0A=
-#include "tar.h"=0A=
 #include "diskfull.h"=0A=
 #include "msg.h"=0A=
 #include "mount.h"=0A=
@@ -47,6 +49,11 @@ static char *cvsid =3D "\n%%% $Id: install=0A=
 #include "hash.h"=0A=
 #include "mount.h"=0A=
 #include "filemanip.h"=0A=
+#include "io_stream.h"=0A=
+#include "compress.h"=0A=
+#include "compress_gz.h"=0A=
+#include "archive.h"=0A=
+#include "tar.h"=0A=
 =0A=
 #include "port.h"=0A=
 =0A=
@@ -71,13 +78,12 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
     case IDCANCEL:=0A=
       exit_setup (1);=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)=0A=
 {=0A=
-  int i, j;=0A=
-  HWND listbox;=0A=
   switch (message)=0A=
     {=0A=
     case WM_INITDIALOG:=0A=
@@ -102,19 +108,19 @@ dialog (void *)=0A=
   int rv =3D 0;=0A=
   MSG m;=0A=
   HWND ins_dialog =3D CreateDialog (hinstance, MAKEINTRESOURCE =
(IDD_INSTATUS),=0A=
-				   0, dialog_proc);=0A=
+				  0, dialog_proc);=0A=
   if (ins_dialog =3D=3D 0)=0A=
     fatal ("create dialog");=0A=
   ShowWindow (ins_dialog, SW_SHOWNORMAL);=0A=
   UpdateWindow (ins_dialog);=0A=
-  while (GetMessage (&m, 0, 0, 0) > 0) {=0A=
-    TranslateMessage (&m);=0A=
-    DispatchMessage (&m);=0A=
-  }=0A=
+  while (GetMessage (&m, 0, 0, 0) > 0)=0A=
+    {=0A=
+      TranslateMessage (&m);=0A=
+      DispatchMessage (&m);=0A=
+    }=0A=
+  return rv;=0A=
 }=0A=
 =0A=
-static DWORD start_tics;=0A=
-=0A=
 static void=0A=
 init_dialog ()=0A=
 {=0A=
@@ -160,14 +166,13 @@ progress (int bytes)=0A=
 static void=0A=
 badrename (char *o, char *n)=0A=
 {=0A=
-  char buf[1000];=0A=
-  char *err =3D strerror (errno);=0A=
+  const char *err =3D strerror (errno);=0A=
   if (!err)=0A=
     err =3D "(unknown error)";=0A=
   note (IDS_ERR_RENAME, o, n, err);=0A=
 }=0A=
 =0A=
-static char *standard_dirs[] =3D {=0A=
+static const char *standard_dirs[] =3D {=0A=
   "/bin",=0A=
   "/etc",=0A=
   "/lib",=0A=
@@ -191,14 +196,14 @@ hash::add_subdirs (char *path)=0A=
 {=0A=
   char *nonp, *pp;=0A=
   for (nonp =3D path; *nonp =3D=3D '\\' || *nonp =3D=3D '/'; nonp++);=0A=
-  for (pp =3D path + strlen(path) - 1; pp>nonp; pp--)=0A=
+  for (pp =3D path + strlen (path) - 1; pp > nonp; pp--)=0A=
     if (*pp =3D=3D '/' || *pp =3D=3D '\\')=0A=
       {=0A=
-	int i, s=3D0;=0A=
+	int i, s =3D 0;=0A=
 	char c =3D *pp;=0A=
 	*pp =3D 0;=0A=
-	for (i=3D0; standard_dirs[i]; i++)=0A=
-	  if (strcmp (standard_dirs[i]+1, path) =3D=3D 0)=0A=
+	for (i =3D 0; standard_dirs[i]; i++)=0A=
+	  if (strcmp (standard_dirs[i] + 1, path) =3D=3D 0)=0A=
 	    {=0A=
 	      s =3D 1;=0A=
 	      break;=0A=
@@ -209,24 +214,18 @@ hash::add_subdirs (char *path)=0A=
       }=0A=
 }=0A=
 =0A=
-static int=0A=
-exists (const char *file)=0A=
-{=0A=
-  if (_access (file, 0) =3D=3D 0)=0A=
-    return 1;=0A=
-  return 0;=0A=
-}=0A=
-=0A=
 static int num_installs, num_uninstalls;=0A=
 =0A=
 static void=0A=
-uninstall_one (Package *pkg, bool src)=0A=
+uninstall_one (Package * pkg, bool src)=0A=
 {=0A=
   hash dirs;=0A=
   char line[_MAX_PATH];=0A=
 =0A=
-  gzFile lst =3D gzopen (cygpath ("/etc/setup/", pkg->name,=0A=
-				(src ? "-src.lst.gz" : ".lst.gz"), 0), "rb");=0A=
+  io_stream *tmp =3D=0A=
+    io_stream::open (concat ("cygfile:///etc/setup/", pkg->name,=0A=
+			     (src ? "-src.lst.gz" : ".lst.gz"), 0), "rb");=0A=
+  io_stream *lst =3D compress::decompress (tmp);=0A=
   if (lst)=0A=
     {=0A=
       SetWindowText (ins_pkgname, pkg->name);=0A=
@@ -236,10 +235,10 @@ uninstall_one (Package *pkg, bool src)=0A=
       else=0A=
 	log (0, "Uninstalling old %s", pkg->name);=0A=
 =0A=
-      while (gzgets (lst, line, sizeof (line)))=0A=
+      while (lst->gets (line, sizeof (line)))=0A=
 	{=0A=
-	  if (line[strlen(line)-1] =3D=3D '\n')=0A=
-	    line[strlen(line)-1] =3D 0;=0A=
+	  if (line[strlen (line) - 1] =3D=3D '\n')=0A=
+	    line[strlen (line) - 1] =3D 0;=0A=
 =0A=
 	  dirs.add_subdirs (line);=0A=
 =0A=
@@ -251,7 +250,7 @@ uninstall_one (Package *pkg, bool src)=0A=
 	      DeleteFile (d);=0A=
 	    }=0A=
 	}=0A=
-      gzclose (lst);=0A=
+      delete lst;=0A=
 =0A=
       remove (cygpath ("/etc/setup/", pkg->name, ".lst.gz", 0));=0A=
 =0A=
@@ -275,45 +274,54 @@ uninstall_one (Package *pkg, bool src)=0A=
 =0A=
 =0A=
 static int=0A=
-install_one (Package *pkg, bool isSrc)=0A=
+install_one (Package * pkg, bool isSrc)=0A=
 {=0A=
   int errors =3D 0;=0A=
-  char *extra;=0A=
+  const char *extra;=0A=
   const char *file;=0A=
   int file_size;=0A=
+  archive *thefile =3D NULL;=0A=
   Info *pi =3D pkg->info + pkg->trust;=0A=
 =0A=
   if (!isSrc)=0A=
     {=0A=
       extra =3D "";=0A=
       file_size =3D pi->install_size;=0A=
-      file =3D pi->install;=0A=
+      file =3D concat ("file://", pi->install, 0);=0A=
     }=0A=
   else if (pi->source)=0A=
     {=0A=
       extra =3D "-src";=0A=
       file_size =3D pi->source_size;=0A=
-      file =3D pi->source;=0A=
+      file =3D concat ("file://", pi->source, 0);=0A=
     }=0A=
   else=0A=
     return 0;=0A=
 =0A=
   char name[strlen (pkg->name) + strlen (extra) + 1];=0A=
   strcat (strcpy (name, pkg->name), extra);=0A=
-  =0A=
+=0A=
+  /* FIXME: this may file now */=0A=
   char *basef =3D base (file);=0A=
   SetWindowText (ins_pkgname, basef);=0A=
 =0A=
-  if (!exists (file))=0A=
+  if (!io_stream::exists (file))=0A=
     file =3D basef;=0A=
-  if (!exists (file))=0A=
+  if (!io_stream::exists (file))=0A=
     {=0A=
       note (IDS_ERR_OPEN_READ, file, "No such file");=0A=
       return 1;=0A=
     }=0A=
 =0A=
-  gzFile lst =3D gzopen (cygpath ("/etc/setup/", name, ".lst.gz", 0),=0A=
-		       "wb9");=0A=
+  io_stream *tmp =3D=0A=
+    io_stream::open (concat ("cygfile:///etc/setup/", name, ".lst.gz", =
0),=0A=
+		     "wb");=0A=
+  io_stream *lst =3D new compress_gz (tmp, "w9");=0A=
+  if (lst->error ())=0A=
+    {=0A=
+      delete lst;=0A=
+      lst =3D NULL;=0A=
+    }=0A=
 =0A=
   package_bytes =3D file_size;=0A=
 =0A=
@@ -342,44 +350,60 @@ install_one (Package *pkg, bool isSrc)=0A=
     case ACTION_TEST:=0A=
       strcat (msg, " test version...");=0A=
       break;=0A=
+    default:=0A=
+      /* FIXME: log this somehow */=0A=
+      break;=0A=
     }=0A=
 =0A=
   SetWindowText (ins_action, msg);=0A=
   log (0, "%s%s", msg, file);=0A=
-  tar_open (file);=0A=
-=0A=
-  char *fn;=0A=
-  while (fn =3D tar_next_file ())=0A=
+  tmp =3D io_stream::open (file, "rb");=0A=
+  if (tmp)=0A=
     {=0A=
-      char *dest_file;=0A=
+      io_stream *tmp2 =3D compress::decompress (tmp);=0A=
+      if (tmp2)=0A=
+	thefile =3D archive::extract (tmp2);=0A=
+      else=0A=
+	thefile =3D archive::extract (tmp);=0A=
+      /* FIXME: potential leak of either *tmp or *tmp2 */=0A=
+      if (thefile)=0A=
+	{=0A=
+	  const char *fn;=0A=
+	  while ((fn =3D thefile->next_file_name ()))=0A=
+	    {=0A=
+	      char *dest_file;=0A=
 =0A=
-      if (lst)=0A=
-	gzprintf (lst, "%s\n", fn);=0A=
+	      if (lst)=0A=
+		lst->write (concat (fn, "\n", 0), strlen (fn) + 1);=0A=
 =0A=
-      dest_file =3D cygpath (isSrc ? "/usr/src/" : "/", fn, NULL);=0A=
+	      dest_file =3D=0A=
+		concat ("cygfile://", isSrc ? "/usr/src/" : "/", NULL);=0A=
 =0A=
-      SetWindowText (ins_filename, dest_file);=0A=
-      log (LOG_BABBLE, "Installing file %s", dest_file);=0A=
-      if (tar_read_file (dest_file) !=3D 0)=0A=
-	{=0A=
-	  log (0, "Unable to install file %s", dest_file);=0A=
-	  errors++;=0A=
-	}=0A=
+	      /* FIXME: concat leaks memory */=0A=
+	      SetWindowText (ins_filename, concat (dest_file, fn, 0));=0A=
+	      log (LOG_BABBLE, "Installing file %s%s", dest_file, fn);=0A=
+	      if (archive::extract_file (thefile, dest_file) !=3D 0)=0A=
+		{=0A=
+		  log (0, "Unable to install file %s%s", dest_file, fn);=0A=
+		  errors++;=0A=
+		}=0A=
+=0A=
+	      progress (tmp->tell ());=0A=
+	      free (dest_file);=0A=
+	      num_installs++;=0A=
+	    }=0A=
+	  delete thefile;=0A=
 =0A=
-      progress (tar_ftell ());=0A=
-      free (dest_file); =0A=
-      num_installs++;=0A=
+	  total_bytes_sofar +=3D file_size;=0A=
+	}=0A=
     }=0A=
-  tar_close ();=0A=
-=0A=
-  total_bytes_sofar +=3D file_size;=0A=
   progress (0);=0A=
 =0A=
   int df =3D diskfull (get_root_dir ());=0A=
   SendMessage (ins_diskfull, PBM_SETPOS, (WPARAM) df, 0);=0A=
 =0A=
   if (lst)=0A=
-    gzclose (lst);=0A=
+    delete lst;=0A=
 =0A=
   if (!errors)=0A=
     {=0A=
@@ -387,7 +411,9 @@ install_one (Package *pkg, bool isSrc)=0A=
       pkg->installed_ix =3D pkg->trust;=0A=
       if (pkg->installed)=0A=
 	free (pkg->installed);=0A=
-      pkg->installed =3D new Info (inf->install, inf->version, =
inf->install_size, inf->source, inf->source_size);=0A=
+      pkg->installed =3D=0A=
+	new Info (inf->install, inf->version, inf->install_size, inf->source,=0A=
+		  inf->source_size);=0A=
     }=0A=
 =0A=
   return errors;=0A=
@@ -404,22 +430,26 @@ check_for_old_cygwin ()=0A=
     return;=0A=
 =0A=
   char msg[sizeof (buf) + 132];=0A=
-  sprintf (msg, "An old version of cygwin1.dll was found =
here:\r\n%s\r\nDelete?", buf);=0A=
-  switch (MessageBox (NULL, msg,=0A=
-		      "What's that doing there?", MB_YESNO | MB_ICONQUESTION | =
MB_TASKMODAL))=0A=
+  sprintf (msg,=0A=
+	   "An old version of cygwin1.dll was found here:\r\n%s\r\nDelete?",=0A=
+	   buf);=0A=
+  switch (MessageBox=0A=
+	  (NULL, msg, "What's that doing there?",=0A=
+	   MB_YESNO | MB_ICONQUESTION | MB_TASKMODAL))=0A=
     {=0A=
     case IDYES:=0A=
       if (!DeleteFile (buf))=0A=
 	{=0A=
 	  sprintf (msg, "Couldn't delete file %s.\r\n"=0A=
-			"Is the DLL in use by another application?\r\n"=0A=
-			"You should delete the old version of cygwin1.dll\r\nat your =
earliest convenience.",=0A=
-			buf);=0A=
-	  MessageBox (NULL, buf, "Couldn't delete file", MB_OK | =
MB_ICONEXCLAMATION | MB_TASKMODAL);=0A=
+		   "Is the DLL in use by another application?\r\n"=0A=
+		   "You should delete the old version of cygwin1.dll\r\nat your =
earliest convenience.",=0A=
+		   buf);=0A=
+	  MessageBox (NULL, buf, "Couldn't delete file",=0A=
+		      MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);=0A=
 	}=0A=
       break;=0A=
     default:=0A=
-	break;=0A=
+      break;=0A=
     }=0A=
 =0A=
   return;=0A=
@@ -437,7 +467,7 @@ do_install (HINSTANCE h)=0A=
 =0A=
   mkdir_p (1, get_root_dir ());=0A=
 =0A=
-  for (i=3D0; standard_dirs[i]; i++)=0A=
+  for (i =3D 0; standard_dirs[i]; i++)=0A=
     {=0A=
       char *p =3D cygpath (standard_dirs[i], 0);=0A=
       mkdir_p (1, p);=0A=
@@ -445,11 +475,8 @@ do_install (HINSTANCE h)=0A=
     }=0A=
 =0A=
   /* Create /var/run/utmp */=0A=
-  char *utmp =3D cygpath ("/var/run/utmp", 0);=0A=
-  FILE *ufp =3D fopen (utmp, "wb");=0A=
-  if (ufp)=0A=
-    fclose (ufp);=0A=
-  free (utmp);=0A=
+  io_stream *utmp =3D io_stream::open ("cygfile:///var/run/utmp", "wb");=0A=
+  delete utmp;=0A=
 =0A=
   dismiss_url_status_dialog ();=0A=
 =0A=
@@ -469,7 +496,7 @@ do_install (HINSTANCE h)=0A=
   create_mount ("/usr/lib", cygpath ("/lib", 0), istext, issystem);=0A=
   set_cygdrive_flags (istext, issystem);=0A=
 =0A=
-  for (Package *pkg =3D package; pkg->name; pkg++)=0A=
+  for (Package * pkg =3D package; pkg->name; pkg++)=0A=
     {=0A=
       Info *pi =3D pkg->info + pkg->trust;=0A=
       if (pkg->action !=3D ACTION_SRC_ONLY)=0A=
@@ -478,7 +505,7 @@ do_install (HINSTANCE h)=0A=
 	total_bytes +=3D pi->source_size;=0A=
     }=0A=
 =0A=
-  for (Package *pkg =3D package; pkg->name; pkg++)=0A=
+  for (Package * pkg =3D package; pkg->name; pkg++)=0A=
     {=0A=
       if (is_uninstall_action (pkg))=0A=
 	{=0A=
@@ -499,7 +526,7 @@ do_install (HINSTANCE h)=0A=
 	      errors++;=0A=
 	    }=0A=
 	}=0A=
-    } // end of big package loop=0A=
+    }				// end of big package loop=0A=
 =0A=
   ShowWindow (ins_dialog, SW_HIDE);=0A=
 =0A=
@@ -514,7 +541,7 @@ do_install (HINSTANCE h)=0A=
 =0A=
   if (!ndb)=0A=
     {=0A=
-      char *err =3D strerror (errno);=0A=
+      const char *err =3D strerror (errno);=0A=
       if (!err)=0A=
 	err =3D "(unknown error)";=0A=
       fatal (IDS_ERR_OPEN_WRITE, ndb, err);=0A=
@@ -523,18 +550,19 @@ do_install (HINSTANCE h)=0A=
   if (odb)=0A=
     {=0A=
       char line[1000], pkgname[1000];=0A=
-      int printit;=0A=
       while (fgets (line, 1000, odb))=0A=
 	{=0A=
 	  sscanf (line, "%s", pkgname);=0A=
 	  Package *pkg =3D getpkgbyname (pkgname);=0A=
-	  if (!pkg || (!is_download_action (pkg) && pkg->action !=3D =
ACTION_UNINSTALL))=0A=
+	  if (!pkg=0A=
+	      || (!is_download_action (pkg)=0A=
+		  && pkg->action !=3D ACTION_UNINSTALL))=0A=
 	    fputs (line, ndb);=0A=
 	}=0A=
 =0A=
     }=0A=
 =0A=
-  for (Package *pkg =3D package; pkg->name; pkg++)=0A=
+  for (Package * pkg =3D package; pkg->name; pkg++)=0A=
     if (is_download_action (pkg))=0A=
       {=0A=
 	Info *pi =3D pkg->info + pkg->installed_ix;=0A=
Index: localdir.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/localdir.cc,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 localdir.cc=0A=
--- localdir.cc	2001/11/06 03:41:00	2.3=0A=
+++ localdir.cc	2001/11/11 06:54:56=0A=
@@ -15,11 +15,13 @@=0A=
  */=0A=
 =0A=
 /* The purpose of this file is to ask the user where they want the=0A=
-   root of the installation to be, and to ask whether the user prefers=0A=
-   text or binary mounts. */=0A=
+ * locally downloaded package files to be cached=0A=
+ */=0A=
 =0A=
-static char *cvsid =3D=0A=
-  "\n%%% $Id: localdir.cc,v 2.3 2001/11/06 03:41:00 rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: localdir.cc,v 2.2 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <shlobj.h>=0A=
@@ -35,34 +37,23 @@ static char *cvsid =3D=0A=
 #include "concat.h"=0A=
 #include "log.h"=0A=
 #include "mkdir.h"=0A=
+#include "io_stream.h"=0A=
 =0A=
-static void=0A=
-get_root_dir_now ()=0A=
-{=0A=
-  int istext;=0A=
-  int issystem;=0A=
-  if (get_root_dir ())=0A=
-    return;=0A=
-  read_mounts ();=0A=
-}=0A=
-=0A=
 void=0A=
 save_local_dir ()=0A=
 {=0A=
-  get_root_dir_now ();=0A=
-  if (!get_root_dir ())=0A=
-    return;=0A=
-=0A=
   mkdir_p (1, local_dir);=0A=
 =0A=
-  FILE *f =3D fopen (cygpath ("/etc/setup/last-cache", 0), "wb");=0A=
-  if (!f)=0A=
-    return;=0A=
-  fprintf (f, "%s", local_dir);=0A=
-  fclose (f);=0A=
+  io_stream *f =3D io_stream::open ("cygfile:///etc/setup/last-cache", =
"wb");=0A=
+  if (f)=0A=
+    {=0A=
+      char temp[1000];=0A=
+      sprintf (temp, "%s", local_dir);=0A=
+      f->write (temp, strlen (temp));=0A=
+      delete f;=0A=
+    }=0A=
 }=0A=
 =0A=
-=0A=
 static void=0A=
 check_if_enable_next (HWND h)=0A=
 {=0A=
@@ -116,7 +107,6 @@ browse (HWND h)=0A=
     }=0A=
 }=0A=
 =0A=
-=0A=
 static BOOL=0A=
 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)=0A=
 {=0A=
@@ -176,6 +166,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -200,13 +191,13 @@ do_local_dir (HINSTANCE h)=0A=
   static int inited =3D 0;=0A=
   if (!inited)=0A=
     {=0A=
-      FILE *f =3D fopen (cygpath ("/etc/setup/last-cache", 0), "rt");=0A=
+      io_stream *f =3D=0A=
+	io_stream::open ("cygfile:///etc/setup/last-cache", "rt");=0A=
       if (f)=0A=
 	{=0A=
 	  char localdir[1000];=0A=
-	  localdir[0] =3D '\0';=0A=
-	  char *fg_ret =3D fgets (localdir, 1000, f);=0A=
-	  fclose (f);=0A=
+	  char *fg_ret =3D f->gets (localdir, 1000);=0A=
+	  delete f;=0A=
 	  if (fg_ret)=0A=
 	    {=0A=
 	      free (local_dir);=0A=
Index: log.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/log.cc,v=0A=
retrieving revision 2.4=0A=
diff -u -p -r2.4 log.cc=0A=
--- log.cc	2001/05/27 07:05:09	2.4=0A=
+++ log.cc	2001/11/11 06:54:57=0A=
@@ -15,7 +15,10 @@=0A=
 =0A=
 /* The purpose of this file is to centralize all the logging functions. =
*/=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: log.cc,v 2.4 2001/05/27 07:05:09 cgf =
Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: log.cc,v 2.4 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -32,7 +35,8 @@ static char *cvsid =3D "\n%%% $Id: log.cc,=0A=
 #include "mkdir.h"=0A=
 #include "mount.h"=0A=
 =0A=
-struct LogEnt {=0A=
+struct LogEnt=0A=
+{=0A=
   LogEnt *next;=0A=
   int flags;=0A=
   time_t when;=0A=
@@ -43,7 +47,7 @@ static LogEnt *first_logent =3D 0;=0A=
 static LogEnt **next_logent =3D &first_logent;=0A=
 =0A=
 void=0A=
-log (int flags, char *fmt, ...)=0A=
+log (int flags, const char *fmt, ...)=0A=
 {=0A=
   char buf[1000];=0A=
   va_list args;=0A=
@@ -70,7 +74,7 @@ log (int flags, char *fmt, ...)=0A=
 }=0A=
 =0A=
 void=0A=
-log_save (int babble, char *filename, int append)=0A=
+log_save (int babble, const char *filename, int append)=0A=
 {=0A=
   static int been_here =3D 0;=0A=
   if (been_here)=0A=
@@ -88,12 +92,12 @@ log_save (int babble, char *filename, in=0A=
 =0A=
   LogEnt *l;=0A=
 =0A=
-  for (l=3Dfirst_logent; l; l=3Dl->next)=0A=
+  for (l =3D first_logent; l; l =3D l->next)=0A=
     {=0A=
       if (babble || !(l->flags & LOG_BABBLE))=0A=
 	{=0A=
 	  fputs (l->msg, f);=0A=
-	  if (l->msg[strlen(l->msg)-1] !=3D '\n')=0A=
+	  if (l->msg[strlen (l->msg) - 1] !=3D '\n')=0A=
 	    fputc ('\n', f);=0A=
 	}=0A=
     }=0A=
Index: log.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/log.h,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 log.h=0A=
--- log.h	2000/08/25 01:32:08	2.1=0A=
+++ log.h	2001/11/11 06:54:57=0A=
@@ -20,13 +20,14 @@=0A=
 #define LOG_BABBLE	1=0A=
 #define LOG_TIMESTAMP	2=0A=
 =0A=
-void log (int flags, char *fmt, ...);=0A=
+void log (int flags, const char *fmt, ...)=0A=
+  __attribute__ ((format (printf, 2, 3)));=0A=
 =0A=
 /* Here, "babble" means to write out the babble also.  If "append" is=0A=
    nonzero, the log is appended to any existing file. */=0A=
 =0A=
-void log_save (int babble, char *filename, int append);=0A=
+void log_save (int babble, const char *filename, int append);=0A=
 =0A=
 /* This is the only legal way to exit.  It writes out all the logs and =
things */=0A=
 =0A=
-void exit_setup (int exit_code);=0A=
+void exit_setup (int exit_code) __attribute__ ((noreturn));=0A=
Index: main.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/main.cc,v=0A=
retrieving revision 2.8=0A=
diff -u -p -r2.8 main.cc=0A=
--- main.cc	2001/11/01 01:58:19	2.8=0A=
+++ main.cc	2001/11/11 06:54:57=0A=
@@ -23,7 +23,10 @@=0A=
    those don't count, although they could).  Replace the IDD_S_* with=0A=
    IDD_* if you create a real dialog for those steps. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: main.cc,v 2.8 2001/11/01 01:58:19 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: main.cc,v 2.8 2001/11/01 01:58:19 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -62,10 +65,10 @@ void=0A=
 set_default_dacl ()=0A=
 {=0A=
   /* To assure that the created files have a useful ACL, the =0A=
-  default DACL in the process token is set to full access to=0A=
-  everyone. This applies to files and subdirectories created=0A=
-  in directories which don't propagate permissions to child=0A=
-  objects. */=0A=
+     default DACL in the process token is set to full access to=0A=
+     everyone. This applies to files and subdirectories created=0A=
+     in directories which don't propagate permissions to child=0A=
+     objects. */=0A=
 =0A=
   /* Create a buffer which has enough room to contain the =
TOKEN_DEFAULT_DACL=0A=
      structure plus an ACL with one ACE. */=0A=
@@ -84,8 +87,8 @@ set_default_dacl ()=0A=
 =0A=
   /* Get the SID for "Everyone". */=0A=
   PSID sid;=0A=
-  SID_IDENTIFIER_AUTHORITY sid_auth =3D SECURITY_WORLD_SID_AUTHORITY;=0A=
-  if (!AllocateAndInitializeSid(&sid_auth, 1, 0, 0, 0, 0, 0, 0, 0, 0, =
&sid))=0A=
+  SID_IDENTIFIER_AUTHORITY sid_auth =3D { SECURITY_WORLD_SID_AUTHORITY =
};=0A=
+  if (!AllocateAndInitializeSid (&sid_auth, 1, 0, 0, 0, 0, 0, 0, 0, 0, =
&sid))=0A=
     {=0A=
       log (LOG_TIMESTAMP, "AllocateAndInitializeSid() failed: %lu",=0A=
 	   GetLastError ());=0A=
@@ -94,16 +97,18 @@ set_default_dacl ()=0A=
 =0A=
   /* Create the ACE which grants full access to "Everyone" and store it=0A=
      in dacl->DefaultDacl. */=0A=
-  if (!AddAccessAllowedAce (dacl->DefaultDacl, ACL_REVISION, =
GENERIC_ALL, sid))=0A=
+  if (!AddAccessAllowedAce=0A=
+      (dacl->DefaultDacl, ACL_REVISION, GENERIC_ALL, sid))=0A=
     {=0A=
-      log (LOG_TIMESTAMP, "AddAccessAllowedAce() failed: %lu", =
GetLastError ());=0A=
+      log (LOG_TIMESTAMP, "AddAccessAllowedAce() failed: %lu",=0A=
+	   GetLastError ());=0A=
       goto out;=0A=
     }=0A=
 =0A=
   /* Get the processes access token. */=0A=
   HANDLE token;=0A=
   if (!OpenProcessToken (GetCurrentProcess (),=0A=
-  			 TOKEN_READ | TOKEN_ADJUST_DEFAULT, &token))=0A=
+			 TOKEN_READ | TOKEN_ADJUST_DEFAULT, &token))=0A=
     {=0A=
       log (LOG_TIMESTAMP, "OpenProcessToken() failed: %lu", =
GetLastError ());=0A=
       goto out;=0A=
@@ -123,9 +128,7 @@ out:=0A=
 =0A=
 int WINAPI=0A=
 WinMain (HINSTANCE h,=0A=
-	 HINSTANCE hPrevInstance,=0A=
-	 LPSTR command_line,=0A=
-	 int cmd_show)=0A=
+	 HINSTANCE hPrevInstance, LPSTR command_line, int cmd_show)=0A=
 {=0A=
   hinstance =3D h;=0A=
 =0A=
@@ -144,7 +147,7 @@ WinMain (HINSTANCE h,=0A=
   for (argc =3D 0, argv =3D __argv; *argv; argv++)=0A=
     log (LOG_TIMESTAMP, "%d - '%s'\n", argc++, *argv);=0A=
   log (LOG_TIMESTAMP, "%d parameters passed\n", argc);=0A=
-  =0A=
+=0A=
   /* Set the default DACL only on NT/W2K. 9x/ME has no idea of access=0A=
      control lists and security at all. */=0A=
   if (iswinnt)=0A=
@@ -154,20 +157,48 @@ WinMain (HINSTANCE h,=0A=
     {=0A=
       switch (next_dialog)=0A=
 	{=0A=
-	case IDD_SPLASH:	do_splash (h);	break;=0A=
-	case IDD_SOURCE:	do_source (h);	break;=0A=
-	case IDD_LOCAL_DIR:	do_local_dir (h); break;=0A=
-	case IDD_ROOT:		do_root (h);	break;=0A=
-	case IDD_NET:		do_net (h);	break;=0A=
-	case IDD_SITE:		do_site (h);	break;=0A=
-	case IDD_OTHER_URL:	do_other (h);	break;=0A=
-	case IDD_S_LOAD_INI:	do_ini (h);	break;=0A=
-	case IDD_S_FROM_CWD:	do_fromcwd (h);	break;=0A=
-	case IDD_CHOOSE:	do_choose (h);	break;=0A=
-	case IDD_S_DOWNLOAD:	do_download (h); break;=0A=
-	case IDD_S_INSTALL:	do_install (h);	break;=0A=
-	case IDD_DESKTOP:	do_desktop (h); break;=0A=
-	case IDD_S_POSTINSTALL:	do_postinstall (h); break;=0A=
+	case IDD_SPLASH:=0A=
+	  do_splash (h);=0A=
+	  break;=0A=
+	case IDD_SOURCE:=0A=
+	  do_source (h);=0A=
+	  break;=0A=
+	case IDD_LOCAL_DIR:=0A=
+	  do_local_dir (h);=0A=
+	  break;=0A=
+	case IDD_ROOT:=0A=
+	  do_root (h);=0A=
+	  break;=0A=
+	case IDD_NET:=0A=
+	  do_net (h);=0A=
+	  break;=0A=
+	case IDD_SITE:=0A=
+	  do_site (h);=0A=
+	  break;=0A=
+	case IDD_OTHER_URL:=0A=
+	  do_other (h);=0A=
+	  break;=0A=
+	case IDD_S_LOAD_INI:=0A=
+	  do_ini (h);=0A=
+	  break;=0A=
+	case IDD_S_FROM_CWD:=0A=
+	  do_fromcwd (h);=0A=
+	  break;=0A=
+	case IDD_CHOOSE:=0A=
+	  do_choose (h);=0A=
+	  break;=0A=
+	case IDD_S_DOWNLOAD:=0A=
+	  do_download (h);=0A=
+	  break;=0A=
+	case IDD_S_INSTALL:=0A=
+	  do_install (h);=0A=
+	  break;=0A=
+	case IDD_DESKTOP:=0A=
+	  do_desktop (h);=0A=
+	  break;=0A=
+	case IDD_S_POSTINSTALL:=0A=
+	  do_postinstall (h);=0A=
+	  break;=0A=
 =0A=
 	default:=0A=
 	  next_dialog =3D 0;=0A=
@@ -176,4 +207,6 @@ WinMain (HINSTANCE h,=0A=
     }=0A=
 =0A=
   exit_setup (0);=0A=
+  /* Keep gcc happy :} */=0A=
+  return 0;=0A=
 }=0A=
Index: mkdir.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/mkdir.cc,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 mkdir.cc=0A=
--- mkdir.cc	2001/05/27 07:05:09	2.2=0A=
+++ mkdir.cc	2001/11/11 06:54:57=0A=
@@ -15,7 +15,10 @@=0A=
 =0A=
 /* see mkdir.h */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: mkdir.cc,v 2.2 2001/05/27 07:05:09 =
cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: mkdir.cc,v 2.2 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -45,7 +48,8 @@ mkdir_p (int isadir, const char *in_path=0A=
 	{=0A=
 	  if (gse =3D=3D ERROR_ALREADY_EXISTS)=0A=
 	    {=0A=
-	      fprintf (stderr, "warning: deleting \"%s\" so I can make a =
directory there\n",=0A=
+	      fprintf (stderr,=0A=
+		       "warning: deleting \"%s\" so I can make a directory there\n",=0A=
 		       path);=0A=
 	      if (DeleteFileA (path))=0A=
 		return mkdir_p (isadir, path);=0A=
Index: mklink2.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/mklink2.c,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 mklink2.c=0A=
--- mklink2.c	2000/08/08 00:27:54	2.0=0A=
+++ mklink2.c	2001/11/11 06:54:57=0A=
@@ -1,7 +1,12 @@=0A=
+#include <stdlib.h>=0A=
 #include "win32.h"=0A=
 #include "shlobj.h"=0A=
+#include "mklink2.h"=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: mklink2.c,v 2.0 2000/08/08 00:27:54 =
dj Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: mklink2.c,v 2.0 2000/08/08 00:27:54 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 /* This part of the code must be in C because the C++ interface to COM=0A=
 doesn't work. */=0A=
@@ -11,7 +16,7 @@ make_link_2 (char *exepath, char *args, =0A=
 {=0A=
   IShellLink *sl;=0A=
   IPersistFile *pf;=0A=
-  WCHAR widepath [_MAX_PATH];=0A=
+  WCHAR widepath[_MAX_PATH];=0A=
 =0A=
   CoCreateInstance (&CLSID_ShellLink, NULL,=0A=
 		    CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID *) & sl);=0A=
@@ -26,4 +31,31 @@ make_link_2 (char *exepath, char *args, =0A=
 =0A=
   pf->lpVtbl->Release (pf);=0A=
   sl->lpVtbl->Release (sl);=0A=
+}=0A=
+=0A=
+#define SYMLINK_COOKIE "!<symlink>"=0A=
+=0A=
+/* Predicate: file is not currently in existence.=0A=
+ * A file race can occur otherwise.=0A=
+ */=0A=
+int=0A=
+mkcygsymlink (const char *from, const char *to)=0A=
+{=0A=
+  char buf[512];=0A=
+  unsigned long w;=0A=
+  HANDLE h =3D CreateFileA (from, GENERIC_WRITE, 0, 0, CREATE_NEW,=0A=
+		   FILE_ATTRIBUTE_NORMAL, 0);=0A=
+  if (h =3D=3D INVALID_HANDLE_VALUE)=0A=
+    return 1;=0A=
+  strcpy (buf, SYMLINK_COOKIE);=0A=
+  strcat (buf, to);=0A=
+  if (WriteFile (h, buf, strlen (buf) + 1, &w, NULL))=0A=
+    {=0A=
+      CloseHandle (h);=0A=
+      SetFileAttributesA (from, FILE_ATTRIBUTE_SYSTEM);=0A=
+      return 0;=0A=
+    }=0A=
+  CloseHandle (h);=0A=
+  DeleteFileA (from);=0A=
+  return 1;=0A=
 }=0A=
Index: mount.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/mount.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 mount.cc=0A=
--- mount.cc	2001/10/31 13:15:05	2.6=0A=
+++ mount.cc	2001/11/11 06:54:57=0A=
@@ -17,7 +17,10 @@=0A=
    Cygwin's mount table.  If the format or location of the mount table=0A=
    changes, this is the file to change to match it. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: mount.cc,v 2.6 2001/10/31 13:15:05 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: mount.cc,v 2.6 2001/10/31 13:15:05 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -34,18 +37,18 @@ static char *cvsid =3D "\n%%% $Id: mount.c=0A=
 #include "concat.h"=0A=
 =0A=
 static struct mnt=0A=
-  {=0A=
-    const char *native;=0A=
-    char *posix;=0A=
-    int istext;=0A=
-  } mount_table[255];=0A=
+{=0A=
+  const char *native;=0A=
+  char *posix;=0A=
+  int istext;=0A=
+}=0A=
+mount_table[255];=0A=
 =0A=
 struct mnt *root_here =3D NULL;=0A=
 =0A=
 static char *=0A=
 find2 (HKEY rkey, int *istext, char *what)=0A=
 {=0A=
-  char buf[1000];=0A=
   char *retval =3D 0;=0A=
   DWORD retvallen =3D 0;=0A=
   DWORD flags =3D 0;=0A=
@@ -59,8 +62,9 @@ find2 (HKEY rkey, int *istext, char *wha=0A=
       =3D=3D ERROR_SUCCESS)=0A=
     {=0A=
       retval =3D (char *) malloc (MAX_PATH + 1);=0A=
-      if (RegQueryValueEx (key, "native", 0, &type, (BYTE *) retval, =
&retvallen)=0A=
-	  !=3D ERROR_SUCCESS)=0A=
+      if (RegQueryValueEx=0A=
+	  (key, "native", 0, &type, (BYTE *) retval,=0A=
+	   &retvallen) !=3D ERROR_SUCCESS)=0A=
 	{=0A=
 	  free (retval);=0A=
 	  retval =3D 0;=0A=
@@ -68,7 +72,7 @@ find2 (HKEY rkey, int *istext, char *wha=0A=
     }=0A=
 =0A=
   retvallen =3D sizeof (flags);=0A=
-  RegQueryValueEx (key, "flags", 0, &type, (BYTE *)&flags, &retvallen);=0A=
+  RegQueryValueEx (key, "flags", 0, &type, (BYTE *) & flags, =
&retvallen);=0A=
 =0A=
   RegCloseKey (key);=0A=
 =0A=
@@ -82,9 +86,8 @@ void=0A=
 create_mount (const char *posix, const char *win32, int istext, int =
issystem)=0A=
 {=0A=
   char buf[1000];=0A=
-  char *retval =3D 0;=0A=
   HKEY key;=0A=
-  DWORD retvallen =3D 0, disposition;=0A=
+  DWORD disposition;=0A=
   DWORD flags;=0A=
 =0A=
   remove_mount (posix);=0A=
@@ -92,23 +95,24 @@ create_mount (const char *posix, const c=0A=
   sprintf (buf, "Software\\%s\\%s\\%s\\%s",=0A=
 	   CYGWIN_INFO_CYGNUS_REGISTRY_NAME,=0A=
 	   CYGWIN_INFO_CYGWIN_REGISTRY_NAME,=0A=
-	   CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,=0A=
-	   posix);=0A=
+	   CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix);=0A=
 =0A=
   HKEY kr =3D issystem ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;=0A=
-  if (RegCreateKeyEx (kr, buf, 0, "Cygwin", 0, KEY_ALL_ACCESS,=0A=
+  if (RegCreateKeyEx (kr, buf, 0, (char *) "Cygwin", 0, KEY_ALL_ACCESS,=0A=
 		      0, &key, &disposition) !=3D ERROR_SUCCESS)=0A=
     fatal ("mount");=0A=
 =0A=
-  RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32, strlen =
(win32) + 1);=0A=
+  RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32,=0A=
+		 strlen (win32) + 1);=0A=
   flags =3D 0;=0A=
   if (!istext)=0A=
     flags |=3D MOUNT_BINARY;=0A=
   if (issystem)=0A=
     flags |=3D MOUNT_SYSTEM;=0A=
-  RegSetValueEx (key, "flags", 0, REG_DWORD, (BYTE *)&flags, sizeof =
(flags));=0A=
-  =0A=
-  RegCloseKey(key);=0A=
+  RegSetValueEx (key, "flags", 0, REG_DWORD, (BYTE *) & flags,=0A=
+		 sizeof (flags));=0A=
+=0A=
+  RegCloseKey (key);=0A=
   read_mounts ();=0A=
 }=0A=
 =0A=
@@ -120,8 +124,7 @@ remove1 (HKEY rkey, const char *posix)=0A=
   sprintf (buf, "Software\\%s\\%s\\%s\\%s",=0A=
 	   CYGWIN_INFO_CYGNUS_REGISTRY_NAME,=0A=
 	   CYGWIN_INFO_CYGWIN_REGISTRY_NAME,=0A=
-	   CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,=0A=
-	   posix);=0A=
+	   CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix);=0A=
 =0A=
   RegDeleteKey (rkey, buf);=0A=
 }=0A=
@@ -144,28 +147,28 @@ set_cygdrive_flags (HKEY key, int istext=0A=
       else=0A=
 	cygdrive_flags &=3D ~MOUNT_BINARY;=0A=
       RegSetValueEx (key, CYGWIN_INFO_CYGDRIVE_FLAGS, 0, REG_DWORD,=0A=
-		     (BYTE *)&cygdrive_flags, sizeof (cygdrive_flags));=0A=
+		     (BYTE *) & cygdrive_flags, sizeof (cygdrive_flags));=0A=
     }=0A=
 }=0A=
 =0A=
 static LONG=0A=
-get_cygdrive_flags (HKEY key, DWORD *cygdrive_flags)=0A=
+get_cygdrive_flags (HKEY key, DWORD * cygdrive_flags)=0A=
 {=0A=
-  DWORD retvallen =3D sizeof(*cygdrive_flags);=0A=
+  DWORD retvallen =3D sizeof (*cygdrive_flags);=0A=
   LONG status =3D RegQueryValueEx (key, CYGWIN_INFO_CYGDRIVE_FLAGS, 0, =
0,=0A=
-				 (BYTE *)cygdrive_flags, &retvallen);=0A=
+				 (BYTE *) cygdrive_flags, &retvallen);=0A=
   return status;=0A=
 }=0A=
 =0A=
 static DWORD=0A=
-default_cygdrive(HKEY key)=0A=
+default_cygdrive (HKEY key)=0A=
 {=0A=
   RegSetValueEx (key, CYGWIN_INFO_CYGDRIVE_PREFIX, 0, REG_SZ,=0A=
-		 (BYTE *)CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX,=0A=
+		 (BYTE *) CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX,=0A=
 		 strlen (CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX) + 1);=0A=
   DWORD cygdrive_flags =3D MOUNT_AUTO;=0A=
   RegSetValueEx (key, CYGWIN_INFO_CYGDRIVE_FLAGS, 0, REG_DWORD,=0A=
-		 (BYTE *)&cygdrive_flags, sizeof (cygdrive_flags));=0A=
+		 (BYTE *) & cygdrive_flags, sizeof (cygdrive_flags));=0A=
   return cygdrive_flags;=0A=
 }=0A=
 =0A=
@@ -185,7 +188,7 @@ set_cygdrive_flags (int istext, int issy=0A=
       HKEY key;=0A=
       DWORD disposition;=0A=
       LONG status =3D RegCreateKeyEx (HKEY_LOCAL_MACHINE, buf, 0, 0, 0,=0A=
-      				    KEY_ALL_ACCESS, 0, &key, &disposition);=0A=
+				    KEY_ALL_ACCESS, 0, &key, &disposition);=0A=
       if (status =3D=3D ERROR_SUCCESS)=0A=
 	{=0A=
 	  DWORD cygdrive_flags =3D 0;=0A=
@@ -195,14 +198,15 @@ set_cygdrive_flags (int istext, int issy=0A=
 	      set_cygdrive_flags (key, istext, cygdrive_flags);=0A=
 	      found_system =3D 1;=0A=
 	    }=0A=
-	  RegCloseKey(key);=0A=
+	  RegCloseKey (key);=0A=
 	}=0A=
     }=0A=
 =0A=
   HKEY key;=0A=
   DWORD disposition;=0A=
-  LONG status =3D RegCreateKeyEx (HKEY_CURRENT_USER, buf, 0, 0, 0, =
KEY_ALL_ACCESS,=0A=
-				0, &key, &disposition);=0A=
+  LONG status =3D=0A=
+    RegCreateKeyEx (HKEY_CURRENT_USER, buf, 0, 0, 0, KEY_ALL_ACCESS,=0A=
+		    0, &key, &disposition);=0A=
   if (status !=3D ERROR_SUCCESS)=0A=
     fatal ("set_cygdrive_flags");=0A=
 =0A=
@@ -210,20 +214,20 @@ set_cygdrive_flags (int istext, int issy=0A=
   status =3D get_cygdrive_flags (key, &cygdrive_flags);=0A=
   if (status =3D=3D ERROR_FILE_NOT_FOUND && !found_system)=0A=
     {=0A=
-      cygdrive_flags =3D default_cygdrive(key);=0A=
+      cygdrive_flags =3D default_cygdrive (key);=0A=
       status =3D ERROR_SUCCESS;=0A=
     }=0A=
 =0A=
   if (status =3D=3D ERROR_SUCCESS)=0A=
     set_cygdrive_flags (key, istext, cygdrive_flags);=0A=
 =0A=
-  RegCloseKey(key);=0A=
+  RegCloseKey (key);=0A=
 }=0A=
 =0A=
 static int=0A=
 in_table (struct mnt *m)=0A=
 {=0A=
-  for (struct mnt *m1 =3D mount_table; m1 < m; m1++)=0A=
+  for (struct mnt * m1 =3D mount_table; m1 < m; m1++)=0A=
     if (strcasecmp (m1->posix, m->posix) =3D=3D 0)=0A=
       return 1;=0A=
   return 0;=0A=
@@ -247,7 +251,7 @@ is_admin ()=0A=
 =0A=
   // Get the process token for the current process=0A=
   HANDLE token;=0A=
-  BOOL status =3D OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, =
&token);=0A=
+  BOOL status =3D OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, =
&token);=0A=
   if (!status)=0A=
     return 0;=0A=
 =0A=
@@ -255,26 +259,33 @@ is_admin ()=0A=
   UCHAR token_info[1024];=0A=
   PTOKEN_GROUPS groups =3D (PTOKEN_GROUPS) token_info;=0A=
   DWORD token_info_len =3D sizeof (token_info);=0A=
-  status =3D GetTokenInformation (token, TokenGroups, token_info, =
token_info_len, &token_info_len);=0A=
-  CloseHandle(token);=0A=
+  status =3D=0A=
+    GetTokenInformation (token, TokenGroups, token_info, token_info_len,=0A=
+			 &token_info_len);=0A=
+  CloseHandle (token);=0A=
   if (!status)=0A=
     return 0;=0A=
 =0A=
   // Create the Administrators group SID=0A=
   PSID admin_sid;=0A=
-  SID_IDENTIFIER_AUTHORITY authority =3D SECURITY_NT_AUTHORITY;=0A=
-  status =3D AllocateAndInitializeSid (&authority, 2, =
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, =
&admin_sid);=0A=
+  SID_IDENTIFIER_AUTHORITY authority =3D { SECURITY_NT_AUTHORITY };=0A=
+  status =3D=0A=
+    AllocateAndInitializeSid (&authority, 2, =
SECURITY_BUILTIN_DOMAIN_RID,=0A=
+			      DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,=0A=
+			      &admin_sid);=0A=
   if (!status)=0A=
     return 0;=0A=
 =0A=
   // Check to see if the user is a member of the Administrators group=0A=
   status =3D 0;=0A=
-  for (UINT i=3D0; i<groups->GroupCount; i++) {=0A=
-    if (EqualSid(groups->Groups[i].Sid, admin_sid)) {=0A=
-      status =3D 1;=0A=
-      break;=0A=
+  for (UINT i =3D 0; i < groups->GroupCount; i++)=0A=
+    {=0A=
+      if (EqualSid (groups->Groups[i].Sid, admin_sid))=0A=
+	{=0A=
+	  status =3D 1;=0A=
+	  break;=0A=
+	}=0A=
     }=0A=
-  }=0A=
 =0A=
   // Destroy the Administrators group SID=0A=
   FreeSid (admin_sid);=0A=
@@ -293,7 +304,7 @@ read_mounts ()=0A=
   char buf[10000];=0A=
 =0A=
   root_here =3D NULL;=0A=
-  for (mnt *m1 =3D mount_table; m1->posix; m1++)=0A=
+  for (mnt * m1 =3D mount_table; m1->posix; m1++)=0A=
     {=0A=
       free (m1->posix);=0A=
       if (m1->native)=0A=
@@ -313,10 +324,10 @@ read_mounts ()=0A=
 	       CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME);=0A=
 =0A=
       HKEY key =3D issystem ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;=0A=
-      if (RegCreateKeyEx (key, buf, 0, "Cygwin", 0, KEY_ALL_ACCESS,=0A=
+      if (RegCreateKeyEx (key, buf, 0, (char *) "Cygwin", 0, =
KEY_ALL_ACCESS,=0A=
 			  0, &key, &disposition) !=3D ERROR_SUCCESS)=0A=
 	break;=0A=
-      for (int i =3D 0; ;i++, m++)=0A=
+      for (int i =3D 0;; i++, m++)=0A=
 	{=0A=
 	  m->posix =3D (char *) malloc (MAX_PATH + 1);=0A=
 	  posix_path_size =3D MAX_PATH;=0A=
@@ -342,7 +353,7 @@ read_mounts ()=0A=
 	      m->native =3D find2 (key, &m->istext, m->posix);=0A=
 	      if (!m->native)=0A=
 		goto no_go;=0A=
-		  =0A=
+=0A=
 	      if (strcmp (m->posix, "/") =3D=3D 0)=0A=
 		{=0A=
 		  root_here =3D m;=0A=
@@ -371,7 +382,7 @@ read_mounts ()=0A=
       m->posix =3D strdup ("/");=0A=
       char windir[_MAX_PATH];=0A=
       root_text =3D IDC_ROOT_BINARY;=0A=
-      root_scope =3D (is_admin()) ? IDC_ROOT_SYSTEM : IDC_ROOT_USER;=0A=
+      root_scope =3D (is_admin ())? IDC_ROOT_SYSTEM : IDC_ROOT_USER;=0A=
       GetWindowsDirectory (windir, sizeof (windir));=0A=
       windir[2] =3D 0;=0A=
       set_root_dir (concat (windir, "\\cygwin", 0));=0A=
@@ -425,8 +436,8 @@ char *=0A=
 cygpath (const char *s, ...)=0A=
 {=0A=
   va_list v;=0A=
-  int i, max_len =3D -1;=0A=
-  struct mnt *m, *match;=0A=
+  int max_len =3D -1;=0A=
+  struct mnt *m, *match =3D NULL;=0A=
 =0A=
   va_start (v, s);=0A=
   char *path =3D vconcat (s, v);=0A=
@@ -435,7 +446,7 @@ cygpath (const char *s, ...)=0A=
   if (strncmp (path, "/./", 3) =3D=3D 0)=0A=
     memmove (path + 1, path + 3, strlen (path + 3) + 1);=0A=
 =0A=
-  for (m =3D mount_table; m->posix ; m++)=0A=
+  for (m =3D mount_table; m->posix; m++)=0A=
     {=0A=
       int n =3D strlen (m->posix);=0A=
       if (n < max_len || !path_prefix_p (m->posix, path, n))=0A=
@@ -444,8 +455,11 @@ cygpath (const char *s, ...)=0A=
       match =3D m;=0A=
     }=0A=
 =0A=
+  if (!match)=0A=
+    return NULL;=0A=
+=0A=
   char *native;=0A=
-  if (max_len =3D=3D strlen (path))=0A=
+  if (max_len =3D=3D (int) strlen (path))=0A=
     native =3D strdup (match->native);=0A=
   else=0A=
     native =3D concat (match->native, "/", path + max_len, NULL);=0A=
Index: mount.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/mount.h,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 mount.h=0A=
--- mount.h	2001/05/27 07:05:09	2.3=0A=
+++ mount.h	2001/11/11 06:54:57=0A=
@@ -17,13 +17,14 @@=0A=
    nonzero if the existing mount is a text mount, else zero for=0A=
    binary. */=0A=
 =0A=
-char *	find_mount (int *istext, int *issystem, char *path);=0A=
+char *find_mount (int *istext, int *issystem, char *path);=0A=
 =0A=
 /* Similar to the mount and umount functions, but simplified */=0A=
 =0A=
-void	create_mount (const char *posix, const char *win32, int istext, =
int issystem);=0A=
-void	remove_mount (const char *posix);=0A=
-void	read_mounts ();=0A=
+void create_mount (const char *posix, const char *win32, int istext,=0A=
+		   int issystem);=0A=
+void remove_mount (const char *posix);=0A=
+void read_mounts ();=0A=
 =0A=
 /* Sets the cygdrive flags.  Used to make the automounted drives' =
binary/text=0A=
 mode consistent with the standard Cygwin mounts. */=0A=
Index: msg.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/msg.cc,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 msg.cc=0A=
--- msg.cc	2000/08/25 01:32:08	2.1=0A=
+++ msg.cc	2001/11/11 06:54:57=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to centralize all the message=0A=
    functions. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: msg.cc,v 2.1 2000/08/25 01:32:08 dj =
Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: msg.cc,v 2.1 2000/08/25 01:32:08 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -25,7 +28,7 @@ static char *cvsid =3D "\n%%% $Id: msg.cc,=0A=
 #include "log.h"=0A=
 =0A=
 void=0A=
-msg (char *fmt, ...)=0A=
+msg (const char *fmt, ...)=0A=
 {=0A=
   char buf[1000];=0A=
   va_list args;=0A=
@@ -35,7 +38,7 @@ msg (char *fmt, ...)=0A=
 }=0A=
 =0A=
 static int=0A=
-mbox (char *name, int type, int id, va_list args)=0A=
+mbox (const char *name, int type, int id, va_list args)=0A=
 {=0A=
   char buf[1000], fmt[1000];=0A=
 =0A=
Index: msg.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/msg.h,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 msg.h=0A=
--- msg.h	2000/08/08 00:27:54	2.0=0A=
+++ msg.h	2001/11/11 06:54:57=0A=
@@ -17,7 +17,7 @@=0A=
    OutputDebugString, which can be seen while debugging under GDB or=0A=
    via a debug message monitor. */=0A=
 =0A=
-void msg(char *fmt, ...);=0A=
+void msg (const char *fmt, ...);=0A=
 =0A=
 /* This pops up a dialog with text from the string table ("id"), which=0A=
    is interpreted like printf.  The program exits when the user=0A=
Index: net.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/net.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 net.cc=0A=
--- net.cc	2001/11/01 13:22:46	2.6=0A=
+++ net.cc	2001/11/11 06:54:57=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to get the network configuration=0A=
    information from the user. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: net.cc,v 2.6 2001/11/01 13:22:46 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: net.cc,v 2.6 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -108,6 +111,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -119,11 +123,14 @@ dialog_proc (HWND h, UINT message, WPARA=0A=
       load_dialog (h);=0A=
 =0A=
       // Check to see if any radio buttons are selected. If not, select =
a default.=0A=
-      if ((!SendMessage(GetDlgItem (h, IDC_NET_IE5), BM_GETCHECK, 0, 0) =
=3D=3D BST_CHECKED)=0A=
-        && (!SendMessage(GetDlgItem (h, IDC_NET_PROXY), BM_GETCHECK, 0, =
0) =3D=3D BST_CHECKED))=0A=
-        {=0A=
-          SendMessage(GetDlgItem (h, IDC_NET_DIRECT), BM_CLICK, 0, 0);=0A=
-        }=0A=
+      if (=0A=
+	  (!SendMessage (GetDlgItem (h, IDC_NET_IE5), BM_GETCHECK, 0, 0) =3D=3D=0A=
+	   BST_CHECKED)=0A=
+	  && (!SendMessage (GetDlgItem (h, IDC_NET_PROXY), BM_GETCHECK, 0, 0)=0A=
+	      =3D=3D BST_CHECKED))=0A=
+	{=0A=
+	  SendMessage (GetDlgItem (h, IDC_NET_DIRECT), BM_CLICK, 0, 0);=0A=
+	}=0A=
       return FALSE;=0A=
     case WM_COMMAND:=0A=
       return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);=0A=
@@ -145,4 +152,3 @@ do_net (HINSTANCE h)=0A=
        (net_method =3D=3D IDC_NET_IE5) ? "IE5" :=0A=
        (net_method =3D=3D IDC_NET_DIRECT) ? "Direct" : "Proxy");=0A=
 }=0A=
-=0A=
Index: netio.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/netio.cc,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 netio.cc=0A=
--- netio.cc	2001/05/28 08:31:02	2.3=0A=
+++ netio.cc	2001/11/11 06:54:57=0A=
@@ -17,7 +17,10 @@=0A=
    methods known to setup.  To add a new method, create a pair of=0A=
    nio-*.[ch] files and add the logic to NetIO::open here */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: netio.cc,v 2.3 2001/05/28 08:31:02 =
corinna Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: netio.cc,v 2.3 2001/05/28 08:31:02 corinna Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -78,7 +81,7 @@ NetIO::set_url (char *Purl)=0A=
   *ep =3D 0;=0A=
   proto =3D _strdup (bp);=0A=
   *ep =3D ':';=0A=
-  bp =3D ep+3;=0A=
+  bp =3D ep + 3;=0A=
 =0A=
   ep =3D bp + strcspn (bp, ":/");=0A=
   c =3D *ep;=0A=
@@ -88,7 +91,7 @@ NetIO::set_url (char *Purl)=0A=
 =0A=
   if (*ep =3D=3D ':')=0A=
     {=0A=
-      port =3D atoi (ep+1);=0A=
+      port =3D atoi (ep + 1);=0A=
       ep =3D strchr (ep, '/');=0A=
     }=0A=
 =0A=
@@ -112,7 +115,9 @@ NetIO *=0A=
 NetIO::open (char *url, BOOL allow_ftp_auth)=0A=
 {=0A=
   NetIO *rv =3D 0;=0A=
-  enum {http, ftp, file} proto;=0A=
+  enum=0A=
+  { http, ftp, file }=0A=
+  proto;=0A=
   if (strncmp (url, "http://", 7) =3D=3D 0)=0A=
     proto =3D http;=0A=
   else if (strncmp (url, "ftp://", 6) =3D=3D 0)=0A=
@@ -136,6 +141,9 @@ NetIO::open (char *url, BOOL allow_ftp_a=0A=
 	case ftp:=0A=
 	  rv =3D new NetIO_FTP (url, allow_ftp_auth);=0A=
 	  break;=0A=
+	case file:=0A=
+	  rv =3D new NetIO_File (url);=0A=
+	  break;=0A=
 	}=0A=
     }=0A=
 =0A=
@@ -203,6 +211,7 @@ auth_cmd (HWND h, int id, HWND hwndctl, =0A=
       exit_setup (1);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
Index: netio.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/netio.h,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 netio.h=0A=
--- netio.h	2001/05/28 08:31:02	2.2=0A=
+++ netio.h	2001/11/11 06:54:57=0A=
@@ -16,7 +16,8 @@=0A=
 /* This is the parent class for all the access methods known to setup=0A=
    (i.e. ways to download files from the internet or other sources */=0A=
 =0A=
-class NetIO {=0A=
+class NetIO=0A=
+{=0A=
 protected:=0A=
   NetIO (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
   void set_url (char *url);=0A=
@@ -31,13 +32,13 @@ public:=0A=
   char *host;=0A=
   int port;=0A=
   char *path;=0A=
-  virtual ~NetIO ();=0A=
+    virtual ~ NetIO ();=0A=
 =0A=
   /* The user calls this function to create a suitable accessor for=0A=
      the given URL.  It uses the network setup state in state.h.  If=0A=
      anything fails, either the return values is NULL or the returned=0A=
      object is !ok() */=0A=
-  static NetIO * open (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
+  static NetIO *open (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
 =0A=
   /* If !ok() that means the transfer isn't happening. */=0A=
   virtual int ok ();=0A=
Index: nio-file.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-file.cc,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 nio-file.cc=0A=
--- nio-file.cc	2001/06/13 16:11:01	2.2=0A=
+++ nio-file.cc	2001/11/11 06:54:57=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to manage access to files stored on the=0A=
    local disk (i.e. "downloading" setup.ini).  Called from netio.cc */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: nio-file.cc,v 2.2 2001/06/13 =
16:11:01 cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: nio-file.cc,v 2.2 2001/06/13 16:11:01 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -29,18 +32,17 @@ static char *cvsid =3D "\n%%% $Id: nio-fil=0A=
 #include "msg.h"=0A=
 #include "filemanip.h"=0A=
 =0A=
-NetIO_File::NetIO_File (char *Purl)=0A=
-  : NetIO (Purl)=0A=
+NetIO_File::NetIO_File (char *Purl):=0A=
+NetIO (Purl)=0A=
 {=0A=
-  struct stat s;=0A=
   fd =3D fopen (path, "rb");=0A=
   if (fd)=0A=
     {=0A=
-      file_size =3D get_file_size(path);=0A=
+      file_size =3D get_file_size (path);=0A=
     }=0A=
   else=0A=
     {=0A=
-      char *err =3D strerror (errno);=0A=
+      const char *err =3D strerror (errno);=0A=
       if (!err)=0A=
 	err =3D "(unknown error)";=0A=
       note (IDS_ERR_OPEN_READ, path, err);=0A=
@@ -50,7 +52,7 @@ NetIO_File::NetIO_File (char *Purl)=0A=
 NetIO_File::~NetIO_File ()=0A=
 {=0A=
   if (fd)=0A=
-    fclose ((FILE *)fd);=0A=
+    fclose ((FILE *) fd);=0A=
 }=0A=
 =0A=
 int=0A=
@@ -62,5 +64,5 @@ NetIO_File::ok ()=0A=
 int=0A=
 NetIO_File::read (char *buf, int nbytes)=0A=
 {=0A=
-  return fread (buf, 1, nbytes, (FILE *)fd);=0A=
+  return fread (buf, 1, nbytes, (FILE *) fd);=0A=
 }=0A=
Index: nio-file.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-file.h,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 nio-file.h=0A=
--- nio-file.h	2000/08/08 00:27:54	2.0=0A=
+++ nio-file.h	2001/11/11 06:54:57=0A=
@@ -15,11 +15,12 @@=0A=
 =0A=
 /* see nio-file.cc */=0A=
 =0A=
-class NetIO_File : public NetIO {=0A=
+class NetIO_File:public NetIO=0A=
+{=0A=
 public:=0A=
   NetIO_File (char *url);=0A=
   void *fd;=0A=
-  ~NetIO_File ();=0A=
+   ~NetIO_File ();=0A=
   virtual int ok ();=0A=
   virtual int read (char *buf, int nbytes);=0A=
 };=0A=
Index: nio-ftp.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-ftp.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 nio-ftp.cc=0A=
--- nio-ftp.cc	2001/11/09 13:03:02	2.6=0A=
+++ nio-ftp.cc	2001/11/11 06:54:57=0A=
@@ -17,7 +17,8 @@=0A=
    channels.  It is intentionally simplistic. */=0A=
 =0A=
 #if 0=0A=
-static const char *cvsid =3D "\n%%% $Id: nio-ftp.cc,v 2.6 2001/11/09 =
13:03:02 rbcollins Exp $\n";=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: nio-ftp.cc,v 2.6 2001/11/09 13:03:02 rbcollins Exp $\n";=0A=
 #endif=0A=
 =0A=
 #include "win32.h"=0A=
@@ -41,20 +42,22 @@ static int cmd_port =3D 0;=0A=
 static char *last_line;=0A=
 =0A=
 static int=0A=
-ftp_line (SimpleSocket *s)=0A=
+ftp_line (SimpleSocket * s)=0A=
 {=0A=
-  do {=0A=
-    last_line =3D s->gets ();=0A=
-    log (LOG_BABBLE, "ftp > %s", last_line ? last_line : "error");=0A=
-  } while (last_line && (!isdigit (last_line[0]) || last_line[3] !=3D ' =
'));=0A=
-  return atoi (last_line ?: "0");=0A=
+  do=0A=
+    {=0A=
+      last_line =3D s->gets ();=0A=
+      log (LOG_BABBLE, "ftp > %s", last_line ? last_line : "error");=0A=
+    }=0A=
+  while (last_line && (!isdigit (last_line[0]) || last_line[3] !=3D ' =
'));=0A=
+  return atoi (last_line ? : "0");=0A=
 }=0A=
 =0A=
-NetIO_FTP::NetIO_FTP (char *Purl, BOOL allow_ftp_auth)=0A=
-  : NetIO (Purl, allow_ftp_auth)=0A=
+NetIO_FTP::NetIO_FTP (char *Purl, BOOL allow_ftp_auth):NetIO (Purl, =
allow_ftp_auth)=0A=
 {=0A=
   s =3D 0;=0A=
-  int code;=0A=
+  int=0A=
+    code;=0A=
 =0A=
   if (port =3D=3D 0)=0A=
     port =3D 21;=0A=
@@ -63,7 +66,8 @@ NetIO_FTP::NetIO_FTP (char *Purl, BOOL a=0A=
     {=0A=
       if (cmd)=0A=
 	cmd->printf ("QUIT\r\n");=0A=
-      delete cmd;=0A=
+      delete=0A=
+	cmd;=0A=
       free (cmd_host);=0A=
       cmd =3D 0;=0A=
       cmd_host =3D 0;=0A=
@@ -71,14 +75,15 @@ NetIO_FTP::NetIO_FTP (char *Purl, BOOL a=0A=
 =0A=
   if (cmd =3D=3D 0)=0A=
     {=0A=
-      SimpleSocket *c =3D new SimpleSocket (host, port);=0A=
+      SimpleSocket *=0A=
+	c =3D new SimpleSocket (host, port);=0A=
       code =3D ftp_line (c);=0A=
 =0A=
-auth_retry:=0A=
+    auth_retry:=0A=
       if (net_ftp_user)=0A=
-        c->printf ("USER %s\r\n", net_ftp_user);=0A=
+	c->printf ("USER %s\r\n", net_ftp_user);=0A=
       else=0A=
-        c->printf ("USER anonymous\r\n");=0A=
+	c->printf ("USER anonymous\r\n");=0A=
       code =3D ftp_line (c);=0A=
       if (code =3D=3D 331)=0A=
 	{=0A=
@@ -88,8 +93,8 @@ auth_retry:=0A=
 	    c->printf ("PASS cygwin-setup@\r\n");=0A=
 	  code =3D ftp_line (c);=0A=
 	}=0A=
-      if (code =3D=3D 530) /* Authentication failed, retry */=0A=
-        {=0A=
+      if (code =3D=3D 530)		/* Authentication failed, retry */=0A=
+	{=0A=
 	  get_ftp_auth ();=0A=
 	  if (net_ftp_user && net_ftp_passwd)=0A=
 	    goto auth_retry;=0A=
@@ -97,7 +102,8 @@ auth_retry:=0A=
 =0A=
       if (code < 200 || code >=3D 300)=0A=
 	{=0A=
-	  delete c;=0A=
+	  delete=0A=
+	    c;=0A=
 	  return;=0A=
 	}=0A=
 =0A=
@@ -110,27 +116,33 @@ auth_retry:=0A=
     }=0A=
 =0A=
   cmd->printf ("PASV\r\n");=0A=
-  do {=0A=
-    code =3D ftp_line (cmd);=0A=
-  } while (code =3D=3D 226); /* previous RETR */=0A=
+  do=0A=
+    {=0A=
+      code =3D ftp_line (cmd);=0A=
+    }=0A=
+  while (code =3D=3D 226);		/* previous RETR */=0A=
   if (code !=3D 227)=0A=
     return;=0A=
 =0A=
-  char *paren =3D strchr (last_line, '(');=0A=
+  char *=0A=
+    paren =3D strchr (last_line, '(');=0A=
   if (!paren)=0A=
     return;=0A=
 =0A=
-  int i1, i2, i3, i4, p1, p2;=0A=
-  sscanf (paren+1, "%d,%d,%d,%d,%d,%d", &i1, &i2, &i3, &i4, &p1, &p2);=0A=
-  char tmp[20];=0A=
+  int=0A=
+    i1, i2, i3, i4, p1, p2;=0A=
+  sscanf (paren + 1, "%d,%d,%d,%d,%d,%d", &i1, &i2, &i3, &i4, &p1, &p2);=0A=
+  char=0A=
+    tmp[20];=0A=
   sprintf (tmp, "%d.%d.%d.%d", i1, i2, i3, i4);=0A=
-  s =3D new SimpleSocket (tmp, p1*256 + p2);=0A=
+  s =3D new SimpleSocket (tmp, p1 * 256 + p2);=0A=
 =0A=
   cmd->printf ("RETR %s\r\n", path);=0A=
   code =3D ftp_line (cmd);=0A=
   if (code !=3D 150 && code !=3D 125)=0A=
     {=0A=
-      delete s;=0A=
+      delete=0A=
+	s;=0A=
       s =3D 0;=0A=
       return;=0A=
     }=0A=
Index: nio-ftp.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-ftp.h,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 nio-ftp.h=0A=
--- nio-ftp.h	2001/05/28 08:31:02	2.2=0A=
+++ nio-ftp.h	2001/11/11 06:54:57=0A=
@@ -17,12 +17,13 @@=0A=
 =0A=
 class SimpleSocket;=0A=
 =0A=
-class NetIO_FTP : public NetIO {=0A=
+class NetIO_FTP:public NetIO=0A=
+{=0A=
   SimpleSocket *s;=0A=
 =0A=
 public:=0A=
-  NetIO_FTP (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
-  virtual ~NetIO_FTP ();=0A=
+    NetIO_FTP (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
+    virtual ~ NetIO_FTP ();=0A=
 =0A=
   /* If !ok() that means the transfer isn't happening. */=0A=
   virtual int ok ();=0A=
Index: nio-http.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-http.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 nio-http.cc=0A=
--- nio-http.cc	2001/11/09 13:03:02	2.6=0A=
+++ nio-http.cc	2001/11/11 06:54:57=0A=
@@ -17,7 +17,8 @@=0A=
    channels.  It is intentionally simplistic. */=0A=
 =0A=
 #if 0=0A=
-static const char *cvsid =3D "\n%%% $Id: nio-http.cc,v 2.6 2001/11/09 =
13:03:02 rbcollins Exp $\n";=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: nio-http.cc,v 2.6 2001/11/09 13:03:02 rbcollins Exp $\n";=0A=
 #endif=0A=
 =0A=
 #include "win32.h"=0A=
@@ -35,11 +36,11 @@ static const char *cvsid =3D "\n%%% $Id: n=0A=
 #include "nio-http.h"=0A=
 =0A=
 static char six2pr[64] =3D {=0A=
-    'A','B','C','D','E','F','G','H','I','J','K','L','M',=0A=
-    'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',=0A=
-    'a','b','c','d','e','f','g','h','i','j','k','l','m',=0A=
-    'n','o','p','q','r','s','t','u','v','w','x','y','z',=0A=
-    '0','1','2','3','4','5','6','7','8','9','+','/'=0A=
+  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',=0A=
+  'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',=0A=
+  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',=0A=
+  'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',=0A=
+  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'=0A=
 };=0A=
 =0A=
 static char *=0A=
@@ -56,7 +57,7 @@ base64_encode (char *username, char *pas=0A=
   strcpy (up, username);=0A=
   strcat (up, ":");=0A=
   strcat (up, password);=0A=
-  ep =3D (unsigned char *)up + strlen (up);=0A=
+  ep =3D (unsigned char *) up + strlen (up);=0A=
   *ep++ =3D 0;=0A=
   *ep++ =3D 0;=0A=
   *ep++ =3D 0;=0A=
@@ -65,7 +66,7 @@ base64_encode (char *username, char *pas=0A=
 =0A=
   rp =3D rv;=0A=
 =0A=
-  for (ep =3D (unsigned char *)up; *ep; ep +=3D 3)=0A=
+  for (ep =3D (unsigned char *) up; *ep; ep +=3D 3)=0A=
     {=0A=
       block[0] =3D six2pr[ep[0] >> 2];=0A=
       block[1] =3D six2pr[((ep[0] << 4) & 0x30) | ((ep[1] >> 4) & =
0x0f)];=0A=
@@ -86,10 +87,9 @@ base64_encode (char *username, char *pas=0A=
   return rv;=0A=
 }=0A=
 =0A=
-NetIO_HTTP::NetIO_HTTP (char *Purl, BOOL allow_ftp_auth)=0A=
-  : NetIO (Purl, allow_ftp_auth)=0A=
+NetIO_HTTP::NetIO_HTTP (char *Purl, BOOL allow_ftp_auth):NetIO (Purl, =
allow_ftp_auth)=0A=
 {=0A=
- retry_get:=0A=
+retry_get:=0A=
   if (port =3D=3D 0)=0A=
     port =3D 80;=0A=
 =0A=
@@ -98,9 +98,10 @@ NetIO_HTTP::NetIO_HTTP (char *Purl, BOOL=0A=
   else=0A=
     s =3D new SimpleSocket (host, port);=0A=
 =0A=
-  if (!s->ok())=0A=
+  if (!s->ok ())=0A=
     {=0A=
-      delete s;=0A=
+      delete=0A=
+	s;=0A=
       s =3D NULL;=0A=
       return;=0A=
     }=0A=
@@ -121,61 +122,69 @@ NetIO_HTTP::NetIO_HTTP (char *Purl, BOOL=0A=
 =0A=
   s->printf ("\r\n");=0A=
 =0A=
-  char *l =3D s->gets ();=0A=
-  int code;=0A=
+  char *=0A=
+    l =3D s->gets ();=0A=
+  int=0A=
+    code;=0A=
   if (!l)=0A=
     return;=0A=
   sscanf (l, "%*s %d", &code);=0A=
   if (code >=3D 300 && code < 400)=0A=
     {=0A=
-      while ((l =3D s->gets ()) !=3D 0) {=0A=
-	if (_strnicmp (l, "Location:", 9) =3D=3D 0)=0A=
-	  {=0A=
-	    char *u =3D l + 9;=0A=
-	    while (*u =3D=3D ' ' || *u =3D=3D '\t')=0A=
-	      u++;=0A=
-	    set_url (u);=0A=
-	    delete s;=0A=
-	    goto retry_get;=0A=
-	  }=0A=
-      }=0A=
+      while ((l =3D s->gets ()) !=3D 0)=0A=
+	{=0A=
+	  if (_strnicmp (l, "Location:", 9) =3D=3D 0)=0A=
+	    {=0A=
+	      char *=0A=
+		u =3D l + 9;=0A=
+	      while (*u =3D=3D ' ' || *u =3D=3D '\t')=0A=
+		u++;=0A=
+	      set_url (u);=0A=
+	      delete=0A=
+		s;=0A=
+	      goto retry_get;=0A=
+	    }=0A=
+	}=0A=
     }=0A=
-  if (code =3D=3D 401) /* authorization required */=0A=
+  if (code =3D=3D 401)		/* authorization required */=0A=
     {=0A=
       get_auth ();=0A=
-      delete s;=0A=
+      delete=0A=
+	s;=0A=
       goto retry_get;=0A=
     }=0A=
-  if (code =3D=3D 407) /* proxy authorization required */=0A=
+  if (code =3D=3D 407)		/* proxy authorization required */=0A=
     {=0A=
       get_proxy_auth ();=0A=
-      delete s;=0A=
+      delete=0A=
+	s;=0A=
       goto retry_get;=0A=
     }=0A=
-  if (code =3D=3D 500 /* ftp authentication through proxy required */=0A=
-      && net_method =3D=3D IDC_NET_PROXY=0A=
-      && !strncmp (url, "ftp://", 6))=0A=
+  if (code =3D=3D 500		/* ftp authentication through proxy required */=0A=
+      && net_method =3D=3D IDC_NET_PROXY && !strncmp (url, "ftp://", 6))=0A=
     {=0A=
       get_ftp_auth ();=0A=
       if (net_ftp_user && net_ftp_passwd)=0A=
-        {=0A=
-	  delete s;=0A=
+	{=0A=
+	  delete=0A=
+	    s;=0A=
 	  url =3D concat ("ftp://", net_ftp_user,=0A=
-	  		":", net_ftp_passwd,=0A=
-			"@", url + 6, 0);=0A=
-          goto retry_get;=0A=
+			":", net_ftp_passwd, "@", url + 6, 0);=0A=
+	  goto retry_get;=0A=
 	}=0A=
     }=0A=
   if (code >=3D 300)=0A=
     {=0A=
-      delete s;=0A=
+      delete=0A=
+	s;=0A=
       s =3D 0;=0A=
       return;=0A=
+    }=0A=
+  while ((l =3D s->gets ()) !=3D 0)=0A=
+    {=0A=
+      if (_strnicmp (l, "Content-Length:", 15) =3D=3D 0)=0A=
+	sscanf (l, "%*s %d", &file_size);=0A=
     }=0A=
-  while ((l =3D s->gets ()) !=3D 0) {=0A=
-    if (_strnicmp (l, "Content-Length:", 15) =3D=3D 0)=0A=
-      sscanf (l, "%*s %d", &file_size);=0A=
-  }=0A=
 }=0A=
 =0A=
 NetIO_HTTP::~NetIO_HTTP ()=0A=
Index: nio-http.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-http.h,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 nio-http.h=0A=
--- nio-http.h	2001/05/28 08:31:02	2.2=0A=
+++ nio-http.h	2001/11/11 06:54:57=0A=
@@ -17,12 +17,13 @@=0A=
 =0A=
 class SimpleSocket;=0A=
 =0A=
-class NetIO_HTTP : public NetIO {=0A=
+class NetIO_HTTP:public NetIO=0A=
+{=0A=
   SimpleSocket *s;=0A=
 =0A=
 public:=0A=
-  NetIO_HTTP (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
-  virtual ~NetIO_HTTP ();=0A=
+    NetIO_HTTP (char *url, BOOL allow_ftp_auth =3D FALSE);=0A=
+    virtual ~ NetIO_HTTP ();=0A=
 =0A=
   /* If !ok() that means the transfer isn't happening. */=0A=
   virtual int ok ();=0A=
Index: nio-ie5.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-ie5.cc,v=0A=
retrieving revision 2.2=0A=
diff -u -p -r2.2 nio-ie5.cc=0A=
--- nio-ie5.cc	2000/08/30 01:05:42	2.2=0A=
+++ nio-ie5.cc	2001/11/11 06:54:57=0A=
@@ -18,7 +18,10 @@=0A=
    must already have installed and configured IE5.  This module is=0A=
    called from netio.cc, which is called from geturl.cc */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: nio-ie5.cc,v 2.2 2000/08/30 01:05:42 =
dj Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: nio-ie5.cc,v 2.2 2000/08/30 01:05:42 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -31,8 +34,8 @@ static char *cvsid =3D "\n%%% $Id: nio-ie5=0A=
 =0A=
 static HINTERNET internet =3D 0;=0A=
 =0A=
-NetIO_IE5::NetIO_IE5 (char *_url)=0A=
-  : NetIO (_url)=0A=
+NetIO_IE5::NetIO_IE5 (char *_url):=0A=
+NetIO (_url)=0A=
 {=0A=
   int resend =3D 0;=0A=
 =0A=
@@ -55,12 +58,11 @@ NetIO_IE5::NetIO_IE5 (char *_url)=0A=
     INTERNET_FLAG_KEEP_CONNECTION |=0A=
     INTERNET_FLAG_PRAGMA_NOCACHE |=0A=
     INTERNET_FLAG_RELOAD |=0A=
-    INTERNET_FLAG_EXISTING_CONNECT |=0A=
-    INTERNET_FLAG_PASSIVE;=0A=
+    INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_PASSIVE;=0A=
 =0A=
   connection =3D InternetOpenUrl (internet, url, NULL, 0, flags, 0);=0A=
 =0A=
- try_again:=0A=
+try_again:=0A=
 =0A=
   if (net_user && net_passwd)=0A=
     {=0A=
@@ -87,7 +89,7 @@ NetIO_IE5::NetIO_IE5 (char *_url)=0A=
       if (GetLastError () =3D=3D ERROR_INTERNET_EXTENDED_ERROR)=0A=
 	{=0A=
 	  char buf[2000];=0A=
-	  DWORD e, l=3Dsizeof (buf);=0A=
+	  DWORD e, l =3D sizeof (buf);=0A=
 	  InternetGetLastResponseInfo (&e, buf, &l);=0A=
 	  MessageBox (0, buf, "Internet Error", 0);=0A=
 	}=0A=
@@ -107,16 +109,16 @@ NetIO_IE5::NetIO_IE5 (char *_url)=0A=
 			 HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,=0A=
 			 &type, &type_s, NULL))=0A=
 	{=0A=
-	  if (type =3D=3D 401) /* authorization required */=0A=
+	  if (type =3D=3D 401)	/* authorization required */=0A=
 	    {=0A=
-	      flush_io();=0A=
+	      flush_io ();=0A=
 	      get_auth ();=0A=
 	      resend =3D 1;=0A=
 	      goto try_again;=0A=
 	    }=0A=
-	  else if (type =3D=3D 407) /* proxy authorization required */=0A=
+	  else if (type =3D=3D 407)	/* proxy authorization required */=0A=
 	    {=0A=
-	      flush_io();=0A=
+	      flush_io ();=0A=
 	      get_proxy_auth ();=0A=
 	      resend =3D 1;=0A=
 	      goto try_again;=0A=
@@ -135,9 +137,11 @@ NetIO_IE5::flush_io ()=0A=
 {=0A=
   DWORD actual =3D 0;=0A=
   char buf[1024];=0A=
-  do {=0A=
-    InternetReadFile (connection, buf, 1024, &actual);=0A=
-  } while (actual > 0);=0A=
+  do=0A=
+    {=0A=
+      InternetReadFile (connection, buf, 1024, &actual);=0A=
+    }=0A=
+  while (actual > 0);=0A=
 }=0A=
 =0A=
 NetIO_IE5::~NetIO_IE5 ()=0A=
Index: nio-ie5.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/nio-ie5.h,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 nio-ie5.h=0A=
--- nio-ie5.h	2000/08/24 02:48:14	2.1=0A=
+++ nio-ie5.h	2001/11/11 06:54:57=0A=
@@ -15,12 +15,13 @@=0A=
 =0A=
 /* see nio-ie5.cc */=0A=
 =0A=
-class NetIO_IE5 : public NetIO {=0A=
+class NetIO_IE5:public NetIO=0A=
+{=0A=
   HINTERNET connection;=0A=
 public:=0A=
-  NetIO_IE5 (char *url);=0A=
-  ~NetIO_IE5 ();=0A=
+    NetIO_IE5 (char *url);=0A=
+   ~NetIO_IE5 ();=0A=
   virtual int ok ();=0A=
   virtual int read (char *buf, int nbytes);=0A=
-  void flush_io();=0A=
+  void flush_io ();=0A=
 };=0A=
Index: other.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/other.cc,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 other.cc=0A=
--- other.cc	2000/08/25 01:32:08	2.1=0A=
+++ other.cc	2001/11/11 06:54:57=0A=
@@ -16,7 +16,10 @@=0A=
 /* This handles the "other URL" option from the mirror site=0A=
    selection. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: other.cc,v 2.1 2000/08/25 01:32:08 =
dj Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: other.cc,v 2.1 2000/08/25 01:32:08 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <shlobj.h>=0A=
@@ -76,6 +79,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -102,4 +106,3 @@ do_other (HINSTANCE h)=0A=
 =0A=
   log (0, "site: %s", other_url);=0A=
 }=0A=
-=0A=
Index: port.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/port.h,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 port.h=0A=
--- port.h	2000/08/08 00:27:54	2.0=0A=
+++ port.h	2001/11/11 06:54:57=0A=
@@ -24,5 +24,4 @@=0A=
 =0A=
 #define _access access=0A=
 #define _strdup strdup=0A=
-=0A=
 #endif=0A=
Index: postinstall.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/postinstall.cc,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 postinstall.cc=0A=
--- postinstall.cc	2001/10/27 15:56:47	2.3=0A=
+++ postinstall.cc	2001/11/11 06:54:57=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to run all the post-install scripts=0A=
    in their various forms. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: postinstall.cc,v 2.3 2001/10/27 =
15:56:47 cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: postinstall.cc,v 2.3 2001/10/27 15:56:47 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 =0A=
@@ -32,14 +35,14 @@ static char *cvsid =3D "\n%%% $Id: postins=0A=
 #include "port.h"=0A=
 =0A=
 static char *sh =3D 0;=0A=
-static char *cmd =3D 0;=0A=
+static const char *cmd =3D 0;=0A=
 static OSVERSIONINFO verinfo;=0A=
 =0A=
 static void=0A=
-run (char *sh, char *args, char *file)=0A=
+run (const char *sh, const char *args, const char *file)=0A=
 {=0A=
   BOOL b;=0A=
-  char cmdline [_MAX_PATH];=0A=
+  char cmdline[_MAX_PATH];=0A=
   STARTUPINFO si;=0A=
   PROCESS_INFORMATION pi;=0A=
 =0A=
@@ -47,7 +50,7 @@ run (char *sh, char *args, char *file)=0A=
   memset (&pi, 0, sizeof (pi));=0A=
   memset (&si, 0, sizeof (si));=0A=
   si.cb =3D sizeof (si);=0A=
-  si.lpTitle =3D "Cygwin Setup Post-Install Script";=0A=
+  si.lpTitle =3D (char *) "Cygwin Setup Post-Install Script";=0A=
   si.dwFlags =3D STARTF_USEPOSITION;=0A=
 =0A=
   b =3D CreateProcess (0, cmdline, 0, 0, 0,=0A=
@@ -86,7 +89,7 @@ each (char *fname, unsigned int size)=0A=
 	  cygpath ("/etc/postinstall/", fname, ".done", 0));=0A=
 }=0A=
 =0A=
-static char *shells [] =3D {=0A=
+static const char *shells[] =3D {=0A=
   "/bin/sh.exe",=0A=
   "/usr/bin/sh.exe",=0A=
   "/bin/bash.exe",=0A=
@@ -99,7 +102,7 @@ do_postinstall (HINSTANCE h)=0A=
 {=0A=
   next_dialog =3D 0;=0A=
   int i;=0A=
-  for (i=3D0; shells[i]; i++)=0A=
+  for (i =3D 0; shells[i]; i++)=0A=
     {=0A=
       sh =3D backslash (cygpath (shells[i], 0));=0A=
       if (_access (sh, 0) =3D=3D 0)=0A=
@@ -112,8 +115,8 @@ do_postinstall (HINSTANCE h)=0A=
   GetEnvironmentVariable ("PATH", old_path, sizeof (old_path));=0A=
   SetEnvironmentVariable ("PATH",=0A=
 			  backslash (cygpath ("/bin;",=0A=
-					     get_root_dir (), "/usr/bin;",=0A=
-					     old_path, 0)));=0A=
+					      get_root_dir (), "/usr/bin;",=0A=
+					      old_path, 0)));=0A=
 =0A=
   SetEnvironmentVariable ("CYGWINROOT", get_root_dir ());=0A=
   SetCurrentDirectory (get_root_dir ());=0A=
Index: root.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/root.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 root.cc=0A=
--- root.cc	2001/11/01 13:22:46	2.6=0A=
+++ root.cc	2001/11/11 06:54:58=0A=
@@ -17,7 +17,10 @@=0A=
    root of the installation to be, and to ask whether the user prefers=0A=
    text or binary mounts. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: root.cc,v 2.6 2001/11/01 13:22:46 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: root.cc,v 2.6 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <shlobj.h>=0A=
@@ -39,7 +42,8 @@ static int su[] =3D { IDC_ROOT_SYSTEM, IDC=0A=
 static void=0A=
 check_if_enable_next (HWND h)=0A=
 {=0A=
-  EnableWindow (GetDlgItem (h, IDOK), root_text && get_root_dir () && =
root_scope);=0A=
+  EnableWindow (GetDlgItem (h, IDOK), root_text && get_root_dir ()=0A=
+		&& root_scope);=0A=
 }=0A=
 =0A=
 static void=0A=
@@ -143,7 +147,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
     case IDOK:=0A=
       save_dialog (h);=0A=
 =0A=
-      if (! directory_is_absolute ())=0A=
+      if (!directory_is_absolute ())=0A=
 	{=0A=
 	  note (IDS_ROOT_ABSOLUTE);=0A=
 	  break;=0A=
@@ -169,6 +173,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -199,4 +204,3 @@ do_root (HINSTANCE h)=0A=
        (root_text =3D=3D IDC_ROOT_TEXT) ? "text" : "binary",=0A=
        (root_scope =3D=3D IDC_ROOT_USER) ? "user" : "system");=0A=
 }=0A=
-=0A=
Index: simpsock.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/simpsock.cc,v=0A=
retrieving revision 2.4=0A=
diff -u -p -r2.4 simpsock.cc=0A=
--- simpsock.cc	2001/11/09 13:03:02	2.4=0A=
+++ simpsock.cc	2001/11/11 06:54:58=0A=
@@ -16,7 +16,8 @@=0A=
 /* Simplified socket access functions */=0A=
 =0A=
 #if 0=0A=
-static const char *cvsid =3D "\n%%% $Id: simpsock.cc,v 2.4 2001/11/09 =
13:03:02 rbcollins Exp $\n";=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: simpsock.cc,v 2.4 2001/11/09 13:03:02 rbcollins Exp $\n";=0A=
 #endif=0A=
 =0A=
 #include "win32.h"=0A=
@@ -37,7 +38,7 @@ SimpleSocket::SimpleSocket (const char *=0A=
     {=0A=
       initted =3D 1;=0A=
       WSADATA d;=0A=
-      WSAStartup (MAKEWORD (1,1), &d);=0A=
+      WSAStartup (MAKEWORD (1, 1), &d);=0A=
     }=0A=
 =0A=
   s =3D INVALID_SOCKET;=0A=
@@ -80,7 +81,7 @@ SimpleSocket::SimpleSocket (const char *=0A=
   name.sin_port =3D htons (port);=0A=
   memcpy (&name.sin_addr, ip, 4);=0A=
 =0A=
-  if (connect (s, (sockaddr *)&name, sizeof(name)))=0A=
+  if (connect (s, (sockaddr *) & name, sizeof (name)))=0A=
     {=0A=
       msg ("Can't connect to %s:%d", hostname, port);=0A=
       closesocket (s);=0A=
@@ -146,7 +147,7 @@ SimpleSocket::fill ()=0A=
     }=0A=
   else if (r < 0 && putp =3D=3D getp)=0A=
     {=0A=
-      invalidate();=0A=
+      invalidate ();=0A=
     }=0A=
   return r;=0A=
 }=0A=
@@ -156,7 +157,7 @@ SimpleSocket::gets ()=0A=
 {=0A=
   if (getp > 0 && putp > getp)=0A=
     {=0A=
-      memmove (buf, buf+getp, putp-getp);=0A=
+      memmove (buf, buf + getp, putp - getp);=0A=
       putp -=3D getp;=0A=
       getp =3D 0;=0A=
     }=0A=
@@ -166,7 +167,7 @@ SimpleSocket::gets ()=0A=
 =0A=
   // getp is zero, always, here, and putp is the count=0A=
   char *nl;=0A=
-  while ((nl =3D (char *)memchr (buf, '\n', putp)) =3D=3D NULL && putp =
< SSBUFSZ)=0A=
+  while ((nl =3D (char *) memchr (buf, '\n', putp)) =3D=3D NULL && putp =
< SSBUFSZ)=0A=
     if (fill () <=3D 0)=0A=
       break;=0A=
 =0A=
@@ -196,11 +197,11 @@ SimpleSocket::read (char *ubuf, int ulen=0A=
   if (!ok ())=0A=
     return -1;=0A=
 =0A=
-  int n, rv=3D0;=0A=
+  int n, rv =3D 0;=0A=
   if (putp > getp)=0A=
     {=0A=
-      n =3D MIN (ulen, putp-getp);=0A=
-      memmove (ubuf, buf+getp, n);=0A=
+      n =3D MIN (ulen, putp - getp);=0A=
+      memmove (ubuf, buf + getp, n);=0A=
       getp +=3D n;=0A=
       ubuf +=3D n;=0A=
       ulen -=3D n;=0A=
@@ -210,9 +211,9 @@ SimpleSocket::read (char *ubuf, int ulen=0A=
     {=0A=
       n =3D recv (s, ubuf, ulen, 0);=0A=
       if (n < 0)=0A=
-        invalidate();=0A=
+	invalidate ();=0A=
       if (n <=3D 0)=0A=
-        return rv > 0 ? rv : n;=0A=
+	return rv > 0 ? rv : n;=0A=
       ubuf +=3D n;=0A=
       ulen -=3D n;=0A=
       rv +=3D n;=0A=
Index: simpsock.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/simpsock.h,v=0A=
retrieving revision 2.3=0A=
diff -u -p -r2.3 simpsock.h=0A=
--- simpsock.h	2001/11/09 13:03:02	2.3=0A=
+++ simpsock.h	2001/11/11 06:54:58=0A=
@@ -15,7 +15,8 @@=0A=
 =0A=
 /* Simplified socket access functions */=0A=
 =0A=
-class SimpleSocket {=0A=
+class SimpleSocket=0A=
+{=0A=
 =0A=
   SOCKET s;=0A=
   char *buf;=0A=
@@ -23,9 +24,9 @@ class SimpleSocket {=0A=
   int fill ();=0A=
   void invalidate (void);=0A=
 =0A=
- public:=0A=
-  SimpleSocket (const char *hostname, int port);=0A=
-  ~SimpleSocket ();=0A=
+public:=0A=
+    SimpleSocket (const char *hostname, int port);=0A=
+   ~SimpleSocket ();=0A=
 =0A=
   int ok ();=0A=
 =0A=
@@ -33,5 +34,5 @@ class SimpleSocket {=0A=
   int write (const char *buf, int len);=0A=
 =0A=
   char *gets ();=0A=
-  int	read (char *buf, int len);=0A=
+  int read (char *buf, int len);=0A=
 };=0A=
Index: site.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/site.cc,v=0A=
retrieving revision 2.7=0A=
diff -u -p -r2.7 site.cc=0A=
--- site.cc	2001/05/27 07:05:09	2.7=0A=
+++ site.cc	2001/11/11 06:54:58=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to get the list of mirror sites and ask=0A=
    the user which mirror site they want to download from. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: site.cc,v 2.7 2001/05/27 07:05:09 =
cgf Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: site.cc,v 2.7 2001/05/27 07:05:09 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -29,19 +32,21 @@ static char *cvsid =3D "\n%%% $Id: site.cc=0A=
 #include "geturl.h"=0A=
 #include "msg.h"=0A=
 #include "concat.h"=0A=
-#include "mount.h"=0A=
 #include "log.h"=0A=
+#include "io_stream.h"=0A=
 =0A=
 #include "port.h"=0A=
 =0A=
 #define NO_IDX (-1)=0A=
 #define OTHER_IDX (-2)=0A=
 =0A=
-typedef struct {=0A=
+typedef struct=0A=
+{=0A=
   char *url;=0A=
   char *displayed_url;=0A=
   char *sort_key;=0A=
-} site_list_type;=0A=
+}=0A=
+site_list_type;=0A=
 =0A=
 static site_list_type *site_list =3D 0;=0A=
 static int list_idx =3D NO_IDX;=0A=
@@ -82,31 +87,21 @@ save_dialog (HWND h)=0A=
     }=0A=
 }=0A=
 =0A=
-static void=0A=
-get_root_dir_now ()=0A=
-{=0A=
-  int istext;=0A=
-  int issystem;=0A=
-  if (get_root_dir ())=0A=
-    return;=0A=
-  read_mounts ();=0A=
-}=0A=
-=0A=
 void=0A=
 save_site_url ()=0A=
 {=0A=
-  if (! MIRROR_SITE)=0A=
-    return;=0A=
-=0A=
-  get_root_dir_now ();=0A=
-  if (!get_root_dir ())=0A=
+  if (!MIRROR_SITE)=0A=
     return;=0A=
 =0A=
-  FILE *f =3D fopen (cygpath ("/etc/setup/last-mirror", 0), "wb");=0A=
-  if (!f)=0A=
-    return;=0A=
-  fprintf (f, "%s\n", MIRROR_SITE);=0A=
-  fclose (f);=0A=
+  io_stream *f =3D io_stream::open ("cygfile:///etc/setup/last-mirror", =
"wb");=0A=
+  if (f)=0A=
+    {=0A=
+      char temp[_MAX_PATH];=0A=
+      /* TODO: potential buffer overflow. we need snprintf asap. */=0A=
+      sprintf (temp, "%s\n", MIRROR_SITE);=0A=
+      f->write (temp, strlen (temp));=0A=
+      delete f;=0A=
+    }=0A=
 }=0A=
 =0A=
 static BOOL=0A=
@@ -141,6 +136,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -152,12 +148,14 @@ dialog_proc (HWND h, UINT message, WPARA=0A=
     {=0A=
     case WM_INITDIALOG:=0A=
       listbox =3D GetDlgItem (h, IDC_URL_LIST);=0A=
-      for (i=3D0; site_list[i].url; i++)=0A=
+      for (i =3D 0; site_list[i].url; i++)=0A=
 	{=0A=
-	  j =3D SendMessage (listbox, LB_ADDSTRING, 0, =
(LPARAM)site_list[i].displayed_url);=0A=
+	  j =3D=0A=
+	    SendMessage (listbox, LB_ADDSTRING, 0,=0A=
+			 (LPARAM) site_list[i].displayed_url);=0A=
 	  SendMessage (listbox, LB_SETITEMDATA, j, i);=0A=
 	}=0A=
-      j =3D SendMessage (listbox, LB_ADDSTRING, 0, (LPARAM)"Other URL");=0A=
+      j =3D SendMessage (listbox, LB_ADDSTRING, 0, (LPARAM) "Other =
URL");=0A=
       SendMessage (listbox, LB_SETITEMDATA, j, OTHER_IDX);=0A=
       load_dialog (h);=0A=
       return FALSE;=0A=
@@ -170,8 +168,8 @@ dialog_proc (HWND h, UINT message, WPARA=0A=
 static int=0A=
 site_sort (const void *va, const void *vb)=0A=
 {=0A=
-  site_list_type *a =3D (site_list_type *)va;=0A=
-  site_list_type *b =3D (site_list_type *)vb;=0A=
+  site_list_type *a =3D (site_list_type *) va;=0A=
+  site_list_type *b =3D (site_list_type *) vb;=0A=
   return strcmp (a->sort_key, b->sort_key);=0A=
 }=0A=
 =0A=
@@ -190,10 +188,10 @@ get_site_list (HINSTANCE h)=0A=
 =0A=
 =0A=
   /* null plus account for possibly missing NL plus account for "Other=0A=
-    URL" from previous run. */=0A=
+     URL" from previous run. */=0A=
   int nmirrors =3D 3;=0A=
 =0A=
-  for (bol=3Dmirrors; *bol; bol++)=0A=
+  for (bol =3D mirrors; *bol; bol++)=0A=
     if (*bol =3D=3D '\n')=0A=
       nmirrors++;=0A=
 =0A=
@@ -204,9 +202,9 @@ get_site_list (HINSTANCE h)=0A=
   while (*nl)=0A=
     {=0A=
       bol =3D nl;=0A=
-      for (eol =3D bol; *eol && *eol !=3D '\n'; eol++) ;=0A=
+      for (eol =3D bol; *eol && *eol !=3D '\n'; eol++);=0A=
       if (*eol)=0A=
-	nl =3D eol+1;=0A=
+	nl =3D eol + 1;=0A=
       else=0A=
 	nl =3D eol;=0A=
       while (eol > bol && eol[-1] =3D=3D '\r')=0A=
@@ -226,7 +224,8 @@ get_site_list (HINSTANCE h)=0A=
 	      if (dot)=0A=
 		*dot =3D 0;=0A=
 	    }=0A=
-	  site_list[nmirrors].sort_key =3D (char *) malloc (2*strlen (bol) + =
3);=0A=
+	  site_list[nmirrors].sort_key =3D=0A=
+	    (char *) malloc (2 * strlen (bol) + 3);=0A=
 =0A=
 	  dot =3D site_list[nmirrors].displayed_url;=0A=
 	  dot +=3D strlen (dot);=0A=
@@ -237,8 +236,8 @@ get_site_list (HINSTANCE h)=0A=
 		{=0A=
 		  char *sp;=0A=
 		  if (dot[3] =3D=3D 0)=0A=
-		    *dp++ =3D '~'; /* sort .com/.edu/.org together */=0A=
-		  for (sp=3Ddot+1; *sp && *sp !=3D '.' && *sp !=3D '/';)=0A=
+		    *dp++ =3D '~';	/* sort .com/.edu/.org together */=0A=
+		  for (sp =3D dot + 1; *sp && *sp !=3D '.' && *sp !=3D '/';)=0A=
 		    *dp++ =3D *sp++;=0A=
 		  *dp++ =3D ' ';=0A=
 		}=0A=
@@ -269,19 +268,14 @@ get_site_list (HINSTANCE h)=0A=
 static void=0A=
 get_initial_list_idx ()=0A=
 {=0A=
-  get_root_dir_now ();=0A=
-  if (!get_root_dir ())=0A=
-    return;=0A=
-=0A=
-  FILE *f =3D fopen (cygpath ("/etc/setup/last-mirror", 0), "rt");=0A=
+  io_stream *f =3D io_stream::open ("cygfile:///etc/setup/last-mirror", =
"rt");=0A=
   if (!f)=0A=
     return;=0A=
 =0A=
   char site[1000];=0A=
-  site[0]=3D'\0';=0A=
-  char * fg_ret =3D fgets (site, 1000, f);=0A=
-  fclose (f);=0A=
-  if (! fg_ret)=0A=
+  char *fg_ret =3D f->gets (site, 1000);=0A=
+  delete f;=0A=
+  if (!fg_ret)=0A=
     return;=0A=
 =0A=
   char *eos =3D site + strlen (site) - 1;=0A=
@@ -296,17 +290,16 @@ get_initial_list_idx ()=0A=
     if (strcmp (site_list[i].url, site) =3D=3D 0)=0A=
       break;=0A=
 =0A=
-  if (! site_list[i].url)=0A=
+  if (!site_list[i].url)=0A=
     {=0A=
       /* Don't default to certain machines ever since they suffer=0A=
-	 from bandwidth limitations. */=0A=
+         from bandwidth limitations. */=0A=
       if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) =3D=3D 0=0A=
 	  || strnicmp (site, NOSAVE2, NOSAVE2_LEN) =3D=3D 0=0A=
 	  || strnicmp (site, NOSAVE3, NOSAVE3_LEN) =3D=3D 0)=0A=
 	return;=0A=
-      site_list[i].displayed_url =3D=0A=
-      site_list[i].url =3D _strdup (site);=0A=
-      site_list[i+1].url =3D 0;=0A=
+      site_list[i].displayed_url =3D site_list[i].url =3D _strdup =
(site);=0A=
+      site_list[i + 1].url =3D 0;=0A=
     }=0A=
 =0A=
   mirror_idx =3D list_idx =3D i;=0A=
@@ -333,4 +326,3 @@ do_site (HINSTANCE h)=0A=
   if (mirror_idx !=3D OTHER_IDX)=0A=
     log (0, "site: %s", mirror_site);=0A=
 }=0A=
-=0A=
Index: source.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/source.cc,v=0A=
retrieving revision 2.6=0A=
diff -u -p -r2.6 source.cc=0A=
--- source.cc	2001/11/06 03:41:00	2.6=0A=
+++ source.cc	2001/11/11 06:54:58=0A=
@@ -17,7 +17,10 @@=0A=
    user choose the source of the install - from the net, from the=0A=
    current directory, or to just download files. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: source.cc,v 2.6 2001/11/06 03:41:00 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -27,25 +30,18 @@ static char *cvsid =3D "\n%%% $Id: source.=0A=
 #include "msg.h"=0A=
 #include "log.h"=0A=
 =0A=
-static int rb[] =3D { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, =
IDC_SOURCE_CWD, 0 };=0A=
+static int rb[] =3D=0A=
+  { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };=0A=
 =0A=
 static void=0A=
-check_if_enable_next (HWND h)=0A=
-{=0A=
-  EnableWindow (GetDlgItem (h, IDOK), source ? 1 : 0);=0A=
-}=0A=
-=0A=
-static void=0A=
 load_dialog (HWND h)=0A=
 {=0A=
-  int i;=0A=
   rbset (h, rb, source);=0A=
 }=0A=
 =0A=
 static void=0A=
 save_dialog (HWND h)=0A=
 {=0A=
-  int i;=0A=
   source =3D rbget (h, rb);=0A=
 }=0A=
 =0A=
@@ -78,6 +74,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
     default:=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -88,11 +85,16 @@ dialog_proc (HWND h, UINT message, WPARA=0A=
     case WM_INITDIALOG:=0A=
       load_dialog (h);=0A=
       // Check to see if any radio buttons are selected. If not, select =
a default.=0A=
-      if ((!SendMessage(GetDlgItem (h, IDC_SOURCE_DOWNLOAD), =
BM_GETCHECK, 0, 0) =3D=3D BST_CHECKED)=0A=
-        && (!SendMessage(GetDlgItem (h, IDC_SOURCE_CWD), BM_GETCHECK, =
0, 0) =3D=3D BST_CHECKED))=0A=
-        {=0A=
-          SendMessage(GetDlgItem (h, IDC_SOURCE_NETINST), BM_SETCHECK, =
BST_CHECKED, 0);=0A=
-        }=0A=
+      if (=0A=
+	  (!SendMessage=0A=
+	   (GetDlgItem (h, IDC_SOURCE_DOWNLOAD), BM_GETCHECK, 0,=0A=
+	    0) =3D=3D BST_CHECKED)=0A=
+	  && (!SendMessage (GetDlgItem (h, IDC_SOURCE_CWD), BM_GETCHECK, 0, 0)=0A=
+	      =3D=3D BST_CHECKED))=0A=
+	{=0A=
+	  SendMessage (GetDlgItem (h, IDC_SOURCE_NETINST), BM_SETCHECK,=0A=
+		       BST_CHECKED, 0);=0A=
+	}=0A=
       return FALSE;=0A=
     case WM_COMMAND:=0A=
       return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);=0A=
@@ -104,7 +106,7 @@ void=0A=
 do_source (HINSTANCE h)=0A=
 {=0A=
   int rv =3D 0;=0A=
-  /* source =3D IDC_SOURCE_CWD;*/=0A=
+  /* source =3D IDC_SOURCE_CWD; */=0A=
   source =3D IDC_SOURCE_NETINST;=0A=
   rv =3D DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), 0, dialog_proc);=0A=
   if (rv =3D=3D -1)=0A=
@@ -114,4 +116,3 @@ do_source (HINSTANCE h)=0A=
        (source =3D=3D IDC_SOURCE_DOWNLOAD) ? "download" :=0A=
        (source =3D=3D IDC_SOURCE_NETINST) ? "network install" : "from =
cwd");=0A=
 }=0A=
-=0A=
Index: splash.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/splash.cc,v=0A=
retrieving revision 2.5=0A=
diff -u -p -r2.5 splash.cc=0A=
--- splash.cc	2001/11/02 00:52:06	2.5=0A=
+++ splash.cc	2001/11/11 06:54:58=0A=
@@ -16,7 +16,10 @@=0A=
 /* The purpose of this file is to display the program name, version,=0A=
    copyright notice, and project URL. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: splash.cc,v 2.5 2001/11/02 00:52:06 =
rbcollins Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: splash.cc,v 2.5 2001/11/02 00:52:06 rbcollins Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
@@ -49,6 +52,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl=0A=
       NEXT (0);=0A=
       break;=0A=
     }=0A=
+  return 0;=0A=
 }=0A=
 =0A=
 static BOOL CALLBACK=0A=
@@ -73,4 +77,3 @@ do_splash (HINSTANCE h)=0A=
   if (rv =3D=3D -1)=0A=
     fatal (IDS_DIALOG_FAILED);=0A=
 }=0A=
-=0A=
Index: state.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/state.cc,v=0A=
retrieving revision 2.0=0A=
diff -u -p -r2.0 state.cc=0A=
--- state.cc	2000/08/08 00:59:08	2.0=0A=
+++ state.cc	2001/11/11 06:54:58=0A=
@@ -15,7 +15,10 @@=0A=
 =0A=
 /* All we do here is instantiate the extern'd variables from state.h */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: state.cc,v 2.0 2000/08/08 00:59:08 =
dj Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: state.cc,v 2.0 2000/08/08 00:59:08 dj Exp $\n";=0A=
+#endif=0A=
 =0A=
 #define extern=0A=
 #include "state.h"=0A=
Index: state.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/state.h,v=0A=
retrieving revision 2.4=0A=
diff -u -p -r2.4 state.h=0A=
--- state.h	2001/05/28 08:31:02	2.4=0A=
+++ state.h	2001/11/11 06:54:58=0A=
@@ -18,29 +18,29 @@=0A=
    information that the user has provided so far.  These are set by=0A=
    the various dialogs and used by the various actions. */=0A=
 =0A=
-extern int	source;=0A=
+extern int source;=0A=
 =0A=
-extern char *	local_dir;=0A=
+extern char *local_dir;=0A=
 =0A=
-extern int	root_text;=0A=
-extern int	root_scope;=0A=
-extern int   root_menu;=0A=
-extern int   root_desktop;=0A=
-=0A=
-extern int	net_method;=0A=
-extern char *	net_proxy_host;=0A=
-extern int	net_proxy_port;=0A=
-=0A=
-extern char *	net_user;=0A=
-extern char *	net_passwd;=0A=
-extern char *	net_proxy_user;=0A=
-extern char *	net_proxy_passwd;=0A=
-extern char *	net_ftp_user;=0A=
-extern char *	net_ftp_passwd;=0A=
+extern int root_text;=0A=
+extern int root_scope;=0A=
+extern int root_menu;=0A=
+extern int root_desktop;=0A=
+=0A=
+extern int net_method;=0A=
+extern char *net_proxy_host;=0A=
+extern int net_proxy_port;=0A=
+=0A=
+extern char *net_user;=0A=
+extern char *net_passwd;=0A=
+extern char *net_proxy_user;=0A=
+extern char *net_proxy_passwd;=0A=
+extern char *net_ftp_user;=0A=
+extern char *net_ftp_passwd;=0A=
 =0A=
-extern char *	mirror_site;=0A=
-extern char *	other_url;=0A=
+extern char *mirror_site;=0A=
+extern char *other_url;=0A=
 =0A=
-extern int	trust_level;=0A=
+extern int trust_level;=0A=
 =0A=
 #define MIRROR_SITE (mirror_site ? mirror_site : other_url)=0A=
Index: tar.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/tar.cc,v=0A=
retrieving revision 2.5=0A=
diff -u -p -r2.5 tar.cc=0A=
--- tar.cc	2001/06/13 16:11:01	2.5=0A=
+++ tar.cc	2001/11/11 06:54:58=0A=
@@ -15,268 +15,229 @@=0A=
 =0A=
 /* Built-in tar functionality.  See tar.h for usage. */=0A=
 =0A=
-static char *cvsid =3D "\n%%% $Id: tar.cc,v 2.5 2001/06/13 16:11:01 cgf =
Exp $\n";=0A=
+#if 0=0A=
+static const char *cvsid =3D=0A=
+  "\n%%% $Id: tar.cc,v 2.5 2001/06/13 16:11:01 cgf Exp $\n";=0A=
+#endif=0A=
 =0A=
 #include "win32.h"=0A=
 #include <stdio.h>=0A=
 #include <stdlib.h>=0A=
 #include <sys/types.h>=0A=
 #include <sys/fcntl.h>=0A=
+#include <errno.h>=0A=
 =0A=
-#include "zlib/zlib.h"=0A=
+//#include "zlib/zlib.h"=0A=
+#include "io_stream.h"=0A=
+//#include "compress.h"=0A=
+#include "archive.h"=0A=
 #include "tar.h"=0A=
 #include "mkdir.h"=0A=
 #include "log.h"=0A=
 #include "filemanip.h"=0A=
+#include "concat.h"=0A=
 =0A=
 #include "port.h"=0A=
+#if 0=0A=
 #undef _WIN32=0A=
 #include "bzlib.h"=0A=
 =0A=
 #define FACTOR (0x19db1ded53ea710LL)=0A=
 #define NSPERSEC 10000000LL=0A=
 #define SYMLINK_COOKIE "!<symlink>"=0A=
-=0A=
-typedef struct {=0A=
-  char name[100];               /*   0 */=0A=
-  char mode[8];                 /* 100 */=0A=
-  char uid[8];                  /* 108 */=0A=
-  char gid[8];                  /* 116 */=0A=
-  char size[12];                /* 124 */=0A=
-  char mtime[12];               /* 136 */=0A=
-  char chksum[8];               /* 148 */=0A=
-  char typeflag;                /* 156 */=0A=
-  char linkname[100];           /* 157 */=0A=
-  char magic[6];                /* 257 */=0A=
-  char version[2];              /* 263 */=0A=
-  char uname[32];               /* 265 */=0A=
-  char gname[32];               /* 297 */=0A=
-  char devmajor[8];             /* 329 */=0A=
-  char devminor[8];             /* 337 */=0A=
-  char prefix[155];             /* 345 */=0A=
-  char junk[12];		/* 500 */=0A=
-} tar_header_type;=0A=
-=0A=
-typedef struct tar_map_result_type_s {=0A=
-  struct tar_map_result_type_s *next;=0A=
-  char *stored_name;=0A=
-  char *mapped_name;=0A=
-} tar_map_result_type;=0A=
-=0A=
-static tar_map_result_type *tar_map_result =3D 0;=0A=
-=0A=
+#endif=0A=
 static int err;=0A=
 =0A=
-static char file_name[_MAX_PATH+512];=0A=
-static char have_longname =3D 0;=0A=
-static int  file_length;=0A=
+//static char file_name[_MAX_PATH+512];=0A=
+//static char have_longname =3D 0;=0A=
+//static int  file_length;=0A=
 =0A=
-static tar_header_type tar_header;=0A=
 static char buf[512];=0A=
 =0A=
-static int _tar_file_size =3D 0;=0A=
 int _tar_verbose =3D 0;=0A=
-FILE * _tar_vfile =3D 0;=0A=
+FILE *_tar_vfile =3D 0;=0A=
 #define vp if (_tar_verbose) fprintf=0A=
 #define vp2 if (_tar_verbose>1) fprintf=0A=
-=0A=
-class gzbz=0A=
-{=0A=
- protected:=0A=
-  union=0A=
-  {=0A=
-    gzFile g;=0A=
-    BZFILE *b;=0A=
-  };=0A=
-  int fd;=0A=
-public:=0A=
-  virtual int read (void *buf, int len) {};=0A=
-  virtual int close () {};=0A=
-  virtual off_t tell () {};=0A=
-  operator int () {return (int) g;}=0A=
-};=0A=
-=0A=
-class gz: public gzbz=0A=
-{=0A=
- public:=0A=
-  gz (const char *pathname)=0A=
-  {=0A=
-    g =3D gzopen (pathname, "rb");=0A=
-  }=0A=
-  int read (void *buf, int len)=0A=
-  {=0A=
-    return gzread (g, buf, len);=0A=
-  }=0A=
-  int close ()=0A=
-  {=0A=
-    return gzclose (g);=0A=
-  }=0A=
-  off_t tell () {return gzctell (g);}=0A=
-  ~gz () {close ();}=0A=
-};=0A=
-=0A=
-class bz: public gzbz=0A=
-{=0A=
- public:=0A=
-  bz (const char *pathname)=0A=
-  {=0A=
-    fd =3D open (pathname, O_RDONLY | O_BINARY);=0A=
-    if (fd)=0A=
-      b =3D BZ2_bzdopen (fd, "rb");=0A=
-    else=0A=
-      b =3D NULL;=0A=
-  }=0A=
-  int read (void *buf, int len)=0A=
-  {=0A=
-    return BZ2_bzread (b, buf, len);=0A=
-  }=0A=
-  int close ()=0A=
-  {=0A=
-    BZ2_bzclose (b);=0A=
-    return 0;=0A=
-  }=0A=
-  off_t tell () {return ::tell (fd);}=0A=
-  ~bz () {close ();}=0A=
-};=0A=
 =0A=
-gzbz *z =3D NULL;=0A=
-=0A=
-static char *=0A=
-xstrdup (char *c)=0A=
+archive_tar::archive_tar (io_stream * original)=0A=
 {=0A=
-  char *r =3D (char *) malloc (strlen (c) + 1);=0A=
-  if (!r)=0A=
-    exit_setup (1);=0A=
-  strcpy (r, c);=0A=
-  return r;=0A=
-}=0A=
-=0A=
-int=0A=
-tar_open (const char *pathname)=0A=
-{=0A=
+  archive_children =3D 0;=0A=
   if (_tar_vfile =3D=3D 0)=0A=
     _tar_vfile =3D stderr;=0A=
 =0A=
-  vp2 (_tar_vfile, "tar: open `%s'\n", pathname);=0A=
-  DWORD size;=0A=
-  if ((size =3D get_file_size (pathname)) =3D=3D 0)=0A=
-    return 1;=0A=
-  _tar_file_size =3D size;=0A=
-=0A=
-  if (strstr (pathname, ".bz2"))=0A=
-    z =3D new bz (pathname);=0A=
-  else=0A=
-    z =3D new gz (pathname);=0A=
-  if (sizeof (tar_header) !=3D 512)=0A=
+  vp2 (_tar_vfile, "tar: open `%p'\n", original);=0A=
+=0A=
+  if (!original)=0A=
     {=0A=
+      state.lasterr =3D EBADF;=0A=
+      return;=0A=
+    }=0A=
+  state.parent =3D original;=0A=
+=0A=
+  if (sizeof (state.tar_header) !=3D 512)=0A=
+    {=0A=
       /* drastic, but important */=0A=
       fprintf (stderr, "compilation error: tar header struct not 512"=0A=
-	       " bytes (it's %d)\n", sizeof (tar_header));=0A=
+	       " bytes (it's %d)\n", sizeof (state.tar_header));=0A=
       exit_setup (1);=0A=
     }=0A=
-  err =3D 0;=0A=
-  return *z ? 0 : 1;=0A=
 }=0A=
 =0A=
+ssize_t=0A=
+archive_tar::read (void *buffer, size_t len)=0A=
+{=0A=
+  return -1;=0A=
+}=0A=
+=0A=
+ssize_t=0A=
+archive_tar::write (void *buffer, size_t len)=0A=
+{=0A=
+  return 0;=0A=
+}=0A=
+=0A=
+ssize_t=0A=
+archive_tar::peek (void *buffer, size_t len)=0A=
+{=0A=
+  return 0;=0A=
+}=0A=
+=0A=
 int=0A=
-tar_ftell ()=0A=
+archive_tar::error ()=0A=
 {=0A=
-  return z->tell ();=0A=
+  return state.lasterr;=0A=
 }=0A=
 =0A=
-static void=0A=
-skip_file ()=0A=
+long=0A=
+archive_tar::tell ()=0A=
 {=0A=
-  while (file_length > 0)=0A=
+  return state.file_offset;=0A=
+}=0A=
+=0A=
+int=0A=
+archive_tar::skip_file ()=0A=
+{=0A=
+  while (state.file_length > state.file_offset)=0A=
     {=0A=
-      z->read (buf, 512);=0A=
-      file_length -=3D 512;=0A=
+      int len =3D state.parent->read (buf, 512);=0A=
+      state.file_offset +=3D 512;=0A=
+      if (len !=3D 512)=0A=
+	return 1;=0A=
     }=0A=
+  state.file_length =3D 0;=0A=
+  state.file_offset =3D 0;=0A=
+  state.header_read =3D 0;=0A=
+  return 0;=0A=
 }=0A=
 =0A=
-char *=0A=
-tar_next_file ()=0A=
+const char *=0A=
+archive_tar::next_file_name ()=0A=
 {=0A=
-  int r, n;=0A=
   char *c;=0A=
-  r =3D z->read (&tar_header, 512);=0A=
 =0A=
+  if (state.header_read)=0A=
+    if (strlen (state.filename))=0A=
+      return state.filename;=0A=
+    else=0A=
+      /* End of tar */=0A=
+      return NULL;=0A=
+=0A=
+  int r =3D state.parent->read (&state.tar_header, 512);=0A=
+=0A=
   /* See if we're at end of file */=0A=
   if (r !=3D 512)=0A=
-    return 0;=0A=
+    return NULL;=0A=
 =0A=
   /* See if the header is all zeros (i.e. last block) */=0A=
-  n =3D 0;=0A=
-  for (r =3D 512/sizeof (int); r; r--)=0A=
-    n |=3D ((int *)&tar_header)[r-1];=0A=
+  int n =3D 0;=0A=
+  for (r =3D 512 / sizeof (int); r; r--)=0A=
+    n |=3D ((int *) &state.tar_header)[r - 1];=0A=
   if (n =3D=3D 0)=0A=
-    return 0;=0A=
+    return NULL;=0A=
 =0A=
-  if (!have_longname && tar_header.typeflag !=3D 'L')=0A=
+  if (!state.have_longname && state.tar_header.typeflag !=3D 'L')=0A=
     {=0A=
-      memcpy (file_name, tar_header.name, 100);=0A=
-      file_name[100] =3D 0;=0A=
+      memcpy (state.filename, state.tar_header.name, 100);=0A=
+      state.filename[100] =3D 0;=0A=
     }=0A=
 =0A=
-  sscanf (tar_header.size, "%o", &file_length);=0A=
+  sscanf (state.tar_header.size, "%o", &state.file_length);=0A=
+  state.file_offset =3D 0;=0A=
 =0A=
-  vp2 (_tar_vfile, "%c %9d %s\n", tar_header.typeflag, file_length, =
file_name);=0A=
+//  vp2 (_tar_vfile, "%c %9d %s\n", state.tar_header.typeflag,=0A=
+//      state.file_length, state.filename);=0A=
 =0A=
-  switch (tar_header.typeflag)=0A=
+  switch (state.tar_header.typeflag)=0A=
     {=0A=
-    case 'L': /* GNU tar long name extension */=0A=
-      if (file_length > _MAX_PATH)=0A=
+    case 'L':			/* GNU tar long name extension */=0A=
+      /* we read the 'file' into the long filename, then call back into =
here=0A=
+       * to find out if the actual file is a real file, or a special =
file..=0A=
+       */=0A=
+      if (state.file_length > _MAX_PATH)=0A=
 	{=0A=
 	  skip_file ();=0A=
 	  fprintf (stderr, "error: long file name exceeds %d characters\n",=0A=
 		   _MAX_PATH);=0A=
 	  err++;=0A=
-	  z->read (&tar_header, 512);=0A=
-	  sscanf (tar_header.size, "%o", &file_length);=0A=
+	  state.parent->read (&state.tar_header, 512);=0A=
+	  sscanf (state.tar_header.size, "%o", &state.file_length);=0A=
+	  state.file_offset =3D 0;=0A=
 	  skip_file ();=0A=
-	  return tar_next_file ();=0A=
+	  return next_file_name ();=0A=
 	}=0A=
-      c =3D file_name;=0A=
-      while (file_length > 0)=0A=
+      c =3D state.filename;=0A=
+      /* FIXME: this should be a single read() call */=0A=
+      while (state.file_length > state.file_offset)=0A=
 	{=0A=
-	  int need =3D file_length > 512 ? 512 : file_length;=0A=
-	  if (z->read (buf, 512) < 512)=0A=
+	  int need =3D=0A=
+	    state.file_length - state.file_offset >=0A=
+	    512 ? 512 : state.file_length - state.file_offset;=0A=
+	  if (state.parent->read (buf, 512) < 512)=0A=
 	    return 0;=0A=
 	  memcpy (c, buf, need);=0A=
 	  c +=3D need;=0A=
-	  file_length -=3D need;=0A=
+	  state.file_offset +=3D need;=0A=
 	}=0A=
       *c =3D 0;=0A=
-      have_longname =3D 1;=0A=
-      return tar_next_file ();=0A=
+      state.have_longname =3D 1;=0A=
+      return next_file_name ();=0A=
 =0A=
-    case '3': /* char */=0A=
-    case '4': /* block */=0A=
-    case '6': /* fifo */=0A=
+    case '3':			/* char */=0A=
+    case '4':			/* block */=0A=
+    case '6':			/* fifo */=0A=
       fprintf (stderr, "warning: not extracting special file %s\n",=0A=
-	       file_name);=0A=
+	       state.filename);=0A=
       err++;=0A=
-      return tar_next_file ();=0A=
+      return next_file_name ();=0A=
 =0A=
-    case '0': /* regular file */=0A=
-    case 0: /* regular file also */=0A=
-    case '2': /* symbolic link */=0A=
-    case '5': /* directory */=0A=
-    case '7': /* contiguous file */=0A=
-      return file_name;=0A=
+    case '0':			/* regular file */=0A=
+    case 0:			/* regular file also */=0A=
+    case '2':			/* symbolic link */=0A=
+    case '5':			/* directory */=0A=
+    case '7':			/* contiguous file */=0A=
+      state.header_read =3D 1;=0A=
+      return state.filename;=0A=
+=0A=
+    case '1':			/* hard link, we just copy */=0A=
+      state.header_read =3D 1;=0A=
+      return state.filename;=0A=
 =0A=
-    case '1': /* hard link, we just copy */=0A=
-      return file_name;=0A=
-=0A=
     default:=0A=
       fprintf (stderr, "error: unknown (or unsupported) file type =
`%c'\n",=0A=
-	       tar_header.typeflag);=0A=
+	       state.tar_header.typeflag);=0A=
       err++;=0A=
       skip_file ();=0A=
-      return tar_next_file ();=0A=
+      return next_file_name ();=0A=
     }=0A=
+  return NULL;=0A=
+}=0A=
+=0A=
+archive_tar::~archive_tar ()=0A=
+{=0A=
+  if (state.parent)=0A=
+    delete state.parent;=0A=
 }=0A=
 =0A=
+# if 0=0A=
 static void=0A=
 fix_time_stamp (char *path)=0A=
 {=0A=
@@ -298,32 +259,8 @@ fix_time_stamp (char *path)=0A=
       CloseHandle (h);=0A=
     }=0A=
 }=0A=
-=0A=
-static FILE *=0A=
-common_fopen (char *path)=0A=
-{=0A=
-  FILE *out;=0A=
-  out =3D fopen (path, "wb");=0A=
-  if (!out)=0A=
-    {=0A=
-      /* maybe we need to create a directory */=0A=
-      if (mkdir_p (0, path))=0A=
-	{=0A=
-	  skip_file ();=0A=
-	  return 0;=0A=
-	}=0A=
-      out =3D fopen (path, "wb");=0A=
-    }=0A=
-  if (!out)=0A=
-    {=0A=
-      fprintf (stderr, "unable to write to file %s\n", path);=0A=
-      perror ("The error was");=0A=
-      skip_file ();=0A=
-      return 0;=0A=
-    }=0A=
-  return out;=0A=
-}=0A=
-=0A=
+#endif=0A=
+#if 0=0A=
 static void=0A=
 prepare_for_file (char *path)=0A=
 {=0A=
@@ -335,11 +272,14 @@ prepare_for_file (char *path)=0A=
     {=0A=
       char *tmp =3D (char *) malloc (strlen (path) + 10);=0A=
       int i =3D 0;=0A=
-      do {=0A=
-	i++;=0A=
-	sprintf (tmp, "%s.old-%d", path, i);=0A=
-      } while (GetFileAttributes (tmp) !=3D 0xffffffff);=0A=
-      fprintf (stderr, "warning: moving directory \"%s\" out of the =
way.\n", path);=0A=
+      do=0A=
+	{=0A=
+	  i++;=0A=
+	  sprintf (tmp, "%s.old-%d", path, i);=0A=
+	}=0A=
+      while (GetFileAttributes (tmp) !=3D 0xffffffff);=0A=
+      fprintf (stderr, "warning: moving directory \"%s\" out of the =
way.\n",=0A=
+	       path);=0A=
       MoveFile (path, tmp);=0A=
       free (tmp);=0A=
     }=0A=
@@ -347,18 +287,70 @@ prepare_for_file (char *path)=0A=
   DeleteFileA (path);=0A=
 }=0A=
 =0A=
+static char *=0A=
+xstrdup (char *c)=0A=
+{=0A=
+  char *r =3D (char *) malloc (strlen (c) + 1);=0A=
+  if (!r)=0A=
+    exit_setup (1);=0A=
+  strcpy (r, c);=0A=
+  return r;=0A=
+}=0A=
+#endif=0A=
+archive_file_t=0A=
+archive_tar::next_file_type ()=0A=
+{=0A=
+  switch (state.tar_header.typeflag)=0A=
+    {=0A=
+      /* regular files */=0A=
+    case '0':=0A=
+    case 0:=0A=
+    case '7':=0A=
+      return ARCHIVE_FILE_REGULAR;=0A=
+    case '1':=0A=
+      return ARCHIVE_FILE_HARDLINK;=0A=
+    case '5':=0A=
+      return ARCHIVE_FILE_DIRECTORY;=0A=
+    case '2':=0A=
+      return ARCHIVE_FILE_SYMLINK;=0A=
+    default:=0A=
+      return ARCHIVE_FILE_INVALID;=0A=
+    }=0A=
+}=0A=
+=0A=
+const char *=0A=
+archive_tar::linktarget ()=0A=
+{=0A=
+  /* TODO: consider .. path traversal issues */=0A=
+  if (next_file_type () =3D=3D ARCHIVE_FILE_SYMLINK ||=0A=
+      next_file_type () =3D=3D ARCHIVE_FILE_HARDLINK)=0A=
+    return state.tar_header.linkname;=0A=
+  return NULL;=0A=
+}=0A=
+=0A=
+io_stream *=0A=
+archive_tar::extract_file ()=0A=
+{=0A=
+  if (archive_children)=0A=
+    return NULL;=0A=
+  archive_tar_file *rv =3D new archive_tar_file (state);=0A=
+  return rv;=0A=
+}=0A=
+=0A=
+=0A=
+#if 0=0A=
 int=0A=
 tar_read_file (char *path)=0A=
 {=0A=
   FILE *out, *copy;=0A=
   HANDLE h;=0A=
-  DWORD w, startticks;=0A=
+  DWORD w;=0A=
   int got;=0A=
   tar_map_result_type *tmr;=0A=
 =0A=
   switch (tar_header.typeflag)=0A=
     {=0A=
-    case '0':	/* regular files */=0A=
+    case '0':			/* regular files */=0A=
     case 0:=0A=
     case '7':=0A=
       vp (_tar_vfile, "F %s\n", path);=0A=
@@ -374,7 +366,8 @@ tar_read_file (char *path)=0A=
 	  got =3D z->read (buf, 512);=0A=
 	  if (got < 512)=0A=
 	    {=0A=
-	      fprintf (stderr, "tar: unexpected end of file reading %s\n", =
path);=0A=
+	      fprintf (stderr, "tar: unexpected end of file reading %s\n",=0A=
+		       path);=0A=
 	      fclose (out);=0A=
 	      remove (path);=0A=
 	      return 1;=0A=
@@ -403,8 +396,8 @@ tar_read_file (char *path)=0A=
 =0A=
       return 0;=0A=
 =0A=
-    case '1':	/* hard links; we just copy */=0A=
-      for (tmr =3D tar_map_result; tmr; tmr=3Dtmr->next)=0A=
+    case '1':			/* hard links; we just copy */=0A=
+      for (tmr =3D tar_map_result; tmr; tmr =3D tmr->next)=0A=
 	if (strcmp (tmr->stored_name, tar_header.linkname) =3D=3D 0)=0A=
 	  break;=0A=
       if (!tmr)=0A=
@@ -443,22 +436,23 @@ tar_read_file (char *path)=0A=
       fix_time_stamp (path);=0A=
       return 0;=0A=
 =0A=
-    case '5':	/* directories */=0A=
+    case '5':			/* directories */=0A=
       vp (_tar_vfile, "D %s\n", path);=0A=
-      while (path[0] && path[strlen (path)-1] =3D=3D '/')=0A=
+      while (path[0] && path[strlen (path) - 1] =3D=3D '/')=0A=
 	path[strlen (path) - 1] =3D 0;=0A=
       return mkdir_p (1, path);=0A=
 =0A=
 =0A=
-    case '2':	/* symbolic links */=0A=
+    case '2':			/* symbolic links */=0A=
       vp (_tar_vfile, "L %s -> %s\n", path, tar_header.linkname);=0A=
       prepare_for_file (path);=0A=
       h =3D CreateFileA (path, GENERIC_WRITE, 0, 0, CREATE_NEW,=0A=
-		      FILE_ATTRIBUTE_NORMAL, 0);=0A=
+		       FILE_ATTRIBUTE_NORMAL, 0);=0A=
       if (h =3D=3D INVALID_HANDLE_VALUE)=0A=
 	{=0A=
-	  fprintf (stderr, "error: unable to create symlink \"%s\" -> =
\"%s\"\n",=0A=
-		   path, tar_header.linkname);=0A=
+	  fprintf (stderr,=0A=
+		   "error: unable to create symlink \"%s\" -> \"%s\"\n", path,=0A=
+		   tar_header.linkname);=0A=
 	  return 1;=0A=
 	}=0A=
       strcpy (buf, SYMLINK_COOKIE);=0A=
@@ -473,95 +467,8 @@ tar_read_file (char *path)=0A=
       fprintf (stderr, "error: unable to write symlink \"%s\"\n", path);=0A=
       DeleteFileA (path);=0A=
       return 1;=0A=
+    default:=0A=
+      return 0;=0A=
     }=0A=
 }=0A=
-=0A=
-int=0A=
-tar_close ()=0A=
-{=0A=
-#if 0=0A=
-  while (tar_map_result)=0A=
-    {=0A=
-      tar_map_result_type *t =3D tar_map_result->next;=0A=
-      free (tar_map_result->stored_name);=0A=
-      free (tar_map_result->mapped_name);=0A=
-      free (tar_map_result);=0A=
-      tar_map_result =3D t;=0A=
-    }=0A=
 #endif=0A=
-  tar_map_result =3D 0;=0A=
-=0A=
-  if (z->close ())=0A=
-    err++;=0A=
-  return err; /* includes errors for skipped files, etc */=0A=
-}=0A=
-=0A=
-typedef struct {=0A=
-  char *from;=0A=
-  int from_len;=0A=
-  char *to;=0A=
-  int to_len;=0A=
-} map_type;=0A=
-=0A=
-static map_type *map;=0A=
-static int nmaps;=0A=
-=0A=
-int=0A=
-tar_auto (char *pathname, char **maplist)=0A=
-{=0A=
-  char *c;=0A=
-  int err =3D 0;=0A=
-  int i, j;=0A=
-  map_type mtemp;=0A=
-  char newname[_MAX_PATH+512];=0A=
-  static char twiddles[] =3D "|\b/\b-\b\\\b";=0A=
-  int t =3D 0;=0A=
-=0A=
-  for (nmaps=3D0; maplist[nmaps*2]; nmaps++) ;=0A=
-  map =3D (map_type *) malloc ((nmaps+1) * sizeof (map_type));=0A=
-  for (nmaps=3D0; maplist[nmaps*2]; nmaps++)=0A=
-    {=0A=
-      map[nmaps].from =3D maplist[nmaps*2];=0A=
-      map[nmaps].from_len =3D strlen (maplist[nmaps*2]);=0A=
-      map[nmaps].to =3D maplist[nmaps*2+1];=0A=
-      map[nmaps].to_len =3D strlen (maplist[nmaps*2+1]);=0A=
-    }=0A=
-  /* bubble sort - expect the maps to be short */=0A=
-  for (i=3D0; i<nmaps-1; i++)=0A=
-    for (j=3Di+1; j<nmaps; j++)=0A=
-      if (map[i].from_len < map[j].from_len)=0A=
-	{=0A=
-	  mtemp =3D map[i];=0A=
-	  map[i] =3D map[j];=0A=
-	  map[j] =3D mtemp;=0A=
-	}=0A=
-=0A=
-  if (tar_open (pathname))=0A=
-    return 1;=0A=
-  while (c =3D tar_next_file ())=0A=
-    {=0A=
-      int l =3D strlen (c);=0A=
-      for (i=3D0; i<nmaps; i++)=0A=
-	if (l >=3D map[i].from_len=0A=
-	    && strncmp (c, map[i].from, map[i].from_len) =3D=3D 0)=0A=
-	  {=0A=
-	    strcpy (newname, map[i].to);=0A=
-	    strcpy (newname+map[i].to_len, c + map[i].from_len);=0A=
-	    c =3D newname;=0A=
-	    break;=0A=
-	  }=0A=
-=0A=
-      t =3D (t+2) % 8;=0A=
-      fwrite (twiddles+t, 1, 2, stderr);=0A=
-=0A=
-      if (tar_read_file (c))=0A=
-	err++;=0A=
-    }=0A=
-  if (tar_close ())=0A=
-    err++;=0A=
-=0A=
-  fwrite (" \b", 1, 2, stderr);=0A=
-=0A=
-  vp2 (_tar_vfile, "tar_auto returns %d\n", err);=0A=
-  return err;=0A=
-}=0A=
Index: tar.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cinstall/tar.h,v=0A=
retrieving revision 2.1=0A=
diff -u -p -r2.1 tar.h=0A=
--- tar.h	2001/06/13 16:11:01	2.1=0A=
+++ tar.h	2001/11/11 06:54:58=0A=
@@ -10,36 +10,148 @@=0A=
  *     http://www.gnu.org/=0A=
  *=0A=
  * Written by DJ Delorie <dj AT cygnus DOT com>=0A=
+ * Made OOP by R Collins <rbtcollins AT hotmail DOT com>=0A=
  *=0A=
  */=0A=
 =0A=
 #ifndef __TAR_H_=0A=
 #define __TAR_H_=0A=
 =0A=
+typedef struct=0A=
+{=0A=
+  char name[100];		/*   0 */=0A=
+  char mode[8];			/* 100 */=0A=
+  char uid[8];			/* 108 */=0A=
+  char gid[8];			/* 116 */=0A=
+  char size[12];		/* 124 */=0A=
+  char mtime[12];		/* 136 */=0A=
+  char chksum[8];		/* 148 */=0A=
+  char typeflag;		/* 156 */=0A=
+  char linkname[100];		/* 157 */=0A=
+  char magic[6];		/* 257 */=0A=
+  char version[2];		/* 263 */=0A=
+  char uname[32];		/* 265 */=0A=
+  char gname[32];		/* 297 */=0A=
+  char devmajor[8];		/* 329 */=0A=
+  char devminor[8];		/* 337 */=0A=
+  char prefix[155];		/* 345 */=0A=
+  char junk[12];		/* 500 */=0A=
+}=0A=
+tar_header_type;=0A=
+=0A=
+typedef struct tar_map_result_type_s=0A=
+{=0A=
+  struct tar_map_result_type_s *next;=0A=
+  char *stored_name;=0A=
+  char *mapped_name;=0A=
+}=0A=
+tar_map_result_type;=0A=
+=0A=
+class tar_state=0A=
+{=0A=
+public:=0A=
+  tar_state ():lasterr (0), eocf (0), have_longname ('\0'), file_offset =
(0),=0A=
+    file_length (0), header_read (0)=0A=
+  {=0A=
+    parent =3D NULL;=0A=
+    filename[0] =3D '\0';=0A=
+    tar_map_result =3D NULL;=0A=
+  };=0A=
+  io_stream *parent;=0A=
+  int lasterr;=0A=
+  int eocf;=0A=
+  char have_longname;=0A=
+  /* where in the current file are we? */=0A=
+  size_t file_offset;=0A=
+  size_t file_length;=0A=
+  int header_read;=0A=
+  tar_header_type tar_header;=0A=
+  char filename[_MAX_PATH + 512];=0A=
+  tar_map_result_type *tar_map_result;=0A=
+};=0A=
+=0A=
+class archive_tar_file:public io_stream=0A=
+{=0A=
+public:=0A=
+  archive_tar_file (tar_state &);=0A=
+  virtual ssize_t read (void *buffer, size_t len);=0A=
+  /* provide data to (double duh!) */=0A=
+  virtual ssize_t write (void *buffer, size_t len);=0A=
+  /* read data without removing it from the class's internal buffer */=0A=
+  virtual ssize_t peek (void *buffer, size_t len);=0A=
+  virtual long tell ();=0A=
+  /* try guessing this one */=0A=
+  virtual int error ();=0A=
+  virtual char *next_file_name ()=0A=
+  {=0A=
+    return NULL;=0A=
+  };=0A=
+  virtual int set_mtime (int)=0A=
+  {=0A=
+    return 1;=0A=
+  };=0A=
+    virtual ~ archive_tar_file ();=0A=
+private:=0A=
+    tar_state & state;=0A=
+};=0A=
+=0A=
+class archive_tar:public archive=0A=
+{=0A=
+public:=0A=
+  archive_tar (io_stream * original);=0A=
+  virtual io_stream *extract_file ();=0A=
+  /* read data (duh!) */=0A=
+  virtual ssize_t read (void *buffer, size_t len);=0A=
+  /* provide data to (double duh!) */=0A=
+  virtual ssize_t write (void *buffer, size_t len);=0A=
+  /* read data without removing it from the class's internal buffer */=0A=
+  virtual ssize_t peek (void *buffer, size_t len);=0A=
+  virtual long tell ();=0A=
+  /* try guessing this one */=0A=
+  virtual int error ();=0A=
+  /* Find out the next stream name -=0A=
+   * ie for foo.tar.gz, at offset 0, next_file_name =3D foo.tar=0A=
+   * for foobar that is an compress, next_file_name is the next=0A=
+   * extractable filename.=0A=
+   */=0A=
+  virtual const char *next_file_name ();=0A=
+  virtual archive_file_t next_file_type ();=0A=
+  /* only of use when we support writing to tar */=0A=
+  virtual int set_mtime (int)=0A=
+  {=0A=
+    return 1;=0A=
+  };=0A=
+  virtual const char *linktarget ();=0A=
+  virtual int skip_file ();=0A=
+  /* if you are still needing these hints... give up now! */=0A=
+    virtual ~ archive_tar ();=0A=
+private:=0A=
+    archive_tar ()=0A=
+  {=0A=
+  };=0A=
+  tar_state state;=0A=
+  unsigned int archive_children;=0A=
+};=0A=
+=0A=
 /* Only one tarfile may be open at a time.  gzipped files handled=0A=
    automatically */=0A=
 =0A=
 /* returns zero on success, nonzero on failure */=0A=
-int	tar_open (const char *pathname);=0A=
-=0A=
-/* returns pointer to static buf containing name of next file */=0A=
-char *	tar_next_file ();=0A=
+//int   tar_open (const char *pathname);=0A=
 =0A=
-/* byte position in [compressed] file */=0A=
-int	tar_ftell ();=0A=
-=0A=
 /* pass adjusted path, returns zero on success, nonzero on failure */=0A=
-int	tar_read_file (char *path);=0A=
+//int   tar_read_file (char *path);=0A=
 =0A=
-/* closes the file */=0A=
-int	tar_close ();=0A=
 =0A=
+#if 0=0A=
 /* pass path to tar file and from/to pairs for path prefix (NULLs at=0A=
    end , returns zero if completely successful, nonzero (counts=0A=
    errors) on failure */=0A=
-int	tar_auto (char *pathname, char **map);=0A=
+int tar_auto (char *pathname, char **map);=0A=
+#endif=0A=
+=0A=
 =0A=
-int	tar_mkdir_p (int isadir, char *path);=0A=
+//int   tar_mkdir_p (int isadir, char *path);=0A=
 =0A=
 /*=0A=
 extern int _tar_verbose;=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="archive.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="archive.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* Archive IO operations=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
#include "concat.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "archive.h"=0A=
#include <stdlib.h>=0A=
#include "tar.h"=0A=
=0A=
/* In case you are wondering why the file magic is not in one place:=0A=
 * It could be. But there is little (any?) benefit.=0A=
 * What is important is that the file magic required for any _task_ is =
centralised.=0A=
 * One such task is identifying archives=0A=
 *=0A=
 * to federate into each class one might add a magic parameter to the =
constructor, which=0A=
 * the class could test itself. =0A=
 */=0A=
=0A=
/* GNU TAR:=0A=
 * offset 257     string  ustar\040\040\0=0A=
 */=0A=
=0A=
=0A=
#define longest_magic 265=0A=
=0A=
archive *=0A=
archive::extract (io_stream * original)=0A=
{=0A=
  if (!original)=0A=
    return NULL;=0A=
  char magic[longest_magic];=0A=
  if (original->peek (magic, longest_magic) > 0)=0A=
    {=0A=
      if (memcmp (&magic[257], "ustar\040\040\0", 8) =3D=3D 0)=0A=
	{=0A=
	  /* tar */=0A=
	  archive_tar *rv =3D new archive_tar (original);=0A=
	  if (!rv->error ())=0A=
	    return rv;=0A=
	  return NULL;=0A=
	}=0A=
#if 0=0A=
      else if (memcmp (magic, "BZh", 3) =3D=3D 0)=0A=
	{=0A=
	  archive_bz *rv =3D new archive_bz (original);=0A=
	  if (!rv->error ())=0A=
	    return rv;=0A=
	  return NULL;=0A=
	}=0A=
#endif=0A=
    }=0A=
  return NULL;=0A=
}=0A=
=0A=
int=0A=
archive::extract_file (archive * source, const char *prefix)=0A=
{=0A=
  if (!source)=0A=
    return 1;=0A=
  const char *destfilename =3D concat (prefix, source->next_file_name =
(), 0);=0A=
  switch (source->next_file_type ())=0A=
    {=0A=
    case ARCHIVE_FILE_REGULAR:=0A=
      {=0A=
=0A=
	/* TODO: remove in-the-way directories via mkpath_p */=0A=
	if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))=0A=
	  return 1;=0A=
	io_stream::remove (destfilename);=0A=
	io_stream *tmp =3D io_stream::open (destfilename, "wb");=0A=
	if (!tmp)=0A=
	  return 1;=0A=
	io_stream *in =3D source->extract_file ();=0A=
	if (!in)=0A=
	  {=0A=
	    delete tmp;=0A=
	    return 1;=0A=
	  }=0A=
	char buffer[16384];=0A=
	ssize_t countin, countout;=0A=
	while ((countin =3D in->read (buffer, 16384)) > 0)=0A=
	  {=0A=
	    countout =3D tmp->write (buffer, countin);=0A=
	    if (countout !=3D countin)=0A=
	      {=0A=
		log (LOG_TIMESTAMP, "Failed to write %ld bytes to %s",=0A=
		     countin, destfilename);=0A=
		io_stream::remove (destfilename);=0A=
		delete tmp;=0A=
		delete in;=0A=
		return 1;=0A=
	      }=0A=
	  }=0A=
	delete in;=0A=
	delete tmp;=0A=
	if (countin < 0)=0A=
	  {=0A=
	    log (LOG_TIMESTAMP, "File IO error reading from archive");=0A=
	    io_stream::remove (destfilename);=0A=
	  }=0A=
      }=0A=
      break;=0A=
    case ARCHIVE_FILE_SYMLINK:=0A=
      {=0A=
	/* TODO: remove in-the-way directories via mkpath_p */=0A=
	if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))=0A=
	  return 1;=0A=
	io_stream::remove (destfilename);=0A=
	int ok =3D=0A=
	  io_stream::mklink (destfilename,=0A=
			     concat (prefix, source->linktarget (), 0),=0A=
			     IO_STREAM_SYMLINK);=0A=
	/* FIXME: check what tar's filelength is set to for symlinks */=0A=
	source->skip_file ();=0A=
	return ok;=0A=
      }=0A=
    case ARCHIVE_FILE_HARDLINK:=0A=
      {=0A=
	/* TODO: remove in-the-way directories via mkpath_p */=0A=
	if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))=0A=
	  return 1;=0A=
	io_stream::remove (destfilename);=0A=
	int ok =3D=0A=
	  io_stream::mklink (destfilename,=0A=
			     concat (prefix, source->linktarget (), 0),=0A=
			     IO_STREAM_HARDLINK);=0A=
	/* FIXME: check what tar's filelength is set to for hardlinks */=0A=
	source->skip_file ();=0A=
	return ok;=0A=
      }=0A=
    case ARCHIVE_FILE_DIRECTORY:=0A=
      {=0A=
	char *path =3D (char *) alloca (strlen (destfilename));=0A=
	strcpy (path, destfilename);=0A=
	while (path[0] && path[strlen (path) - 1] =3D=3D '/')=0A=
	  path[strlen (path) - 1] =3D 0;=0A=
	source->skip_file ();=0A=
	return io_stream::mkpath_p (PATH_TO_DIR, path);=0A=
      }=0A=
    case ARCHIVE_FILE_INVALID:=0A=
      source->skip_file ();=0A=
      break;=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
#if 0=0A=
ssize_t archive::read (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::read called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t archive::write (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::write called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t archive::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::peek called");=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
archive::tell ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "bz::tell called");=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
archive::error ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::error called");=0A=
  return 0;=0A=
}=0A=
=0A=
const char *=0A=
archive::next_file_name ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::next_file_name called");=0A=
  return NULL;=0A=
}=0A=
=0A=
archive::~archive ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "archive::~archive called");=0A=
  return;=0A=
}=0A=
#endif=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="archive.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="archive.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _ARCHIVE_H_=0A=
#define _ARCHIVE_H_=0A=
=0A=
/* this is the parent class for all archive IO operations. =0A=
 * It =0A=
 */=0A=
=0A=
/* The read/write the archive stream to get the archive data is flawed.=0A=
 * The problem is that you then need a *different* gzip etc class to be =
able=0A=
 * to ungzip a gzip from within an archive.=0A=
 * The correct way is to =0A=
 * 1) retrieve the file name.=0A=
 * 2) the user creates their own output object.=0A=
 * 3) the user calls extract_file (output strea,).=0A=
 */=0A=
=0A=
typedef enum=0A=
{=0A=
  ARCHIVE_FILE_INVALID,=0A=
  ARCHIVE_FILE_REGULAR,=0A=
  ARCHIVE_FILE_HARDLINK,=0A=
  ARCHIVE_FILE_SYMLINK,=0A=
  ARCHIVE_FILE_DIRECTORY=0A=
}=0A=
archive_file_t;=0A=
=0A=
=0A=
class archive:public io_stream=0A=
{=0A=
public:=0A=
  /* get an archive child class from an io_stream */=0A=
  static archive *extract (io_stream *);=0A=
  /* get an ouput stream for the next files from the archive.=0A=
   * returns NULL on failure.=0A=
   * The stream is not taken over - it will not be automatically deleted=0A=
   */=0A=
  virtual io_stream *extract_file () =3D NULL;=0A=
  /* extract the next file to the given prefix in one step=0A=
   * returns 1 on failure.=0A=
   */=0A=
  static int extract_file (archive *, const char *);=0A=
=0A=
  /* =0A=
   * To create a stream that will be compressed, you should open the =
url, and then get a new stream=0A=
   * from compress::compress. =0A=
   */=0A=
  /* read data - not valid for archives (duh!) =0A=
   * Could be made valid via the read-child-directly model =0A=
   */=0A=
//  virtual ssize_t read(void *buffer, size_t len) {return -1;};=0A=
  /* provide data to (double duh!) */=0A=
//  virtual ssize_t write(void *buffer, size_t len) { return -1;};=0A=
  /* read data without removing it from the class's internal buffer */=0A=
//  virtual ssize_t peek(void *buffer, size_t len);=0A=
//  virtual long tell ();=0A=
  /* try guessing this one */=0A=
//  virtual int error ();=0A=
  /* Find out the next stream name -=0A=
   * ie for foo.tar.gz, at offset 0, next_file_name =3D foo.tar=0A=
   * for foobar that is an compress, next_file_name is the next=0A=
   * extractable filename.=0A=
   * The way this works is that when read returns 0, you are at the end =
of *a* file.=0A=
   * next_file_name will allow read to be called again, if it returns =
!NULL=0A=
   */=0A=
  virtual const char *next_file_name () =3D NULL;=0A=
  virtual archive_file_t next_file_type () =3D ARCHIVE_FILE_INVALID;=0A=
  virtual const char *linktarget () =3D NULL;=0A=
  virtual int skip_file () =3D 0;=0A=
  /* if you are still needing these hints... give up now! */=0A=
//  virtual ~compress ();=0A=
private:=0A=
//  archive () {};=0A=
};=0A=
=0A=
#endif /* _ARCHIVE_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="archive_tar_file.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="archive_tar_file.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins =0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* An individual stream from a tar archive. */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D "\n%%% $Id:  Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include <stdlib.h>=0A=
#include <sys/types.h>=0A=
#include <sys/fcntl.h>=0A=
#include <errno.h>=0A=
=0A=
#include "zlib/zlib.h"=0A=
#include "io_stream.h"=0A=
#include "compress.h"=0A=
#include "archive.h"=0A=
#include "tar.h"=0A=
#include "log.h"=0A=
#include "concat.h"=0A=
=0A=
#include "port.h"=0A=
=0A=
archive_tar_file::archive_tar_file (tar_state & newstate):state =
(newstate)=0A=
{=0A=
}=0A=
=0A=
archive_tar_file::~archive_tar_file ()=0A=
{=0A=
  state.header_read =3D 0;=0A=
}=0A=
=0A=
/* Virtual memebrs */=0A=
ssize_t archive_tar_file::read (void *buffer, size_t len)=0A=
{=0A=
  /* how many bytes do we want to give the user */=0A=
  int=0A=
    want =3D min (len, state.file_length - state.file_offset);=0A=
  /* how many do we need to read after that to line up the file pointer =
*/=0A=
  int=0A=
    roundup =3D (512 - (want % 512)) % 512;=0A=
  if (want)=0A=
    {=0A=
      ssize_t=0A=
	got =3D state.parent->read (buffer, want);=0A=
      char=0A=
	throwaway[512];=0A=
      ssize_t=0A=
	got2 =3D state.parent->read (throwaway, roundup);=0A=
      if (got =3D=3D want && got2 =3D=3D roundup)=0A=
	{=0A=
	  state.file_offset +=3D got;=0A=
	  return got;=0A=
	}=0A=
      else=0A=
	{=0A=
	  /* unexpected EOF or read error in the tar parent stream */=0A=
	  /* the user can query the parent for the error */=0A=
	  state.lasterr =3D EIO;=0A=
	  return EIO;=0A=
	}=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
/* provide data to (double duh!) */=0A=
ssize_t archive_tar_file::write (void *buffer, size_t len)=0A=
{=0A=
  /* write not supported */=0A=
  return EBADF;=0A=
}=0A=
=0A=
/* read data without removing it from the class's internal buffer */=0A=
ssize_t archive_tar_file::peek (void *buffer, size_t len)=0A=
{=0A=
  int=0A=
    want =3D min (len, state.file_length - state.file_offset);=0A=
  if (want)=0A=
    {=0A=
      ssize_t=0A=
	got =3D state.parent->peek (buffer, want);=0A=
      if (got =3D=3D want)=0A=
	{=0A=
	  return got;=0A=
	}=0A=
      else=0A=
	{=0A=
	  /* unexpected EOF or read error in the tar parent stream */=0A=
	  /* the user can query the parent for the error */=0A=
	  state.lasterr =3D EIO;=0A=
	  return EIO;=0A=
	}=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
archive_tar_file::tell ()=0A=
{=0A=
  return state.file_offset;=0A=
}=0A=
=0A=
/* try guessing this one */=0A=
int=0A=
archive_tar_file::error ()=0A=
{=0A=
  return state.lasterr;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress_gz.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress_gz.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _COMPRESS_GZ_H_=0A=
#define _COMPRESS_GZ_H_=0A=
=0A=
/* this is the parent class for all compress IO operations. =0A=
 * It =0A=
 */=0A=
=0A=
class compress_gz:public compress=0A=
{=0A=
public:=0A=
  /* assumes decompression */=0A=
  compress_gz (io_stream *);=0A=
  /* the mode allows control, but this implementation only does =
compression */=0A=
  compress_gz (io_stream *, const char *);=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len);=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len);=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len);=0A=
  virtual long tell ();=0A=
  /* try guessing this one */=0A=
  virtual int error ();=0A=
  /* Find out the next stream name -=0A=
   * ie for foo.tar.gz, at offset 0, next_file_name =3D foo.tar=0A=
   * for foobar that is an compress, next_file_name is the next=0A=
   * extractable filename.=0A=
   */=0A=
  virtual const char *next_file_name ()=0A=
  {=0A=
    return NULL;=0A=
  };=0A=
  virtual int set_mtime (int);=0A=
  /* if you are still needing these hints... give up now! */=0A=
    virtual ~ compress_gz ();=0A=
private:=0A=
    compress_gz ()=0A=
  {=0A=
  };=0A=
  char peekbuf[512];=0A=
  size_t peeklen;=0A=
  void construct (io_stream *, const char *);=0A=
  void check_header ();=0A=
  int get_byte ();=0A=
  unsigned long getLong ();=0A=
  void putLong (unsigned long);=0A=
  void destroy ();=0A=
  int do_flush (int);=0A=
  io_stream *original;=0A=
  /* from zlib */=0A=
  z_stream stream;=0A=
  int z_err;			/* error code for last stream operation */=0A=
  int z_eof;			/* set if end of input file */=0A=
  unsigned char *inbuf;		/* input buffer */=0A=
  unsigned char *outbuf;	/* output buffer */=0A=
  uLong crc;			/* crc32 of uncompressed data */=0A=
  char *msg;			/* error message */=0A=
  int transparent;		/* 1 if input file is not a .gz file */=0A=
  char mode;			/* 'w' or 'r' */=0A=
  long startpos;		/* start of compressed data in file (header skipped) */=0A=
};=0A=
=0A=
#endif /* _COMPRESS_GZ_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _COMPRESS_H_=0A=
#define _COMPRESS_H_=0A=
=0A=
/* this is the parent class for all compress IO operations. =0A=
 * It =0A=
 */=0A=
=0A=
class compress:public io_stream=0A=
{=0A=
public:=0A=
  /* Get a decompressed stream from a normal stream. If this function =
returns non-null=0A=
   * a valid compress header was found. The io_stream pointer passed to =
decompress=0A=
   * should be discarded. The old io_stream will be automatically closed =
when the =0A=
   * decompression stream is closed=0A=
   */=0A=
  static io_stream *decompress (io_stream *);=0A=
  /* =0A=
   * To create a stream that will be compressed, you should open the =
url, and then get a new stream=0A=
   * from compress::compress. =0A=
   */=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len);=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len);=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len);=0A=
  virtual long tell ();=0A=
  /* try guessing this one */=0A=
  virtual int error ();=0A=
  /* Find out the next stream name -=0A=
   * ie for foo.tar.gz, at offset 0, next_file_name =3D foo.tar=0A=
   * for foobar that is an compress, next_file_name is the next=0A=
   * extractable filename.=0A=
   */=0A=
  virtual const char *next_file_name () =3D NULL;=0A=
  /* if you are still needing these hints... give up now! */=0A=
    virtual ~ compress ();=0A=
};=0A=
=0A=
#endif /* _COMPRESS_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress_bz.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress_bz.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* Archive IO operations=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include <errno.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "compress.h"=0A=
#include "compress_bz.h"=0A=
=0A=
compress_bz::compress_bz (io_stream * parent)=0A=
{=0A=
  original =3D NULL;=0A=
  lasterr =3D 0;=0A=
  if (!parent)=0A=
    lasterr =3D EBADF;=0A=
  original =3D parent;=0A=
}=0A=
=0A=
ssize_t compress_bz::read (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::read called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t compress_bz::write (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::write called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t compress_bz::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::peek called");=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
compress_bz::tell ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::tell called");=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
compress_bz::error ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::error called");=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
compress_bz::set_mtime (int time)=0A=
{=0A=
  if (original)=0A=
    return original->set_mtime (time);=0A=
  return 1;=0A=
}=0A=
=0A=
compress_bz::~compress_bz ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_bz::~bz called");=0A=
  return;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress_bz.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress_bz.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _COMPRESS_BZ_H_=0A=
#define _COMPRESS_BZ_H_=0A=
=0A=
/* this is the parent class for all compress IO operations. =0A=
 * It =0A=
 */=0A=
=0A=
class compress_bz:public compress=0A=
{=0A=
public:=0A=
  /* assumes decompression */=0A=
  compress_bz (io_stream *);=0A=
  /* allows comp/decomp but this implementation only handles comp */=0A=
  compress_bz (io_stream *, const char *);=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len);=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len);=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len);=0A=
  virtual long tell ();=0A=
  /* try guessing this one */=0A=
  virtual int error ();=0A=
  /* Find out the next stream name -=0A=
   * ie for foo.tar.bz, at offset 0, next_file_name =3D foo.tar=0A=
   * for foobar that is an compress, next_file_name is the next=0A=
   * extractable filename.=0A=
   */=0A=
  virtual const char *next_file_name ()=0A=
  {=0A=
    return NULL;=0A=
  };=0A=
  virtual int set_mtime (int);=0A=
  /* if you are still needing these hints... give up now! */=0A=
    virtual ~ compress_bz ();=0A=
private:=0A=
    compress_bz ()=0A=
  {=0A=
  };=0A=
  io_stream *original;=0A=
  int lasterr;=0A=
};=0A=
=0A=
#endif /* _COMPRESS_BZ_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress_gz.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress_gz.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* Archive IO operations for gz files=0A=
 * Portions copyright under the zlib licence - this class was derived =
from gzio.c in that=0A=
 * library.=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include <stdlib.h>=0A=
#include <errno.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "compress.h"=0A=
#include "zlib/zlib.h"=0A=
#include "compress_gz.h"=0A=
=0A=
#define HEAD_CRC     0x02	/* bit 1 set: header CRC present */=0A=
#define EXTRA_FIELD  0x04	/* bit 2 set: extra field present */=0A=
#define ORIG_NAME    0x08	/* bit 3 set: original file name present */=0A=
#define COMMENT      0x10	/* bit 4 set: file comment present */=0A=
#define RESERVED     0xE0	/* bits 5..7: reserved */=0A=
=0A=
=0A=
/* TODO make this a static member and federate the magic logic */=0A=
static int gz_magic[2] =3D { 0x1f, 0x8b };	/* gzip magic header */=0A=
=0A=
/*=0A=
 * Predicate: the stream is open for read. For writing the class =
constructor variant with=0A=
 * mode must be called directly=0A=
 */=0A=
compress_gz::compress_gz (io_stream * parent)=0A=
{=0A=
  construct (parent, "r");=0A=
}=0A=
=0A=
compress_gz::compress_gz (io_stream * parent, const char *openmode)=0A=
{=0A=
  construct (parent, openmode);=0A=
}=0A=
=0A=
void=0A=
compress_gz::construct (io_stream * parent, const char *openmode)=0A=
{=0A=
  if (!parent)=0A=
    {=0A=
      z_err =3D Z_STREAM_ERROR;=0A=
      return;=0A=
    }=0A=
=0A=
  original =3D parent;=0A=
  peeklen =3D 0;=0A=
  int err;=0A=
  int level =3D Z_DEFAULT_COMPRESSION;	/* compression level */=0A=
  int strategy =3D Z_DEFAULT_STRATEGY;	/* compression strategy */=0A=
  char *p =3D (char *) openmode;=0A=
  char fmode[80];		/* copy of openmode, without the compression level */=0A=
  char *m =3D fmode;=0A=
=0A=
  stream.zalloc =3D (alloc_func) NULL;=0A=
  stream.zfree =3D (free_func) NULL;=0A=
  stream.opaque =3D (voidpf) NULL;=0A=
  stream.next_in =3D inbuf =3D NULL;=0A=
  stream.next_out =3D outbuf =3D NULL;=0A=
  stream.avail_in =3D stream.avail_out =3D 0;=0A=
  z_err =3D Z_OK;=0A=
  z_eof =3D 0;=0A=
  crc =3D crc32 (0L, Z_NULL, 0);=0A=
  msg =3D NULL;=0A=
  transparent =3D 0;=0A=
=0A=
  mode =3D '\0';=0A=
  do=0A=
    {=0A=
      if (*p =3D=3D 'r')=0A=
	mode =3D 'r';=0A=
      if (*p =3D=3D 'w' || *p =3D=3D 'a')=0A=
	mode =3D 'w';=0A=
      if (*p >=3D '0' && *p <=3D '9')=0A=
	{=0A=
	  level =3D *p - '0';=0A=
	}=0A=
      else if (*p =3D=3D 'f')=0A=
	{=0A=
	  strategy =3D Z_FILTERED;=0A=
	}=0A=
      else if (*p =3D=3D 'h')=0A=
	{=0A=
	  strategy =3D Z_HUFFMAN_ONLY;=0A=
	}=0A=
      else=0A=
	{=0A=
	  *m++ =3D *p;		/* copy the mode */=0A=
	}=0A=
    }=0A=
  while (*p++ && m !=3D fmode + sizeof (fmode));=0A=
  if (mode =3D=3D '\0')=0A=
    {=0A=
      destroy ();=0A=
      z_err =3D Z_STREAM_ERROR;=0A=
      return;=0A=
    }=0A=
=0A=
=0A=
  if (mode =3D=3D 'w')=0A=
    {=0A=
      err =3D deflateInit2 (&(stream), level,=0A=
			  Z_DEFLATED, -MAX_WBITS, 8, strategy);=0A=
      /* windowBits is passed < 0 to suppress zlib header */=0A=
=0A=
      stream.next_out =3D outbuf =3D (Byte *) malloc (16384);=0A=
      if (err !=3D Z_OK || outbuf =3D=3D Z_NULL)=0A=
	{=0A=
	  destroy ();=0A=
	  z_err =3D Z_STREAM_ERROR;=0A=
	  return;=0A=
	}=0A=
    }=0A=
  else=0A=
    {=0A=
=0A=
      stream.next_in =3D inbuf =3D (unsigned char *) malloc (16384);=0A=
      err =3D inflateInit2 (&stream, -MAX_WBITS);=0A=
      /* windowBits is passed < 0 to tell that there is no zlib header.=0A=
       * Note that in this case inflate *requires* an extra "dummy" byte=0A=
       * after the compressed stream in order to complete decompression =
and=0A=
       * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes =
are=0A=
       * present after the compressed stream.=0A=
       */=0A=
      if (err !=3D Z_OK || inbuf =3D=3D Z_NULL)=0A=
	{=0A=
	  destroy ();=0A=
	  z_err =3D Z_STREAM_ERROR;=0A=
	  return;=0A=
	}=0A=
    }=0A=
  stream.avail_out =3D 16384;=0A=
=0A=
  errno =3D 0;=0A=
  if (mode =3D=3D 'w')=0A=
    {=0A=
      /* Write a very simple .gz header:=0A=
       */=0A=
      char temp[20];=0A=
      sprintf (temp, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],=0A=
	       Z_DEFLATED, 0 /*flags */ , 0, 0, 0, 0 /*time */ ,=0A=
	       0 /*xflags */ , 0x0b);=0A=
      original->write (temp, 10);=0A=
      startpos =3D 10L;=0A=
      /* We use 10L instead of ftell(s->file) to because ftell causes an=0A=
       * fflush on some systems. This version of the library doesn't use=0A=
       * startpos anyway in write mode, so this initialization is not=0A=
       * necessary. =0A=
       */=0A=
    }=0A=
  else=0A=
    {=0A=
=0A=
      check_header ();		/* skip the .gz header */=0A=
      startpos =3D (original->tell () - stream.avail_in);=0A=
    }=0A=
=0A=
  return;=0A=
}=0A=
=0A=
/* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
   Outputs a long in LSB order to the given file=0A=
*/=0A=
void=0A=
compress_gz::putLong (unsigned long x)=0A=
{=0A=
  int n;=0A=
  for (n =3D 0; n < 4; n++)=0A=
    {=0A=
      unsigned char c =3D (unsigned char) (x & 0xff);=0A=
      original->write (&c, 1);=0A=
      x =3D x >> 8;=0A=
    }=0A=
}=0A=
=0A=
=0A=
uLong=0A=
compress_gz::getLong ()=0A=
{=0A=
  uLong x =3D (uLong) get_byte ();=0A=
  int c;=0A=
=0A=
  x +=3D ((uLong) get_byte ()) << 8;=0A=
  x +=3D ((uLong) get_byte ()) << 16;=0A=
  c =3D get_byte ();=0A=
  if (c =3D=3D EOF)=0A=
    z_err =3D Z_DATA_ERROR;=0A=
  x +=3D ((uLong) c) << 24;=0A=
  return x;=0A=
}=0A=
=0A=
=0A=
ssize_t=0A=
compress_gz::read (void *buffer, size_t len)=0A=
{=0A=
  if (!len)=0A=
    return 0;=0A=
=0A=
  if (peeklen)=0A=
    {=0A=
      ssize_t tmplen =3D min (peeklen, len);=0A=
      peeklen -=3D tmplen;=0A=
      memcpy (buffer, peekbuf, tmplen);=0A=
      memmove (peekbuf, peekbuf + tmplen, tmplen);=0A=
      ssize_t tmpread =3D read (&((char *) buffer)[tmplen], len - =
tmplen);=0A=
      if (tmpread >=3D 0)=0A=
	return tmpread + tmplen;=0A=
      else=0A=
	return tmpread;=0A=
    }=0A=
=0A=
  Bytef *start =3D (Bytef *) buffer;	/* starting point for crc =
computation */=0A=
  Byte *next_out;		/* =3D=3D stream.next_out but not forced far (for =
MSDOS) */=0A=
=0A=
  if (mode !=3D 'r')=0A=
    return Z_STREAM_ERROR;=0A=
=0A=
  if (z_err =3D=3D Z_DATA_ERROR || z_err =3D=3D Z_ERRNO)=0A=
    return -1;=0A=
  if (z_err =3D=3D Z_STREAM_END)=0A=
    return 0;			/* EOF */=0A=
=0A=
  next_out =3D (Byte *) buffer;=0A=
  stream.next_out =3D (Bytef *) buffer;=0A=
  stream.avail_out =3D len;=0A=
=0A=
  while (stream.avail_out !=3D 0)=0A=
    {=0A=
=0A=
      if (transparent)=0A=
	{=0A=
	  /* Copy first the lookahead bytes: */=0A=
	  uInt n =3D stream.avail_in;=0A=
	  if (n > stream.avail_out)=0A=
	    n =3D stream.avail_out;=0A=
	  if (n > 0)=0A=
	    {=0A=
	      memcpy (stream.next_out, stream.next_in, n);=0A=
	      next_out +=3D n;=0A=
	      stream.next_out =3D next_out;=0A=
	      stream.next_in +=3D n;=0A=
	      stream.avail_out -=3D n;=0A=
	      stream.avail_in -=3D n;=0A=
	    }=0A=
	  if (stream.avail_out > 0)=0A=
	    {=0A=
	      stream.avail_out -=3D original->read (next_out, stream.avail_out);=0A=
	    }=0A=
	  len -=3D stream.avail_out;=0A=
	  stream.total_in +=3D (uLong) len;=0A=
	  stream.total_out +=3D (uLong) len;=0A=
	  if (len =3D=3D 0)=0A=
	    z_eof =3D 1;=0A=
	  return (int) len;=0A=
	}=0A=
      if (stream.avail_in =3D=3D 0 && !z_eof)=0A=
	{=0A=
=0A=
	  errno =3D 0;=0A=
	  stream.avail_in =3D original->read (inbuf, 16384);=0A=
	  if (stream.avail_in =3D=3D 0)=0A=
	    {=0A=
	      z_eof =3D 1;=0A=
	      if (original->error ())=0A=
		{=0A=
		  z_err =3D Z_ERRNO;=0A=
		  break;=0A=
		}=0A=
	    }=0A=
	  stream.next_in =3D inbuf;=0A=
	}=0A=
      z_err =3D inflate (&(stream), Z_NO_FLUSH);=0A=
=0A=
      if (z_err =3D=3D Z_STREAM_END)=0A=
	{=0A=
	  /* Check CRC and original size */=0A=
	  crc =3D crc32 (crc, start, (uInt) (stream.next_out - start));=0A=
	  start =3D stream.next_out;=0A=
=0A=
	  if (getLong () !=3D crc)=0A=
	    {=0A=
	      z_err =3D Z_DATA_ERROR;=0A=
	    }=0A=
	  else=0A=
	    {=0A=
	      (void) getLong ();=0A=
	      /* The uncompressed length returned by above getlong() may=0A=
	       * be different from stream.total_out) in case of=0A=
	       * concatenated .gz files. Check for such files:=0A=
	       */=0A=
	      check_header ();=0A=
	      if (z_err =3D=3D Z_OK)=0A=
		{=0A=
		  uLong total_in =3D stream.total_in;=0A=
		  uLong total_out =3D stream.total_out;=0A=
=0A=
		  inflateReset (&(stream));=0A=
		  stream.total_in =3D total_in;=0A=
		  stream.total_out =3D total_out;=0A=
		  crc =3D crc32 (0L, Z_NULL, 0);=0A=
		}=0A=
	    }=0A=
	}=0A=
      if (z_err !=3D Z_OK || z_eof)=0A=
	break;=0A=
    }=0A=
  crc =3D crc32 (crc, start, (uInt) (stream.next_out - start));=0A=
=0A=
  return (int) (len - stream.avail_out);=0A=
}=0A=
=0A=
=0A=
/* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
   Writes the given number of uncompressed bytes into the compressed =
file.=0A=
   gzwrite returns the number of bytes actually written (0 in case of =
error).=0A=
*/=0A=
ssize_t=0A=
compress_gz::write (void *buffer, size_t len)=0A=
{=0A=
  if (mode !=3D 'w')=0A=
    return Z_STREAM_ERROR;=0A=
=0A=
  stream.next_in =3D (Bytef *) buffer;=0A=
  stream.avail_in =3D len;=0A=
=0A=
  while (stream.avail_in !=3D 0)=0A=
    {=0A=
=0A=
      if (stream.avail_out =3D=3D 0)=0A=
	{=0A=
=0A=
	  stream.next_out =3D outbuf;=0A=
	  if (original->write (outbuf, 16384) !=3D 16384)=0A=
	    {=0A=
	      z_err =3D Z_ERRNO;=0A=
	      break;=0A=
	    }=0A=
	  stream.avail_out =3D 16384;=0A=
	}=0A=
      z_err =3D deflate (&(stream), Z_NO_FLUSH);=0A=
      if (z_err !=3D Z_OK)=0A=
	break;=0A=
    }=0A=
  crc =3D crc32 (crc, (const Bytef *) buffer, len);=0A=
=0A=
  return (int) (len - stream.avail_in);=0A=
}=0A=
=0A=
ssize_t=0A=
compress_gz::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_gz::peek called");=0A=
  if (mode !=3D 'r')=0A=
    return Z_STREAM_ERROR;=0A=
  /* can only peek 512 bytes */=0A=
  if (len > 512)=0A=
    return ENOMEM;=0A=
=0A=
  if (len > peeklen)=0A=
    {=0A=
      size_t want =3D len - peeklen;=0A=
      ssize_t got =3D read (&peekbuf[peeklen], want);=0A=
      if (got >=3D 0)=0A=
	peeklen +=3D got;=0A=
      else=0A=
	/* error */=0A=
	return got;=0A=
      /* we may have read less than requested. */=0A=
      memcpy (buffer, peekbuf, peeklen);=0A=
      return peeklen;=0A=
    }=0A=
  else=0A=
    {=0A=
      memcpy (buffer, peekbuf, len);=0A=
      return len;=0A=
    }=0A=
}=0A=
=0A=
long=0A=
compress_gz::tell ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_gz::tell called");=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
compress_gz::error ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_gz::error called");=0A=
  return z_err;=0A=
}=0A=
=0A=
int=0A=
compress_gz::set_mtime (int time)=0A=
{=0A=
  if (original)=0A=
    return original->set_mtime (time);=0A=
  return 1;=0A=
}=0A=
=0A=
void=0A=
compress_gz::destroy ()=0A=
{=0A=
  if (msg)=0A=
    free (msg);=0A=
  if (stream.state !=3D NULL)=0A=
    {=0A=
      if (mode =3D=3D 'w')=0A=
	{=0A=
	  z_err =3D deflateEnd (&(stream));=0A=
	}=0A=
      else if (mode =3D=3D 'r')=0A=
	{=0A=
	  z_err =3D inflateEnd (&(stream));=0A=
	}=0A=
    }=0A=
=0A=
  if (inbuf)=0A=
=0A=
    free (inbuf);=0A=
  if (outbuf)=0A=
    free (outbuf);=0A=
  if (original)=0A=
    delete original;=0A=
}=0A=
=0A=
compress_gz::~compress_gz ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress_gz::~gz called");=0A=
  if (mode =3D=3D 'w')=0A=
    {=0A=
      z_err =3D do_flush (Z_FINISH);=0A=
      if (z_err !=3D Z_OK)=0A=
	{=0A=
	  destroy ();=0A=
	  return;=0A=
	}=0A=
=0A=
      putLong (crc);=0A=
      putLong (stream.total_in);=0A=
    }=0A=
  destroy ();=0A=
  return;=0A=
}=0A=
=0A=
int=0A=
compress_gz::do_flush (int flush)=0A=
{=0A=
  uInt len;=0A=
  int done =3D 0;=0A=
  if (mode !=3D 'w')=0A=
    return Z_STREAM_ERROR;=0A=
  stream.avail_in =3D 0;		/* should be zero already anyway */=0A=
  for (;;)=0A=
    {=0A=
      len =3D 16384 - stream.avail_out;=0A=
      if (len !=3D 0)=0A=
	{=0A=
	  if ((uInt) original->write (outbuf, len) !=3D len)=0A=
	    {=0A=
	      z_err =3D Z_ERRNO;=0A=
	      return Z_ERRNO;=0A=
	    }=0A=
	  stream.next_out =3D outbuf;=0A=
	  stream.avail_out =3D 16384;=0A=
	}=0A=
      if (done)=0A=
	break;=0A=
      z_err =3D deflate (&(stream), flush);=0A=
      /* Ignore the second of two consecutive flushes: */=0A=
      if (len =3D=3D 0 && z_err =3D=3D Z_BUF_ERROR)=0A=
	z_err =3D Z_OK;=0A=
      /* deflate has finished flushing only when it hasn't used up=0A=
       * all the available space in the output buffer:=0A=
       */=0A=
      done =3D (stream.avail_out !=3D 0 || z_err =3D=3D Z_STREAM_END);=0A=
      if (z_err !=3D Z_OK && z_err !=3D Z_STREAM_END)=0A=
	break;=0A=
    }=0A=
  return z_err =3D=3D Z_STREAM_END ? Z_OK : z_err;=0A=
}=0A=
=0A=
=0A=
#if 0=0A=
=0A=
gzclose (lst);=0A=
#endif=0A=
/* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
 *  Read a byte from a gz_stream; update next_in and avail_in. Return EOF=0A=
 *  for end of file.=0A=
 *  IN assertion: the stream s has been sucessfully opened for reading.=0A=
 */=0A=
int=0A=
compress_gz::get_byte ()=0A=
{=0A=
  if (z_eof)=0A=
    return EOF;=0A=
  if (stream.avail_in =3D=3D 0)=0A=
    {=0A=
      errno =3D 0;=0A=
      stream.avail_in =3D original->read (inbuf, 16384);=0A=
      if (stream.avail_in =3D=3D 0)=0A=
	{=0A=
	  z_eof =3D 1;=0A=
	  if (original->error ())=0A=
	    z_err =3D Z_ERRNO;=0A=
	  return EOF;=0A=
	}=0A=
      stream.next_in =3D inbuf;=0A=
    }=0A=
  stream.avail_in--;=0A=
  return *(stream.next_in)++;=0A=
}=0A=
=0A=
=0A=
/* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
      Check the gzip header of a gz_stream opened for reading. Set the =
stream=0A=
    mode to transparent if the gzip magic header is not present; set =
s->err=0A=
    to Z_DATA_ERROR if the magic header is present but the rest of the =
header=0A=
    is incorrect.=0A=
    IN assertion: the stream s has already been created sucessfully;=0A=
       s->stream.avail_in is zero for the first time, but may be non-zero=0A=
       for concatenated .gz files.=0A=
*/=0A=
void=0A=
compress_gz::check_header ()=0A=
{=0A=
  int method;			/* method byte */=0A=
  int flags;			/* flags byte */=0A=
  uInt len;=0A=
  int c;=0A=
  /* Check the gzip magic header */=0A=
  for (len =3D 0; len < 2; len++)=0A=
    {=0A=
      c =3D get_byte ();=0A=
      if (c !=3D gz_magic[len])=0A=
	{=0A=
	  if (len !=3D 0)=0A=
	    stream.avail_in++, stream.next_in--;=0A=
	  if (c !=3D EOF)=0A=
	    {=0A=
	      stream.avail_in++, stream.next_in--;=0A=
	      transparent =3D 1;=0A=
	    }=0A=
	  z_err =3D stream.avail_in !=3D 0 ? Z_OK : Z_STREAM_END;=0A=
	  return;=0A=
	}=0A=
    }=0A=
  method =3D get_byte ();=0A=
  flags =3D get_byte ();=0A=
  if (method !=3D Z_DEFLATED || (flags & RESERVED) !=3D 0)=0A=
    {=0A=
      z_err =3D Z_DATA_ERROR;=0A=
      return;=0A=
    }=0A=
=0A=
  /* Discard time, xflags and OS code: */=0A=
  for (len =3D 0; len < 6; len++)=0A=
    (void) get_byte ();=0A=
  if ((flags & EXTRA_FIELD) !=3D 0)=0A=
    {				/* skip the extra field */=0A=
      len =3D (uInt) get_byte ();=0A=
      len +=3D ((uInt) get_byte ()) << 8;=0A=
      /* len is garbage if EOF but the loop below will quit anyway */=0A=
      while (len-- !=3D 0 && get_byte () !=3D EOF);=0A=
    }=0A=
  if ((flags & ORIG_NAME) !=3D 0)=0A=
    {				/* skip the original file name */=0A=
      while ((c =3D get_byte ()) !=3D 0 && c !=3D EOF);=0A=
    }=0A=
  if ((flags & COMMENT) !=3D 0)=0A=
    {				/* skip the .gz file comment */=0A=
      while ((c =3D get_byte ()) !=3D 0 && c !=3D EOF);=0A=
    }=0A=
  if ((flags & HEAD_CRC) !=3D 0)=0A=
    {				/* skip the header crc */=0A=
      for (len =3D 0; len < 2; len++)=0A=
	(void) get_byte ();=0A=
    }=0A=
  z_err =3D z_eof ? Z_DATA_ERROR : Z_OK;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="compress.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="compress.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* Archive IO operations=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "compress.h"=0A=
#include "zlib/zlib.h"=0A=
#include "compress_gz.h"=0A=
#include "compress_bz.h"=0A=
=0A=
/* In case you are wondering why the file magic is not in one place:=0A=
 * It could be. But there is little (any?) benefit.=0A=
 * What is important is that the file magic required for any _task_ is =
centralised.=0A=
 * One such task is identifying compresss=0A=
 *=0A=
 * to federate into each class one might add a magic parameter to the =
constructor, which=0A=
 * the class could test itself. =0A=
 */=0A=
=0A=
#define longest_magic 3=0A=
=0A=
io_stream *=0A=
compress::decompress (io_stream * original)=0A=
{=0A=
  if (!original)=0A=
    return NULL;=0A=
  char magic[longest_magic];=0A=
  if (original->peek (magic, longest_magic) > 0)=0A=
    {=0A=
      if (memcmp (magic, "\037\213", 2) =3D=3D 0)=0A=
	{=0A=
	  /* tar */=0A=
	  compress_gz *rv =3D new compress_gz (original);=0A=
	  if (!rv->error ())=0A=
	    return rv;=0A=
	  return NULL;=0A=
	}=0A=
      else if (memcmp (magic, "BZh", 3) =3D=3D 0)=0A=
	{=0A=
	  compress_bz *rv =3D new compress_bz (original);=0A=
	  if (!rv->error ())=0A=
	    return rv;=0A=
	  return NULL;=0A=
	}=0A=
    }=0A=
  return NULL;=0A=
}=0A=
=0A=
ssize_t=0A=
compress::read (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::read called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t=0A=
compress::write (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::write called");=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t=0A=
compress::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::peek called");=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
compress::tell ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "bz::tell called");=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
compress::error ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::error called");=0A=
  return 0;=0A=
}=0A=
=0A=
const char *=0A=
compress::next_file_name ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::next_file_name called");=0A=
  return NULL;=0A=
}=0A=
=0A=
compress::~compress ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "compress::~compress called");=0A=
  return;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream_file.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream_file.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _IO_STREAM_FILE_H_=0A=
#define _IO_STREAM_FILE_H_=0A=
=0A=
=0A=
/* io_stream on disk files=0A=
 */=0A=
=0A=
class io_stream_file:public io_stream=0A=
{=0A=
public:=0A=
  static int exists (const char *);=0A=
  static int remove (const char *);=0A=
  static int mklink (const char *, const char *, io_stream_link_t);=0A=
    io_stream_file (const char *, const char *);=0A=
   ~io_stream_file ();=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len);=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len);=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len);=0A=
  virtual long tell ();=0A=
  /* can't guess, oh well */=0A=
  virtual int error ();=0A=
  virtual int set_mtime (int);=0A=
  /* dummy for io_stream_file */=0A=
  virtual const char *next_file_name ()=0A=
  {=0A=
    return NULL;=0A=
  };=0A=
private:=0A=
  /* always require parameters */=0A=
    io_stream_file ()=0A=
  {=0A=
  };=0A=
  FILE *fp;=0A=
  int lasterr;=0A=
  char *fname;=0A=
};=0A=
=0A=
#endif /* _IO_STREAM_FILE_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
/* this is the parent class for all IO operations. It's flexable enough =
to be cover for=0A=
 * HTTP access, local file access, and files being extracted from =
archives.=0A=
 * It also encapsulates the idea of an archive, and all non-archives =
become the special =0A=
 * case.=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "io_stream_file.h"=0A=
#include "io_stream_cygfile.h"=0A=
#include "mkdir.h"=0A=
=0A=
/* Static members */=0A=
io_stream *=0A=
io_stream::factory (io_stream * parent)=0A=
{=0A=
  /* something like,  =0A=
   * if !next_file_name =0A=
   *   return NULL=0A=
   * switch (magic_id(peek (parent), max_magic_length))=0A=
   * case io_stream * foo =3D new tar=0A=
   * case io_stream * foo =3D new bz2=0A=
   * return foo=0A=
   */=0A=
  log (LOG_TIMESTAMP, "io_stream::factory has been called");=0A=
  return NULL;=0A=
}=0A=
=0A=
io_stream *=0A=
io_stream::open (const char *name, const char *mode)=0A=
{=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||=0A=
      !mode || IsBadStringPtr (mode, 5) || !mode[0])=0A=
    return NULL;=0A=
  /* iterate through the known url prefix's */=0A=
  if (!strncasecmp ("file://", name, 7))=0A=
    {=0A=
      io_stream_file *rv =3D new io_stream_file (&name[7], mode);=0A=
      if (!rv->error ())=0A=
	return rv;=0A=
      delete rv;=0A=
      return NULL;=0A=
    }=0A=
  if (!strncasecmp ("cygfile://", name, 10))=0A=
    {=0A=
      io_stream_cygfile *rv =3D new io_stream_cygfile (&name[10], mode);=0A=
      if (!rv->error ())=0A=
	return rv;=0A=
      delete rv;=0A=
      return NULL;=0A=
    }=0A=
  return NULL;=0A=
}=0A=
=0A=
int=0A=
io_stream::mkpath_p (path_type_t isadir, const char *name)=0A=
{=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])=0A=
    return 1;=0A=
  /* iterate through the known url prefix's */=0A=
  if (!strncasecmp ("file://", name, 7))=0A=
    {=0A=
      return mkdir_p (isadir =3D=3D PATH_TO_DIR ? 1 : 0, &name[7]);=0A=
    }=0A=
  if (!strncasecmp ("cygfile://", name, 10))=0A=
    {=0A=
      return cygmkdir_p (isadir =3D=3D PATH_TO_DIR ? 1 : 0, &name[10]);=0A=
    }=0A=
  return 1;=0A=
}=0A=
=0A=
/* remove a file or directory. */=0A=
int=0A=
io_stream::remove (const char *name)=0A=
{=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])=0A=
    return 1;=0A=
  /* iterate through the known url prefix's */=0A=
  if (!strncasecmp ("file://", name, 7))=0A=
    return io_stream_file::remove (&name[7]);=0A=
  if (!strncasecmp ("cygfile://", name, 10))=0A=
    return io_stream_cygfile::remove (&name[10]);=0A=
  return 1;=0A=
}=0A=
=0A=
int=0A=
io_stream::mklink (const char *from, const char *to,=0A=
		   io_stream_link_t linktype)=0A=
{=0A=
  if (!from || IsBadStringPtr (from, MAX_PATH) ||=0A=
      !to || IsBadStringPtr (to, MAX_PATH))=0A=
    return 1;=0A=
  /* iterate through the known url prefixes */=0A=
  if (!strncasecmp ("file://", from, 7))=0A=
    {=0A=
      /* file urls can symlink or hardlink to file url's. */=0A=
      /* TODO: allow linking to cygfile url's */=0A=
      if (!strncasecmp ("file://", to, 7))=0A=
	return io_stream_file::mklink (from, to, linktype);=0A=
      return 1;=0A=
    }=0A=
  if (!strncasecmp ("cygfile://", from, 10))=0A=
    {=0A=
      /* cygfile urls can symlink or hardlink to cygfile urls's. */=0A=
      /* TODO: allow -> file urls */=0A=
      if (!strncasecmp ("cygfile://", to, 10))=0A=
	return io_stream_cygfile::mklink (from, to, linktype);=0A=
      return 1;=0A=
    }=0A=
#if 0=0A=
  if (!strmcasecmp ("http://", from, 7))=0A=
    {=0A=
      /* http urls can symlink to http or ftp url's */=0A=
    }=0A=
#endif=0A=
  return 1;=0A=
}=0A=
=0A=
char *=0A=
io_stream::gets (char *buffer, size_t length)=0A=
{=0A=
  char *pos =3D buffer;=0A=
  size_t count =3D 0;=0A=
  while (count + 1 < length && read (pos, 1) =3D=3D 1)=0A=
    {=0A=
      count++;=0A=
      pos++;=0A=
      if (*(pos - 1) =3D=3D '\n')=0A=
	{=0A=
	  /* end of line */=0A=
	  /* TODO: remove the \r if it is present depending on the =0A=
	   * file's mode =0A=
	   */=0A=
	  break;=0A=
	}=0A=
    }=0A=
  if (count =3D=3D 0 || error ())=0A=
    /* EOF when no chars found, or an error */=0A=
    return NULL;=0A=
  *pos =3D '\0';=0A=
  return buffer;=0A=
}=0A=
=0A=
int=0A=
io_stream::exists (const char *name)=0A=
{=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])=0A=
    return 1;=0A=
  /* iterate through the known url prefix's */=0A=
  if (!strncasecmp ("file://", name, 7))=0A=
    return io_stream_file::exists (&name[7]);=0A=
  if (!strncasecmp ("cygfile://", name, 10))=0A=
    return io_stream_cygfile::exists (&name[10]);=0A=
  return 1;=0A=
}=0A=
=0A=
/* virtual members */=0A=
=0A=
io_stream::~io_stream ()=0A=
{=0A=
  log (LOG_TIMESTAMP, "io_stream::~io_stream called");=0A=
  return;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _IO_STREAM_H_=0A=
#define _IO_STREAM_H_=0A=
=0A=
/* this is the parent class for all IO operations. It's flexable enough =
to be cover for=0A=
 * HTTP access, local file access, and files being extracted from =
archives.=0A=
 * It also encapsulates the idea of an archive, and all non-archives =
become the special =0A=
 * case.=0A=
 */=0A=
=0A=
/* Some things don't fit cleanly just - TODO=0A=
 * make mkdir_p fit in the hierarchy=0A=
 */=0A=
=0A=
//Where is this defined?=0A=
typedef signed long ssize_t;=0A=
=0A=
#if __GNUC__=0A=
#define _ATTR_(foo) __attribute__ foo=0A=
#else=0A=
#define _ATTR_(foo)=0A=
#endif=0A=
=0A=
typedef enum=0A=
{=0A=
  PATH_TO_DIR,=0A=
  PATH_TO_FILE=0A=
}=0A=
path_type_t;=0A=
=0A=
typedef enum=0A=
{=0A=
  IO_STREAM_INVALID,=0A=
  IO_STREAM_STREAM,=0A=
  IO_STREAM_COMPRESS,=0A=
  IO_STREAM_ARCHIVE=0A=
}=0A=
io_stream_type_t;=0A=
=0A=
typedef enum=0A=
{=0A=
  IO_STREAM_SYMLINK,=0A=
  IO_STREAM_HARDLINK=0A=
}=0A=
io_stream_link_t;=0A=
=0A=
class io_stream=0A=
{=0A=
public:=0A=
  /* create a new stream from an existing one - used to get=0A=
   * decompressed data=0A=
   * or open archives.=0A=
   * will return NULL if there is no sub-stream available (ie (peek()=0A=
   * didn't match any known magic number) && nextfilename () =3D NULL=0A=
   */=0A=
  static io_stream *factory (io_stream *);=0A=
  /* open a stream by url. The particular stream type returned=0A=
   * will depend on the url passed.=0A=
   * ie for file:// it will be a disk file.=0A=
   * for ftp:// it will perform an upload to a ftp site.=0A=
   * the second parameter - mode can specify r|w && t|b. Other flags are =
not currently=0A=
   * supported.=0A=
   * Automatic decompression does not occur. Compressed files will =
return a io_stream=0A=
   * from archive::decompress. This behaviour is by design - to allow =
deliberate access=0A=
   * to the compressed data.=0A=
   * To create a stream that will be compressed, you should open the =
url, and then get a new stream=0A=
   * from archive::compress. =0A=
   * If a stream is opened for reading, and it's an archive, the =
next_file_name method=0A=
   * will return non-NULL. To access the files within the archive use =
io_stream::factory=0A=
   * to create a new stream that will read from the archive.=0A=
   */=0A=
  static io_stream *open (const char *, const char *);=0A=
  static int remove (const char *);=0A=
  static int exists (const char *);=0A=
  /* ensure that we have access to the entire path */=0A=
  /* Create a directory, and any needed parent directories.=0A=
   * returns 1 on failure.=0A=
   */=0A=
  static int mkpath_p (path_type_t, const char *);=0A=
  /* link from, to, type. Returns 1 on failure */=0A=
  static int mklink (const char *, const char *, io_stream_link_t);=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len) =3D 0;=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len) =3D 0;=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len) =3D 0;=0A=
  /* ever read the f* functions from libc ? */=0A=
  virtual long tell () =3D 0;=0A=
  /* try guessing this one */=0A=
  virtual int error () =3D 0;=0A=
  /* hmm, yet another for the guessing books */=0A=
  virtual char *gets (char *, size_t len);=0A=
  /* what sort of stream is this?=0A=
   * known types are:=0A=
   * IO_STREAM_INVALID - not a valid stream.=0A=
   * IO_STREAM_STREAM - just another stream.=0A=
   * IO_STREAM_COMPRESS - a compressed or compressing stream.=0A=
   * IO_STREAM_ARCHIVE - an archive of some sort, with > 0 files.=0A=
   * this is a crutch for real runtime type evaluation.=0A=
   */=0A=
  /* Find out the next stream name -=0A=
   * ie for foo.tar.gz, at offset 0, next_file_name =3D foo.tar=0A=
   * for foobar that is an archive, next_file_name is the next=0A=
   * extractable filename.=0A=
   */=0A=
//  virtual const char* next_file_name() =3D NULL;=0A=
  /* set the modification time of a file - returns 1 on failure */=0A=
  virtual int set_mtime (int) =3D 0;=0A=
  /* if you are still needing these hints... give up now! */=0A=
    virtual ~ io_stream ();=0A=
};=0A=
=0A=
#endif /* _IO_STREAM_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream_cygfile.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream_cygfile.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include <stdlib.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
#include "mount.h"=0A=
#include "mkdir.h"=0A=
#include "mklink2.h"=0A=
#include <unistd.h>=0A=
=0A=
#include "io_stream.h"=0A=
#include "io_stream_cygfile.h"=0A=
=0A=
/* For set mtime */=0A=
#define FACTOR (0x19db1ded53ea710LL)=0A=
#define NSPERSEC 10000000LL=0A=
=0A=
static void=0A=
get_root_dir_now ()=0A=
{=0A=
  if (get_root_dir ())=0A=
    return;=0A=
  read_mounts ();=0A=
}=0A=
=0A=
io_stream_cygfile::io_stream_cygfile (const char *name, const char *mode)=0A=
{=0A=
  fname =3D NULL;=0A=
  fp =3D NULL;=0A=
  errno =3D 0;=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||=0A=
      !mode || IsBadStringPtr (mode, 5) || !mode[0])=0A=
    return;=0A=
=0A=
  /* do this every time because the mount points may change due to =
fwd/back button use...=0A=
   * TODO: make this less...manual=0A=
   */=0A=
  get_root_dir_now ();=0A=
  if (!get_root_dir ())=0A=
    /* TODO: assign a errno for "no mount table :} " */=0A=
    return;=0A=
=0A=
  fname =3D cygpath (name, 0);=0A=
  fp =3D fopen (fname, mode);=0A=
  if (!fp)=0A=
    lasterr =3D errno;=0A=
}=0A=
=0A=
io_stream_cygfile::~io_stream_cygfile ()=0A=
{=0A=
  if (fname)=0A=
    free (fname);=0A=
  if (fp)=0A=
    fclose (fp);=0A=
}=0A=
=0A=
/* Static members */=0A=
int=0A=
io_stream_cygfile::exists (const char *path)=0A=
{=0A=
  get_root_dir_now ();=0A=
  if (get_root_dir () && _access (cygpath (path, 0), 0) =3D=3D 0)=0A=
    return 1;=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
io_stream_cygfile::remove (const char *path)=0A=
{=0A=
  if (!path)=0A=
    return 1;=0A=
  get_root_dir_now ();=0A=
  if (!get_root_dir ())=0A=
    /* TODO: assign a errno for "no mount table :} " */=0A=
    return 1;=0A=
=0A=
  unsigned long w =3D GetFileAttributes (cygpath (path, 0));=0A=
  if (w !=3D 0xffffffff && w & FILE_ATTRIBUTE_DIRECTORY)=0A=
    {=0A=
      char *tmp =3D (char *) malloc (strlen (cygpath (path, 0)) + 10);=0A=
      int i =3D 0;=0A=
      do=0A=
	{=0A=
	  i++;=0A=
	  sprintf (tmp, "%s.old-%d", cygpath (path, 0), i);=0A=
	}=0A=
      while (GetFileAttributes (tmp) !=3D 0xffffffff);=0A=
      fprintf (stderr, "warning: moving directory \"%s\" out of the =
way.\n",=0A=
	       path);=0A=
      MoveFile (cygpath (path, 0), tmp);=0A=
      free (tmp);=0A=
    }=0A=
  return !DeleteFileA (cygpath (path, 0));=0A=
}=0A=
=0A=
int=0A=
io_stream_cygfile::mklink (const char *from, const char *to,=0A=
			   io_stream_link_t linktype)=0A=
{=0A=
  /* FIXME: badstring check */=0A=
  if (!from || !to)=0A=
    return 1;=0A=
  switch (linktype)=0A=
    {=0A=
    case IO_STREAM_SYMLINK:=0A=
      return mkcygsymlink (cygpath (from, 0), to);=0A=
    case IO_STREAM_HARDLINK:=0A=
      return 1;=0A=
    }=0A=
  return 1;=0A=
}=0A=
=0A=
=0A=
/* virtuals */=0A=
=0A=
ssize_t=0A=
io_stream_cygfile::read (void *buffer, size_t len)=0A=
{=0A=
  if (fp)=0A=
    return fread (buffer, 1, len, fp);=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t=0A=
io_stream_cygfile::write (void *buffer, size_t len)=0A=
{=0A=
  if (fp)=0A=
    return fwrite (buffer, 1, len, fp);=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t=0A=
io_stream_cygfile::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "io_stream_cygfile::peek called");=0A=
  if (fp)=0A=
    {=0A=
      int pos =3D ftell (fp);=0A=
      ssize_t rv =3D fread (buffer, 1, len, fp);=0A=
      fseek (fp, pos, SEEK_SET);=0A=
      return rv;=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
io_stream_cygfile::tell ()=0A=
{=0A=
  if (fp)=0A=
    {=0A=
      return ftell (fp);=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
io_stream_cygfile::error ()=0A=
{=0A=
  if (fp)=0A=
    return ferror (fp);=0A=
  return lasterr;=0A=
}=0A=
=0A=
int=0A=
cygmkdir_p (int isadir, const char *name)=0A=
{=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])=0A=
    return 1;=0A=
  get_root_dir_now ();=0A=
  if (!get_root_dir ())=0A=
    /* TODO: assign a errno for "no mount table :} " */=0A=
    return 1;=0A=
  return mkdir_p (isadir, cygpath (name, 0));=0A=
}=0A=
=0A=
int=0A=
io_stream_cygfile::set_mtime (int mtime)=0A=
{=0A=
  if (!fname)=0A=
    return 1;=0A=
  long long ftimev =3D mtime * NSPERSEC + FACTOR;=0A=
  FILETIME ftime;=0A=
  ftime.dwHighDateTime =3D ftimev >> 32;=0A=
  ftime.dwLowDateTime =3D ftimev;=0A=
  HANDLE h =3D=0A=
    CreateFileA (fname, GENERIC_WRITE, FILE_SHARE_READ | =
FILE_SHARE_WRITE,=0A=
		 0, OPEN_EXISTING,=0A=
		 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);=0A=
  if (h)=0A=
    {=0A=
      SetFileTime (h, 0, 0, &ftime);=0A=
      CloseHandle (h);=0A=
      return 0;=0A=
    }=0A=
  return 1;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream_cygfile.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream_cygfile.h"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#ifndef _IO_STREAM_CYGFILE_H_=0A=
#define _IO_STREAM_CYGFILE_H_=0A=
=0A=
=0A=
/* io_stream on disk files using cygwin paths=0A=
 * and potentially understanding links in the future=0A=
 */=0A=
=0A=
extern int cygmkdir_p (int isadir, const char *path);=0A=
=0A=
class io_stream_cygfile:public io_stream=0A=
{=0A=
public:=0A=
  static int exists (const char *);=0A=
  static int remove (const char *);=0A=
  static int mklink (const char *, const char *, io_stream_link_t);=0A=
    io_stream_cygfile (const char *, const char *);=0A=
   ~io_stream_cygfile ();=0A=
  /* read data (duh!) */=0A=
  virtual ssize_t read (void *buffer, size_t len);=0A=
  /* provide data to (double duh!) */=0A=
  virtual ssize_t write (void *buffer, size_t len);=0A=
  /* read data without removing it from the class's internal buffer */=0A=
  virtual ssize_t peek (void *buffer, size_t len);=0A=
  virtual long tell ();=0A=
  /* can't guess, oh well */=0A=
  virtual int error ();=0A=
  virtual int set_mtime (int);=0A=
  /* dummy for io_stream_file */=0A=
  virtual const char *next_file_name ()=0A=
  {=0A=
    return NULL;=0A=
  };=0A=
private:=0A=
  /* always require parameters */=0A=
    io_stream_cygfile ()=0A=
  {=0A=
  };=0A=
  FILE *fp;=0A=
  int lasterr;=0A=
  char *fname;=0A=
};=0A=
=0A=
#endif /* _IO_STREAM_CYGFILE_H_ */=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970
Content-Type: application/octet-stream;
	name="io_stream_file.cc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="io_stream_file.cc"

/*=0A=
 * Copyright (c) 2001, Robert Collins.=0A=
 *=0A=
 *     This program is free software; you can redistribute it and/or =
modify=0A=
 *     it under the terms of the GNU General Public License as published =
by=0A=
 *     the Free Software Foundation; either version 2 of the License, or=0A=
 *     (at your option) any later version.=0A=
 *=0A=
 *     A copy of the GNU General Public License can be found at=0A=
 *     http://www.gnu.org/=0A=
 *=0A=
 * Written by Robert Collins  <rbtcollins AT hotmail DOT com>=0A=
 *=0A=
 */=0A=
=0A=
#if 0=0A=
static const char *cvsid =3D=0A=
  "\n%%% $Id: source.cc,v 2.5 2001/11/01 13:22:46 rbcollins Exp $\n";=0A=
#endif=0A=
=0A=
#include "win32.h"=0A=
#include <stdio.h>=0A=
#include <stdlib.h>=0A=
#include <unistd.h>=0A=
#include "log.h"=0A=
#include "port.h"=0A=
#include "mklink2.h"=0A=
=0A=
#include "io_stream.h"=0A=
#include "io_stream_file.h"=0A=
=0A=
/* for set_mtime */=0A=
#define FACTOR (0x19db1ded53ea710LL)=0A=
#define NSPERSEC 10000000LL=0A=
=0A=
io_stream_file::io_stream_file (const char *name, const char *mode)=0A=
{=0A=
  fname =3D NULL;=0A=
  fp =3D NULL;=0A=
  errno =3D 0;=0A=
  if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||=0A=
      !mode || IsBadStringPtr (mode, 5) || !mode[0])=0A=
    return;=0A=
  fname =3D strdup (name);=0A=
  fp =3D fopen (name, mode);=0A=
  if (!fp)=0A=
    lasterr =3D errno;=0A=
}=0A=
=0A=
io_stream_file::~io_stream_file ()=0A=
{=0A=
  if (fname)=0A=
    free (fname);=0A=
  if (fp)=0A=
    fclose (fp);=0A=
}=0A=
=0A=
int=0A=
io_stream_file::exists (const char *path)=0A=
{=0A=
  if (_access (path, 0) =3D=3D 0)=0A=
    return 1;=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
io_stream_file::remove (const char *path)=0A=
{=0A=
  if (!path)=0A=
    return 1;=0A=
=0A=
  unsigned long w =3D GetFileAttributes (path);=0A=
  if (w !=3D 0xffffffff && w & FILE_ATTRIBUTE_DIRECTORY)=0A=
    {=0A=
      char *tmp =3D (char *) malloc (strlen (path) + 10);=0A=
      int i =3D 0;=0A=
      do=0A=
	{=0A=
	  i++;=0A=
	  sprintf (tmp, "%s.old-%d", path, i);=0A=
	}=0A=
      while (GetFileAttributes (tmp) !=3D 0xffffffff);=0A=
      fprintf (stderr, "warning: moving directory \"%s\" out of the =
way.\n",=0A=
	       path);=0A=
      MoveFile (path, tmp);=0A=
      free (tmp);=0A=
    }=0A=
  return !DeleteFileA (path);=0A=
=0A=
}=0A=
=0A=
int=0A=
io_stream_file::mklink (const char *from, const char *to,=0A=
			io_stream_link_t linktype)=0A=
{=0A=
  /* FIXME: badstring check */=0A=
  if (!from || !to)=0A=
    return 1;=0A=
  switch (linktype)=0A=
    {=0A=
    case IO_STREAM_SYMLINK:=0A=
      return mkcygsymlink (from, to);=0A=
    case IO_STREAM_HARDLINK:=0A=
      return 1;=0A=
    }=0A=
  return 1;=0A=
}=0A=
=0A=
/* virtuals */=0A=
=0A=
=0A=
ssize_t io_stream_file::read (void *buffer, size_t len)=0A=
{=0A=
  if (fp)=0A=
    return fread (buffer, 1, len, fp);=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t io_stream_file::write (void *buffer, size_t len)=0A=
{=0A=
  if (fp)=0A=
    return fwrite (buffer, 1, len, fp);=0A=
  return 0;=0A=
}=0A=
=0A=
ssize_t io_stream_file::peek (void *buffer, size_t len)=0A=
{=0A=
  log (LOG_TIMESTAMP, "io_stream_file::peek called");=0A=
  if (fp)=0A=
    {=0A=
      int=0A=
	pos =3D ftell (fp);=0A=
      ssize_t=0A=
	rv =3D fread (buffer, 1, len, fp);=0A=
      fseek (fp, pos, SEEK_SET);=0A=
      return rv;=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
long=0A=
io_stream_file::tell ()=0A=
{=0A=
  if (fp)=0A=
    {=0A=
      return ftell (fp);=0A=
    }=0A=
  return 0;=0A=
}=0A=
=0A=
int=0A=
io_stream_file::error ()=0A=
{=0A=
  if (fp)=0A=
    return ferror (fp);=0A=
  return lasterr;=0A=
}=0A=
=0A=
int=0A=
io_stream_file::set_mtime (int mtime)=0A=
{=0A=
  if (!fname)=0A=
    return 1;=0A=
  long long ftimev =3D mtime * NSPERSEC + FACTOR;=0A=
  FILETIME ftime;=0A=
  ftime.dwHighDateTime =3D ftimev >> 32;=0A=
  ftime.dwLowDateTime =3D ftimev;=0A=
  HANDLE h =3D=0A=
    CreateFileA (fname, GENERIC_WRITE, FILE_SHARE_READ | =
FILE_SHARE_WRITE,=0A=
		 0, OPEN_EXISTING,=0A=
		 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);=0A=
  if (h)=0A=
    {=0A=
      SetFileTime (h, 0, 0, &ftime);=0A=
      CloseHandle (h);=0A=
      return 0;=0A=
    }=0A=
  return 1;=0A=
}=0A=

------=_NextPart_000_019A_01C16ADB.DDDD8970--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019