Blame SOURCES/unzip-6.0-close.patch

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