Fix the pwd and group functions. The bb_ stuff was a leftover from
[oweals/busybox.git] / gzip.c
diff --git a/gzip.c b/gzip.c
index 49c429b3af84a7da4eecd908cdcec125a59b840f..5a74868c19d4adec4ae458fad66d8e213f9458dd 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -45,6 +45,7 @@
  */
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #define memzero(s, n)     memset ((void *)(s), 0, (n))
 
 #ifndef RETSIGTYPE
@@ -1808,6 +1809,8 @@ int gzip_main(int argc, char **argv)
                        case '1': case '2': case '3': case '4': case '5':
                        case '6': case '7': case '8': case '9':
                                break;
+                       case 'd':
+                               exit(gunzip_main(argc, argv));
                        default:
                                usage(gzip_usage);
                        }
@@ -1865,18 +1868,13 @@ int gzip_main(int argc, char **argv)
                        usage(gzip_usage);
                strncpy(ifname, *argv, MAX_PATH_LEN);
 
-               /* Open input fille */
+               /* Open input file */
                inFileNum = open(ifname, O_RDONLY);
-               if (inFileNum < 0) {
-                       perror(ifname);
-                       exit(WARNING);
-               }
+               if (inFileNum < 0)
+                       perror_msg_and_die("%s", ifname);
                /* Get the time stamp on the input file. */
-               result = stat(ifname, &statBuf);
-               if (result < 0) {
-                       perror(ifname);
-                       exit(WARNING);
-               }
+               if (stat(ifname, &statBuf) < 0)
+                       perror_msg_and_die("%s", ifname);
                time_stamp = statBuf.st_ctime;
                ifile_size = statBuf.st_size;
        }
@@ -1907,10 +1905,8 @@ int gzip_main(int argc, char **argv)
 #else
                outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
 #endif
-               if (outFileNum < 0) {
-                       perror(ofname);
-                       exit(WARNING);
-               }
+               if (outFileNum < 0)
+                       perror_msg_and_die("%s", ofname);
                SET_BINARY_MODE(outFileNum);
                /* Set permissions on the file */
                fchmod(outFileNum, statBuf.st_mode);
@@ -1928,10 +1924,8 @@ int gzip_main(int argc, char **argv)
                else
                        delFileName = ofname;
 
-               if (unlink(delFileName) < 0) {
-                       perror(delFileName);
-                       exit(EXIT_FAILURE);
-               }
+               if (unlink(delFileName) < 0)
+                       perror_msg_and_die("%s", delFileName);
        }
 
        return(exit_code);