Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unzip.c 95KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666
  1. /*
  2. Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2009-Jan-02 or later
  4. (the contents of which are also included in unzip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /*---------------------------------------------------------------------------
  9. unzip.c
  10. UnZip - a zipfile extraction utility. See below for make instructions, or
  11. read the comments in Makefile and the various Contents files for more de-
  12. tailed explanations. To report a bug, submit a *complete* description via
  13. //www.info-zip.org/zip-bug.html; include machine type, operating system and
  14. version, compiler and version, and reasonably detailed error messages or
  15. problem report. To join Info-ZIP, see the instructions in README.
  16. UnZip 5.x is a greatly expanded and partially rewritten successor to 4.x,
  17. which in turn was almost a complete rewrite of version 3.x. For a detailed
  18. revision history, see UnzpHist.zip at quest.jpl.nasa.gov. For a list of
  19. the many (near infinite) contributors, see "CONTRIBS" in the UnZip source
  20. distribution.
  21. UnZip 6.0 adds support for archives larger than 4 GiB using the Zip64
  22. extensions as well as support for Unicode information embedded per the
  23. latest zip standard additions.
  24. ---------------------------------------------------------------------------
  25. [from original zipinfo.c]
  26. This program reads great gobs of totally nifty information, including the
  27. central directory stuff, from ZIP archives ("zipfiles" for short). It
  28. started as just a testbed for fooling with zipfiles, but at this point it
  29. is actually a useful utility. It also became the basis for the rewrite of
  30. UnZip (3.16 -> 4.0), using the central directory for processing rather than
  31. the individual (local) file headers.
  32. As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
  33. If the executable is named "unzip" (or "unzip.exe", depending), it behaves
  34. like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
  35. ZipInfo. The ZipInfo behavior may also be triggered by use of unzip's -Z
  36. option; for example, "unzip -Z [zipinfo_options] archive.zip".
  37. Another dandy product from your buddies at Newtware!
  38. Author: Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
  39. 23 August 1990 -> April 1997
  40. ---------------------------------------------------------------------------
  41. Version: unzip5??.{tar.Z | tar.gz | zip} for Unix, VMS, OS/2, MS-DOS, Amiga,
  42. Atari, Windows 3.x/95/NT/CE, Macintosh, Human68K, Acorn RISC OS,
  43. AtheOS, BeOS, SMS/QDOS, VM/CMS, MVS, AOS/VS, Tandem NSK, Theos
  44. and TOPS-20.
  45. Copyrights: see accompanying file "LICENSE" in UnZip source distribution.
  46. (This software is free but NOT IN THE PUBLIC DOMAIN.)
  47. ---------------------------------------------------------------------------*/
  48. #define __UNZIP_C /* identifies this source module */
  49. #define UNZIP_INTERNAL
  50. #include "unzip.h" /* includes, typedefs, macros, prototypes, etc. */
  51. #include "crypt.h"
  52. #include "unzvers.h"
  53. #include "unzipfx/appDetails.h"
  54. #ifndef WINDLL /* The WINDLL port uses windll/windll.c instead... */
  55. /***************************/
  56. /* Local type declarations */
  57. /***************************/
  58. #if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
  59. typedef struct _sign_info
  60. {
  61. struct _sign_info *previous;
  62. void (*sighandler)(int);
  63. int sigtype;
  64. } savsigs_info;
  65. #endif
  66. /*******************/
  67. /* Local Functions */
  68. /*******************/
  69. #if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
  70. static int setsignalhandler OF((__GPRO__ savsigs_info **p_savedhandler_chain,
  71. int signal_type, void (*newhandler)(int)));
  72. #endif
  73. #ifndef SFX
  74. static void help_extended OF((__GPRO));
  75. static void show_version_info OF((__GPRO));
  76. #endif
  77. /*************/
  78. /* Constants */
  79. /*************/
  80. #include "consts.h" /* all constant global variables are in here */
  81. /* (non-constant globals were moved to globals.c) */
  82. /* constant local variables: */
  83. #ifndef SFX
  84. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  85. static ZCONST char Far EnvUnZip[] = ENV_UNZIP;
  86. static ZCONST char Far EnvUnZip2[] = ENV_UNZIP2;
  87. static ZCONST char Far EnvZipInfo[] = ENV_ZIPINFO;
  88. static ZCONST char Far EnvZipInfo2[] = ENV_ZIPINFO2;
  89. #ifdef RISCOS
  90. static ZCONST char Far EnvUnZipExts[] = ENV_UNZIPEXTS;
  91. #endif /* RISCOS */
  92. static ZCONST char Far NoMemEnvArguments[] =
  93. "envargs: cannot get memory for arguments";
  94. #endif /* !_WIN32_WCE */
  95. static ZCONST char Far CmdLineParamTooLong[] =
  96. "error: command line parameter #%d exceeds internal size limit\n";
  97. #endif /* !SFX */
  98. #if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
  99. static ZCONST char Far CantSaveSigHandler[] =
  100. "error: cannot save signal handler settings\n";
  101. #endif
  102. #if (!defined(SFX) || defined(SFX_EXDIR))
  103. static ZCONST char Far NotExtracting[] =
  104. "caution: not extracting; -d ignored\n";
  105. static ZCONST char Far MustGiveExdir[] =
  106. "error: must specify directory to which to extract with -d option\n";
  107. static ZCONST char Far OnlyOneExdir[] =
  108. "error: -d option used more than once (only one exdir allowed)\n";
  109. #endif
  110. #if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR))
  111. static ZCONST char Far UTF8EscapeUnSupp[] =
  112. "warning: -U \"escape all non-ASCII UTF-8 chars\" is not supported\n";
  113. #endif
  114. #if CRYPT
  115. static ZCONST char Far MustGivePasswd[] =
  116. "error: must give decryption password with -P option\n";
  117. #endif
  118. #ifndef SFX
  119. static ZCONST char Far Zfirst[] =
  120. "error: -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
  121. #endif
  122. static ZCONST char Far InvalidOptionsMsg[] = "error:\
  123. -fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
  124. static ZCONST char Far IgnoreOOptionMsg[] =
  125. "caution: both -n and -o specified; ignoring -o\n";
  126. /* usage() strings */
  127. #ifndef SFX
  128. #ifdef VMS
  129. static ZCONST char Far Example3[] = "vms.c";
  130. static ZCONST char Far Example2[] = " unzip \"-V\" foo \"Bar\"\
  131. (Quote names to preserve case, unless SET PROC/PARS=EXT)\n";
  132. #else /* !VMS */
  133. static ZCONST char Far Example3[] = "ReadMe";
  134. #ifdef RISCOS
  135. static ZCONST char Far Example2[] =
  136. " unzip foo -d RAM:$ => extract all files from foo into RAMDisc\n";
  137. #else /* !RISCOS */
  138. #if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
  139. static ZCONST char Far Example2[] =
  140. ""; /* no room: too many local3[] items */
  141. #else /* !OS2 */
  142. #ifdef MACOS
  143. static ZCONST char Far Example2[] = ""; /* not needed */
  144. #else /* !MACOS */
  145. static ZCONST char Far Example2[] = " \
  146. unzip -p foo | more => send contents of foo.zip via pipe into program more\n";
  147. #endif /* ?MACOS */
  148. #endif /* ?OS2 */
  149. #endif /* ?RISCOS */
  150. #endif /* ?VMS */
  151. /* local1[]: command options */
  152. #if defined(TIMESTAMP)
  153. static ZCONST char Far local1[] =
  154. " -T timestamp archive to latest";
  155. #else /* !TIMESTAMP */
  156. static ZCONST char Far local1[] = "";
  157. #endif /* ?TIMESTAMP */
  158. /* local2[] and local3[]: modifier options */
  159. #ifdef DOS_FLX_H68_OS2_W32
  160. #ifdef FLEXOS
  161. static ZCONST char Far local2[] = "";
  162. #else
  163. static ZCONST char Far local2[] =
  164. " -$ label removables (-$$ => fixed disks)";
  165. #endif
  166. #ifdef OS2
  167. #ifdef MORE
  168. static ZCONST char Far local3[] = "\
  169. -X restore ACLs if supported -s spaces in filenames => '_'\n\
  170. -M pipe through \"more\" pager\n";
  171. #else
  172. static ZCONST char Far local3[] = " \
  173. -X restore ACLs if supported -s spaces in filenames => '_'\n\n";
  174. #endif /* ?MORE */
  175. #else /* !OS2 */
  176. #ifdef WIN32
  177. #ifdef NTSD_EAS
  178. #ifdef MORE
  179. static ZCONST char Far local3[] = "\
  180. -X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\
  181. -M pipe through \"more\" pager\n";
  182. #else
  183. static ZCONST char Far local3[] = " \
  184. -X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\n";
  185. #endif /* ?MORE */
  186. #else /* !NTSD_EAS */
  187. #ifdef MORE
  188. static ZCONST char Far local3[] = "\
  189. -M pipe through \"more\" pager \
  190. -s spaces in filenames => '_'\n\n";
  191. #else
  192. static ZCONST char Far local3[] = " \
  193. -s spaces in filenames => '_'\n\n";
  194. #endif /* ?MORE */
  195. #endif /* ?NTSD_EAS */
  196. #else /* !WIN32 */
  197. #ifdef MORE
  198. static ZCONST char Far local3[] = " -\
  199. M pipe through \"more\" pager -s spaces in filenames => '_'\n\n";
  200. #else
  201. static ZCONST char Far local3[] = "\
  202. -s spaces in filenames => '_'\n";
  203. #endif
  204. #endif /* ?WIN32 */
  205. #endif /* ?OS2 || ?WIN32 */
  206. #else /* !DOS_FLX_OS2_W32 */
  207. #ifdef VMS
  208. static ZCONST char Far local2[] = " -X restore owner/ACL protection info";
  209. #ifdef MORE
  210. static ZCONST char Far local3[] = "\
  211. -Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
  212. --D restore dir (-D: no) timestamps -M pipe through \"more\" pager\n\
  213. (Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
  214. \n\n";
  215. #else
  216. static ZCONST char Far local3[] = "\n\
  217. -Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
  218. --D restore dir (-D: no) timestamps\n\
  219. (Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
  220. \n\n";
  221. #endif
  222. #else /* !VMS */
  223. #ifdef ATH_BEO_UNX
  224. static ZCONST char Far local2[] = " -X restore UID/GID info";
  225. #ifdef MORE
  226. static ZCONST char Far local3[] = "\
  227. -K keep setuid/setgid/tacky permissions -M pipe through \"more\" pager\n";
  228. #else
  229. static ZCONST char Far local3[] = "\
  230. -K keep setuid/setgid/tacky permissions\n";
  231. #endif
  232. #else /* !ATH_BEO_UNX */
  233. #ifdef TANDEM
  234. static ZCONST char Far local2[] = "\
  235. -X restore Tandem User ID -r remove file extensions\n\
  236. -b create 'C' (180) text files ";
  237. #ifdef MORE
  238. static ZCONST char Far local3[] = " \
  239. -M pipe through \"more\" pager\n";
  240. #else
  241. static ZCONST char Far local3[] = "\n";
  242. #endif
  243. #else /* !TANDEM */
  244. #ifdef AMIGA
  245. static ZCONST char Far local2[] = " -N restore comments as filenotes";
  246. #ifdef MORE
  247. static ZCONST char Far local3[] = " \
  248. -M pipe through \"more\" pager\n";
  249. #else
  250. static ZCONST char Far local3[] = "\n";
  251. #endif
  252. #else /* !AMIGA */
  253. #ifdef MACOS
  254. static ZCONST char Far local2[] = " -E show Mac info during extraction";
  255. static ZCONST char Far local3[] = " \
  256. -i ignore filenames in mac extra info -J junk (ignore) Mac extra info\n\
  257. \n";
  258. #else /* !MACOS */
  259. #ifdef MORE
  260. static ZCONST char Far local2[] = " -M pipe through \"more\" pager";
  261. static ZCONST char Far local3[] = "\n";
  262. #else
  263. static ZCONST char Far local2[] = ""; /* Atari, Mac, CMS/MVS etc. */
  264. static ZCONST char Far local3[] = "";
  265. #endif
  266. #endif /* ?MACOS */
  267. #endif /* ?AMIGA */
  268. #endif /* ?TANDEM */
  269. #endif /* ?ATH_BEO_UNX */
  270. #endif /* ?VMS */
  271. #endif /* ?DOS_FLX_OS2_W32 */
  272. #endif /* !SFX */
  273. #ifndef NO_ZIPINFO
  274. #ifdef VMS
  275. static ZCONST char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
  276. #else
  277. static ZCONST char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
  278. #endif
  279. static ZCONST char Far ZipInfoUsageLine1[] = "\
  280. ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
  281. \n\
  282. List name, date/time, attribute, size, compression method, etc., about files\n\
  283. in list (excluding those in xlist) contained in the specified .zip archive(s).\
  284. \n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
  285. usage: zipinfo [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n\
  286. or: unzip %s-Z%s [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n";
  287. static ZCONST char Far ZipInfoUsageLine2[] = "\nmain\
  288. listing-format options: -s short Unix \"ls -l\" format (def.)\n\
  289. -1 filenames ONLY, one per line -m medium Unix \"ls -l\" format\n\
  290. -2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
  291. -v verbose, multi-page format\n";
  292. static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
  293. -h print header line -t print totals for listed files or for all\n\
  294. -z print zipfile comment -T print file times in sortable decimal format\
  295. \n -C be case-insensitive %s\
  296. -x exclude filenames that follow from listing\n";
  297. #ifdef MORE
  298. static ZCONST char Far ZipInfoUsageLine4[] =
  299. " -M page output through built-in \"more\"\n";
  300. #else /* !MORE */
  301. static ZCONST char Far ZipInfoUsageLine4[] = "";
  302. #endif /* ?MORE */
  303. #endif /* !NO_ZIPINFO */
  304. #ifdef BETA
  305. # ifdef VMSCLI
  306. /* BetaVersion[] is also used in vms/cmdline.c: do not make it static */
  307. ZCONST char Far BetaVersion[] = "%s\
  308. THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
  309. # else
  310. static ZCONST char Far BetaVersion[] = "%s\
  311. THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
  312. # endif
  313. #endif
  314. #ifdef SFX
  315. # ifdef VMSCLI
  316. /* UnzipSFXBanner[] is also used in vms/cmdline.c: do not make it static */
  317. ZCONST char Far UnzipSFXBanner[] =
  318. # else
  319. static ZCONST char Far UnzipSFXBanner[] =
  320. # endif
  321. SFX_APP_BANNER "\n";
  322. # ifdef SFX_EXDIR
  323. static ZCONST char Far UnzipSFXOpts[] =
  324. "Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
  325. # else
  326. static ZCONST char Far UnzipSFXOpts[] =
  327. "Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
  328. # endif
  329. #else /* !SFX */
  330. static ZCONST char Far CompileOptions[] =
  331. "UnZip special compilation options:\n";
  332. static ZCONST char Far CompileOptFormat[] = " %s\n";
  333. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  334. static ZCONST char Far EnvOptions[] =
  335. "\nUnZip and ZipInfo environment options:\n";
  336. static ZCONST char Far EnvOptFormat[] = "%16s: %.1024s\n";
  337. #endif
  338. static ZCONST char Far None[] = "[none]";
  339. # ifdef ACORN_FTYPE_NFS
  340. static ZCONST char Far AcornFtypeNFS[] = "ACORN_FTYPE_NFS";
  341. # endif
  342. # ifdef ASM_CRC
  343. static ZCONST char Far AsmCRC[] = "ASM_CRC";
  344. # endif
  345. # ifdef ASM_INFLATECODES
  346. static ZCONST char Far AsmInflateCodes[] = "ASM_INFLATECODES";
  347. # endif
  348. # ifdef CHECK_VERSIONS
  349. static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS";
  350. # endif
  351. # ifdef COPYRIGHT_CLEAN
  352. static ZCONST char Far Copyright_Clean[] =
  353. "COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
  354. # endif
  355. # ifdef DEBUG
  356. static ZCONST char Far UDebug[] = "DEBUG";
  357. # endif
  358. # ifdef DEBUG_TIME
  359. static ZCONST char Far DebugTime[] = "DEBUG_TIME";
  360. # endif
  361. # ifdef DLL
  362. static ZCONST char Far Dll[] = "DLL";
  363. # endif
  364. # ifdef DOSWILD
  365. static ZCONST char Far DosWild[] = "DOSWILD";
  366. # endif
  367. # ifdef LZW_CLEAN
  368. static ZCONST char Far LZW_Clean[] =
  369. "LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
  370. # endif
  371. # ifndef MORE
  372. static ZCONST char Far No_More[] = "NO_MORE";
  373. # endif
  374. # ifdef NO_ZIPINFO
  375. static ZCONST char Far No_ZipInfo[] = "NO_ZIPINFO";
  376. # endif
  377. # ifdef NTSD_EAS
  378. static ZCONST char Far NTSDExtAttrib[] = "NTSD_EAS";
  379. # endif
  380. # if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
  381. static ZCONST char Far W32NoIZTimeFix[] = "NO_W32TIMES_IZFIX";
  382. # endif
  383. # ifdef OLD_THEOS_EXTRA
  384. static ZCONST char Far OldTheosExtra[] =
  385. "OLD_THEOS_EXTRA (handle also old Theos port extra field)";
  386. # endif
  387. # ifdef OS2_EAS
  388. static ZCONST char Far OS2ExtAttrib[] = "OS2_EAS";
  389. # endif
  390. # ifdef QLZIP
  391. static ZCONST char Far SMSExFldOnUnix[] = "QLZIP";
  392. # endif
  393. # ifdef REENTRANT
  394. static ZCONST char Far Reentrant[] = "REENTRANT";
  395. # endif
  396. # ifdef REGARGS
  397. static ZCONST char Far RegArgs[] = "REGARGS";
  398. # endif
  399. # ifdef RETURN_CODES
  400. static ZCONST char Far Return_Codes[] = "RETURN_CODES";
  401. # endif
  402. # ifdef SET_DIR_ATTRIB
  403. static ZCONST char Far SetDirAttrib[] = "SET_DIR_ATTRIB";
  404. # endif
  405. # ifdef SYMLINKS
  406. static ZCONST char Far SymLinkSupport[] =
  407. "SYMLINKS (symbolic links supported, if RTL and file system permit)";
  408. # endif
  409. # ifdef TIMESTAMP
  410. static ZCONST char Far TimeStamp[] = "TIMESTAMP";
  411. # endif
  412. # ifdef UNIXBACKUP
  413. static ZCONST char Far UnixBackup[] = "UNIXBACKUP";
  414. # endif
  415. # ifdef USE_EF_UT_TIME
  416. static ZCONST char Far Use_EF_UT_time[] = "USE_EF_UT_TIME";
  417. # endif
  418. # ifndef LZW_CLEAN
  419. static ZCONST char Far Use_Unshrink[] =
  420. "USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
  421. # endif
  422. # ifndef COPYRIGHT_CLEAN
  423. static ZCONST char Far Use_Smith_Code[] =
  424. "USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
  425. # endif
  426. # ifdef USE_DEFLATE64
  427. static ZCONST char Far Use_Deflate64[] =
  428. "USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)";
  429. # endif
  430. # ifdef UNICODE_SUPPORT
  431. # ifdef UTF8_MAYBE_NATIVE
  432. # ifdef UNICODE_WCHAR
  433. /* direct native UTF-8 check AND charset transform via wchar_t */
  434. static ZCONST char Far Use_Unicode[] =
  435. "UNICODE_SUPPORT [wide-chars, char coding: %s] (handle UTF-8 paths)";
  436. # else
  437. /* direct native UTF-8 check, only */
  438. static ZCONST char Far Use_Unicode[] =
  439. "UNICODE_SUPPORT [char coding: %s] (handle UTF-8 paths)";
  440. # endif
  441. static ZCONST char Far SysChUTF8[] = "UTF-8";
  442. static ZCONST char Far SysChOther[] = "other";
  443. # else /* !UTF8_MAYBE_NATIVE */
  444. /* charset transform via wchar_t, no native UTF-8 support */
  445. static ZCONST char Far Use_Unicode[] =
  446. "UNICODE_SUPPORT [wide-chars] (handle UTF-8 paths)";
  447. # endif /* ?UTF8_MAYBE_NATIVE */
  448. # endif /* UNICODE_SUPPORT */
  449. # ifdef _MBCS
  450. static ZCONST char Far Have_MBCS_Support[] =
  451. "MBCS-support (multibyte character support, MB_CUR_MAX = %u)";
  452. # endif
  453. # ifdef MULT_VOLUME
  454. static ZCONST char Far Use_MultiVol[] =
  455. "MULT_VOLUME (multi-volume archives supported)";
  456. # endif
  457. # ifdef LARGE_FILE_SUPPORT
  458. static ZCONST char Far Use_LFS[] =
  459. "LARGE_FILE_SUPPORT (large files over 2 GiB supported)";
  460. # endif
  461. # ifdef ZIP64_SUPPORT
  462. static ZCONST char Far Use_Zip64[] =
  463. "ZIP64_SUPPORT (archives using Zip64 for large files supported)";
  464. # endif
  465. # if (defined(__DJGPP__) && (__DJGPP__ >= 2))
  466. # ifdef USE_DJGPP_ENV
  467. static ZCONST char Far Use_DJGPP_Env[] = "USE_DJGPP_ENV";
  468. # endif
  469. # ifdef USE_DJGPP_GLOB
  470. static ZCONST char Far Use_DJGPP_Glob[] = "USE_DJGPP_GLOB";
  471. # endif
  472. # endif /* __DJGPP__ && (__DJGPP__ >= 2) */
  473. # ifdef USE_VFAT
  474. static ZCONST char Far Use_VFAT_support[] = "USE_VFAT";
  475. # endif
  476. # ifdef USE_ZLIB
  477. static ZCONST char Far UseZlib[] =
  478. "USE_ZLIB (compiled with version %s; using version %s)";
  479. # endif
  480. # ifdef USE_BZIP2
  481. static ZCONST char Far UseBZip2[] =
  482. "USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version %s)";
  483. # endif
  484. # ifdef VMS_TEXT_CONV
  485. static ZCONST char Far VmsTextConv[] = "VMS_TEXT_CONV";
  486. # endif
  487. # ifdef VMSCLI
  488. static ZCONST char Far VmsCLI[] = "VMSCLI";
  489. # endif
  490. # ifdef VMSWILD
  491. static ZCONST char Far VmsWild[] = "VMSWILD";
  492. # endif
  493. # ifdef WILD_STOP_AT_DIR
  494. static ZCONST char Far WildStopAtDir[] = "WILD_STOP_AT_DIR";
  495. # endif
  496. # if CRYPT
  497. # ifdef PASSWD_FROM_STDIN
  498. static ZCONST char Far PasswdStdin[] = "PASSWD_FROM_STDIN";
  499. # endif
  500. static ZCONST char Far Decryption[] =
  501. " [decryption, version %d.%d%s of %s]\n";
  502. static ZCONST char Far CryptDate[] = CR_VERSION_DATE;
  503. # endif
  504. # ifndef __RSXNT__
  505. # ifdef __EMX__
  506. static ZCONST char Far EnvEMX[] = "EMX";
  507. static ZCONST char Far EnvEMXOPT[] = "EMXOPT";
  508. # endif
  509. # if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
  510. static ZCONST char Far EnvGO32[] = "GO32";
  511. static ZCONST char Far EnvGO32TMP[] = "GO32TMP";
  512. # endif
  513. # endif /* !__RSXNT__ */
  514. #ifdef VMS
  515. /* UnzipUsageLine1[] is also used in vms/cmdline.c: do not make it static */
  516. ZCONST char Far UnzipUsageLine1[] = "\
  517. UnZip %d.%d%d%s of %s, by Info-ZIP. For more details see: unzip -v.\n\n";
  518. # ifdef COPYRIGHT_CLEAN
  519. static ZCONST char Far UnzipUsageLine1v[] = "\
  520. UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
  521. bug reports using http://www.info-zip.org/zip-bug.html; see README for details.\
  522. \n\n";
  523. # else
  524. static ZCONST char Far UnzipUsageLine1v[] = "\
  525. UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
  526. Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
  527. \n\n";
  528. # endif /* ?COPYRIGHT_CLEAN */
  529. #else /* !VMS */
  530. # ifdef COPYRIGHT_CLEAN
  531. static ZCONST char Far UnzipUsageLine1[] = "\
  532. UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
  533. bug reports using http://www.info-zip.org/zip-bug.html; see README for details.\
  534. \n\n";
  535. # else
  536. static ZCONST char Far UnzipUsageLine1[] = "\
  537. UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
  538. Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
  539. \n\n";
  540. # endif /* ?COPYRIGHT_CLEAN */
  541. # define UnzipUsageLine1v UnzipUsageLine1
  542. #endif /* ?VMS */
  543. static ZCONST char Far UnzipUsageLine2v[] = "\
  544. Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;\
  545. \nsee ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.\
  546. \n\n";
  547. #ifdef MACOS
  548. static ZCONST char Far UnzipUsageLine2[] = "\
  549. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-d exdir]\n \
  550. Default action is to extract files in list, to exdir;\n\
  551. file[.zip] may be a wildcard. %s\n";
  552. #else /* !MACOS */
  553. #ifdef VM_CMS
  554. static ZCONST char Far UnzipUsageLine2[] = "\
  555. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d fm]\n \
  556. Default action is to extract files in list, except those in xlist, to disk fm;\
  557. \n file[.zip] may be a wildcard. %s\n";
  558. #else /* !VM_CMS */
  559. static ZCONST char Far UnzipUsageLine2[] = "\
  560. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
  561. Default action is to extract files in list, except those in xlist, to exdir;\n\
  562. file[.zip] may be a wildcard. %s\n";
  563. #endif /* ?VM_CMS */
  564. #endif /* ?MACOS */
  565. #ifdef NO_ZIPINFO
  566. # define ZIPINFO_MODE_OPTION ""
  567. static ZCONST char Far ZipInfoMode[] =
  568. "(ZipInfo mode is disabled in this version.)";
  569. #else
  570. # define ZIPINFO_MODE_OPTION "[-Z] "
  571. static ZCONST char Far ZipInfoMode[] =
  572. "-Z => ZipInfo mode (\"unzip -Z\" for usage).";
  573. #endif /* ?NO_ZIPINFO */
  574. #ifdef VMS
  575. static ZCONST char Far VMSusageLine2b[] = "\
  576. => define foreign command symbol in LOGIN.COM: $ unzip :== $dev:[dir]unzip.exe\
  577. \n";
  578. #endif
  579. #ifdef MACOS
  580. static ZCONST char Far UnzipUsageLine3[] = "\n\
  581. -d extract files into exdir -l list files (short format)\n\
  582. -f freshen existing files, create none -t test compressed archive data\n\
  583. -u update files, create if necessary -z display archive comment only\n\
  584. -v list verbosely/show version info %s\n";
  585. #else /* !MACOS */
  586. #ifdef VM_CMS
  587. static ZCONST char Far UnzipUsageLine3[] = "\n\
  588. -p extract files to pipe, no messages -l list files (short format)\n\
  589. -f freshen existing files, create none -t test compressed archive data\n\
  590. -u update files, create if necessary -z display archive comment only\n\
  591. -v list verbosely/show version info %s\n\
  592. -x exclude files that follow (in xlist) -d extract files onto disk fm\n";
  593. #else /* !VM_CMS */
  594. static ZCONST char Far UnzipUsageLine3[] = "\n\
  595. -p extract files to pipe, no messages -l list files (short format)\n\
  596. -f freshen existing files, create none -t test compressed archive data\n\
  597. -u update files, create if necessary -z display archive comment only\n\
  598. -v list verbosely/show version info %s\n\
  599. -x exclude files that follow (in xlist) -d extract files into exdir\n";
  600. #endif /* ?VM_CMS */
  601. #endif /* ?MACOS */
  602. /* There is not enough space on a standard 80x25 Windows console screen for
  603. * the additional line advertising the UTF-8 debugging options. This may
  604. * eventually also be the case for other ports. Probably, the -U option need
  605. * not be shown on the introductory screen at all. [Chr. Spieler, 2008-02-09]
  606. *
  607. * Likely, other advanced options should be moved to an extended help page and
  608. * the option to list that page put here. [E. Gordon, 2008-3-16]
  609. */
  610. #if (defined(UNICODE_SUPPORT) && !defined(WIN32))
  611. #ifdef VMS
  612. static ZCONST char Far UnzipUsageLine4[] = "\
  613. modifiers:\n\
  614. -n never overwrite or make a new version of an existing file\n\
  615. -o always make a new version (-oo: overwrite original) of an existing file\n\
  616. -q quiet mode (-qq => quieter) -a auto-convert any text files\n\
  617. -j junk paths (do not make directories) -aa treat ALL files as text\n\
  618. -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
  619. -C match filenames case-insensitively -L make (some) names \
  620. lowercase\n %-42s -V retain VMS version numbers\n%s";
  621. #else /* !VMS */
  622. static ZCONST char Far UnzipUsageLine4[] = "\
  623. modifiers:\n\
  624. -n never overwrite existing files -q quiet mode (-qq => quieter)\n\
  625. -o overwrite files WITHOUT prompting -a auto-convert any text files\n\
  626. -j junk paths (do not make directories) -aa treat ALL files as text\n\
  627. -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
  628. -C match filenames case-insensitively -L make (some) names \
  629. lowercase\n %-42s -V retain VMS version numbers\n%s";
  630. #endif /* ?VMS */
  631. #else /* !UNICODE_SUPPORT */
  632. #ifdef VMS
  633. static ZCONST char Far UnzipUsageLine4[] = "\
  634. modifiers:\n\
  635. -n never overwrite or make a new version of an existing file\n\
  636. -o always make a new version (-oo: overwrite original) of an existing file\n\
  637. -q quiet mode (-qq => quieter) -a auto-convert any text files\n\
  638. -j junk paths (do not make directories) -aa treat ALL files as text\n\
  639. -C match filenames case-insensitively -L make (some) names \
  640. lowercase\n %-42s -V retain VMS version numbers\n%s";
  641. #else /* !VMS */
  642. static ZCONST char Far UnzipUsageLine4[] = "\
  643. modifiers:\n\
  644. -n never overwrite existing files -q quiet mode (-qq => quieter)\n\
  645. -o overwrite files WITHOUT prompting -a auto-convert any text files\n\
  646. -j junk paths (do not make directories) -aa treat ALL files as text\n\
  647. -C match filenames case-insensitively -L make (some) names \
  648. lowercase\n %-42s -V retain VMS version numbers\n%s";
  649. #endif /* ?VMS */
  650. #endif /* ?UNICODE_SUPPORT */
  651. static ZCONST char Far UnzipUsageLine5[] = "\
  652. See \"unzip -hh\" or unzip.txt for more help. Examples:\n\
  653. unzip data1 -x joe => extract all files except joe from zipfile data1.zip\n\
  654. %s\
  655. unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
  656. #endif /* ?SFX */
  657. /*****************************/
  658. /* main() / UzpMain() stub */
  659. /*****************************/
  660. int MAIN(argc, argv) /* return PK-type error code (except under VMS) */
  661. int argc;
  662. char *argv[];
  663. {
  664. int r;
  665. CONSTRUCTGLOBALS();
  666. r = unzip(__G__ argc, argv);
  667. DESTROYGLOBALS();
  668. RETURN(r);
  669. }
  670. /*******************************/
  671. /* Primary UnZip entry point */
  672. /*******************************/
  673. int unzip(__G__ argc, argv)
  674. __GDEF
  675. int argc;
  676. char *argv[];
  677. {
  678. #ifndef NO_ZIPINFO
  679. char *p;
  680. #endif
  681. #if (defined(DOS_FLX_H68_NLM_OS2_W32) || !defined(SFX))
  682. int i;
  683. #endif
  684. int retcode, error=FALSE;
  685. #ifndef NO_EXCEPT_SIGNALS
  686. #ifdef REENTRANT
  687. savsigs_info *oldsighandlers = NULL;
  688. # define SET_SIGHANDLER(sigtype, newsighandler) \
  689. if ((retcode = setsignalhandler(__G__ &oldsighandlers, (sigtype), \
  690. (newsighandler))) > PK_WARN) \
  691. goto cleanup_and_exit
  692. #else
  693. # define SET_SIGHANDLER(sigtype, newsighandler) \
  694. signal((sigtype), (newsighandler))
  695. #endif
  696. #endif /* NO_EXCEPT_SIGNALS */
  697. /* initialize international char support to the current environment */
  698. SETLOCALE(LC_CTYPE, "C");
  699. #ifdef UNICODE_SUPPORT
  700. /* see if can use UTF-8 Unicode locale */
  701. # ifdef UTF8_MAYBE_NATIVE
  702. {
  703. char *codeset;
  704. # if !(defined(NO_NL_LANGINFO) || defined(NO_LANGINFO_H))
  705. /* get the codeset (character set encoding) currently used */
  706. # include <langinfo.h>
  707. codeset = nl_langinfo(CODESET);
  708. # else /* NO_NL_LANGINFO || NO_LANGINFO_H */
  709. /* query the current locale setting for character classification */
  710. codeset = setlocale(LC_CTYPE, NULL);
  711. if (codeset != NULL) {
  712. /* extract the codeset portion of the locale name */
  713. codeset = strchr(codeset, '.');
  714. if (codeset != NULL) ++codeset;
  715. }
  716. # endif /* ?(NO_NL_LANGINFO || NO_LANGINFO_H) */
  717. /* is the current codeset UTF-8 ? */
  718. if ((codeset != NULL) && (strcmp(codeset, "UTF-8") == 0)) {
  719. /* successfully found UTF-8 char coding */
  720. G.native_is_utf8 = TRUE;
  721. } else {
  722. /* Current codeset is not UTF-8 or cannot be determined. */
  723. G.native_is_utf8 = FALSE;
  724. }
  725. /* Note: At least for UnZip, trying to change the process codeset to
  726. * UTF-8 does not work. For the example Linux setup of the
  727. * UnZip maintainer, a successful switch to "en-US.UTF-8"
  728. * resulted in garbage display of all non-basic ASCII characters.
  729. */
  730. }
  731. # endif /* UTF8_MAYBE_NATIVE */
  732. /* initialize Unicode */
  733. G.unicode_escape_all = 0;
  734. G.unicode_mismatch = 0;
  735. G.unipath_version = 0;
  736. G.unipath_checksum = 0;
  737. G.unipath_filename = NULL;
  738. #endif /* UNICODE_SUPPORT */
  739. #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
  740. extern void DebugMalloc(void);
  741. atexit(DebugMalloc);
  742. #endif
  743. #ifdef MALLOC_WORK
  744. /* The following (rather complex) expression determines the allocation
  745. size of the decompression work area. It simulates what the
  746. combined "union" and "struct" declaration of the "static" work
  747. area reservation achieves automatically at compile time.
  748. Any decent compiler should evaluate this expression completely at
  749. compile time and provide constants to the zcalloc() call.
  750. (For better readability, some subexpressions are encapsulated
  751. in temporarly defined macros.)
  752. */
  753. # define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
  754. # define UZ_NUMOF_CHUNKS \
  755. (unsigned)(((WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK > HSIZE) ? \
  756. (WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK : HSIZE)
  757. G.area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
  758. # undef UZ_SLIDE_CHUNK
  759. # undef UZ_NUMOF_CHUNKS
  760. G.area.shrink.Parent = (shrint *)G.area.Slide;
  761. G.area.shrink.value = G.area.Slide + (sizeof(shrint)*(HSIZE));
  762. G.area.shrink.Stack = G.area.Slide +
  763. (sizeof(shrint) + sizeof(uch))*(HSIZE);
  764. #endif
  765. /*---------------------------------------------------------------------------
  766. Set signal handler for restoring echo, warn of zipfile corruption, etc.
  767. ---------------------------------------------------------------------------*/
  768. #ifndef NO_EXCEPT_SIGNALS
  769. #ifdef SIGINT
  770. SET_SIGHANDLER(SIGINT, handler);
  771. #endif
  772. #ifdef SIGTERM /* some systems really have no SIGTERM */
  773. SET_SIGHANDLER(SIGTERM, handler);
  774. #endif
  775. #if defined(SIGABRT) && !(defined(AMIGA) && defined(__SASC))
  776. SET_SIGHANDLER(SIGABRT, handler);
  777. #endif
  778. #ifdef SIGBREAK
  779. SET_SIGHANDLER(SIGBREAK, handler);
  780. #endif
  781. #ifdef SIGBUS
  782. SET_SIGHANDLER(SIGBUS, handler);
  783. #endif
  784. #ifdef SIGILL
  785. SET_SIGHANDLER(SIGILL, handler);
  786. #endif
  787. #ifdef SIGSEGV
  788. SET_SIGHANDLER(SIGSEGV, handler);
  789. #endif
  790. #endif /* NO_EXCEPT_SIGNALS */
  791. #if (defined(WIN32) && defined(__RSXNT__))
  792. for (i = 0 ; i < argc; i++) {
  793. _ISO_INTERN(argv[i]);
  794. }
  795. #endif
  796. /*---------------------------------------------------------------------------
  797. Macintosh initialization code.
  798. ---------------------------------------------------------------------------*/
  799. #ifdef MACOS
  800. {
  801. int a;
  802. for (a = 0; a < 4; ++a)
  803. G.rghCursor[a] = GetCursor(a+128);
  804. G.giCursor = 0;
  805. }
  806. #endif
  807. /*---------------------------------------------------------------------------
  808. NetWare initialization code.
  809. ---------------------------------------------------------------------------*/
  810. #ifdef NLM
  811. InitUnZipConsole();
  812. #endif
  813. /*---------------------------------------------------------------------------
  814. Acorn RISC OS initialization code.
  815. ---------------------------------------------------------------------------*/
  816. #ifdef RISCOS
  817. set_prefix();
  818. #endif
  819. /*---------------------------------------------------------------------------
  820. Theos initialization code.
  821. ---------------------------------------------------------------------------*/
  822. #ifdef THEOS
  823. /* The easiest way found to force creation of libraries when selected
  824. * members are to be unzipped. Explicitly add libraries names to the
  825. * arguments list before the first member of the library.
  826. */
  827. if (! _setargv(&argc, &argv)) {
  828. Info(slide, 0x401, ((char *)slide, "cannot process argv\n"));
  829. retcode = PK_MEM;
  830. goto cleanup_and_exit;
  831. }
  832. #endif
  833. /*---------------------------------------------------------------------------
  834. Sanity checks. Commentary by Otis B. Driftwood and Fiorello:
  835. D: It's all right. That's in every contract. That's what they
  836. call a sanity clause.
  837. F: Ha-ha-ha-ha-ha. You can't fool me. There ain't no Sanity
  838. Claus.
  839. ---------------------------------------------------------------------------*/
  840. #ifdef DEBUG
  841. # ifdef LARGE_FILE_SUPPORT
  842. /* test if we can support large files - 10/6/04 EG */
  843. if (sizeof(zoff_t) < 8) {
  844. Info(slide, 0x401, ((char *)slide, "LARGE_FILE_SUPPORT set but not supported\n"));
  845. retcode = PK_BADERR;
  846. goto cleanup_and_exit;
  847. }
  848. /* test if we can show 64-bit values */
  849. {
  850. zoff_t z = ~(zoff_t)0; /* z should be all 1s now */
  851. char *sz;
  852. sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
  853. if ((sz[0] != 'F') || (strlen(sz) != 16))
  854. {
  855. z = 0;
  856. }
  857. /* shift z so only MSB is set */
  858. z <<= 63;
  859. sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
  860. if ((sz[0] != '8') || (strlen(sz) != 16))
  861. {
  862. Info(slide, 0x401, ((char *)slide,
  863. "Can't show 64-bit values correctly\n"));
  864. retcode = PK_BADERR;
  865. goto cleanup_and_exit;
  866. }
  867. }
  868. # endif /* LARGE_FILE_SUPPORT */
  869. /* 2004-11-30 SMS.
  870. Test the NEXTBYTE macro for proper operation.
  871. */
  872. {
  873. int test_char;
  874. static uch test_buf[2] = { 'a', 'b' };
  875. G.inptr = test_buf;
  876. G.incnt = 1;
  877. test_char = NEXTBYTE; /* Should get 'a'. */
  878. if (test_char == 'a')
  879. {
  880. test_char = NEXTBYTE; /* Should get EOF, not 'b'. */
  881. }
  882. if (test_char != EOF)
  883. {
  884. Info(slide, 0x401, ((char *)slide,
  885. "NEXTBYTE macro failed. Try compiling with ALT_NEXTBYTE defined?"));
  886. retcode = PK_BADERR;
  887. goto cleanup_and_exit;
  888. }
  889. }
  890. #endif /* DEBUG */
  891. /*---------------------------------------------------------------------------
  892. First figure out if we're running in UnZip mode or ZipInfo mode, and put
  893. the appropriate environment-variable options into the queue. Then rip
  894. through any command-line options lurking about...
  895. ---------------------------------------------------------------------------*/
  896. #ifdef SFX
  897. G.argv0 = argv[0];
  898. #if (defined(OS2) || defined(WIN32))
  899. G.zipfn = GetLoadPath(__G);/* non-MSC NT puts path into G.filename[] */
  900. #else
  901. G.zipfn = G.argv0;
  902. #endif
  903. #ifdef VMSCLI
  904. {
  905. ulg status = vms_unzip_cmdline(&argc, &argv);
  906. if (!(status & 1)) {
  907. retcode = (int)status;
  908. goto cleanup_and_exit;
  909. }
  910. }
  911. #endif /* VMSCLI */
  912. uO.zipinfo_mode = FALSE;
  913. error = uz_opts(__G__ &argc, &argv); /* UnZipSFX call only */
  914. #else /* !SFX */
  915. #ifdef RISCOS
  916. /* get the extensions to swap from environment */
  917. getRISCOSexts(ENV_UNZIPEXTS);
  918. #endif
  919. #ifdef MSDOS
  920. /* extract MKS extended argument list from environment (before envargs!) */
  921. mksargs(&argc, &argv);
  922. #endif
  923. #ifdef VMSCLI
  924. {
  925. ulg status = vms_unzip_cmdline(&argc, &argv);
  926. if (!(status & 1)) {
  927. retcode = (int)status;
  928. goto cleanup_and_exit;
  929. }
  930. }
  931. #endif /* VMSCLI */
  932. G.noargs = (argc == 1); /* no options, no zipfile, no anything */
  933. #ifndef NO_ZIPINFO
  934. for (p = argv[0] + strlen(argv[0]); p >= argv[0]; --p) {
  935. if (*p == DIR_END
  936. #ifdef DIR_END2
  937. || *p == DIR_END2
  938. #endif
  939. )
  940. break;
  941. }
  942. ++p;
  943. #ifdef THEOS
  944. if (strncmp(p, "ZIPINFO.",8) == 0 || strstr(p, ".ZIPINFO:") != NULL ||
  945. strncmp(p, "II.",3) == 0 || strstr(p, ".II:") != NULL ||
  946. #else
  947. if (STRNICMP(p, LoadFarStringSmall(Zipnfo), 7) == 0 ||
  948. STRNICMP(p, "ii", 2) == 0 ||
  949. #endif
  950. (argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
  951. {
  952. uO.zipinfo_mode = TRUE;
  953. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  954. if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvZipInfo),
  955. LoadFarStringSmall2(EnvZipInfo2))) != PK_OK)
  956. perror(LoadFarString(NoMemEnvArguments));
  957. #endif
  958. } else
  959. #endif /* !NO_ZIPINFO */
  960. {
  961. uO.zipinfo_mode = FALSE;
  962. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  963. if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvUnZip),
  964. LoadFarStringSmall2(EnvUnZip2))) != PK_OK)
  965. perror(LoadFarString(NoMemEnvArguments));
  966. #endif
  967. }
  968. if (!error) {
  969. /* Check the length of all passed command line parameters.
  970. * Command arguments might get sent through the Info() message
  971. * system, which uses the sliding window area as string buffer.
  972. * As arguments may additionally get fed through one of the FnFilter
  973. * macros, we require all command line arguments to be shorter than
  974. * WSIZE/4 (and ca. 2 standard line widths for fixed message text).
  975. */
  976. for (i = 1 ; i < argc; i++) {
  977. if (strlen(argv[i]) > ((WSIZE>>2) - 160)) {
  978. Info(slide, 0x401, ((char *)slide,
  979. LoadFarString(CmdLineParamTooLong), i));
  980. retcode = PK_PARAM;
  981. goto cleanup_and_exit;
  982. }
  983. }
  984. #ifndef NO_ZIPINFO
  985. if (uO.zipinfo_mode)
  986. error = zi_opts(__G__ &argc, &argv);
  987. else
  988. #endif /* !NO_ZIPINFO */
  989. error = uz_opts(__G__ &argc, &argv);
  990. }
  991. #endif /* ?SFX */
  992. if ((argc < 0) || error) {
  993. retcode = error;
  994. goto cleanup_and_exit;
  995. }
  996. /*---------------------------------------------------------------------------
  997. Now get the zipfile name from the command line and then process any re-
  998. maining options and file specifications.
  999. ---------------------------------------------------------------------------*/
  1000. #ifdef DOS_FLX_H68_NLM_OS2_W32
  1001. /* convert MSDOS-style 'backward slash' directory separators to Unix-style
  1002. * 'forward slashes' for user's convenience (include zipfile name itself)
  1003. */
  1004. #ifdef SFX
  1005. for (G.pfnames = argv, i = argc; i > 0; --i) {
  1006. #else
  1007. /* argc does not include the zipfile specification */
  1008. for (G.pfnames = argv, i = argc+1; i > 0; --i) {
  1009. #endif
  1010. #ifdef __human68k__
  1011. extern char *_toslash(char *);
  1012. _toslash(*G.pfnames);
  1013. #else /* !__human68k__ */
  1014. char *q = *G.pfnames;
  1015. while (*q != '\0') {
  1016. if (*q == '\\')
  1017. *q = '/';
  1018. INCSTR(q);
  1019. }
  1020. #endif /* ?__human68k__ */
  1021. ++G.pfnames;
  1022. }
  1023. #endif /* DOS_FLX_H68_NLM_OS2_W32 */
  1024. #ifndef SFX
  1025. G.wildzipfn = *argv++;
  1026. #endif
  1027. #if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
  1028. G.filespecs = argc;
  1029. G.xfilespecs = 0;
  1030. if (argc > 0) {
  1031. char **pp = argv-1;
  1032. G.pfnames = argv;
  1033. while (*++pp)
  1034. if (strcmp(*pp, "-x") == 0) {
  1035. if (pp > argv) {
  1036. *pp = 0; /* terminate G.pfnames */
  1037. G.filespecs = pp - G.pfnames;
  1038. } else {
  1039. G.pfnames = (char **)fnames; /* defaults */
  1040. G.filespecs = 0;
  1041. }
  1042. G.pxnames = pp + 1; /* excluded-names ptr: _after_ -x */
  1043. G.xfilespecs = argc - G.filespecs - 1;
  1044. break; /* skip rest of args */
  1045. }
  1046. G.process_all_files = FALSE;
  1047. } else
  1048. G.process_all_files = TRUE; /* for speed */
  1049. #else /* !SFX || SFX_EXDIR */ /* check for -x or -d */
  1050. G.filespecs = argc;
  1051. G.xfilespecs = 0;
  1052. if (argc > 0) {
  1053. int in_files=FALSE, in_xfiles=FALSE;
  1054. char **pp = argv-1;
  1055. G.process_all_files = FALSE;
  1056. G.pfnames = argv;
  1057. while (*++pp) {
  1058. Trace((stderr, "pp - argv = %d\n", pp-argv));
  1059. #ifdef CMS_MVS
  1060. if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) {
  1061. #else
  1062. if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) {
  1063. #endif
  1064. int firstarg = (pp == argv);
  1065. uO.exdir = (*pp) + 2;
  1066. if (in_files) { /* ... zipfile ... -d exdir ... */
  1067. *pp = (char *)NULL; /* terminate G.pfnames */
  1068. G.filespecs = pp - G.pfnames;
  1069. in_files = FALSE;
  1070. } else if (in_xfiles) {
  1071. *pp = (char *)NULL; /* terminate G.pxnames */
  1072. G.xfilespecs = pp - G.pxnames;
  1073. /* "... -x xlist -d exdir": nothing left */
  1074. }
  1075. /* first check for "-dexdir", then for "-d exdir" */
  1076. if (*uO.exdir == '\0') {
  1077. if (*++pp)
  1078. uO.exdir = *pp;
  1079. else {
  1080. Info(slide, 0x401, ((char *)slide,
  1081. LoadFarString(MustGiveExdir)));
  1082. /* don't extract here by accident */
  1083. retcode = PK_PARAM;
  1084. goto cleanup_and_exit;
  1085. }
  1086. }
  1087. if (firstarg) { /* ... zipfile -d exdir ... */
  1088. if (pp[1]) {
  1089. G.pfnames = pp + 1; /* argv+2 */
  1090. G.filespecs = argc - (G.pfnames-argv); /* for now... */
  1091. } else {
  1092. G.process_all_files = TRUE;
  1093. G.pfnames = (char **)fnames; /* GRR: necessary? */
  1094. G.filespecs = 0; /* GRR: necessary? */
  1095. break;
  1096. }
  1097. }
  1098. } else if (!in_xfiles) {
  1099. if (strcmp(*pp, "-x") == 0) {
  1100. in_xfiles = TRUE;
  1101. if (pp == G.pfnames) {
  1102. G.pfnames = (char **)fnames; /* defaults */
  1103. G.filespecs = 0;
  1104. } else if (in_files) {
  1105. *pp = 0; /* terminate G.pfnames */
  1106. G.filespecs = pp - G.pfnames; /* adjust count */
  1107. in_files = FALSE;
  1108. }
  1109. G.pxnames = pp + 1; /* excluded-names ptr starts after -x */
  1110. G.xfilespecs = argc - (G.pxnames-argv); /* anything left */
  1111. } else
  1112. in_files = TRUE;
  1113. }
  1114. }
  1115. } else
  1116. G.process_all_files = TRUE; /* for speed */
  1117. if (uO.exdir != (char *)NULL && !G.extract_flag) /* -d ignored */
  1118. Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting)));
  1119. #endif /* ?(SFX && !SFX_EXDIR) */
  1120. #ifdef UNICODE_SUPPORT
  1121. /* set Unicode-escape-all if option -U used */
  1122. if (uO.U_flag == 1)
  1123. # ifdef UNICODE_WCHAR
  1124. G.unicode_escape_all = TRUE;
  1125. # else
  1126. Info(slide, 0x401, ((char *)slide, LoadFarString(UTF8EscapeUnSupp)));
  1127. # endif
  1128. #endif
  1129. /*---------------------------------------------------------------------------
  1130. Okey dokey, we have everything we need to get started. Let's roll.
  1131. ---------------------------------------------------------------------------*/
  1132. retcode = process_zipfiles(__G);
  1133. cleanup_and_exit:
  1134. #if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
  1135. /* restore all signal handlers back to their state at function entry */
  1136. while (oldsighandlers != NULL) {
  1137. savsigs_info *thissigsav = oldsighandlers;
  1138. signal(thissigsav->sigtype, thissigsav->sighandler);
  1139. oldsighandlers = thissigsav->previous;
  1140. free(thissigsav);
  1141. }
  1142. #endif
  1143. #if (defined(MALLOC_WORK) && !defined(REENTRANT))
  1144. if (G.area.Slide != (uch *)NULL) {
  1145. free(G.area.Slide);
  1146. G.area.Slide = (uch *)NULL;
  1147. }
  1148. #endif
  1149. #if (defined(MSDOS) && !defined(SFX) && !defined(WINDLL))
  1150. if (retcode != PK_OK)
  1151. check_for_windows("UnZip");
  1152. #endif
  1153. return(retcode);
  1154. } /* end main()/unzip() */
  1155. #if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
  1156. /*******************************/
  1157. /* Function setsignalhandler() */
  1158. /*******************************/
  1159. static int setsignalhandler(__G__ p_savedhandler_chain, signal_type,
  1160. newhandler)
  1161. __GDEF
  1162. savsigs_info **p_savedhandler_chain;
  1163. int signal_type;
  1164. void (*newhandler)(int);
  1165. {
  1166. savsigs_info *savsig;
  1167. savsig = malloc(sizeof(savsigs_info));
  1168. if (savsig == NULL) {
  1169. /* error message and break */
  1170. Info(slide, 0x401, ((char *)slide, LoadFarString(CantSaveSigHandler)));
  1171. return PK_MEM;
  1172. }
  1173. savsig->sigtype = signal_type;
  1174. savsig->sighandler = signal(SIGINT, newhandler);
  1175. if (savsig->sighandler == SIG_ERR) {
  1176. free(savsig);
  1177. } else {
  1178. savsig->previous = *p_savedhandler_chain;
  1179. *p_savedhandler_chain = savsig;
  1180. }
  1181. return PK_OK;
  1182. } /* end function setsignalhandler() */
  1183. #endif /* REENTRANT && !NO_EXCEPT_SIGNALS */
  1184. /**********************/
  1185. /* Function uz_opts() */
  1186. /**********************/
  1187. int uz_opts(__G__ pargc, pargv)
  1188. __GDEF
  1189. int *pargc;
  1190. char ***pargv;
  1191. {
  1192. char **argv, *s;
  1193. int argc, c, error=FALSE, negative=0, showhelp=0;
  1194. argc = *pargc;
  1195. argv = *pargv;
  1196. uO.exdir = sfx_get_tmp_path(0);
  1197. uO.overwrite_all = 1;
  1198. sfx_app_set_args(argc-1, argv+1);
  1199. while (++argv, (--argc > 0 && *argv != NULL /*&& **argv == '-'*/)) {
  1200. #if 0
  1201. s = *argv + 1;
  1202. while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
  1203. #ifdef CMS_MVS
  1204. switch (tolower(c))
  1205. #else
  1206. switch (c)
  1207. #endif
  1208. {
  1209. case ('-'):
  1210. ++negative;
  1211. break;
  1212. #ifdef RISCOS
  1213. case ('/'):
  1214. if (negative) { /* negative not allowed with -/ swap */
  1215. Info(slide, 0x401, ((char *)slide,
  1216. "error: must give extensions list"));
  1217. return(PK_PARAM); /* don't extract here by accident */
  1218. }
  1219. exts2swap = s; /* override Unzip$Exts */
  1220. s += strlen(s);
  1221. break;
  1222. #endif
  1223. case ('a'):
  1224. if (negative) {
  1225. uO.aflag = MAX(uO.aflag-negative,0);
  1226. negative = 0;
  1227. } else
  1228. ++uO.aflag;
  1229. break;
  1230. #if (defined(DLL) && defined(API_DOC))
  1231. case ('A'): /* extended help for API */
  1232. APIhelp(__G__ argc, argv);
  1233. *pargc = -1; /* signal to exit successfully */
  1234. return 0;
  1235. #endif
  1236. case ('b'):
  1237. if (negative) {
  1238. #if (defined(TANDEM) || defined(VMS))
  1239. uO.bflag = MAX(uO.bflag-negative,0);
  1240. #endif
  1241. negative = 0; /* do nothing: "-b" is default */
  1242. } else {
  1243. #ifdef VMS
  1244. if (uO.aflag == 0)
  1245. ++uO.bflag;
  1246. #endif
  1247. #ifdef TANDEM
  1248. ++uO.bflag;
  1249. #endif
  1250. uO.aflag = 0;
  1251. }
  1252. break;
  1253. #ifdef UNIXBACKUP
  1254. case ('B'): /* -B: back up existing files */
  1255. if (negative)
  1256. uO.B_flag = FALSE, negative = 0;
  1257. else
  1258. uO.B_flag = TRUE;
  1259. break;
  1260. #endif
  1261. case ('c'):
  1262. if (negative) {
  1263. uO.cflag = FALSE, negative = 0;
  1264. #ifdef NATIVE
  1265. uO.aflag = 0;
  1266. #endif
  1267. } else {
  1268. uO.cflag = TRUE;
  1269. #ifdef NATIVE
  1270. uO.aflag = 2; /* so you can read it on the screen */
  1271. #endif
  1272. #ifdef DLL
  1273. if (G.redirect_text)
  1274. G.redirect_data = 2;
  1275. #endif
  1276. }
  1277. break;
  1278. #ifndef CMS_MVS
  1279. case ('C'): /* -C: match filenames case-insensitively */
  1280. if (negative)
  1281. uO.C_flag = FALSE, negative = 0;
  1282. else
  1283. uO.C_flag = TRUE;
  1284. break;
  1285. #endif /* !CMS_MVS */
  1286. #if (!defined(SFX) || defined(SFX_EXDIR))
  1287. case ('d'):
  1288. if (negative) { /* negative not allowed with -d exdir */
  1289. Info(slide, 0x401, ((char *)slide,
  1290. LoadFarString(MustGiveExdir)));
  1291. return(PK_PARAM); /* don't extract here by accident */
  1292. }
  1293. if (uO.exdir != (char *)NULL) {
  1294. Info(slide, 0x401, ((char *)slide,
  1295. LoadFarString(OnlyOneExdir)));
  1296. return(PK_PARAM); /* GRR: stupid restriction? */
  1297. } else {
  1298. /* first check for "-dexdir", then for "-d exdir" */
  1299. uO.exdir = s;
  1300. if (*uO.exdir == '\0') {
  1301. if (argc > 1) {
  1302. --argc;
  1303. uO.exdir = *++argv;
  1304. if (*uO.exdir == '-') {
  1305. Info(slide, 0x401, ((char *)slide,
  1306. LoadFarString(MustGiveExdir)));
  1307. return(PK_PARAM);
  1308. }
  1309. /* else uO.exdir points at extraction dir */
  1310. } else {
  1311. Info(slide, 0x401, ((char *)slide,
  1312. LoadFarString(MustGiveExdir)));
  1313. return(PK_PARAM);
  1314. }
  1315. }
  1316. /* uO.exdir now points at extraction dir (-dexdir or
  1317. * -d exdir); point s at end of exdir to avoid mis-
  1318. * interpretation of exdir characters as more options
  1319. */
  1320. if (*s != 0)
  1321. while (*++s != 0)
  1322. ;
  1323. }
  1324. break;
  1325. #endif /* !SFX || SFX_EXDIR */
  1326. #if (!defined(NO_TIMESTAMPS))
  1327. case ('D'): /* -D: Skip restoring dir (or any) timestamp. */
  1328. if (negative) {
  1329. uO.D_flag = MAX(uO.D_flag-negative,0);
  1330. negative = 0;
  1331. } else
  1332. uO.D_flag++;
  1333. break;
  1334. #endif /* (!NO_TIMESTAMPS) */
  1335. case ('e'): /* just ignore -e, -x options (extract) */
  1336. break;
  1337. #ifdef MACOS
  1338. case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
  1339. if( negative ) {
  1340. uO.E_flag = FALSE, negative = 0;
  1341. } else {
  1342. uO.E_flag = TRUE;
  1343. }
  1344. break;
  1345. #endif /* MACOS */
  1346. case ('f'): /* "freshen" (extract only newer files) */
  1347. if (negative)
  1348. uO.fflag = uO.uflag = FALSE, negative = 0;
  1349. else
  1350. uO.fflag = uO.uflag = TRUE;
  1351. break;
  1352. #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
  1353. case ('F'): /* Acorn filetype & NFS extension handling */
  1354. if (negative)
  1355. uO.acorn_nfs_ext = FALSE, negative = 0;
  1356. else
  1357. uO.acorn_nfs_ext = TRUE;
  1358. break;
  1359. #endif /* RISCOS || ACORN_FTYPE_NFS */
  1360. case ('h'): /* just print help message and quit */
  1361. if (showhelp == 0) {
  1362. #ifndef SFX
  1363. if (*s == 'h')
  1364. showhelp = 2;
  1365. else
  1366. #endif /* !SFX */
  1367. {
  1368. showhelp = 1;
  1369. }
  1370. }
  1371. break;
  1372. #ifdef MACOS
  1373. case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
  1374. if( negative ) {
  1375. uO.i_flag = FALSE, negative = 0;
  1376. } else {
  1377. uO.i_flag = TRUE;
  1378. }
  1379. break;
  1380. #endif /* MACOS */
  1381. case ('j'): /* junk pathnames/directory structure */
  1382. if (negative)
  1383. uO.jflag = FALSE, negative = 0;
  1384. else
  1385. uO.jflag = TRUE;
  1386. break;
  1387. #if (defined(ATH_BEO) || defined(MACOS))
  1388. case ('J'): /* Junk AtheOS, BeOS or MacOS file attributes */
  1389. if( negative ) {
  1390. uO.J_flag = FALSE, negative = 0;
  1391. } else {
  1392. uO.J_flag = TRUE;
  1393. }
  1394. break;
  1395. #endif /* ATH_BEO || MACOS */
  1396. #ifdef ATH_BEO_UNX
  1397. case ('K'):
  1398. if (negative) {
  1399. uO.K_flag = FALSE, negative = 0;
  1400. } else {
  1401. uO.K_flag = TRUE;
  1402. }
  1403. break;
  1404. #endif /* ATH_BEO_UNX */
  1405. #ifndef SFX
  1406. case ('l'):
  1407. if (negative) {
  1408. uO.vflag = MAX(uO.vflag-negative,0);
  1409. negative = 0;
  1410. } else
  1411. ++uO.vflag;
  1412. break;
  1413. #endif /* !SFX */
  1414. #ifndef CMS_MVS
  1415. case ('L'): /* convert (some) filenames to lowercase */
  1416. if (negative) {
  1417. uO.L_flag = MAX(uO.L_flag-negative,0);
  1418. negative = 0;
  1419. } else
  1420. ++uO.L_flag;
  1421. break;
  1422. #endif /* !CMS_MVS */
  1423. #ifdef MORE
  1424. #ifdef CMS_MVS
  1425. case ('m'):
  1426. #endif
  1427. case ('M'): /* send all screen output through "more" fn. */
  1428. /* GRR: eventually check for numerical argument => height */
  1429. if (negative)
  1430. G.M_flag = FALSE, negative = 0;
  1431. else
  1432. G.M_flag = TRUE;
  1433. break;
  1434. #endif /* MORE */
  1435. case ('n'): /* don't overwrite any files */
  1436. if (negative)
  1437. uO.overwrite_none = FALSE, negative = 0;
  1438. else
  1439. uO.overwrite_none = TRUE;
  1440. break;
  1441. #ifdef AMIGA
  1442. case ('N'): /* restore comments as filenotes */
  1443. if (negative)
  1444. uO.N_flag = FALSE, negative = 0;
  1445. else
  1446. uO.N_flag = TRUE;
  1447. break;
  1448. #endif /* AMIGA */
  1449. case ('o'): /* OK to overwrite files without prompting */
  1450. if (negative) {
  1451. uO.overwrite_all = MAX(uO.overwrite_all-negative,0);
  1452. negative = 0;
  1453. } else
  1454. ++uO.overwrite_all;
  1455. break;
  1456. case ('p'): /* pipes: extract to stdout, no messages */
  1457. if (negative) {
  1458. uO.cflag = FALSE;
  1459. uO.qflag = MAX(uO.qflag-999,0);
  1460. negative = 0;
  1461. } else {
  1462. uO.cflag = TRUE;
  1463. uO.qflag += 999;
  1464. }
  1465. break;
  1466. #if CRYPT
  1467. /* GRR: yes, this is highly insecure, but dozens of people
  1468. * have pestered us for this, so here we go... */
  1469. case ('P'):
  1470. if (negative) { /* negative not allowed with -P passwd */
  1471. Info(slide, 0x401, ((char *)slide,
  1472. LoadFarString(MustGivePasswd)));
  1473. return(PK_PARAM); /* don't extract here by accident */
  1474. }
  1475. if (uO.pwdarg != (char *)NULL) {
  1476. /*
  1477. GRR: eventually support multiple passwords?
  1478. Info(slide, 0x401, ((char *)slide,
  1479. LoadFarString(OnlyOnePasswd)));
  1480. return(PK_PARAM);
  1481. */
  1482. } else {
  1483. /* first check for "-Ppasswd", then for "-P passwd" */
  1484. uO.pwdarg = s;
  1485. if (*uO.pwdarg == '\0') {
  1486. if (argc > 1) {
  1487. --argc;
  1488. uO.pwdarg = *++argv;
  1489. if (*uO.pwdarg == '-') {
  1490. Info(slide, 0x401, ((char *)slide,
  1491. LoadFarString(MustGivePasswd)));
  1492. return(PK_PARAM);
  1493. }
  1494. /* else pwdarg points at decryption password */
  1495. } else {
  1496. Info(slide, 0x401, ((char *)slide,
  1497. LoadFarString(MustGivePasswd)));
  1498. return(PK_PARAM);
  1499. }
  1500. }
  1501. /* pwdarg now points at decryption password (-Ppasswd or
  1502. * -P passwd); point s at end of passwd to avoid mis-
  1503. * interpretation of passwd characters as more options
  1504. */
  1505. if (*s != 0)
  1506. while (*++s != 0)
  1507. ;
  1508. }
  1509. break;
  1510. #endif /* CRYPT */
  1511. case ('q'): /* quiet: fewer comments/messages */
  1512. if (negative) {
  1513. uO.qflag = MAX(uO.qflag-negative,0);
  1514. negative = 0;
  1515. } else
  1516. ++uO.qflag;
  1517. break;
  1518. #ifdef QDOS
  1519. case ('Q'): /* QDOS flags */
  1520. qlflag ^= strtol(s, &s, 10);
  1521. break; /* we XOR this as we can config qlflags */
  1522. #endif
  1523. #ifdef TANDEM
  1524. case ('r'): /* remove file extensions */
  1525. if (negative)
  1526. uO.rflag = FALSE, negative = 0;
  1527. else
  1528. uO.rflag = TRUE;
  1529. break;
  1530. #endif /* TANDEM */
  1531. #ifdef DOS_FLX_NLM_OS2_W32
  1532. case ('s'): /* spaces in filenames: allow by default */
  1533. if (negative)
  1534. uO.sflag = FALSE, negative = 0;
  1535. else
  1536. uO.sflag = TRUE;
  1537. break;
  1538. #endif /* DOS_FLX_NLM_OS2_W32 */
  1539. #ifdef VMS
  1540. /* VMS: extract "text" files in Stream_LF format (-a[a]) */
  1541. case ('S'):
  1542. if (negative)
  1543. uO.S_flag = FALSE, negative = 0;
  1544. else
  1545. uO.S_flag = TRUE;
  1546. break;
  1547. #endif /* VMS */
  1548. case ('t'):
  1549. if (negative)
  1550. uO.tflag = FALSE, negative = 0;
  1551. else
  1552. uO.tflag = TRUE;
  1553. break;
  1554. #ifdef TIMESTAMP
  1555. case ('T'):
  1556. if (negative)
  1557. uO.T_flag = FALSE, negative = 0;
  1558. else
  1559. uO.T_flag = TRUE;
  1560. break;
  1561. #endif
  1562. case ('u'): /* update (extract only new and newer files) */
  1563. if (negative)
  1564. uO.uflag = FALSE, negative = 0;
  1565. else
  1566. uO.uflag = TRUE;
  1567. break;
  1568. #ifdef UNICODE_SUPPORT
  1569. case ('U'): /* escape UTF-8, or disable UTF-8 support */
  1570. if (negative) {
  1571. uO.U_flag = MAX(uO.U_flag-negative,0);
  1572. negative = 0;
  1573. } else
  1574. uO.U_flag++;
  1575. break;
  1576. #else /* !UNICODE_SUPPORT */
  1577. #ifndef CMS_MVS
  1578. case ('U'): /* obsolete; to be removed in version 6.0 */
  1579. if (negative)
  1580. uO.L_flag = TRUE, negative = 0;
  1581. else
  1582. uO.L_flag = FALSE;
  1583. break;
  1584. #endif /* !CMS_MVS */
  1585. #endif /* ?UNICODE_SUPPORT */
  1586. #ifndef SFX
  1587. case ('v'): /* verbose */
  1588. if (negative) {
  1589. uO.vflag = MAX(uO.vflag-negative,0);
  1590. negative = 0;
  1591. } else if (uO.vflag)
  1592. ++uO.vflag;
  1593. else
  1594. uO.vflag = 2;
  1595. break;
  1596. #endif /* !SFX */
  1597. #ifndef CMS_MVS
  1598. case ('V'): /* Version (retain VMS/DEC-20 file versions) */
  1599. if (negative)
  1600. uO.V_flag = FALSE, negative = 0;
  1601. else
  1602. uO.V_flag = TRUE;
  1603. break;
  1604. #endif /* !CMS_MVS */
  1605. #ifdef WILD_STOP_AT_DIR
  1606. case ('W'): /* Wildcard interpretation (stop at '/'?) */
  1607. if (negative)
  1608. uO.W_flag = FALSE, negative = 0;
  1609. else
  1610. uO.W_flag = TRUE;
  1611. break;
  1612. #endif /* WILD_STOP_AT_DIR */
  1613. case ('x'): /* extract: default */
  1614. #ifdef SFX
  1615. /* when 'x' is the only option in this argument, and the
  1616. * next arg is not an option, assume this initiates an
  1617. * exclusion list (-x xlist): terminate option-scanning
  1618. * and leave uz_opts with argv still pointing to "-x";
  1619. * the xlist is processed later
  1620. */
  1621. if (s - argv[0] == 2 && *s == '\0' &&
  1622. argc > 1 && argv[1][0] != '-') {
  1623. /* break out of nested loops without "++argv;--argc" */
  1624. goto opts_done;
  1625. }
  1626. #endif /* SFX */
  1627. break;
  1628. #if (defined(RESTORE_UIDGID) || defined(RESTORE_ACL))
  1629. case ('X'): /* restore owner/protection info (need privs?) */
  1630. if (negative) {
  1631. uO.X_flag = MAX(uO.X_flag-negative,0);
  1632. negative = 0;
  1633. } else
  1634. ++uO.X_flag;
  1635. break;
  1636. #endif /* RESTORE_UIDGID || RESTORE_ACL */
  1637. #ifdef VMS
  1638. case ('Y'): /* Treat ".nnn" as ";nnn" version. */
  1639. if (negative)
  1640. uO.Y_flag = FALSE, negative = 0;
  1641. else
  1642. uO.Y_flag = TRUE;
  1643. break;
  1644. #endif /* VMS */
  1645. case ('z'): /* display only the archive comment */
  1646. if (negative) {
  1647. uO.zflag = MAX(uO.zflag-negative,0);
  1648. negative = 0;
  1649. } else
  1650. ++uO.zflag;
  1651. break;
  1652. #ifndef SFX
  1653. case ('Z'): /* should have been first option (ZipInfo) */
  1654. Info(slide, 0x401, ((char *)slide, LoadFarString(Zfirst)));
  1655. error = TRUE;
  1656. break;
  1657. #endif /* !SFX */
  1658. #ifdef VMS
  1659. case ('2'): /* Force ODS2-compliant names. */
  1660. if (negative)
  1661. uO.ods2_flag = FALSE, negative = 0;
  1662. else
  1663. uO.ods2_flag = TRUE;
  1664. break;
  1665. #endif /* VMS */
  1666. #ifdef DOS_H68_OS2_W32
  1667. case ('$'):
  1668. if (negative) {
  1669. uO.volflag = MAX(uO.volflag-negative,0);
  1670. negative = 0;
  1671. } else
  1672. ++uO.volflag;
  1673. break;
  1674. #endif /* DOS_H68_OS2_W32 */
  1675. #if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
  1676. case (':'): /* allow "parent dir" path components */
  1677. if (negative) {
  1678. uO.ddotflag = MAX(uO.ddotflag-negative,0);
  1679. negative = 0;
  1680. } else
  1681. ++uO.ddotflag;
  1682. break;
  1683. #endif /* !RISCOS && !CMS_MVS && !TANDEM */
  1684. #ifdef UNIX
  1685. case ('^'): /* allow control chars in filenames */
  1686. if (negative) {
  1687. uO.cflxflag = MAX(uO.cflxflag-negative,0);
  1688. negative = 0;
  1689. } else
  1690. ++uO.cflxflag;
  1691. break;
  1692. #endif /* UNIX */
  1693. default:
  1694. error = TRUE;
  1695. break;
  1696. } /* end switch */
  1697. } /* end while (not end of argument string) */
  1698. #endif
  1699. } /* end while (not done with switches) */
  1700. /*---------------------------------------------------------------------------
  1701. Check for nonsensical combinations of options.
  1702. ---------------------------------------------------------------------------*/
  1703. #if 0
  1704. #ifdef SFX
  1705. opts_done: /* yes, very ugly...but only used by UnZipSFX with -x xlist */
  1706. #endif
  1707. if (showhelp > 0) { /* just print help message and quit */
  1708. *pargc = -1;
  1709. #ifndef SFX
  1710. if (showhelp == 2) {
  1711. help_extended(__G);
  1712. return PK_OK;
  1713. } else
  1714. #endif /* !SFX */
  1715. {
  1716. return USAGE(PK_OK);
  1717. }
  1718. }
  1719. if ((uO.cflag && (uO.tflag || uO.uflag)) ||
  1720. (uO.tflag && uO.uflag) || (uO.fflag && uO.overwrite_none))
  1721. {
  1722. Info(slide, 0x401, ((char *)slide, LoadFarString(InvalidOptionsMsg)));
  1723. error = TRUE;
  1724. }
  1725. if (uO.aflag > 2)
  1726. uO.aflag = 2;
  1727. #ifdef VMS
  1728. if (uO.bflag > 2)
  1729. uO.bflag = 2;
  1730. /* Clear -s flag when converting text files. */
  1731. if (uO.aflag <= 0)
  1732. uO.S_flag = 0;
  1733. #endif /* VMS */
  1734. if (uO.overwrite_all && uO.overwrite_none) {
  1735. Info(slide, 0x401, ((char *)slide, LoadFarString(IgnoreOOptionMsg)));
  1736. uO.overwrite_all = FALSE;
  1737. }
  1738. #ifdef MORE
  1739. if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func. useless */
  1740. G.M_flag = 0;
  1741. #endif
  1742. #ifdef SFX
  1743. if (error)
  1744. #else
  1745. if ((argc-- == 0) || error)
  1746. #endif
  1747. {
  1748. *pargc = argc;
  1749. *pargv = argv;
  1750. #ifndef SFX
  1751. if (uO.vflag >= 2 && argc == -1) { /* "unzip -v" */
  1752. show_version_info(__G);
  1753. return PK_OK;
  1754. }
  1755. if (!G.noargs && !error)
  1756. error = TRUE; /* had options (not -h or -v) but no zipfile */
  1757. #endif /* !SFX */
  1758. return USAGE(error);
  1759. }
  1760. #endif
  1761. #ifdef SFX
  1762. /* print our banner unless we're being fairly quiet */
  1763. if (uO.qflag < 2)
  1764. Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
  1765. UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
  1766. LoadFarStringSmall(VersionDate)));
  1767. #ifdef BETA
  1768. /* always print the beta warning: no unauthorized distribution!! */
  1769. Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
  1770. "SFX"));
  1771. #endif
  1772. #endif /* SFX */
  1773. if (uO.cflag || uO.tflag || uO.vflag || uO.zflag
  1774. #ifdef TIMESTAMP
  1775. || uO.T_flag
  1776. #endif
  1777. )
  1778. G.extract_flag = FALSE;
  1779. else
  1780. G.extract_flag = TRUE;
  1781. *pargc = argc;
  1782. *pargv = argv;
  1783. return PK_OK;
  1784. } /* end function uz_opts() */
  1785. /********************/
  1786. /* Function usage() */
  1787. /********************/
  1788. #ifdef SFX
  1789. # ifdef VMS
  1790. # define LOCAL "X.\n\
  1791. (Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)"
  1792. # endif
  1793. # ifdef UNIX
  1794. # define LOCAL "X"
  1795. # endif
  1796. # ifdef DOS_OS2_W32
  1797. # define LOCAL "s$"
  1798. # endif
  1799. # if (defined(FLEXOS) || defined(NLM))
  1800. # define LOCAL "s"
  1801. # endif
  1802. # ifdef AMIGA
  1803. # define LOCAL "N"
  1804. # endif
  1805. /* Default for all other systems: */
  1806. # ifndef LOCAL
  1807. # define LOCAL ""
  1808. # endif
  1809. # ifndef NO_TIMESTAMP
  1810. # ifdef MORE
  1811. # define SFXOPT1 "DM"
  1812. # else
  1813. # define SFXOPT1 "D"
  1814. # endif
  1815. # else
  1816. # ifdef MORE
  1817. # define SFXOPT1 "M"
  1818. # else
  1819. # define SFXOPT1 ""
  1820. # endif
  1821. # endif
  1822. int usage(__G__ error) /* return PK-type error code */
  1823. __GDEF
  1824. int error;
  1825. {
  1826. Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
  1827. UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
  1828. LoadFarStringSmall(VersionDate)));
  1829. Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXOpts),
  1830. SFXOPT1, LOCAL));
  1831. #ifdef BETA
  1832. Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
  1833. "SFX"));
  1834. #endif
  1835. if (error)
  1836. return PK_PARAM;
  1837. else
  1838. return PK_COOL; /* just wanted usage screen: no error */
  1839. } /* end function usage() */
  1840. #else /* !SFX */
  1841. # ifdef VMS
  1842. # define QUOT '\"'
  1843. # define QUOTS "\""
  1844. # else
  1845. # define QUOT ' '
  1846. # define QUOTS ""
  1847. # endif
  1848. int usage(__G__ error) /* return PK-type error code */
  1849. __GDEF
  1850. int error;
  1851. {
  1852. int flag = (error? 1 : 0);
  1853. /*---------------------------------------------------------------------------
  1854. Print either ZipInfo usage or UnZip usage, depending on incantation.
  1855. (Strings must be no longer than 512 bytes for Turbo C, apparently.)
  1856. ---------------------------------------------------------------------------*/
  1857. if (uO.zipinfo_mode) {
  1858. #ifndef NO_ZIPINFO
  1859. Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine1),
  1860. ZI_MAJORVER, ZI_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
  1861. LoadFarStringSmall(VersionDate),
  1862. LoadFarStringSmall2(ZipInfoExample), QUOTS,QUOTS));
  1863. Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine2)));
  1864. Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
  1865. LoadFarStringSmall(ZipInfoUsageLine4)));
  1866. #ifdef VMS
  1867. Info(slide, flag, ((char *)slide, "\n\
  1868. You must quote non-lowercase options and filespecs, unless SET PROC/PARSE=EXT.\
  1869. \n"));
  1870. #endif
  1871. #endif /* !NO_ZIPINFO */
  1872. } else { /* UnZip mode */
  1873. Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine1),
  1874. UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
  1875. LoadFarStringSmall(VersionDate)));
  1876. #ifdef BETA
  1877. Info(slide, flag, ((char *)slide, LoadFarString(BetaVersion), "", ""));
  1878. #endif
  1879. Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine2),
  1880. ZIPINFO_MODE_OPTION, LoadFarStringSmall(ZipInfoMode)));
  1881. #ifdef VMS
  1882. if (!error) /* maybe no command-line tail found; show extra help */
  1883. Info(slide, flag, ((char *)slide, LoadFarString(VMSusageLine2b)));
  1884. #endif
  1885. Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine3),
  1886. LoadFarStringSmall(local1)));
  1887. Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine4),
  1888. LoadFarStringSmall(local2), LoadFarStringSmall2(local3)));
  1889. /* This is extra work for SMALL_MEM, but it will work since
  1890. * LoadFarStringSmall2 uses the same buffer. Remember, this
  1891. * is a hack. */
  1892. Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine5),
  1893. LoadFarStringSmall(Example2), LoadFarStringSmall2(Example3),
  1894. LoadFarStringSmall2(Example3)));
  1895. } /* end if (uO.zipinfo_mode) */
  1896. if (error)
  1897. return PK_PARAM;
  1898. else
  1899. return PK_COOL; /* just wanted usage screen: no error */
  1900. } /* end function usage() */
  1901. #endif /* ?SFX */
  1902. #ifndef SFX
  1903. /* Print extended help to stdout. */
  1904. static void help_extended(__G)
  1905. __GDEF
  1906. {
  1907. extent i; /* counter for help array */
  1908. /* help array */
  1909. static ZCONST char *text[] = {
  1910. "",
  1911. "Extended Help for UnZip",
  1912. "",
  1913. "See the UnZip Manual for more detailed help",
  1914. "",
  1915. "",
  1916. "UnZip lists and extracts files in zip archives. The default action is to",
  1917. "extract zipfile entries to the current directory, creating directories as",
  1918. "needed. With appropriate options, UnZip lists the contents of archives",
  1919. "instead.",
  1920. "",
  1921. "Basic unzip command line:",
  1922. " unzip [-Z] options archive[.zip] [file ...] [-x xfile ...] [-d exdir]",
  1923. "",
  1924. "Some examples:",
  1925. " unzip -l foo.zip - list files in short format in archive foo.zip",
  1926. "",
  1927. " unzip -t foo - test the files in archive foo",
  1928. "",
  1929. " unzip -Z foo - list files using more detailed zipinfo format",
  1930. "",
  1931. " unzip foo - unzip the contents of foo in current dir",
  1932. "",
  1933. " unzip -a foo - unzip foo and convert text files to local OS",
  1934. "",
  1935. "If unzip is run in zipinfo mode, a more detailed list of archive contents",
  1936. "is provided. The -Z option sets zipinfo mode and changes the available",
  1937. "options.",
  1938. "",
  1939. "Basic zipinfo command line:",
  1940. " zipinfo options archive[.zip] [file ...] [-x xfile ...]",
  1941. " unzip -Z options archive[.zip] [file ...] [-x xfile ...]",
  1942. "",
  1943. "Below, Mac OS refers to Mac OS before Mac OS X. Mac OS X is a Unix based",
  1944. "port and is referred to as Unix Apple.",
  1945. "",
  1946. "",
  1947. "unzip options:",
  1948. " -Z Switch to zipinfo mode. Must be first option.",
  1949. " -hh Display extended help.",
  1950. " -A [OS/2, Unix DLL] Print extended help for DLL.",
  1951. " -c Extract files to stdout/screen. As -p but include names. Also,",
  1952. " -a allowed and EBCDIC conversions done if needed.",
  1953. " -f Freshen by extracting only if older file on disk.",
  1954. " -l List files using short form.",
  1955. " -p Extract files to pipe (stdout). Only file data is output and all",
  1956. " files extracted in binary mode (as stored).",
  1957. " -t Test archive files.",
  1958. " -T Set timestamp on archive(s) to that of newest file. Similar to",
  1959. " zip -o but faster.",
  1960. " -u Update existing older files on disk as -f and extract new files.",
  1961. " -v Use verbose list format. If given alone as unzip -v show version",
  1962. " information. Also can be added to other list commands for more",
  1963. " verbose output.",
  1964. " -z Display only archive comment.",
  1965. "",
  1966. "unzip modifiers:",
  1967. " -a Convert text files to local OS format. Convert line ends, EOF",
  1968. " marker, and from or to EBCDIC character set as needed.",
  1969. " -b Treat all files as binary. [Tandem] Force filecode 180 ('C').",
  1970. " [VMS] Autoconvert binary files. -bb forces convert of all files.",
  1971. " -B [UNIXBACKUP compile option enabled] Save a backup copy of each",
  1972. " overwritten file in foo~ or foo~99999 format.",
  1973. " -C Use case-insensitive matching.",
  1974. " -D Skip restoration of timestamps for extracted directories. On VMS this",
  1975. " is on by default and -D essentially becames -DD.",
  1976. " -DD Skip restoration of timestamps for all entries.",
  1977. " -E [MacOS (not Unix Apple)] Display contents of MacOS extra field during",
  1978. " restore.",
  1979. " -F [Acorn] Suppress removal of NFS filetype extension. [Non-Acorn if",
  1980. " ACORN_FTYPE_NFS] Translate filetype and append to name.",
  1981. " -i [MacOS] Ignore filenames in MacOS extra field. Instead, use name in",
  1982. " standard header.",
  1983. " -j Junk paths and deposit all files in extraction directory.",
  1984. " -J [BeOS] Junk file attributes. [MacOS] Ignore MacOS specific info.",
  1985. " -K [AtheOS, BeOS, Unix] Restore SUID/SGID/Tacky file attributes.",
  1986. " -L Convert to lowercase any names from uppercase only file system.",
  1987. " -LL Convert all files to lowercase.",
  1988. " -M Pipe all output through internal pager similar to Unix more(1).",
  1989. " -n Never overwrite existing files. Skip extracting that file, no prompt.",
  1990. " -N [Amiga] Extract file comments as Amiga filenotes.",
  1991. " -o Overwrite existing files without prompting. Useful with -f. Use with",
  1992. " care.",
  1993. " -P p Use password p to decrypt files. THIS IS INSECURE! Some OS show",
  1994. " command line to other users.",
  1995. " -q Perform operations quietly. The more q (as in -qq) the quieter.",
  1996. " -s [OS/2, NT, MS-DOS] Convert spaces in filenames to underscores.",
  1997. " -S [VMS] Convert text files (-a, -aa) into Stream_LF format.",
  1998. " -U [UNICODE enabled] Show non-local characters as #Uxxxx or #Lxxxxxx ASCII",
  1999. " text escapes where x is hex digit. [Old] -U used to leave names",
  2000. " uppercase if created on MS-DOS, VMS, etc. See -L.",
  2001. " -UU [UNICODE enabled] Disable use of stored UTF-8 paths. Note that UTF-8",
  2002. " paths stored as native local paths are still processed as Unicode.",
  2003. " -V Retain VMS file version numbers.",
  2004. " -W [Only if WILD_STOP_AT_DIR] Modify pattern matching so ? and * do not",
  2005. " match directory separator /, but ** does. Allows matching at specific",
  2006. " directory levels.",
  2007. " -X [VMS, Unix, OS/2, NT, Tandem] Restore UICs and ACL entries under VMS,",
  2008. " or UIDs/GIDs under Unix, or ACLs under certain network-enabled",
  2009. " versions of OS/2, or security ACLs under Windows NT. Can require",
  2010. " user privileges.",
  2011. " -XX [NT] Extract NT security ACLs after trying to enable additional",
  2012. " system privileges.",
  2013. " -Y [VMS] Treat archived name endings of .nnn as VMS version numbers.",
  2014. " -$ [MS-DOS, OS/2, NT] Restore volume label if extraction medium is",
  2015. " removable. -$$ allows fixed media (hard drives) to be labeled.",
  2016. " -/ e [Acorn] Use e as extension list.",
  2017. " -: [All but Acorn, VM/CMS, MVS, Tandem] Allow extract archive members into",
  2018. " locations outside of current extraction root folder. This allows",
  2019. " paths such as ../foo to be extracted above the current extraction",
  2020. " directory, which can be a security problem.",
  2021. " -^ [Unix] Allow control characters in names of extracted entries. Usually",
  2022. " this is not a good thing and should be avoided.",
  2023. " -2 [VMS] Force unconditional conversion of names to ODS-compatible names.",
  2024. " Default is to exploit destination file system, preserving cases and",
  2025. " extended name characters on ODS5 and applying ODS2 filtering on ODS2.",
  2026. "",
  2027. "",
  2028. "Wildcards:",
  2029. " Internally unzip supports the following wildcards:",
  2030. " ? (or %% or #, depending on OS) matches any single character",
  2031. " * matches any number of characters, including zero",
  2032. " [list] matches char in list (regex), can do range [ac-f], all but [!bf]",
  2033. " If port supports [], must escape [ as [[]",
  2034. " For shells that expand wildcards, escape (\\* or \"*\") so unzip can recurse.",
  2035. "",
  2036. "Include and Exclude:",
  2037. " -i pattern pattern ... include files that match a pattern",
  2038. " -x pattern pattern ... exclude files that match a pattern",
  2039. " Patterns are paths with optional wildcards and match paths as stored in",
  2040. " archive. Exclude and include lists end at next option or end of line.",
  2041. " unzip archive -x pattern pattern ...",
  2042. "",
  2043. "Multi-part (split) archives (archives created as a set of split files):",
  2044. " Currently split archives are not readable by unzip. A workaround is",
  2045. " to use zip to convert the split archive to a single-file archive and",
  2046. " use unzip on that. See the manual page for Zip 3.0 or later.",
  2047. "",
  2048. "Streaming (piping into unzip):",
  2049. " Currently unzip does not support streaming. The funzip utility can be",
  2050. " used to process the first entry in a stream.",
  2051. " cat archive | funzip",
  2052. "",
  2053. "Testing archives:",
  2054. " -t test contents of archive",
  2055. " This can be modified using -q for quieter operation, and -qq for even",
  2056. " quieter operation.",
  2057. "",
  2058. "Unicode:",
  2059. " If compiled with Unicode support, unzip automatically handles archives",
  2060. " with Unicode entries. Currently Unicode on Win32 systems is limited.",
  2061. " Characters not in the current character set are shown as ASCII escapes",
  2062. " in the form #Uxxxx where the Unicode character number fits in 16 bits,",
  2063. " or #Lxxxxxx where it doesn't, where x is the ASCII character for a hex",
  2064. " digit.",
  2065. "",
  2066. "",
  2067. "zipinfo options (these are used in zipinfo mode (unzip -Z ...)):",
  2068. " -1 List names only, one per line. No headers/trailers. Good for scripts.",
  2069. " -2 List names only as -1, but include headers, trailers, and comments.",
  2070. " -s List archive entries in short Unix ls -l format. Default list format.",
  2071. " -m List in long Unix ls -l format. As -s, but includes compression %.",
  2072. " -l List in long Unix ls -l format. As -m, but compression in bytes.",
  2073. " -v List zipfile information in verbose, multi-page format.",
  2074. " -h List header line. Includes archive name, actual size, total files.",
  2075. " -M Pipe all output through internal pager similar to Unix more(1) command.",
  2076. " -t List totals for files listed or for all files. Includes uncompressed",
  2077. " and compressed sizes, and compression factors.",
  2078. " -T Print file dates and times in a sortable decimal format (yymmdd.hhmmss)",
  2079. " Default date and time format is a more human-readable version.",
  2080. " -U [UNICODE] If entry has a UTF-8 Unicode path, display any characters",
  2081. " not in current character set as text #Uxxxx and #Lxxxxxx escapes",
  2082. " representing the Unicode character number of the character in hex.",
  2083. " -UU [UNICODE] Disable use of any UTF-8 path information.",
  2084. " -z Include archive comment if any in listing.",
  2085. "",
  2086. "",
  2087. "funzip stream extractor:",
  2088. " funzip extracts the first member in an archive to stdout. Typically",
  2089. " used to unzip the first member of a stream or pipe. If a file argument",
  2090. " is given, read from that file instead of stdin.",
  2091. "",
  2092. "funzip command line:",
  2093. " funzip [-password] [input[.zip|.gz]]",
  2094. "",
  2095. "",
  2096. "unzipsfx self extractor:",
  2097. " Self-extracting archives made with unzipsfx are no more (or less)",
  2098. " portable across different operating systems than unzip executables.",
  2099. " In general, a self-extracting archive made on a particular Unix system,",
  2100. " for example, will only self-extract under the same flavor of Unix.",
  2101. " Regular unzip may still be used to extract embedded archive however.",
  2102. "",
  2103. "unzipsfx command line:",
  2104. " <unzipsfx+archive_filename> [-options] [file(s) ... [-x xfile(s) ...]]",
  2105. "",
  2106. "unzipsfx options:",
  2107. " -c, -p - Output to pipe. (See above for unzip.)",
  2108. " -f, -u - Freshen and Update, as for unzip.",
  2109. " -t - Test embedded archive. (Can be used to list contents.)",
  2110. " -z - Print archive comment. (See unzip above.)",
  2111. "",
  2112. "unzipsfx modifiers:",
  2113. " Most unzip modifiers are supported. These include",
  2114. " -a - Convert text files.",
  2115. " -n - Never overwrite.",
  2116. " -o - Overwrite without prompting.",
  2117. " -q - Quiet operation.",
  2118. " -C - Match names case-insensitively.",
  2119. " -j - Junk paths.",
  2120. " -V - Keep version numbers.",
  2121. " -s - Convert spaces to underscores.",
  2122. " -$ - Restore volume label.",
  2123. "",
  2124. "If unzipsfx compiled with SFX_EXDIR defined, -d option also available:",
  2125. " -d exd - Extract to directory exd.",
  2126. "By default, all files extracted to current directory. This option",
  2127. "forces extraction to specified directory.",
  2128. "",
  2129. "See unzipsfx manual page for more information.",
  2130. ""
  2131. };
  2132. for (i = 0; i < sizeof(text)/sizeof(char *); i++)
  2133. {
  2134. Info(slide, 0, ((char *)slide, "%s\n", text[i]));
  2135. }
  2136. } /* end function help_extended() */
  2137. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  2138. #if (!defined(MODERN) || defined(NO_STDLIB_H))
  2139. /* Declare getenv() to be sure (might be missing in some environments) */
  2140. extern char *getenv();
  2141. #endif
  2142. #endif
  2143. /********************************/
  2144. /* Function show_version_info() */
  2145. /********************************/
  2146. static void show_version_info(__G)
  2147. __GDEF
  2148. {
  2149. if (uO.qflag > 3) /* "unzip -vqqqq" */
  2150. Info(slide, 0, ((char *)slide, "%d\n",
  2151. (UZ_MAJORVER*100 + UZ_MINORVER*10 + UZ_PATCHLEVEL)));
  2152. else {
  2153. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  2154. char *envptr;
  2155. #endif
  2156. int numopts = 0;
  2157. Info(slide, 0, ((char *)slide, LoadFarString(UnzipUsageLine1v),
  2158. UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
  2159. LoadFarStringSmall(VersionDate)));
  2160. Info(slide, 0, ((char *)slide,
  2161. LoadFarString(UnzipUsageLine2v)));
  2162. version(__G);
  2163. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptions)));
  2164. #ifdef ACORN_FTYPE_NFS
  2165. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2166. LoadFarStringSmall(AcornFtypeNFS)));
  2167. ++numopts;
  2168. #endif
  2169. #ifdef ASM_CRC
  2170. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2171. LoadFarStringSmall(AsmCRC)));
  2172. ++numopts;
  2173. #endif
  2174. #ifdef ASM_INFLATECODES
  2175. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2176. LoadFarStringSmall(AsmInflateCodes)));
  2177. ++numopts;
  2178. #endif
  2179. #ifdef CHECK_VERSIONS
  2180. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2181. LoadFarStringSmall(Check_Versions)));
  2182. ++numopts;
  2183. #endif
  2184. #ifdef COPYRIGHT_CLEAN
  2185. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2186. LoadFarStringSmall(Copyright_Clean)));
  2187. ++numopts;
  2188. #endif
  2189. #ifdef DEBUG
  2190. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2191. LoadFarStringSmall(UDebug)));
  2192. ++numopts;
  2193. #endif
  2194. #ifdef DEBUG_TIME
  2195. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2196. LoadFarStringSmall(DebugTime)));
  2197. ++numopts;
  2198. #endif
  2199. #ifdef DLL
  2200. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2201. LoadFarStringSmall(Dll)));
  2202. ++numopts;
  2203. #endif
  2204. #ifdef DOSWILD
  2205. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2206. LoadFarStringSmall(DosWild)));
  2207. ++numopts;
  2208. #endif
  2209. #ifdef LZW_CLEAN
  2210. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2211. LoadFarStringSmall(LZW_Clean)));
  2212. ++numopts;
  2213. #endif
  2214. #ifndef MORE
  2215. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2216. LoadFarStringSmall(No_More)));
  2217. ++numopts;
  2218. #endif
  2219. #ifdef NO_ZIPINFO
  2220. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2221. LoadFarStringSmall(No_ZipInfo)));
  2222. ++numopts;
  2223. #endif
  2224. #ifdef NTSD_EAS
  2225. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2226. LoadFarStringSmall(NTSDExtAttrib)));
  2227. ++numopts;
  2228. #endif
  2229. #if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
  2230. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2231. LoadFarStringSmall(W32NoIZTimeFix)));
  2232. ++numopts;
  2233. #endif
  2234. #ifdef OLD_THEOS_EXTRA
  2235. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2236. LoadFarStringSmall(OldTheosExtra)));
  2237. ++numopts;
  2238. #endif
  2239. #ifdef OS2_EAS
  2240. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2241. LoadFarStringSmall(OS2ExtAttrib)));
  2242. ++numopts;
  2243. #endif
  2244. #ifdef QLZIP
  2245. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2246. LoadFarStringSmall(SMSExFldOnUnix)));
  2247. ++numopts;
  2248. #endif
  2249. #ifdef REENTRANT
  2250. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2251. LoadFarStringSmall(Reentrant)));
  2252. ++numopts;
  2253. #endif
  2254. #ifdef REGARGS
  2255. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2256. LoadFarStringSmall(RegArgs)));
  2257. ++numopts;
  2258. #endif
  2259. #ifdef RETURN_CODES
  2260. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2261. LoadFarStringSmall(Return_Codes)));
  2262. ++numopts;
  2263. #endif
  2264. #ifdef SET_DIR_ATTRIB
  2265. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2266. LoadFarStringSmall(SetDirAttrib)));
  2267. ++numopts;
  2268. #endif
  2269. #ifdef SYMLINKS
  2270. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2271. LoadFarStringSmall(SymLinkSupport)));
  2272. ++numopts;
  2273. #endif
  2274. #ifdef TIMESTAMP
  2275. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2276. LoadFarStringSmall(TimeStamp)));
  2277. ++numopts;
  2278. #endif
  2279. #ifdef UNIXBACKUP
  2280. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2281. LoadFarStringSmall(UnixBackup)));
  2282. ++numopts;
  2283. #endif
  2284. #ifdef USE_EF_UT_TIME
  2285. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2286. LoadFarStringSmall(Use_EF_UT_time)));
  2287. ++numopts;
  2288. #endif
  2289. #ifndef COPYRIGHT_CLEAN
  2290. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2291. LoadFarStringSmall(Use_Smith_Code)));
  2292. ++numopts;
  2293. #endif
  2294. #ifndef LZW_CLEAN
  2295. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2296. LoadFarStringSmall(Use_Unshrink)));
  2297. ++numopts;
  2298. #endif
  2299. #ifdef USE_DEFLATE64
  2300. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2301. LoadFarStringSmall(Use_Deflate64)));
  2302. ++numopts;
  2303. #endif
  2304. #ifdef UNICODE_SUPPORT
  2305. # ifdef UTF8_MAYBE_NATIVE
  2306. sprintf((char *)(slide+256), LoadFarStringSmall(Use_Unicode),
  2307. LoadFarStringSmall2(G.native_is_utf8 ? SysChUTF8 : SysChOther));
  2308. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2309. (char *)(slide+256)));
  2310. # else
  2311. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2312. LoadFarStringSmall(Use_Unicode)));
  2313. # endif
  2314. ++numopts;
  2315. #endif
  2316. #ifdef _MBCS
  2317. sprintf((char *)(slide+256), LoadFarStringSmall(Have_MBCS_Support),
  2318. (unsigned int)MB_CUR_MAX);
  2319. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2320. (char *)(slide+256)));
  2321. ++numopts;
  2322. #endif
  2323. #ifdef MULT_VOLUME
  2324. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2325. LoadFarStringSmall(Use_MultiVol)));
  2326. ++numopts;
  2327. #endif
  2328. #ifdef LARGE_FILE_SUPPORT
  2329. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2330. LoadFarStringSmall(Use_LFS)));
  2331. ++numopts;
  2332. #endif
  2333. #ifdef ZIP64_SUPPORT
  2334. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2335. LoadFarStringSmall(Use_Zip64)));
  2336. ++numopts;
  2337. #endif
  2338. #if (defined(__DJGPP__) && (__DJGPP__ >= 2))
  2339. # ifdef USE_DJGPP_ENV
  2340. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2341. LoadFarStringSmall(Use_DJGPP_Env)));
  2342. ++numopts;
  2343. # endif
  2344. # ifdef USE_DJGPP_GLOB
  2345. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2346. LoadFarStringSmall(Use_DJGPP_Glob)));
  2347. ++numopts;
  2348. # endif
  2349. #endif /* __DJGPP__ && (__DJGPP__ >= 2) */
  2350. #ifdef USE_VFAT
  2351. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2352. LoadFarStringSmall(Use_VFAT_support)));
  2353. ++numopts;
  2354. #endif
  2355. #ifdef USE_ZLIB
  2356. sprintf((char *)(slide+256), LoadFarStringSmall(UseZlib),
  2357. ZLIB_VERSION, zlibVersion());
  2358. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2359. (char *)(slide+256)));
  2360. ++numopts;
  2361. #endif
  2362. #ifdef USE_BZIP2
  2363. sprintf((char *)(slide+256), LoadFarStringSmall(UseBZip2),
  2364. BZ2_bzlibVersion());
  2365. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2366. (char *)(slide+256)));
  2367. ++numopts;
  2368. #endif
  2369. #ifdef VMS_TEXT_CONV
  2370. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2371. LoadFarStringSmall(VmsTextConv)));
  2372. ++numopts;
  2373. #endif
  2374. #ifdef VMSCLI
  2375. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2376. LoadFarStringSmall(VmsCLI)));
  2377. ++numopts;
  2378. #endif
  2379. #ifdef VMSWILD
  2380. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2381. LoadFarStringSmall(VmsWild)));
  2382. ++numopts;
  2383. #endif
  2384. #ifdef WILD_STOP_AT_DIR
  2385. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2386. LoadFarStringSmall(WildStopAtDir)));
  2387. ++numopts;
  2388. #endif
  2389. #if CRYPT
  2390. # ifdef PASSWD_FROM_STDIN
  2391. Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  2392. LoadFarStringSmall(PasswdStdin)));
  2393. # endif
  2394. Info(slide, 0, ((char *)slide, LoadFarString(Decryption),
  2395. CR_MAJORVER, CR_MINORVER, CR_BETA_VER,
  2396. LoadFarStringSmall(CryptDate)));
  2397. ++numopts;
  2398. #endif /* CRYPT */
  2399. if (numopts == 0)
  2400. Info(slide, 0, ((char *)slide,
  2401. LoadFarString(CompileOptFormat),
  2402. LoadFarStringSmall(None)));
  2403. #ifndef _WIN32_WCE /* Win CE does not support environment variables */
  2404. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptions)));
  2405. envptr = getenv(LoadFarStringSmall(EnvUnZip));
  2406. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2407. LoadFarStringSmall(EnvUnZip),
  2408. (envptr == (char *)NULL || *envptr == 0)?
  2409. LoadFarStringSmall2(None) : envptr));
  2410. envptr = getenv(LoadFarStringSmall(EnvUnZip2));
  2411. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2412. LoadFarStringSmall(EnvUnZip2),
  2413. (envptr == (char *)NULL || *envptr == 0)?
  2414. LoadFarStringSmall2(None) : envptr));
  2415. envptr = getenv(LoadFarStringSmall(EnvZipInfo));
  2416. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2417. LoadFarStringSmall(EnvZipInfo),
  2418. (envptr == (char *)NULL || *envptr == 0)?
  2419. LoadFarStringSmall2(None) : envptr));
  2420. envptr = getenv(LoadFarStringSmall(EnvZipInfo2));
  2421. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2422. LoadFarStringSmall(EnvZipInfo2),
  2423. (envptr == (char *)NULL || *envptr == 0)?
  2424. LoadFarStringSmall2(None) : envptr));
  2425. #ifndef __RSXNT__
  2426. #ifdef __EMX__
  2427. envptr = getenv(LoadFarStringSmall(EnvEMX));
  2428. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2429. LoadFarStringSmall(EnvEMX),
  2430. (envptr == (char *)NULL || *envptr == 0)?
  2431. LoadFarStringSmall2(None) : envptr));
  2432. envptr = getenv(LoadFarStringSmall(EnvEMXOPT));
  2433. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2434. LoadFarStringSmall(EnvEMXOPT),
  2435. (envptr == (char *)NULL || *envptr == 0)?
  2436. LoadFarStringSmall2(None) : envptr));
  2437. #endif /* __EMX__ */
  2438. #if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
  2439. envptr = getenv(LoadFarStringSmall(EnvGO32));
  2440. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2441. LoadFarStringSmall(EnvGO32),
  2442. (envptr == (char *)NULL || *envptr == 0)?
  2443. LoadFarStringSmall2(None) : envptr));
  2444. envptr = getenv(LoadFarStringSmall(EnvGO32TMP));
  2445. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2446. LoadFarStringSmall(EnvGO32TMP),
  2447. (envptr == (char *)NULL || *envptr == 0)?
  2448. LoadFarStringSmall2(None) : envptr));
  2449. #endif /* __GO32__ && !(__DJGPP__ >= 2) */
  2450. #endif /* !__RSXNT__ */
  2451. #ifdef RISCOS
  2452. envptr = getenv(LoadFarStringSmall(EnvUnZipExts));
  2453. Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  2454. LoadFarStringSmall(EnvUnZipExts),
  2455. (envptr == (char *)NULL || *envptr == 0)?
  2456. LoadFarStringSmall2(None) : envptr));
  2457. #endif /* RISCOS */
  2458. #endif /* !_WIN32_WCE */
  2459. }
  2460. } /* end function show_version() */
  2461. #endif /* !SFX */
  2462. #endif /* !WINDLL */