Blame SOURCES/unzip-6.0-close.patch

953429
diff -up unzip60/extract.c.close unzip60/extract.c
953429
--- unzip60/extract.c.close	2009-03-14 02:32:52.000000000 +0100
953429
+++ unzip60/extract.c	2009-11-19 08:17:23.481263496 +0100
953429
@@ -1924,24 +1924,21 @@ static int extract_or_test_member(__G)  
953429
 
953429
 #ifdef VMS                  /* VMS:  required even for stdout! (final flush) */
953429
     if (!uO.tflag)           /* don't close NULL file */
953429
-        close_outfile(__G);
953429
+        error = close_outfile(__G);
953429
 #else
953429
 #ifdef DLL
953429
     if (!uO.tflag && (!uO.cflag || G.redirect_data)) {
953429
         if (G.redirect_data)
953429
             FINISH_REDIRECT();
953429
         else
953429
-            close_outfile(__G);
953429
+            error = close_outfile(__G);
953429
     }
953429
 #else
953429
     if (!uO.tflag && !uO.cflag)   /* don't close NULL file or stdout */
953429
-        close_outfile(__G);
953429
+        error = close_outfile(__G);
953429
 #endif
953429
 #endif /* VMS */
953429
 
953429
-            /* GRR: CONVERT close_outfile() TO NON-VOID:  CHECK FOR ERRORS! */
953429
-
953429
-
953429
     if (G.disk_full) {            /* set by flush() */
953429
         if (G.disk_full > 1) {
953429
 #if (defined(DELETE_IF_FULL) && defined(HAVE_UNLINK))
953429
diff -up unzip60/unix/unix.c.close unzip60/unix/unix.c
953429
--- unzip60/unix/unix.c.close	2009-01-24 00:31:26.000000000 +0100
953429
+++ unzip60/unix/unix.c	2009-11-19 08:33:25.568389171 +0100
953429
@@ -1096,10 +1096,41 @@ static int get_extattribs(__G__ pzt, z_u
953429
 #ifndef MTS
953429
 
953429
 /****************************/
953429
+/* Function CloseError()    */
953429
+/***************************/
953429
+
953429
+int CloseError(__G)
953429
+    __GDEF
953429
+{
953429
+    int errval = PK_OK;
953429
+    
953429
+    if (fclose(G.outfile) < 0) {
953429
+          switch (errno) {
953429
+                case ENOSPC:
953429
+                    /* Do we need this on fileio.c? */
953429
+                    Info(slide, 0x4a1, ((char *)slide, "%s: write error (disk full?).   Continue? (y/n/^C) ",
953429
+                          FnFilter1(G.filename)));
953429
+                    fgets(G.answerbuf, 9, stdin);
953429
+                    if (*G.answerbuf == 'y')     /* stop writing to this file */
953429
+                        G.disk_full = 1;         /* pass to next */
953429
+                    else
953429
+                        G.disk_full = 2;         /* no: exit program */
953429
+          
953429
+                    errval = PK_DISK;
953429
+                    break;
953429
+
953429
+                default:
953429
+                    errval = PK_WARN;
953429
+          }
953429
+     }
953429
+     return errval;
953429
+} /* End of CloseError() */
953429
+
953429
+/****************************/
953429
 /* Function close_outfile() */
953429
 /****************************/
953429
 
953429
-void close_outfile(__G)    /* GRR: change to return PK-style warning level */
953429
+int close_outfile(__G) 
953429
     __GDEF
953429
 {
953429
     union {
953429
@@ -1108,6 +1139,7 @@ void close_outfile(__G)    /* GRR: chang
953429
     } zt;
953429
     ulg z_uidgid[2];
953429
     int have_uidgid_flg;
953429
+    int errval = PK_OK;
953429
 
953429
     have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
953429
 
953429
@@ -1141,16 +1173,16 @@ void close_outfile(__G)    /* GRR: chang
953429
             Info(slide, 0x201, ((char *)slide,
953429
               "warning:  symbolic link (%s) failed: mem alloc overflow\n",
953429
               FnFilter1(G.filename)));
953429
-            fclose(G.outfile);
953429
-            return;
953429
+            errval = CloseError(G.outfile, G.filename);
953429
+            return errval ? errval : PK_WARN;
953429
         }
953429
 
953429
         if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) {
953429
             Info(slide, 0x201, ((char *)slide,
953429
               "warning:  symbolic link (%s) failed: no mem\n",
953429
               FnFilter1(G.filename)));
953429
-            fclose(G.outfile);
953429
-            return;
953429
+            errval = CloseError(G.outfile, G.filename);
953429
+            return errval ? errval : PK_WARN;
953429
         }
953429
         slnk_entry->next = NULL;
953429
         slnk_entry->targetlen = ucsize;
953429
@@ -1174,10 +1206,10 @@ void close_outfile(__G)    /* GRR: chang
953429
               "warning:  symbolic link (%s) failed\n",
953429
               FnFilter1(G.filename)));
953429
             free(slnk_entry);
953429
-            fclose(G.outfile);
953429
-            return;
953429
+            errval = CloseError(G.outfile, G.filename);
953429
+            return errval ? errval : PK_WARN;
953429
         }
953429
-        fclose(G.outfile);                  /* close "link" file for good... */
953429
+        errval = CloseError(G.outfile, G.filename); /* close "link" file for good... */
953429
         slnk_entry->target[ucsize] = '\0';
953429
         if (QCOND2)
953429
             Info(slide, 0, ((char *)slide, "-> %s ",
953429
@@ -1188,7 +1220,7 @@ void close_outfile(__G)    /* GRR: chang
953429
         else
953429
             G.slink_head = slnk_entry;
953429
         G.slink_last = slnk_entry;
953429
-        return;
953429
+        return errval;
953429
     }
953429
 #endif /* SYMLINKS */
953429
 
953429
@@ -1201,7 +1233,7 @@ void close_outfile(__G)    /* GRR: chang
953429
 #endif
953429
 
953429
 #if (defined(NO_FCHOWN))
953429
-    fclose(G.outfile);
953429
+    errval = CloseError(G.outfile, G.filename);
953429
 #endif
953429
 
953429
     /* if -X option was specified and we have UID/GID info, restore it */
953429
@@ -1227,7 +1259,7 @@ void close_outfile(__G)    /* GRR: chang
953429
     }
953429
 
953429
 #if (!defined(NO_FCHOWN) && defined(NO_FCHMOD))
953429
-    fclose(G.outfile);
953429
+    errval = CloseError(G.outfile, G.filename);
953429
 #endif
953429
 
953429
 #if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD))
953429
@@ -1239,7 +1271,7 @@ void close_outfile(__G)    /* GRR: chang
953429
     if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr)))
953429
         perror("fchmod (file attributes) error");
953429
 
953429
-    fclose(G.outfile);
953429
+    errval = CloseError(G.outfile, G.filename);
953429
 #endif /* !NO_FCHOWN && !NO_FCHMOD */
953429
 
953429
     /* skip restoring time stamps on user's request */
953429
@@ -1267,6 +1299,7 @@ void close_outfile(__G)    /* GRR: chang
953429
 #endif
953429
 #endif /* NO_FCHOWN || NO_FCHMOD */
953429
 
953429
+    return errval;
953429
 } /* end function close_outfile() */
953429
 
953429
 #endif /* !MTS */
953429
diff -up unzip60/unzpriv.h.close unzip60/unzpriv.h
953429
--- unzip60/unzpriv.h.close	2009-04-20 01:59:26.000000000 +0200
953429
+++ unzip60/unzpriv.h	2009-11-19 08:19:08.610388618 +0100
953429
@@ -2604,7 +2604,7 @@ char    *GetLoadPath     OF((__GPRO));  
953429
    int   SetFileSize     OF((FILE *file, zusz_t filesize));         /* local */
953429
 #endif
953429
 #ifndef MTS /* macro in MTS */
953429
-   void  close_outfile   OF((__GPRO));                              /* local */
953429
+   int  close_outfile   OF((__GPRO));                              /* local */
953429
 #endif
953429
 #ifdef SET_SYMLINK_ATTRIBS
953429
    int  set_symlnk_attribs  OF((__GPRO__ slinkentry *slnk_entry));  /* local */