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