public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Warren Young <warren@etr-usa.com>
To: Cygwin-L <cygwin@cygwin.com>
Subject: Re: press for cygwin
Date: Fri, 07 Sep 2001 12:27:00 -0000	[thread overview]
Message-ID: <3B991F83.4DC7D708@etr-usa.com> (raw)
In-Reply-To: <3B96CB9C.9453D3CF@etr-usa.com>

Warren Young wrote:
> 
> Done.  See cygwin-patches.

Well, junk.  `pears that cygwin-patches is by invitation only.  So the
patches are inlined below.



This patch adds "*.cwp" ("CygWin Package") file name recognition to
setup.exe.  .tar.gz and .tar.bz2 recognition appears to still work. 
Also, .cwp files can be either bzip2 or gzip files, as the program now
does magic number checking.  This also applies to .tar.gz and .tar.bz2
-- if the file is named .tar.gz and is not actually a gzip file, or
whatever, the program will refuse to even try to open it.

The choose.cc patch is below, and the tar.cc patch follows in the next
message.


Change log entry:

2001-09-05  Warren Young  <warren@etr-usa.com>
        * choose.cc (find_tar_ext): Add *.cgw extension recognition

        * tar.cc (tar_open): Now calls decomp_factory() to create gzbz
        instance by examining the file name given.

        * tar.cc (decomp_factory): new function
          

--- cinstall/choose.cc   Wed Sep  5 18:38:57 2001
+++ cinstall/choose.cc.new       Wed Sep  5 18:36:06 2001
@@ -1208,6 +1208,29 @@ base (const char *s)
 int
 find_tar_ext (const char *path)
 {
+#if 1
+  char temp_path[_MAX_PATH];
+  strncpy(temp_path, path, sizeof(temp_path));
+  temp_path[sizeof(temp_path) - 1] = '\0';
+
+  char* p = strrchr(temp_path, '.');
+  if (!p)
+    return 0;
+
+  if (strcmp(p, ".cwp") == 0)
+    return p - temp_path;
+  else if ((strcmp(p, ".gz") == 0) || (strcmp(p, ".bz2") == 0))
+    {
+      // found .gz or .bz2, make sure ".tar" is before that.
+      *p = '\0';
+      p = strrchr(temp_path, '.');
+      if (p && (strcmp(p, ".tar") == 0))
+        return p - temp_path;
+      return 0;
+    }
+  else
+    return 0;
+#else
   char *p = strchr (path, '\0') - 7;
   if (p <= path)
     return 0;
@@ -1220,6 +1243,7 @@ find_tar_ext (const char *path)
     return 0;

   return p - path;
+#endif
 }

 /* Parse a filename into package, version, and extension components. */







--- cinstall/tar.cc      Wed Sep  5 18:38:58 2001
+++ cinstall/tar.cc.new  Wed Sep  5 17:58:36 2001
@@ -151,6 +151,40 @@ xstrdup (char *c)
   return r;
 }

+static gzbz*
+decomp_factory(const char* pathname)
+{
+#if 1
+  HANDLE h = CreateFile(pathname, GENERIC_READ, 0, 0, OPEN_EXISTING,
+                  FILE_ATTRIBUTE_NORMAL, 0);
+  char ac[3];
+  DWORD n = sizeof(ac);
+
+  if (!h)
+    return 0;
+
+  if (!ReadFile(h, ac, sizeof(ac), &n, 0))
+    {
+         CloseHandle(h);
+      return 0;
+       }
+  CloseHandle(h);
+
+  if (memcmp(ac, "\037\213", 2) == 0)
+    return new gz (pathname);
+  else if (memcmp(ac, "BZh", 3) == 0)
+    return new bz (pathname);
+  else
+    return 0;
+#else
+       if (strstr(pathname, "bz2"))
+               return new bz(pathname);
+       else
+               return new gz(pathname);
+#endif
+}
+
+
 int
 tar_open (const char *pathname)
 {
@@ -163,10 +197,14 @@ tar_open (const char *pathname)
     return 1;
   _tar_file_size = size;

-  if (strstr (pathname, ".bz2"))
-    z = new bz (pathname);
-  else
-    z = new gz (pathname);
+  z = decomp_factory(pathname);
+  if (!z)
+    {
+         fprintf (stderr, "error: could not figure out compression type
"
+                       "for file '%s'\n", pathname);
+         return 1;
+       }
+
   if (sizeof (tar_header) != 512)
     {
       /* drastic, but important */





-- 
= Warren -- ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

  reply	other threads:[~2001-09-07 12:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-03  6:52 Bernard Dautrevaux
2001-09-03  7:56 ` Charles Wilson
2001-09-03  8:14   ` Christopher Faylor
2001-09-03  8:45     ` Michael Schaap
2001-09-03  9:03       ` Christopher Faylor
2001-09-03  9:30         ` Andrew Markebo
2001-09-03  9:36           ` Christopher Faylor
2001-09-03 15:23     ` Robert Collins
2001-09-03 18:23       ` Christopher Faylor
2001-09-03 19:17         ` Charles Wilson
2001-09-03 19:35         ` Robert Collins
2001-09-04  9:52     ` Warren Young
2001-09-04 12:52       ` Christopher Faylor
2001-09-05 18:04         ` Warren Young
2001-09-07 12:27           ` Warren Young [this message]
2001-09-07 12:35             ` Christopher Faylor
2001-09-07 14:22               ` Warren Young
2001-09-07 14:43                 ` Christopher Faylor
  -- strict thread matches above, loose matches on Subject: below --
2001-09-06  1:55 jmarshall
2001-09-05  5:04 jmarshall
2001-09-05  8:52 ` Christopher Faylor
2001-09-03  8:56 Bernard Dautrevaux
2001-08-31  7:36 Mark Bradshaw
2001-08-31  8:07 ` Charles Wilson
2001-08-31 10:29 ` Larry Hall (RFK Partners, Inc)
2001-08-31 17:09 ` Robert Collins
2001-08-31  0:34 Press for Cygwin Peter Ring
2001-08-30 14:34 press for cygwin Peter Buckley
2001-08-30 14:57 ` Christopher Faylor
2001-08-30 14:31 Press for Cygwin yap_noel
2001-08-30 15:38 ` Eric M. Monsler
2001-08-30 14:10 Robinow, David
2001-08-30 14:24 ` Charles Wilson
2001-08-30 13:47 Robinow, David
2001-08-30 12:57 Larry Hall (RFK Partners, Inc)
2001-08-30 13:07 ` Christopher Faylor
2001-08-30 13:12   ` Larry Hall (RFK Partners, Inc)
2001-08-30 13:25     ` Christopher Faylor
2001-08-30 13:37     ` Jonathon Merz
2001-08-30 14:04       ` Charles Wilson
2001-08-30 13:29   ` Rick Rankin
2001-08-30 13:33   ` Gerrit P. Haase
2001-08-30 13:42   ` Michael Schaap
2001-08-30 13:50     ` Christopher Faylor
2001-08-30 14:01       ` Michael Schaap
2001-08-30 14:06   ` Christopher Faylor
2001-09-02 20:24   ` John Marshall
2001-08-30 13:56 ` Gerrit P. Haase
2001-08-30 14:03   ` Michael F. March
2001-08-30 14:12     ` Michael Schaap
2001-08-30 14:06   ` Charles Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B991F83.4DC7D708@etr-usa.com \
    --to=warren@etr-usa.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).