iconv-unzip_c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. $OpenBSD: iconv-unzip_c,v 1.1 2015/05/11 21:19:23 czarkoff Exp $
  2. --- unzip.c.orig Thu Apr 16 20:26:52 2009
  3. +++ unzip.c Sat May 9 13:31:20 2015
  4. @@ -327,11 +327,21 @@ static ZCONST char Far ZipInfoUsageLine2[] = "\nmain\
  5. -2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
  6. -v verbose, multi-page format\n";
  7. +#ifndef UNIX
  8. static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
  9. -h print header line -t print totals for listed files or for all\n\
  10. -z print zipfile comment -T print file times in sortable decimal format\
  11. \n -C be case-insensitive %s\
  12. -x exclude filenames that follow from listing\n";
  13. +#else /* UNIX */
  14. +static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
  15. + -h print header line -t print totals for listed files or for all\n\
  16. + -z print zipfile comment -T print file times in sortable decimal format\
  17. +\n -C be case-insensitive %s\
  18. + -x exclude filenames that follow from listing\n\
  19. + -O CHARSET specify a character encoding for DOS, Windows and OS/2 archives\n\
  20. + -I CHARSET specify a character encoding for UNIX and other archives\n";
  21. +#endif /* !UNIX */
  22. #ifdef MORE
  23. static ZCONST char Far ZipInfoUsageLine4[] =
  24. " -M page output through built-in \"more\"\n";
  25. @@ -665,6 +675,17 @@ modifiers:\n\
  26. -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
  27. -C match filenames case-insensitively -L make (some) names \
  28. lowercase\n %-42s -V retain VMS version numbers\n%s";
  29. +#elif (defined UNIX)
  30. +static ZCONST char Far UnzipUsageLine4[] = "\
  31. +modifiers:\n\
  32. + -n never overwrite existing files -q quiet mode (-qq => quieter)\n\
  33. + -o overwrite files WITHOUT prompting -a auto-convert any text files\n\
  34. + -j junk paths (do not make directories) -aa treat ALL files as text\n\
  35. + -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
  36. + -C match filenames case-insensitively -L make (some) names \
  37. +lowercase\n %-42s -V retain VMS version numbers\n%s\
  38. + -O CHARSET specify a character encoding for DOS, Windows and OS/2 archives\n\
  39. + -I CHARSET specify a character encoding for UNIX and other archives\n\n";
  40. #else /* !VMS */
  41. static ZCONST char Far UnzipUsageLine4[] = "\
  42. modifiers:\n\
  43. @@ -803,6 +824,10 @@ int unzip(__G__ argc, argv)
  44. #endif /* UNICODE_SUPPORT */
  45. +#ifdef UNIX
  46. + init_conversion_charsets();
  47. +#endif
  48. +
  49. #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
  50. extern void DebugMalloc(void);
  51. @@ -1336,6 +1361,11 @@ int uz_opts(__G__ pargc, pargv)
  52. argc = *pargc;
  53. argv = *pargv;
  54. +#ifdef UNIX
  55. + extern char OEM_CP[MAX_CP_NAME];
  56. + extern char ISO_CP[MAX_CP_NAME];
  57. +#endif
  58. +
  59. while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
  60. s = *argv + 1;
  61. while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
  62. @@ -1517,6 +1547,35 @@ int uz_opts(__G__ pargc, pargv)
  63. }
  64. break;
  65. #endif /* MACOS */
  66. +#ifdef UNIX
  67. + case ('I'):
  68. + if (negative) {
  69. + Info(slide, 0x401, ((char *)slide,
  70. + "error: encodings can't be negated"));
  71. + return(PK_PARAM);
  72. + } else {
  73. + if(*s) { /* Handle the -Icharset case */
  74. + /* Assume that charsets can't start with a dash to spot arguments misuse */
  75. + if(*s == '-') {
  76. + Info(slide, 0x401, ((char *)slide,
  77. + "error: a valid character encoding should follow the -I argument"));
  78. + return(PK_PARAM);
  79. + }
  80. + strncpy(ISO_CP, s, sizeof(ISO_CP));
  81. + } else { /* -I charset */
  82. + ++argv;
  83. + if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
  84. + Info(slide, 0x401, ((char *)slide,
  85. + "error: a valid character encoding should follow the -I argument"));
  86. + return(PK_PARAM);
  87. + }
  88. + s = *argv;
  89. + strncpy(ISO_CP, s, sizeof(ISO_CP));
  90. + }
  91. + while(*(++s)); /* No params straight after charset name */
  92. + }
  93. + break;
  94. +#endif /* ?UNIX */
  95. case ('j'): /* junk pathnames/directory structure */
  96. if (negative)
  97. uO.jflag = FALSE, negative = 0;
  98. @@ -1592,6 +1651,35 @@ int uz_opts(__G__ pargc, pargv)
  99. } else
  100. ++uO.overwrite_all;
  101. break;
  102. +#ifdef UNIX
  103. + case ('O'):
  104. + if (negative) {
  105. + Info(slide, 0x401, ((char *)slide,
  106. + "error: encodings can't be negated"));
  107. + return(PK_PARAM);
  108. + } else {
  109. + if(*s) { /* Handle the -Ocharset case */
  110. + /* Assume that charsets can't start with a dash to spot arguments misuse */
  111. + if(*s == '-') {
  112. + Info(slide, 0x401, ((char *)slide,
  113. + "error: a valid character encoding should follow the -I argument"));
  114. + return(PK_PARAM);
  115. + }
  116. + strncpy(OEM_CP, s, sizeof(OEM_CP));
  117. + } else { /* -O charset */
  118. + ++argv;
  119. + if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
  120. + Info(slide, 0x401, ((char *)slide,
  121. + "error: a valid character encoding should follow the -O argument"));
  122. + return(PK_PARAM);
  123. + }
  124. + s = *argv;
  125. + strncpy(OEM_CP, s, sizeof(OEM_CP));
  126. + }
  127. + while(*(++s)); /* No params straight after charset name */
  128. + }
  129. + break;
  130. +#endif /* ?UNIX */
  131. case ('p'): /* pipes: extract to stdout, no messages */
  132. if (negative) {
  133. uO.cflag = FALSE;