*/
//usage:#define unzip_trivial_usage
-//usage: "[-lnopq] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
+//usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]"
//usage:#define unzip_full_usage "\n\n"
-//usage: "Extract files from ZIP archives\n"
-//usage: "\n -l List archive contents (with -q for short form)"
+//usage: "Extract FILEs from ZIP archive\n"
+//usage: "\n -l List contents (with -q for short form)"
//usage: "\n -n Never overwrite files (default: ask)"
//usage: "\n -o Overwrite"
-//usage: "\n -p Send output to stdout"
+//usage: "\n -p Print to stdout"
//usage: "\n -q Quiet"
-//usage: "\n -x XLST Exclude these files"
-//usage: "\n -d DIR Extract files into DIR"
+//usage: "\n -x FILE Exclude FILEs"
+//usage: "\n -d DIR Extract into DIR"
#include "libbb.h"
#include "bb_archive.h"
}
}
+static void my_fgets80(char *buf80)
+{
+ fflush_all();
+ if (!fgets(buf80, 80, stdin)) {
+ bb_perror_msg_and_die("can't read standard input");
+ }
+}
+
int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unzip_main(int argc, char **argv)
{
llist_t *zreject = NULL;
char *base_dir = NULL;
int i, opt;
- char key_buf[80];
+ char key_buf[80]; /* must match size used by my_fgets80 */
struct stat stat_buf;
/* -q, -l and -v: UnZip 5.52 of 28 February 2005, by Info-ZIP:
i = 'y';
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
- fflush_all();
- if (!fgets(key_buf, sizeof(key_buf), stdin)) {
- bb_perror_msg_and_die("can't read input");
- }
+ my_fgets80(key_buf);
i = key_buf[0];
}
} else { /* File is not regular file */
case 'r':
/* Prompt for new name */
printf("new name: ");
- if (!fgets(key_buf, sizeof(key_buf), stdin)) {
- bb_perror_msg_and_die("can't read input");
- }
+ my_fgets80(key_buf);
free(dst_fn);
dst_fn = xstrdup(key_buf);
chomp(dst_fn);