[Python-checkins] CVS: distutils/misc archive.h,1.2,1.3 extract.c,1.3,1.4 install.c,1.7,1.8 wininst.exe,1.5,1.6

Thomas Heller python-dev@python.org
Thu, 12 Oct 2000 12:26:01 -0700


Update of /cvsroot/python/distutils/misc
In directory slayer.i.sourceforge.net:/tmp/cvs-serv6041

Modified Files:
	archive.h extract.c install.c wininst.exe 
Log Message:
Extracting files did look at fields in the zip-datastructures
which are not always valid, now they only look into valid fields.
SOme function signatures had to be changed, because we no longer
pass structures around, but the fields instead.
Recompiled wininst.exe.


Index: archive.h
===================================================================
RCS file: /cvsroot/python/distutils/misc/archive.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** archive.h	2000/09/07 07:36:40	1.2
--- archive.h	2000/10/12 19:25:58	1.3
***************
*** 60,69 ****
  typedef int (*NOTIFYPROC)(int code, LPSTR text, ...);
  
! extern BOOL extract_file (char *dst, struct fhdr *phdr, char *src,
! 			  NOTIFYPROC callback);
  extern BOOL unzip_archive (char *dirname, char *data, DWORD size,
  			   NOTIFYPROC callback);
  extern char *map_new_file (DWORD flags, char *filename, char
! 			   *pathname_part, struct fhdr *pfhdr,
  			   NOTIFYPROC callback);
  extern BOOL ensure_directory (char *pathname, char *new_part,
--- 60,70 ----
  typedef int (*NOTIFYPROC)(int code, LPSTR text, ...);
  
! extern BOOL extract_file (char *dst, char *src, int method, int comp_size,
! 			  int uncomp_size, NOTIFYPROC notify);
  extern BOOL unzip_archive (char *dirname, char *data, DWORD size,
  			   NOTIFYPROC callback);
  extern char *map_new_file (DWORD flags, char *filename, char
! 			   *pathname_part, int size,
! 			   WORD wFatDate, WORD wFatTime,
  			   NOTIFYPROC callback);
  extern BOOL ensure_directory (char *pathname, char *new_part,

Index: extract.c
===================================================================
RCS file: /cvsroot/python/distutils/misc/extract.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** extract.c	2000/09/29 11:20:55	1.3
--- extract.c	2000/10/12 19:25:58	1.4
***************
*** 47,56 ****
   */
  char *map_new_file (DWORD flags, char *filename,
! 		    char *pathname_part, struct fhdr *pfhdr,
  		    NOTIFYPROC notify)
  {
      HANDLE hFile, hFileMapping;
      char *dst;
-     int size = pfhdr->uncomp_size;
      FILETIME ft;
  
--- 47,56 ----
   */
  char *map_new_file (DWORD flags, char *filename,
! 		    char *pathname_part, int size,
! 		    WORD wFatDate, WORD wFatTime,
  		    NOTIFYPROC notify)
  {
      HANDLE hFile, hFileMapping;
      char *dst;
      FILETIME ft;
  
***************
*** 99,104 ****
  	notify (FILE_CREATED, filename);
  
!     DosDateTimeToFileTime (pfhdr->last_mod_file_date,
! 			   pfhdr->last_mod_file_time, &ft);
      SetFileTime (hFile, &ft, &ft, &ft);
  
--- 99,103 ----
  	notify (FILE_CREATED, filename);
  
!     DosDateTimeToFileTime (wFatDate, wFatTime, &ft);
      SetFileTime (hFile, &ft, &ft, &ft);
  
***************
*** 137,152 ****
  
  BOOL
! extract_file (char *dst, struct fhdr *phdr, char *src, NOTIFYPROC notify)
  {
      z_stream zstream;
      int result;
  
!     if (phdr->method == Z_DEFLATED) {
  	int x;
          memset (&zstream, 0, sizeof (zstream));
          zstream.next_in = src;
!         zstream.avail_in = phdr->comp_size+1;
  	zstream.next_out = dst;
!         zstream.avail_out = phdr->uncomp_size;
  
  /* Apparently an undocumented feature of zlib: Set windowsize
--- 136,152 ----
  
  BOOL
! extract_file (char *dst, char *src, int method, int comp_size,
! 	      int uncomp_size, NOTIFYPROC notify)
  {
      z_stream zstream;
      int result;
  
!     if (method == Z_DEFLATED) {
  	int x;
          memset (&zstream, 0, sizeof (zstream));
          zstream.next_in = src;
!         zstream.avail_in = comp_size+1;
  	zstream.next_out = dst;
!         zstream.avail_out = uncomp_size;
  
  /* Apparently an undocumented feature of zlib: Set windowsize
***************
*** 171,176 ****
  	    result = FALSE;
  	}
!     } else if (phdr->method == 0) {
! 	memcpy(dst, src, phdr->uncomp_size);
  	result = TRUE;
      } else
--- 171,176 ----
  	    result = FALSE;
  	}
!     } else if (method == 0) {
! 	memcpy(dst, src, uncomp_size);
  	result = TRUE;
      } else
***************
*** 234,240 ****
  	fixpath (pathname);
  	if (pathname[strlen(pathname)-1] != '\\') {
! 	    dst = map_new_file (0, pathname, new_part, pfhdr, notify);
  	    if (dst) {
! 		if (!extract_file (dst, pfhdr, pcomp, notify))
  		    return FALSE;
  	    } /* else ??? */
--- 234,252 ----
  	fixpath (pathname);
  	if (pathname[strlen(pathname)-1] != '\\') {
! 	    /*
! 	     * The local file header (pfhdr) does not always contain
! 	     * the compressed and uncompressed sizes of the data
! 	     * depending on bit 3 of the flags field.
! 	     * So it seems better to use the data from the
! 	     * central directory (pcdir).
! 	     */
! 	    dst = map_new_file (0, pathname, new_part,
! 				pcdir->uncomp_size,
! 				pcdir->last_mod_file_date,
! 				pcdir->last_mod_file_time, notify);
  	    if (dst) {
! 		if (!extract_file (dst, pcomp, pfhdr->method,
! 				   pcdir->comp_size, pcdir->uncomp_size,
! 				   notify))
  		    return FALSE;
  	    } /* else ??? */

Index: install.c
===================================================================
RCS file: /cvsroot/python/distutils/misc/install.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** install.c	2000/09/29 11:28:41	1.7
--- install.c	2000/10/12 19:25:58	1.8
***************
*** 357,361 ****
      /* read meta_data info */
      struct meta_data_hdr *pmd = (struct meta_data_hdr *)&data[ofs];
-     struct fhdr fhdr;
      char *src, *dst;
      char *ini_file;
--- 357,360 ----
***************
*** 382,387 ****
      }
      
!     fhdr.uncomp_size = pmd->uncomp_size;
!     dst = map_new_file (CREATE_ALWAYS, ini_file, NULL, &fhdr, notify);
      if (!dst)
  	return NULL;
--- 381,386 ----
      }
      
!     dst = map_new_file (CREATE_ALWAYS, ini_file, NULL, pmd->uncomp_size,
! 			0, 0, notify);
      if (!dst)
  	return NULL;

Index: wininst.exe
===================================================================
RCS file: /cvsroot/python/distutils/misc/wininst.exe,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
Binary files /tmp/cvsIoCK1k and /tmp/cvsiqHSMv differ