Introduce new function gunzip_init()
gunzip_init() will make it easier to use gunzip from other bb functions.
diff --git a/archival/gunzip.c b/archival/gunzip.c
index a5846c3..48db7cf 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -1176,10 +1176,43 @@
 	bytes_in = bytes_out = 0L;
 }
 
+/* ===========================================================================
+ * Initialize gunzip buffers and signals
+ */
+static int gunzip_init()
+{
+	foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
+	if (foreground) {
+		(void) signal(SIGINT, (sig_type) abort_gzip);
+	}
+#ifdef SIGTERM
+	if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
+		(void) signal(SIGTERM, (sig_type) abort_gzip);
+	}
+#endif
+#ifdef SIGHUP
+	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
+		(void) signal(SIGHUP, (sig_type) abort_gzip);
+	}
+#endif
+
+	/* Allocate all global buffers (for DYN_ALLOC option) */
+	inbuf = xmalloc((size_t)((INBUFSIZ+INBUF_EXTRA+1L)*sizeof(uch)));
+	outbuf = xmalloc((size_t)((OUTBUFSIZ+OUTBUF_EXTRA+1L)*sizeof(uch)));
+	d_buf = xmalloc((size_t)((DIST_BUFSIZE+1L)*sizeof(ush)));
+	window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(uch)));
+	tab_prefix0 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
+	tab_prefix1 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));
+	
+	clear_bufs();			/* clear input and output buffers */
+	part_nb = 0;
+	return(EXIT_SUCCESS);	
+}
+
+
 /* ======================================================================== */
 int gunzip_main(int argc, char **argv)
 {
-	int file_count;				/* number of files to precess */
 	int tostdout = 0;
 	int fromstdin = 0;
 	int result;
@@ -1229,31 +1262,7 @@
 	if (isatty(fileno(stdout)) && tostdout==1 && force==0)
 		error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
 
-
-	foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
-	if (foreground) {
-		(void) signal(SIGINT, (sig_type) abort_gzip);
-	}
-#ifdef SIGTERM
-	if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
-		(void) signal(SIGTERM, (sig_type) abort_gzip);
-	}
-#endif
-#ifdef SIGHUP
-	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
-		(void) signal(SIGHUP, (sig_type) abort_gzip);
-	}
-#endif
-
-	file_count = argc - optind;
-
-	/* Allocate all global buffers (for DYN_ALLOC option) */
-	inbuf = xmalloc((size_t)((INBUFSIZ+INBUF_EXTRA+1L)*sizeof(uch)));
-	outbuf = xmalloc((size_t)((OUTBUFSIZ+OUTBUF_EXTRA+1L)*sizeof(uch)));
-	d_buf = xmalloc((size_t)((DIST_BUFSIZE+1L)*sizeof(ush)));
-	window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(uch)));
-	tab_prefix0 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
-	tab_prefix1 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
+	gunzip_init();
 
 	if (fromstdin == 1) {
 		strcpy(ofname, "stdin");
@@ -1290,9 +1299,6 @@
 		strcpy(ofname, "stdout");
 		outFileNum = fileno(stdout);
 
-		clear_bufs();			/* clear input and output buffers */
-		part_nb = 0;
-
 		/* Actually do the compression/decompression. */
 		unzip(inFileNum, outFileNum);
 
@@ -1334,9 +1340,6 @@
 		/* Set permissions on the file */
 		fchmod(outFileNum, statBuf.st_mode);
 
-		clear_bufs();			/* clear input and output buffers */
-		part_nb = 0;
-
 		/* Actually do the compression/decompression. */
 		result = unzip(inFileNum, outFileNum);
 
diff --git a/gunzip.c b/gunzip.c
index a5846c3..48db7cf 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -1176,10 +1176,43 @@
 	bytes_in = bytes_out = 0L;
 }
 
+/* ===========================================================================
+ * Initialize gunzip buffers and signals
+ */
+static int gunzip_init()
+{
+	foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
+	if (foreground) {
+		(void) signal(SIGINT, (sig_type) abort_gzip);
+	}
+#ifdef SIGTERM
+	if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
+		(void) signal(SIGTERM, (sig_type) abort_gzip);
+	}
+#endif
+#ifdef SIGHUP
+	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
+		(void) signal(SIGHUP, (sig_type) abort_gzip);
+	}
+#endif
+
+	/* Allocate all global buffers (for DYN_ALLOC option) */
+	inbuf = xmalloc((size_t)((INBUFSIZ+INBUF_EXTRA+1L)*sizeof(uch)));
+	outbuf = xmalloc((size_t)((OUTBUFSIZ+OUTBUF_EXTRA+1L)*sizeof(uch)));
+	d_buf = xmalloc((size_t)((DIST_BUFSIZE+1L)*sizeof(ush)));
+	window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(uch)));
+	tab_prefix0 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
+	tab_prefix1 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));
+	
+	clear_bufs();			/* clear input and output buffers */
+	part_nb = 0;
+	return(EXIT_SUCCESS);	
+}
+
+
 /* ======================================================================== */
 int gunzip_main(int argc, char **argv)
 {
-	int file_count;				/* number of files to precess */
 	int tostdout = 0;
 	int fromstdin = 0;
 	int result;
@@ -1229,31 +1262,7 @@
 	if (isatty(fileno(stdout)) && tostdout==1 && force==0)
 		error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
 
-
-	foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
-	if (foreground) {
-		(void) signal(SIGINT, (sig_type) abort_gzip);
-	}
-#ifdef SIGTERM
-	if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
-		(void) signal(SIGTERM, (sig_type) abort_gzip);
-	}
-#endif
-#ifdef SIGHUP
-	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
-		(void) signal(SIGHUP, (sig_type) abort_gzip);
-	}
-#endif
-
-	file_count = argc - optind;
-
-	/* Allocate all global buffers (for DYN_ALLOC option) */
-	inbuf = xmalloc((size_t)((INBUFSIZ+INBUF_EXTRA+1L)*sizeof(uch)));
-	outbuf = xmalloc((size_t)((OUTBUFSIZ+OUTBUF_EXTRA+1L)*sizeof(uch)));
-	d_buf = xmalloc((size_t)((DIST_BUFSIZE+1L)*sizeof(ush)));
-	window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(uch)));
-	tab_prefix0 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
-	tab_prefix1 = xmalloc((size_t)(((1L<<(BITS-1))+1L)*sizeof(ush)));	
+	gunzip_init();
 
 	if (fromstdin == 1) {
 		strcpy(ofname, "stdin");
@@ -1290,9 +1299,6 @@
 		strcpy(ofname, "stdout");
 		outFileNum = fileno(stdout);
 
-		clear_bufs();			/* clear input and output buffers */
-		part_nb = 0;
-
 		/* Actually do the compression/decompression. */
 		unzip(inFileNum, outFileNum);
 
@@ -1334,9 +1340,6 @@
 		/* Set permissions on the file */
 		fchmod(outFileNum, statBuf.st_mode);
 
-		clear_bufs();			/* clear input and output buffers */
-		part_nb = 0;
-
 		/* Actually do the compression/decompression. */
 		result = unzip(inFileNum, outFileNum);