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.

zipinfo.c 95KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315
  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. zipinfo.c Greg Roelofs et al.
  10. This file contains all of the ZipInfo-specific listing routines for UnZip.
  11. Contains: zi_opts()
  12. zi_end_central()
  13. zipinfo()
  14. zi_long()
  15. zi_short()
  16. zi_time()
  17. ---------------------------------------------------------------------------*/
  18. #define UNZIP_INTERNAL
  19. #include "unzip.h"
  20. #ifndef NO_ZIPINFO /* strings use up too much space in small-memory systems */
  21. /* Define OS-specific attributes for use on ALL platforms--the S_xxxx
  22. * versions of these are defined differently (or not defined) by different
  23. * compilers and operating systems. */
  24. #define UNX_IFMT 0170000 /* Unix file type mask */
  25. #define UNX_IFREG 0100000 /* Unix regular file */
  26. #define UNX_IFSOCK 0140000 /* Unix socket (BSD, not SysV or Amiga) */
  27. #define UNX_IFLNK 0120000 /* Unix symbolic link (not SysV, Amiga) */
  28. #define UNX_IFBLK 0060000 /* Unix block special (not Amiga) */
  29. #define UNX_IFDIR 0040000 /* Unix directory */
  30. #define UNX_IFCHR 0020000 /* Unix character special (not Amiga) */
  31. #define UNX_IFIFO 0010000 /* Unix fifo (BCC, not MSC or Amiga) */
  32. #define UNX_ISUID 04000 /* Unix set user id on execution */
  33. #define UNX_ISGID 02000 /* Unix set group id on execution */
  34. #define UNX_ISVTX 01000 /* Unix directory permissions control */
  35. #define UNX_ENFMT UNX_ISGID /* Unix record locking enforcement flag */
  36. #define UNX_IRWXU 00700 /* Unix read, write, execute: owner */
  37. #define UNX_IRUSR 00400 /* Unix read permission: owner */
  38. #define UNX_IWUSR 00200 /* Unix write permission: owner */
  39. #define UNX_IXUSR 00100 /* Unix execute permission: owner */
  40. #define UNX_IRWXG 00070 /* Unix read, write, execute: group */
  41. #define UNX_IRGRP 00040 /* Unix read permission: group */
  42. #define UNX_IWGRP 00020 /* Unix write permission: group */
  43. #define UNX_IXGRP 00010 /* Unix execute permission: group */
  44. #define UNX_IRWXO 00007 /* Unix read, write, execute: other */
  45. #define UNX_IROTH 00004 /* Unix read permission: other */
  46. #define UNX_IWOTH 00002 /* Unix write permission: other */
  47. #define UNX_IXOTH 00001 /* Unix execute permission: other */
  48. #define VMS_IRUSR UNX_IRUSR /* VMS read/owner */
  49. #define VMS_IWUSR UNX_IWUSR /* VMS write/owner */
  50. #define VMS_IXUSR UNX_IXUSR /* VMS execute/owner */
  51. #define VMS_IRGRP UNX_IRGRP /* VMS read/group */
  52. #define VMS_IWGRP UNX_IWGRP /* VMS write/group */
  53. #define VMS_IXGRP UNX_IXGRP /* VMS execute/group */
  54. #define VMS_IROTH UNX_IROTH /* VMS read/other */
  55. #define VMS_IWOTH UNX_IWOTH /* VMS write/other */
  56. #define VMS_IXOTH UNX_IXOTH /* VMS execute/other */
  57. #define AMI_IFMT 06000 /* Amiga file type mask */
  58. #define AMI_IFDIR 04000 /* Amiga directory */
  59. #define AMI_IFREG 02000 /* Amiga regular file */
  60. #define AMI_IHIDDEN 00200 /* to be supported in AmigaDOS 3.x */
  61. #define AMI_ISCRIPT 00100 /* executable script (text command file) */
  62. #define AMI_IPURE 00040 /* allow loading into resident memory */
  63. #define AMI_IARCHIVE 00020 /* not modified since bit was last set */
  64. #define AMI_IREAD 00010 /* can be opened for reading */
  65. #define AMI_IWRITE 00004 /* can be opened for writing */
  66. #define AMI_IEXECUTE 00002 /* executable image, a loadable runfile */
  67. #define AMI_IDELETE 00001 /* can be deleted */
  68. #define THS_IFMT 0xF000 /* Theos file type mask */
  69. #define THS_IFIFO 0x1000 /* pipe */
  70. #define THS_IFCHR 0x2000 /* char device */
  71. #define THS_IFSOCK 0x3000 /* socket */
  72. #define THS_IFDIR 0x4000 /* directory */
  73. #define THS_IFLIB 0x5000 /* library */
  74. #define THS_IFBLK 0x6000 /* block device */
  75. #define THS_IFREG 0x8000 /* regular file */
  76. #define THS_IFREL 0x9000 /* relative (direct) */
  77. #define THS_IFKEY 0xA000 /* keyed */
  78. #define THS_IFIND 0xB000 /* indexed */
  79. #define THS_IFRND 0xC000 /* ???? */
  80. #define THS_IFR16 0xD000 /* 16 bit real mode program */
  81. #define THS_IFP16 0xE000 /* 16 bit protected mode prog */
  82. #define THS_IFP32 0xF000 /* 32 bit protected mode prog */
  83. #define THS_IMODF 0x0800 /* modified */
  84. #define THS_INHID 0x0400 /* not hidden */
  85. #define THS_IEUSR 0x0200 /* erase permission: owner */
  86. #define THS_IRUSR 0x0100 /* read permission: owner */
  87. #define THS_IWUSR 0x0080 /* write permission: owner */
  88. #define THS_IXUSR 0x0040 /* execute permission: owner */
  89. #define THS_IROTH 0x0004 /* read permission: other */
  90. #define THS_IWOTH 0x0002 /* write permission: other */
  91. #define THS_IXOTH 0x0001 /* execute permission: other */
  92. #ifdef OLD_THEOS_EXTRA
  93. # include "theos/oldstat.h"
  94. #endif
  95. #ifndef NSK_UNSTRUCTURED
  96. # define NSK_UNSTRUCTURED 0
  97. #endif
  98. #ifndef NSK_OBJECTFILECODE
  99. # define NSK_OBJECTFILECODE 100
  100. #endif
  101. #ifndef NSK_EDITFILECODE
  102. # define NSK_EDITFILECODE 101
  103. #endif
  104. #define LFLAG 3 /* short "ls -l" type listing */
  105. static int zi_long OF((__GPRO__ zusz_t *pEndprev, int error_in_archive));
  106. static int zi_short OF((__GPRO));
  107. static void zi_showMacTypeCreator
  108. OF((__GPRO__ uch *ebfield));
  109. static char *zi_time OF((__GPRO__ ZCONST ulg *datetimez,
  110. ZCONST time_t *modtimez, char *d_t_str));
  111. /**********************************************/
  112. /* Strings used in zipinfo.c (ZipInfo half) */
  113. /**********************************************/
  114. static ZCONST char nullStr[] = "";
  115. static ZCONST char PlurSufx[] = "s";
  116. static ZCONST char Far ZipInfHeader2[] =
  117. "Zip file size: %s bytes, number of entries: %s\n";
  118. static ZCONST char Far EndCentDirRec[] = "\nEnd-of-central-directory record:\n";
  119. static ZCONST char Far LineSeparators[] = "-------------------------------\n\n";
  120. static ZCONST char Far ZipFSizeVerbose[] = "\
  121. Zip archive file size: %s (%sh)\n";
  122. static ZCONST char Far ActOffsetCentDir[] = "\
  123. Actual end-cent-dir record offset: %s (%sh)\n\
  124. Expected end-cent-dir record offset: %s (%sh)\n\
  125. (based on the length of the central directory and its expected offset)\n\n";
  126. static ZCONST char Far SinglePartArchive1[] = "\
  127. This zipfile constitutes the sole disk of a single-part archive; its\n\
  128. central directory contains %s %s.\n\
  129. The central directory is %s (%sh) bytes long,\n";
  130. static ZCONST char Far SinglePartArchive2[] = "\
  131. and its (expected) offset in bytes from the beginning of the zipfile\n\
  132. is %s (%sh).\n\n";
  133. static ZCONST char Far MultiPartArchive1[] = "\
  134. This zipfile constitutes disk %lu of a multi-part archive. The central\n\
  135. directory starts on disk %lu at an offset within that archive part\n";
  136. static ZCONST char Far MultiPartArchive2[] = "\
  137. of %s (%sh) bytes. The entire\n\
  138. central directory is %s (%sh) bytes long.\n";
  139. static ZCONST char Far MultiPartArchive3[] = "\
  140. %s of the archive entries %s contained within this zipfile volume,\n\
  141. out of a total of %s %s.\n\n";
  142. static ZCONST char Far CentralDirEntry[] =
  143. "\nCentral directory entry #%lu:\n---------------------------\n\n";
  144. static ZCONST char Far ZipfileStats[] =
  145. "%lu file%s, %s bytes uncompressed, %s bytes compressed: %s%d.%d%%\n";
  146. /* zi_long() strings */
  147. static ZCONST char Far OS_FAT[] = "MS-DOS, OS/2 or NT FAT";
  148. static ZCONST char Far OS_Amiga[] = "Amiga";
  149. static ZCONST char Far OS_VMS[] = "VMS";
  150. static ZCONST char Far OS_Unix[] = "Unix";
  151. static ZCONST char Far OS_VMCMS[] = "VM/CMS";
  152. static ZCONST char Far OS_AtariST[] = "Atari ST";
  153. static ZCONST char Far OS_HPFS[] = "OS/2 or NT HPFS";
  154. static ZCONST char Far OS_Macintosh[] = "Macintosh HFS";
  155. static ZCONST char Far OS_ZSystem[] = "Z-System";
  156. static ZCONST char Far OS_CPM[] = "CP/M";
  157. static ZCONST char Far OS_TOPS20[] = "TOPS-20";
  158. static ZCONST char Far OS_NTFS[] = "NTFS";
  159. static ZCONST char Far OS_QDOS[] = "SMS/QDOS";
  160. static ZCONST char Far OS_Acorn[] = "Acorn RISC OS";
  161. static ZCONST char Far OS_MVS[] = "MVS";
  162. static ZCONST char Far OS_VFAT[] = "Win32 VFAT";
  163. static ZCONST char Far OS_AtheOS[] = "AtheOS";
  164. static ZCONST char Far OS_BeOS[] = "BeOS";
  165. static ZCONST char Far OS_Tandem[] = "Tandem NSK";
  166. static ZCONST char Far OS_Theos[] = "Theos";
  167. static ZCONST char Far OS_MacDarwin[] = "Mac OS/X (Darwin)";
  168. #ifdef OLD_THEOS_EXTRA
  169. static ZCONST char Far OS_TheosOld[] = "Theos (Old)";
  170. #endif /* OLD_THEOS_EXTRA */
  171. static ZCONST char Far MthdNone[] = "none (stored)";
  172. static ZCONST char Far MthdShrunk[] = "shrunk";
  173. static ZCONST char Far MthdRedF1[] = "reduced (factor 1)";
  174. static ZCONST char Far MthdRedF2[] = "reduced (factor 2)";
  175. static ZCONST char Far MthdRedF3[] = "reduced (factor 3)";
  176. static ZCONST char Far MthdRedF4[] = "reduced (factor 4)";
  177. static ZCONST char Far MthdImplode[] = "imploded";
  178. static ZCONST char Far MthdToken[] = "tokenized";
  179. static ZCONST char Far MthdDeflate[] = "deflated";
  180. static ZCONST char Far MthdDeflat64[] = "deflated (enhanced-64k)";
  181. static ZCONST char Far MthdDCLImplode[] = "imploded (PK DCL)";
  182. static ZCONST char Far MthdBZip2[] = "bzipped";
  183. static ZCONST char Far MthdLZMA[] = "LZMA-ed";
  184. static ZCONST char Far MthdTerse[] = "tersed (IBM)";
  185. static ZCONST char Far MthdLZ77[] = "LZ77-compressed (IBM)";
  186. static ZCONST char Far MthdWavPack[] = "WavPacked";
  187. static ZCONST char Far MthdPPMd[] = "PPMd-ed";
  188. static ZCONST char Far DeflNorm[] = "normal";
  189. static ZCONST char Far DeflMax[] = "maximum";
  190. static ZCONST char Far DeflFast[] = "fast";
  191. static ZCONST char Far DeflSFast[] = "superfast";
  192. static ZCONST char Far ExtraBytesPreceding[] =
  193. " There are an extra %s bytes preceding this file.\n\n";
  194. static ZCONST char Far UnknownNo[] = "unknown (%d)";
  195. #ifdef ZIP64_SUPPORT
  196. static ZCONST char Far LocalHeaderOffset[] =
  197. "\n offset of local header from start of archive: %s\n\
  198. (%sh) bytes\n";
  199. #else
  200. static ZCONST char Far LocalHeaderOffset[] =
  201. "\n offset of local header from start of archive: %s (%sh) bytes\n";
  202. #endif
  203. static ZCONST char Far HostOS[] =
  204. " file system or operating system of origin: %s\n";
  205. static ZCONST char Far EncodeSWVer[] =
  206. " version of encoding software: %u.%u\n";
  207. static ZCONST char Far MinOSCompReq[] =
  208. " minimum file system compatibility required: %s\n";
  209. static ZCONST char Far MinSWVerReq[] =
  210. " minimum software version required to extract: %u.%u\n";
  211. static ZCONST char Far CompressMethod[] =
  212. " compression method: %s\n";
  213. static ZCONST char Far SlideWindowSizeImplode[] =
  214. " size of sliding dictionary (implosion): %cK\n";
  215. static ZCONST char Far ShannonFanoTrees[] =
  216. " number of Shannon-Fano trees (implosion): %c\n";
  217. static ZCONST char Far CompressSubtype[] =
  218. " compression sub-type (deflation): %s\n";
  219. static ZCONST char Far FileSecurity[] =
  220. " file security status: %sencrypted\n";
  221. static ZCONST char Far ExtendedLocalHdr[] =
  222. " extended local header: %s\n";
  223. static ZCONST char Far FileModDate[] =
  224. " file last modified on (DOS date/time): %s\n";
  225. #ifdef USE_EF_UT_TIME
  226. static ZCONST char Far UT_FileModDate[] =
  227. " file last modified on (UT extra field modtime): %s %s\n";
  228. static ZCONST char Far LocalTime[] = "local";
  229. #ifndef NO_GMTIME
  230. static ZCONST char Far GMTime[] = "UTC";
  231. #endif
  232. #endif /* USE_EF_UT_TIME */
  233. static ZCONST char Far CRC32Value[] =
  234. " 32-bit CRC value (hex): %.8lx\n";
  235. static ZCONST char Far CompressedFileSize[] =
  236. " compressed size: %s bytes\n";
  237. static ZCONST char Far UncompressedFileSize[] =
  238. " uncompressed size: %s bytes\n";
  239. static ZCONST char Far FilenameLength[] =
  240. " length of filename: %u characters\n";
  241. static ZCONST char Far ExtraFieldLength[] =
  242. " length of extra field: %u bytes\n";
  243. static ZCONST char Far FileCommentLength[] =
  244. " length of file comment: %u characters\n";
  245. static ZCONST char Far FileDiskNum[] =
  246. " disk number on which file begins: disk %lu\n";
  247. static ZCONST char Far ApparentFileType[] =
  248. " apparent file type: %s\n";
  249. static ZCONST char Far VMSFileAttributes[] =
  250. " VMS file attributes (%06o octal): %s\n";
  251. static ZCONST char Far AmigaFileAttributes[] =
  252. " Amiga file attributes (%06o octal): %s\n";
  253. static ZCONST char Far UnixFileAttributes[] =
  254. " Unix file attributes (%06o octal): %s\n";
  255. static ZCONST char Far NonMSDOSFileAttributes[] =
  256. " non-MSDOS external file attributes: %06lX hex\n";
  257. static ZCONST char Far MSDOSFileAttributes[] =
  258. " MS-DOS file attributes (%02X hex): none\n";
  259. static ZCONST char Far MSDOSFileAttributesRO[] =
  260. " MS-DOS file attributes (%02X hex): read-only\n";
  261. static ZCONST char Far MSDOSFileAttributesAlpha[] =
  262. " MS-DOS file attributes (%02X hex): %s%s%s%s%s%s%s%s\n";
  263. static ZCONST char Far TheosFileAttributes[] =
  264. " Theos file attributes (%04X hex): %s\n";
  265. static ZCONST char Far TheosFTypLib[] = "Library ";
  266. static ZCONST char Far TheosFTypDir[] = "Directory ";
  267. static ZCONST char Far TheosFTypReg[] = "Sequential ";
  268. static ZCONST char Far TheosFTypRel[] = "Direct ";
  269. static ZCONST char Far TheosFTypKey[] = "Keyed ";
  270. static ZCONST char Far TheosFTypInd[] = "Indexed ";
  271. static ZCONST char Far TheosFTypR16[] = " 86 program ";
  272. static ZCONST char Far TheosFTypP16[] = "286 program ";
  273. static ZCONST char Far TheosFTypP32[] = "386 program ";
  274. static ZCONST char Far TheosFTypUkn[] = "??? ";
  275. static ZCONST char Far ExtraFieldTrunc[] = "\n\
  276. error: EF data block (type 0x%04x) size %u exceeds remaining extra field\n\
  277. space %u; block length has been truncated.\n";
  278. static ZCONST char Far ExtraFields[] = "\n\
  279. The central-directory extra field contains:";
  280. static ZCONST char Far ExtraFieldType[] = "\n\
  281. - A subfield with ID 0x%04x (%s) and %u data bytes";
  282. static ZCONST char Far efPKSZ64[] = "PKWARE 64-bit sizes";
  283. static ZCONST char Far efAV[] = "PKWARE AV";
  284. static ZCONST char Far efOS2[] = "OS/2";
  285. static ZCONST char Far efPKVMS[] = "PKWARE VMS";
  286. static ZCONST char Far efPKWin32[] = "PKWARE Win32";
  287. static ZCONST char Far efPKUnix[] = "PKWARE Unix";
  288. static ZCONST char Far efIZVMS[] = "Info-ZIP VMS";
  289. static ZCONST char Far efIZUnix[] = "old Info-ZIP Unix/OS2/NT";
  290. static ZCONST char Far efIZUnix2[] = "Unix UID/GID (16-bit)";
  291. static ZCONST char Far efIZUnix3[] = "Unix UID/GID (any size)";
  292. static ZCONST char Far efTime[] = "universal time";
  293. static ZCONST char Far efU8Path[] = "UTF8 path name";
  294. static ZCONST char Far efU8Commnt[] = "UTF8 entry comment";
  295. static ZCONST char Far efJLMac[] = "old Info-ZIP Macintosh";
  296. static ZCONST char Far efMac3[] = "new Info-ZIP Macintosh";
  297. static ZCONST char Far efZipIt[] = "ZipIt Macintosh";
  298. static ZCONST char Far efSmartZip[] = "SmartZip Macintosh";
  299. static ZCONST char Far efZipIt2[] = "ZipIt Macintosh (short)";
  300. static ZCONST char Far efVMCMS[] = "VM/CMS";
  301. static ZCONST char Far efMVS[] = "MVS";
  302. static ZCONST char Far efACL[] = "OS/2 ACL";
  303. static ZCONST char Far efNTSD[] = "Security Descriptor";
  304. static ZCONST char Far efAtheOS[] = "AtheOS";
  305. static ZCONST char Far efBeOS[] = "BeOS";
  306. static ZCONST char Far efQDOS[] = "SMS/QDOS";
  307. static ZCONST char Far efAOSVS[] = "AOS/VS";
  308. static ZCONST char Far efSpark[] = "Acorn SparkFS";
  309. static ZCONST char Far efMD5[] = "Fred Kantor MD5";
  310. static ZCONST char Far efASiUnix[] = "ASi Unix";
  311. static ZCONST char Far efTandem[] = "Tandem NSK";
  312. static ZCONST char Far efTheos[] = "Theos";
  313. static ZCONST char Far efUnknown[] = "unknown";
  314. static ZCONST char Far OS2EAs[] = ".\n\
  315. The local extra field has %lu bytes of OS/2 extended attributes.\n\
  316. (May not match OS/2 \"dir\" amount due to storage method)";
  317. static ZCONST char Far izVMSdata[] = ". The extra\n\
  318. field is %s and has %u bytes of VMS %s information%s";
  319. static ZCONST char Far izVMSstored[] = "stored";
  320. static ZCONST char Far izVMSrleenc[] = "run-length encoded";
  321. static ZCONST char Far izVMSdeflat[] = "deflated";
  322. static ZCONST char Far izVMScunknw[] = "compressed(?)";
  323. static ZCONST char Far *izVMScomp[4] =
  324. {izVMSstored, izVMSrleenc, izVMSdeflat, izVMScunknw};
  325. static ZCONST char Far ACLdata[] = ".\n\
  326. The local extra field has %lu bytes of access control list information";
  327. static ZCONST char Far NTSDData[] = ".\n\
  328. The local extra field has %lu bytes of NT security descriptor data";
  329. static ZCONST char Far UTdata[] = ".\n\
  330. The local extra field has UTC/GMT %s time%s";
  331. static ZCONST char Far UTmodification[] = "modification";
  332. static ZCONST char Far UTaccess[] = "access";
  333. static ZCONST char Far UTcreation[] = "creation";
  334. static ZCONST char Far U8PthCmnComplete[] = ".\n\
  335. The UTF8 data of the extra field (V%u, ASCII name CRC `%.8lx') are:\n ";
  336. static ZCONST char Far U8PthCmnF24[] = ". The first\n\
  337. 24 UTF8 bytes in the extra field (V%u, ASCII name CRC `%.8lx') are:\n ";
  338. static ZCONST char Far ZipItFname[] = ".\n\
  339. The Mac long filename is %s";
  340. static ZCONST char Far Mac3data[] = ".\n\
  341. The local extra field has %lu bytes of %scompressed Macintosh\n\
  342. finder attributes";
  343. /* MacOSdata[] is used by EF_MAC3, EF_ZIPIT, EF_ZIPIT2 and EF_JLEE e. f. */
  344. static ZCONST char Far MacOSdata[] = ".\n\
  345. The associated file has type code `%c%c%c%c' and creator code `%c%c%c%c'";
  346. static ZCONST char Far MacOSdata1[] = ".\n\
  347. The associated file has type code `0x%lx' and creator code `0x%lx'";
  348. static ZCONST char Far MacOSJLEEflags[] = ".\n File is marked as %s";
  349. static ZCONST char Far MacOS_RF[] = "Resource-fork";
  350. static ZCONST char Far MacOS_DF[] = "Data-fork";
  351. static ZCONST char Far MacOSMAC3flags[] = ".\n\
  352. File is marked as %s, File Dates are in %d Bit";
  353. static ZCONST char Far AtheOSdata[] = ".\n\
  354. The local extra field has %lu bytes of %scompressed AtheOS file attributes";
  355. static ZCONST char Far BeOSdata[] = ".\n\
  356. The local extra field has %lu bytes of %scompressed BeOS file attributes";
  357. /* The associated file has type code `%c%c%c%c' and creator code `%c%c%c%c'" */
  358. static ZCONST char Far QDOSdata[] = ".\n\
  359. The QDOS extra field subtype is `%c%c%c%c'";
  360. static ZCONST char Far AOSVSdata[] = ".\n\
  361. The AOS/VS extra field revision is %d.%d";
  362. static ZCONST char Far TandemUnstr[] = "Unstructured";
  363. static ZCONST char Far TandemRel[] = "Relative";
  364. static ZCONST char Far TandemEntry[] = "Entry Sequenced";
  365. static ZCONST char Far TandemKey[] = "Key Sequenced";
  366. static ZCONST char Far TandemEdit[] = "Edit";
  367. static ZCONST char Far TandemObj[] = "Object";
  368. static ZCONST char Far *TandemFileformat[6] =
  369. {TandemUnstr, TandemRel, TandemEntry, TandemKey, TandemEdit, TandemObj};
  370. static ZCONST char Far Tandemdata[] = ".\n\
  371. The file was originally a Tandem %s file, with file code %u";
  372. static ZCONST char Far MD5data[] = ".\n\
  373. The 128-bit MD5 signature is %s";
  374. #ifdef CMS_MVS
  375. static ZCONST char Far VmMvsExtraField[] = ".\n\
  376. The stored file open mode (FLDATA TYPE) is \"%s\"";
  377. static ZCONST char Far VmMvsInvalid[] = "[invalid]";
  378. #endif /* CMS_MVS */
  379. static ZCONST char Far First20[] = ". The first\n 20 are: ";
  380. static ZCONST char Far ColonIndent[] = ":\n ";
  381. static ZCONST char Far efFormat[] = " %02x";
  382. static ZCONST char Far lExtraFieldType[] = "\n\
  383. There %s a local extra field with ID 0x%04x (%s) and\n\
  384. %u data bytes (%s).\n";
  385. static ZCONST char Far efIZuid[] =
  386. "GMT modification/access times and Unix UID/GID";
  387. static ZCONST char Far efIZnouid[] = "GMT modification/access times only";
  388. static ZCONST char Far NoFileComment[] = "\n There is no file comment.\n";
  389. static ZCONST char Far FileCommBegin[] = "\n\
  390. ------------------------- file comment begins ----------------------------\n";
  391. static ZCONST char Far FileCommEnd[] = "\
  392. -------------------------- file comment ends -----------------------------\n";
  393. /* zi_time() strings */
  394. static ZCONST char Far BogusFmt[] = "%03d";
  395. static ZCONST char Far shtYMDHMTime[] = "%02u-%s-%02u %02u:%02u";
  396. static ZCONST char Far lngYMDHMSTime[] = "%u %s %u %02u:%02u:%02u";
  397. static ZCONST char Far DecimalTime[] = "%04u%02u%02u.%02u%02u%02u";
  398. #ifdef USE_EF_UT_TIME
  399. static ZCONST char Far lngYMDHMSTimeError[] = "???? ??? ?? ??:??:??";
  400. #endif
  401. #ifndef WINDLL
  402. /************************/
  403. /* Function zi_opts() */
  404. /************************/
  405. int zi_opts(__G__ pargc, pargv)
  406. int *pargc;
  407. char ***pargv;
  408. __GDEF
  409. {
  410. char **argv, *s;
  411. int argc, c, error=FALSE, negative=0;
  412. int hflag_slmv=TRUE, hflag_2=FALSE; /* diff options => diff defaults */
  413. int tflag_slm=TRUE, tflag_2v=FALSE;
  414. int explicit_h=FALSE, explicit_t=FALSE;
  415. #ifdef MACOS
  416. uO.lflag = LFLAG; /* reset default on each call */
  417. #endif
  418. G.extract_flag = FALSE; /* zipinfo does not extract to disk */
  419. argc = *pargc;
  420. argv = *pargv;
  421. while (--argc > 0 && (*++argv)[0] == '-') {
  422. s = argv[0] + 1;
  423. while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
  424. switch (c) {
  425. case '-':
  426. ++negative;
  427. break;
  428. case '1': /* shortest listing: JUST filenames */
  429. if (negative)
  430. uO.lflag = -2, negative = 0;
  431. else
  432. uO.lflag = 1;
  433. break;
  434. case '2': /* just filenames, plus headers if specified */
  435. if (negative)
  436. uO.lflag = -2, negative = 0;
  437. else
  438. uO.lflag = 2;
  439. break;
  440. #ifndef CMS_MVS
  441. case ('C'): /* -C: match filenames case-insensitively */
  442. if (negative)
  443. uO.C_flag = FALSE, negative = 0;
  444. else
  445. uO.C_flag = TRUE;
  446. break;
  447. #endif /* !CMS_MVS */
  448. case 'h': /* header line */
  449. if (negative)
  450. hflag_2 = hflag_slmv = FALSE, negative = 0;
  451. else {
  452. hflag_2 = hflag_slmv = explicit_h = TRUE;
  453. if (uO.lflag == -1)
  454. uO.lflag = 0;
  455. }
  456. break;
  457. case 'l': /* longer form of "ls -l" type listing */
  458. if (negative)
  459. uO.lflag = -2, negative = 0;
  460. else
  461. uO.lflag = 5;
  462. break;
  463. case 'm': /* medium form of "ls -l" type listing */
  464. if (negative)
  465. uO.lflag = -2, negative = 0;
  466. else
  467. uO.lflag = 4;
  468. break;
  469. #ifdef MORE
  470. case 'M': /* send output through built-in "more" */
  471. if (negative)
  472. G.M_flag = FALSE, negative = 0;
  473. else
  474. G.M_flag = TRUE;
  475. break;
  476. #endif
  477. case 's': /* default: shorter "ls -l" type listing */
  478. if (negative)
  479. uO.lflag = -2, negative = 0;
  480. else
  481. uO.lflag = 3;
  482. break;
  483. case 't': /* totals line */
  484. if (negative)
  485. tflag_2v = tflag_slm = FALSE, negative = 0;
  486. else {
  487. tflag_2v = tflag_slm = explicit_t = TRUE;
  488. if (uO.lflag == -1)
  489. uO.lflag = 0;
  490. }
  491. break;
  492. case ('T'): /* use (sortable) decimal time format */
  493. if (negative)
  494. uO.T_flag = FALSE, negative = 0;
  495. else
  496. uO.T_flag = TRUE;
  497. break;
  498. #ifdef UNICODE_SUPPORT
  499. case ('U'): /* escape UTF-8, or disable UTF-8 support */
  500. if (negative) {
  501. uO.U_flag = MAX(uO.U_flag-negative,0);
  502. negative = 0;
  503. } else
  504. uO.U_flag++;
  505. break;
  506. #endif /* UNICODE_SUPPORT */
  507. case 'v': /* turbo-verbose listing */
  508. if (negative)
  509. uO.lflag = -2, negative = 0;
  510. else
  511. uO.lflag = 10;
  512. break;
  513. #ifdef WILD_STOP_AT_DIR
  514. case ('W'): /* Wildcard interpretation (stop at '/'?) */
  515. if (negative)
  516. uO.W_flag = FALSE, negative = 0;
  517. else
  518. uO.W_flag = TRUE;
  519. break;
  520. #endif /* WILD_STOP_AT_DIR */
  521. case 'z': /* print zipfile comment */
  522. if (negative)
  523. uO.zflag = negative = 0;
  524. else
  525. uO.zflag = 1;
  526. break;
  527. case 'Z': /* ZipInfo mode: ignore */
  528. break;
  529. default:
  530. error = TRUE;
  531. break;
  532. }
  533. }
  534. }
  535. if ((argc-- == 0) || error) {
  536. *pargc = argc;
  537. *pargv = argv;
  538. return USAGE(error);
  539. }
  540. #ifdef MORE
  541. if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func useless */
  542. G.M_flag = 0;
  543. #endif
  544. /* if no listing options given (or all negated), or if only -h/-t given
  545. * with individual files specified, use default listing format */
  546. if ((uO.lflag < 0) || ((argc > 0) && (uO.lflag == 0)))
  547. uO.lflag = LFLAG;
  548. /* set header and totals flags to default or specified values */
  549. switch (uO.lflag) {
  550. case 0: /* 0: can only occur if either -t or -h explicitly given; */
  551. case 2: /* therefore set both flags equal to normally false value */
  552. uO.hflag = hflag_2;
  553. uO.tflag = tflag_2v;
  554. break;
  555. case 1: /* only filenames, *always* */
  556. uO.hflag = FALSE;
  557. uO.tflag = FALSE;
  558. uO.zflag = FALSE;
  559. break;
  560. case 3:
  561. case 4:
  562. case 5:
  563. uO.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
  564. uO.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
  565. break;
  566. case 10:
  567. uO.hflag = hflag_slmv;
  568. uO.tflag = tflag_2v;
  569. break;
  570. }
  571. *pargc = argc;
  572. *pargv = argv;
  573. return 0;
  574. } /* end function zi_opts() */
  575. #endif /* !WINDLL */
  576. /*******************************/
  577. /* Function zi_end_central() */
  578. /*******************************/
  579. void zi_end_central(__G)
  580. __GDEF
  581. {
  582. /*---------------------------------------------------------------------------
  583. Print out various interesting things about the zipfile.
  584. ---------------------------------------------------------------------------*/
  585. if (uO.lflag > 9) {
  586. /* verbose format */
  587. Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));
  588. Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));
  589. Info(slide, 0, ((char *)slide, LoadFarString(ZipFSizeVerbose),
  590. FmZofft(G.ziplen, "11", NULL),
  591. FmZofft(G.ziplen, FZOFFT_HEX_DOT_WID, "X")));
  592. Info(slide, 0, ((char *)slide, LoadFarString(ActOffsetCentDir),
  593. FmZofft(G.real_ecrec_offset, "11", "u"),
  594. FmZofft(G.real_ecrec_offset, FZOFFT_HEX_DOT_WID, "X"),
  595. FmZofft(G.expect_ecrec_offset, "11", "u"),
  596. FmZofft(G.expect_ecrec_offset, FZOFFT_HEX_DOT_WID, "X")));
  597. if (G.ecrec.number_this_disk == 0) {
  598. Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive1),
  599. FmZofft(G.ecrec.total_entries_central_dir, NULL, "u"),
  600. (G.ecrec.total_entries_central_dir == 1)? "entry" : "entries",
  601. FmZofft(G.ecrec.size_central_directory, NULL, "u"),
  602. FmZofft(G.ecrec.size_central_directory,
  603. FZOFFT_HEX_DOT_WID, "X")));
  604. Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive2),
  605. FmZofft(G.ecrec.offset_start_central_directory, NULL, "u"),
  606. FmZofft(G.ecrec.offset_start_central_directory,
  607. FZOFFT_HEX_DOT_WID, "X")));
  608. } else {
  609. Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive1),
  610. (ulg)(G.ecrec.number_this_disk + 1),
  611. (ulg)(G.ecrec.num_disk_start_cdir + 1)));
  612. Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive2),
  613. FmZofft(G.ecrec.offset_start_central_directory, NULL, "u"),
  614. FmZofft(G.ecrec.offset_start_central_directory,
  615. FZOFFT_HEX_DOT_WID, "X"),
  616. FmZofft(G.ecrec.size_central_directory, NULL, "u"),
  617. FmZofft(G.ecrec.size_central_directory,
  618. FZOFFT_HEX_DOT_WID, "X")));
  619. Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive3),
  620. FmZofft(G.ecrec.num_entries_centrl_dir_ths_disk, NULL, "u"),
  621. (G.ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are",
  622. FmZofft(G.ecrec.total_entries_central_dir, NULL, "u"),
  623. (G.ecrec.total_entries_central_dir == 1) ? "entry" : "entries"));
  624. }
  625. }
  626. else if (uO.hflag) {
  627. /* print zip file size and number of contained entries: */
  628. Info(slide, 0, ((char *)slide, LoadFarString(ZipInfHeader2),
  629. FmZofft(G.ziplen, NULL, NULL),
  630. FmZofft(G.ecrec.total_entries_central_dir, NULL, "u")));
  631. }
  632. } /* end function zi_end_central() */
  633. /************************/
  634. /* Function zipinfo() */
  635. /************************/
  636. int zipinfo(__G) /* return PK-type error code */
  637. __GDEF
  638. {
  639. int do_this_file=FALSE, error, error_in_archive=PK_COOL;
  640. int *fn_matched=NULL, *xn_matched=NULL;
  641. ulg j, members=0L;
  642. zusz_t tot_csize=0L, tot_ucsize=0L;
  643. zusz_t endprev; /* buffers end of previous entry for zi_long()'s check
  644. * of extra bytes */
  645. /*---------------------------------------------------------------------------
  646. Malloc space for check on unmatched filespecs (no big deal if one or both
  647. are NULL).
  648. ---------------------------------------------------------------------------*/
  649. if (G.filespecs > 0 &&
  650. (fn_matched=(int *)malloc(G.filespecs*sizeof(int))) != NULL)
  651. for (j = 0; j < G.filespecs; ++j)
  652. fn_matched[j] = FALSE;
  653. if (G.xfilespecs > 0 &&
  654. (xn_matched=(int *)malloc(G.xfilespecs*sizeof(int))) != NULL)
  655. for (j = 0; j < G.xfilespecs; ++j)
  656. xn_matched[j] = FALSE;
  657. /*---------------------------------------------------------------------------
  658. Set file pointer to start of central directory, then loop through cen-
  659. tral directory entries. Check that directory-entry signature bytes are
  660. actually there (just a precaution), then process the entry. We know
  661. the entire central directory is on this disk: we wouldn't have any of
  662. this information unless the end-of-central-directory record was on this
  663. disk, and we wouldn't have gotten to this routine unless this is also
  664. the disk on which the central directory starts. In practice, this had
  665. better be the *only* disk in the archive, but maybe someday we'll add
  666. multi-disk support.
  667. ---------------------------------------------------------------------------*/
  668. uO.L_flag = FALSE; /* zipinfo mode: never convert name to lowercase */
  669. G.pInfo = G.info; /* (re-)initialize, (just to make sure) */
  670. G.pInfo->textmode = 0; /* so one can read on screen (is this ever used?) */
  671. /* reset endprev for new zipfile; account for multi-part archives (?) */
  672. endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;
  673. for (j = 1L;; j++) {
  674. if (readbuf(__G__ G.sig, 4) == 0) {
  675. error_in_archive = PK_EOF;
  676. break;
  677. }
  678. if (memcmp(G.sig, central_hdr_sig, 4)) { /* is it a CentDir entry? */
  679. /* no new central directory entry
  680. * -> is the number of processed entries compatible with the
  681. * number of entries as stored in the end_central record?
  682. */
  683. if (((j - 1) &
  684. (ulg)(G.ecrec.have_ecr64 ? MASK_ZUCN64 : MASK_ZUCN16))
  685. == (ulg)G.ecrec.total_entries_central_dir)
  686. {
  687. /* "j modulus 4T/64k" matches the reported 64/16-bit-unsigned
  688. * number of directory entries -> probably, the regular
  689. * end of the central directory has been reached
  690. */
  691. break;
  692. } else {
  693. Info(slide, 0x401,
  694. ((char *)slide, LoadFarString(CentSigMsg), j));
  695. Info(slide, 0x401,
  696. ((char *)slide, LoadFarString(ReportMsg)));
  697. error_in_archive = PK_BADERR; /* sig not found */
  698. break;
  699. }
  700. }
  701. /* process_cdir_file_hdr() sets pInfo->hostnum, pInfo->lcflag, ...: */
  702. if ((error = process_cdir_file_hdr(__G)) != PK_COOL) {
  703. error_in_archive = error; /* only PK_EOF defined */
  704. break;
  705. }
  706. if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
  707. PK_COOL)
  708. {
  709. if (error > error_in_archive)
  710. error_in_archive = error;
  711. if (error > PK_WARN) /* fatal */
  712. break;
  713. }
  714. if (!G.process_all_files) { /* check if specified on command line */
  715. unsigned i;
  716. if (G.filespecs == 0)
  717. do_this_file = TRUE;
  718. else { /* check if this entry matches an `include' argument */
  719. do_this_file = FALSE;
  720. for (i = 0; i < G.filespecs; i++)
  721. if (match(G.filename, G.pfnames[i], uO.C_flag WISEP)) {
  722. do_this_file = TRUE;
  723. if (fn_matched)
  724. fn_matched[i] = TRUE;
  725. break; /* found match, so stop looping */
  726. }
  727. }
  728. if (do_this_file) { /* check if this is an excluded file */
  729. for (i = 0; i < G.xfilespecs; i++)
  730. if (match(G.filename, G.pxnames[i], uO.C_flag WISEP)) {
  731. do_this_file = FALSE; /* ^-- ignore case in match */
  732. if (xn_matched)
  733. xn_matched[i] = TRUE;
  734. break;
  735. }
  736. }
  737. }
  738. /*-----------------------------------------------------------------------
  739. If current file was specified on command line, or if no names were
  740. specified, do the listing for this file. Otherwise, get rid of the
  741. file comment and go back for the next file.
  742. -----------------------------------------------------------------------*/
  743. if (G.process_all_files || do_this_file) {
  744. /* Read the extra field, if any. The extra field info is required
  745. * for resolving the Zip64 sizes/offsets and may be used in more
  746. * analysis of the entry below.
  747. */
  748. if ((error = do_string(__G__ G.crec.extra_field_length,
  749. EXTRA_FIELD)) != 0)
  750. {
  751. if (G.extra_field != NULL) {
  752. free(G.extra_field);
  753. G.extra_field = NULL;
  754. }
  755. error_in_archive = error;
  756. /* The premature return in case of a "fatal" error (PK_EOF) is
  757. * delayed until we analyze the extra field contents.
  758. * This allows us to display all the other info that has been
  759. * successfully read in.
  760. */
  761. }
  762. switch (uO.lflag) {
  763. case 1:
  764. case 2:
  765. fnprint(__G);
  766. SKIP_(G.crec.file_comment_length)
  767. break;
  768. case 3:
  769. case 4:
  770. case 5:
  771. if ((error = zi_short(__G)) != PK_COOL) {
  772. error_in_archive = error; /* might be warning */
  773. }
  774. break;
  775. case 10:
  776. Info(slide, 0, ((char *)slide,
  777. LoadFarString(CentralDirEntry), j));
  778. if ((error = zi_long(__G__ &endprev,
  779. error_in_archive)) != PK_COOL) {
  780. error_in_archive = error; /* might be warning */
  781. }
  782. break;
  783. default:
  784. SKIP_(G.crec.file_comment_length)
  785. break;
  786. } /* end switch (lflag) */
  787. if (error > PK_WARN) /* fatal */
  788. break;
  789. tot_csize += G.crec.csize;
  790. tot_ucsize += G.crec.ucsize;
  791. if (G.crec.general_purpose_bit_flag & 1)
  792. tot_csize -= 12; /* don't count encryption header */
  793. ++members;
  794. #ifdef DLL
  795. if ((G.statreportcb != NULL) &&
  796. (*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,
  797. G.filename, (zvoid *)&G.crec.ucsize)) {
  798. /* cancel operation by user request */
  799. error_in_archive = IZ_CTRLC;
  800. break;
  801. }
  802. #endif
  803. #ifdef MACOS /* MacOS is no preemptive OS, thus call event-handling by hand */
  804. UserStop();
  805. #endif
  806. } else { /* not listing this file */
  807. SKIP_(G.crec.extra_field_length)
  808. SKIP_(G.crec.file_comment_length)
  809. if (endprev != 0) endprev = 0;
  810. } /* end if (list member?) */
  811. } /* end for-loop (j: member files) */
  812. /*---------------------------------------------------------------------------
  813. Check that we actually found requested files; if so, print totals.
  814. ---------------------------------------------------------------------------*/
  815. if ((error_in_archive <= PK_WARN) && uO.tflag) {
  816. char *sgn = "";
  817. int cfactor = ratio(tot_ucsize, tot_csize);
  818. if (cfactor < 0) {
  819. sgn = "-";
  820. cfactor = -cfactor;
  821. }
  822. Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),
  823. members, (members==1L)? nullStr:PlurSufx,
  824. FmZofft(tot_ucsize, NULL, "u"),
  825. FmZofft(tot_csize, NULL, "u"),
  826. sgn, cfactor/10, cfactor%10));
  827. }
  828. /*---------------------------------------------------------------------------
  829. Check for unmatched filespecs on command line and print warning if any
  830. found.
  831. ---------------------------------------------------------------------------*/
  832. if (fn_matched) {
  833. if (error_in_archive <= PK_WARN)
  834. for (j = 0; j < G.filespecs; ++j)
  835. if (!fn_matched[j])
  836. Info(slide, 0x401, ((char *)slide,
  837. LoadFarString(FilenameNotMatched), G.pfnames[j]));
  838. free((zvoid *)fn_matched);
  839. }
  840. if (xn_matched) {
  841. if (error_in_archive <= PK_WARN)
  842. for (j = 0; j < G.xfilespecs; ++j)
  843. if (!xn_matched[j])
  844. Info(slide, 0x401, ((char *)slide,
  845. LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));
  846. free((zvoid *)xn_matched);
  847. }
  848. /* Skip the following checks in case of a premature listing break. */
  849. if (error_in_archive <= PK_WARN) {
  850. /*---------------------------------------------------------------------------
  851. Double check that we're back at the end-of-central-directory record.
  852. ---------------------------------------------------------------------------*/
  853. if ( (memcmp(G.sig,
  854. (G.ecrec.have_ecr64 ?
  855. end_central64_sig : end_central_sig),
  856. 4) != 0)
  857. && (!G.ecrec.is_zip64_archive)
  858. && (memcmp(G.sig, end_central_sig, 4) != 0)
  859. ) { /* just to make sure again */
  860. Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
  861. error_in_archive = PK_WARN; /* didn't find sig */
  862. }
  863. /* Set specific return code when no files have been found. */
  864. if (members == 0L && error_in_archive <= PK_WARN)
  865. error_in_archive = PK_FIND;
  866. if (uO.lflag >= 10)
  867. (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
  868. }
  869. return error_in_archive;
  870. } /* end function zipinfo() */
  871. /************************/
  872. /* Function zi_long() */
  873. /************************/
  874. static int zi_long(__G__ pEndprev, error_in_archive)
  875. /* return PK-type error code */
  876. __GDEF
  877. zusz_t *pEndprev; /* for zi_long() check of extra bytes */
  878. int error_in_archive; /* may signal premature return */
  879. {
  880. #ifdef USE_EF_UT_TIME
  881. iztimes z_utime;
  882. #endif
  883. int error;
  884. unsigned hostnum, hostver, extnum, extver, methid, methnum, xattr;
  885. char workspace[12], attribs[22];
  886. ZCONST char *varmsg_str;
  887. char unkn[16];
  888. static ZCONST char Far *os[NUM_HOSTS] = {
  889. OS_FAT, OS_Amiga, OS_VMS, OS_Unix, OS_VMCMS, OS_AtariST, OS_HPFS,
  890. OS_Macintosh, OS_ZSystem, OS_CPM, OS_TOPS20, OS_NTFS, OS_QDOS,
  891. OS_Acorn, OS_VFAT, OS_MVS, OS_BeOS, OS_Tandem, OS_Theos, OS_MacDarwin,
  892. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  893. OS_AtheOS
  894. };
  895. static ZCONST char Far *method[NUM_METHODS] = {
  896. MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
  897. MthdImplode, MthdToken, MthdDeflate, MthdDeflat64, MthdDCLImplode,
  898. MthdBZip2, MthdLZMA, MthdTerse, MthdLZ77, MthdWavPack, MthdPPMd
  899. };
  900. static ZCONST char Far *dtypelng[4] = {
  901. DeflNorm, DeflMax, DeflFast, DeflSFast
  902. };
  903. /*---------------------------------------------------------------------------
  904. Check whether there's any extra space inside the zipfile. If *pEndprev is
  905. zero, it's probably a signal that OS/2 extra fields are involved (with
  906. unknown compressed size). We won't worry about prepended junk here...
  907. ---------------------------------------------------------------------------*/
  908. if (G.crec.relative_offset_local_header != *pEndprev && *pEndprev > 0L) {
  909. /* GRR DEBUG
  910. Info(slide, 0, ((char *)slide,
  911. " [crec.relative_offset_local_header = %lu, endprev = %lu]\n",
  912. G.crec.relative_offset_local_header, *pEndprev));
  913. */
  914. Info(slide, 0, ((char *)slide, LoadFarString(ExtraBytesPreceding),
  915. FmZofft((G.crec.relative_offset_local_header - (*pEndprev)),
  916. NULL, NULL)));
  917. }
  918. /* calculate endprev for next time around (problem: extra fields may
  919. * differ in length between local and central-directory records) */
  920. *pEndprev = G.crec.relative_offset_local_header + (4L + LREC_SIZE) +
  921. G.crec.filename_length + G.crec.extra_field_length + G.crec.csize;
  922. /*---------------------------------------------------------------------------
  923. Print out various interesting things about the compressed file.
  924. ---------------------------------------------------------------------------*/
  925. hostnum = (unsigned)(G.pInfo->hostnum);
  926. hostver = (unsigned)(G.pInfo->hostver);
  927. extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
  928. extver = (unsigned)G.crec.version_needed_to_extract[0];
  929. methid = (unsigned)G.crec.compression_method;
  930. methnum = find_compr_idx(G.crec.compression_method);
  931. (*G.message)((zvoid *)&G, (uch *)" ", 2L, 0); fnprint(__G);
  932. Info(slide, 0, ((char *)slide, LoadFarString(LocalHeaderOffset),
  933. FmZofft(G.crec.relative_offset_local_header, NULL, "u"),
  934. FmZofft(G.crec.relative_offset_local_header, FZOFFT_HEX_DOT_WID, "X")));
  935. if (hostnum >= NUM_HOSTS) {
  936. sprintf(unkn, LoadFarString(UnknownNo),
  937. (int)G.crec.version_made_by[1]);
  938. varmsg_str = unkn;
  939. } else {
  940. varmsg_str = LoadFarStringSmall(os[hostnum]);
  941. #ifdef OLD_THEOS_EXTRA
  942. if (hostnum == FS_VFAT_ && hostver == 20) {
  943. /* entry made by old non-official THEOS port zip archive */
  944. varmsg_str = LoadFarStringSmall(OS_TheosOld);
  945. }
  946. #endif /* OLD_THEOS_EXTRA */
  947. }
  948. Info(slide, 0, ((char *)slide, LoadFarString(HostOS), varmsg_str));
  949. Info(slide, 0, ((char *)slide, LoadFarString(EncodeSWVer), hostver/10,
  950. hostver%10));
  951. if ((extnum >= NUM_HOSTS) || (os[extnum] == NULL)) {
  952. sprintf(unkn, LoadFarString(UnknownNo),
  953. (int)G.crec.version_needed_to_extract[1]);
  954. varmsg_str = unkn;
  955. } else {
  956. varmsg_str = LoadFarStringSmall(os[extnum]);
  957. }
  958. Info(slide, 0, ((char *)slide, LoadFarString(MinOSCompReq), varmsg_str));
  959. Info(slide, 0, ((char *)slide, LoadFarString(MinSWVerReq), extver/10,
  960. extver%10));
  961. if (methnum >= NUM_METHODS) {
  962. sprintf(unkn, LoadFarString(UnknownNo), G.crec.compression_method);
  963. varmsg_str = unkn;
  964. } else {
  965. varmsg_str = LoadFarStringSmall(method[methnum]);
  966. }
  967. Info(slide, 0, ((char *)slide, LoadFarString(CompressMethod), varmsg_str));
  968. if (methid == IMPLODED) {
  969. Info(slide, 0, ((char *)slide, LoadFarString(SlideWindowSizeImplode),
  970. (G.crec.general_purpose_bit_flag & 2)? '8' : '4'));
  971. Info(slide, 0, ((char *)slide, LoadFarString(ShannonFanoTrees),
  972. (G.crec.general_purpose_bit_flag & 4)? '3' : '2'));
  973. } else if (methid == DEFLATED || methid == ENHDEFLATED) {
  974. ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
  975. Info(slide, 0, ((char *)slide, LoadFarString(CompressSubtype),
  976. LoadFarStringSmall(dtypelng[dnum])));
  977. }
  978. Info(slide, 0, ((char *)slide, LoadFarString(FileSecurity),
  979. (G.crec.general_purpose_bit_flag & 1) ? nullStr : "not "));
  980. Info(slide, 0, ((char *)slide, LoadFarString(ExtendedLocalHdr),
  981. (G.crec.general_purpose_bit_flag & 8) ? "yes" : "no"));
  982. /* print upper 3 bits for amusement? */
  983. /* For printing of date & time, a "char d_t_buf[21]" is required.
  984. * To save stack space, we reuse the "char attribs[22]" buffer which
  985. * is not used yet.
  986. */
  987. # define d_t_buf attribs
  988. zi_time(__G__ &G.crec.last_mod_dos_datetime, NULL, d_t_buf);
  989. Info(slide, 0, ((char *)slide, LoadFarString(FileModDate), d_t_buf));
  990. #ifdef USE_EF_UT_TIME
  991. if (G.extra_field &&
  992. #ifdef IZ_CHECK_TZ
  993. G.tz_is_valid &&
  994. #endif
  995. (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
  996. G.crec.last_mod_dos_datetime, &z_utime, NULL)
  997. & EB_UT_FL_MTIME))
  998. {
  999. TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0 or Macintosh */
  1000. d_t_buf[0] = (char)0; /* signal "show local time" */
  1001. zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
  1002. Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
  1003. d_t_buf, LoadFarStringSmall(LocalTime)));
  1004. #ifndef NO_GMTIME
  1005. d_t_buf[0] = (char)1; /* signal "show UTC (GMT) time" */
  1006. zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
  1007. Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
  1008. d_t_buf, LoadFarStringSmall(GMTime)));
  1009. #endif /* !NO_GMTIME */
  1010. }
  1011. #endif /* USE_EF_UT_TIME */
  1012. Info(slide, 0, ((char *)slide, LoadFarString(CRC32Value), G.crec.crc32));
  1013. Info(slide, 0, ((char *)slide, LoadFarString(CompressedFileSize),
  1014. FmZofft(G.crec.csize, NULL, "u")));
  1015. Info(slide, 0, ((char *)slide, LoadFarString(UncompressedFileSize),
  1016. FmZofft(G.crec.ucsize, NULL, "u")));
  1017. Info(slide, 0, ((char *)slide, LoadFarString(FilenameLength),
  1018. G.crec.filename_length));
  1019. Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldLength),
  1020. G.crec.extra_field_length));
  1021. Info(slide, 0, ((char *)slide, LoadFarString(FileCommentLength),
  1022. G.crec.file_comment_length));
  1023. Info(slide, 0, ((char *)slide, LoadFarString(FileDiskNum),
  1024. (ulg)(G.crec.disk_number_start + 1)));
  1025. Info(slide, 0, ((char *)slide, LoadFarString(ApparentFileType),
  1026. (G.crec.internal_file_attributes & 1)? "text"
  1027. : (G.crec.internal_file_attributes & 2)? "ebcdic"
  1028. : "binary")); /* changed to accept EBCDIC */
  1029. #ifdef ATARI
  1030. printf(" external file attributes (hex): %.8lx\n",
  1031. G.crec.external_file_attributes);
  1032. #endif
  1033. xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
  1034. if (hostnum == VMS_) {
  1035. char *p=attribs, *q=attribs+1;
  1036. int i, j, k;
  1037. for (k = 0; k < 12; ++k)
  1038. workspace[k] = 0;
  1039. if (xattr & VMS_IRUSR)
  1040. workspace[0] = 'R';
  1041. if (xattr & VMS_IWUSR) {
  1042. workspace[1] = 'W';
  1043. workspace[3] = 'D';
  1044. }
  1045. if (xattr & VMS_IXUSR)
  1046. workspace[2] = 'E';
  1047. if (xattr & VMS_IRGRP)
  1048. workspace[4] = 'R';
  1049. if (xattr & VMS_IWGRP) {
  1050. workspace[5] = 'W';
  1051. workspace[7] = 'D';
  1052. }
  1053. if (xattr & VMS_IXGRP)
  1054. workspace[6] = 'E';
  1055. if (xattr & VMS_IROTH)
  1056. workspace[8] = 'R';
  1057. if (xattr & VMS_IWOTH) {
  1058. workspace[9] = 'W';
  1059. workspace[11] = 'D';
  1060. }
  1061. if (xattr & VMS_IXOTH)
  1062. workspace[10] = 'E';
  1063. *p++ = '(';
  1064. for (k = j = 0; j < 3; ++j) { /* loop over groups of permissions */
  1065. for (i = 0; i < 4; ++i, ++k) /* loop over perms within a group */
  1066. if (workspace[k])
  1067. *p++ = workspace[k];
  1068. *p++ = ','; /* group separator */
  1069. if (j == 0)
  1070. while ((*p++ = *q++) != ',')
  1071. ; /* system, owner perms are same */
  1072. }
  1073. *p-- = '\0';
  1074. *p = ')'; /* overwrite last comma */
  1075. Info(slide, 0, ((char *)slide, LoadFarString(VMSFileAttributes), xattr,
  1076. attribs));
  1077. } else if (hostnum == AMIGA_) {
  1078. switch (xattr & AMI_IFMT) {
  1079. case AMI_IFDIR: attribs[0] = 'd'; break;
  1080. case AMI_IFREG: attribs[0] = '-'; break;
  1081. default: attribs[0] = '?'; break;
  1082. }
  1083. attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
  1084. attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
  1085. attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
  1086. attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
  1087. attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
  1088. attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
  1089. attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
  1090. attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
  1091. attribs[9] = 0; /* better dlm the string */
  1092. Info(slide, 0, ((char *)slide, LoadFarString(AmigaFileAttributes),
  1093. xattr, attribs));
  1094. } else if (hostnum == THEOS_) {
  1095. ZCONST char Far *fpFtyp;
  1096. switch (xattr & THS_IFMT) {
  1097. case THS_IFLIB: fpFtyp = TheosFTypLib; break;
  1098. case THS_IFDIR: fpFtyp = TheosFTypDir; break;
  1099. case THS_IFREG: fpFtyp = TheosFTypReg; break;
  1100. case THS_IFREL: fpFtyp = TheosFTypRel; break;
  1101. case THS_IFKEY: fpFtyp = TheosFTypKey; break;
  1102. case THS_IFIND: fpFtyp = TheosFTypInd; break;
  1103. case THS_IFR16: fpFtyp = TheosFTypR16; break;
  1104. case THS_IFP16: fpFtyp = TheosFTypP16; break;
  1105. case THS_IFP32: fpFtyp = TheosFTypP32; break;
  1106. default: fpFtyp = TheosFTypUkn; break;
  1107. }
  1108. strcpy(attribs, LoadFarStringSmall(fpFtyp));
  1109. attribs[12] = (xattr & THS_INHID) ? '.' : 'H';
  1110. attribs[13] = (xattr & THS_IMODF) ? '.' : 'M';
  1111. attribs[14] = (xattr & THS_IWOTH) ? '.' : 'W';
  1112. attribs[15] = (xattr & THS_IROTH) ? '.' : 'R';
  1113. attribs[16] = (xattr & THS_IEUSR) ? '.' : 'E';
  1114. attribs[17] = (xattr & THS_IXUSR) ? '.' : 'X';
  1115. attribs[18] = (xattr & THS_IWUSR) ? '.' : 'W';
  1116. attribs[19] = (xattr & THS_IRUSR) ? '.' : 'R';
  1117. attribs[20] = 0;
  1118. Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
  1119. xattr, attribs));
  1120. #ifdef OLD_THEOS_EXTRA
  1121. } else if (hostnum == FS_VFAT_ && hostver == 20) {
  1122. /* process old non-official THEOS port zip archive */
  1123. ZCONST char Far *fpFtyp;
  1124. switch (xattr & _THS_IFMT) {
  1125. case _THS_IFLIB: fpFtyp = TheosFTypLib; break;
  1126. case _THS_IFDIR: fpFtyp = TheosFTypDir; break;
  1127. case _THS_IFREG: fpFtyp = TheosFTypReg; break;
  1128. case _THS_IODRC: fpFtyp = TheosFTypRel; break;
  1129. case _THS_IOKEY: fpFtyp = TheosFTypKey; break;
  1130. case _THS_IOIND: fpFtyp = TheosFTypInd; break;
  1131. case _THS_IOPRG: fpFtyp = TheosFTypR16; break;
  1132. case _THS_IO286: fpFtyp = TheosFTypP16; break;
  1133. case _THS_IO386: fpFtyp = TheosFTypP32; break;
  1134. default: fpFtyp = TheosFTypUkn; break;
  1135. }
  1136. strcpy(attribs, LoadFarStringSmall(fpFtyp));
  1137. attribs[12] = (xattr & _THS_HIDDN) ? 'H' : '.';
  1138. attribs[13] = (xattr & _THS_IXOTH) ? '.' : 'X';
  1139. attribs[14] = (xattr & _THS_IWOTH) ? '.' : 'W';
  1140. attribs[15] = (xattr & _THS_IROTH) ? '.' : 'R';
  1141. attribs[16] = (xattr & _THS_IEUSR) ? '.' : 'E';
  1142. attribs[17] = (xattr & _THS_IXUSR) ? '.' : 'X';
  1143. attribs[18] = (xattr & _THS_IWUSR) ? '.' : 'W';
  1144. attribs[19] = (xattr & _THS_IRUSR) ? '.' : 'R';
  1145. attribs[20] = 0;
  1146. Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
  1147. xattr, attribs));
  1148. #endif /* OLD_THEOS_EXTRA */
  1149. } else if ((hostnum != FS_FAT_) && (hostnum != FS_HPFS_) &&
  1150. (hostnum != FS_NTFS_) && (hostnum != FS_VFAT_) &&
  1151. (hostnum != ACORN_) &&
  1152. (hostnum != VM_CMS_) && (hostnum != MVS_))
  1153. { /* assume Unix-like */
  1154. switch ((unsigned)(xattr & UNX_IFMT)) {
  1155. case (unsigned)UNX_IFDIR: attribs[0] = 'd'; break;
  1156. case (unsigned)UNX_IFREG: attribs[0] = '-'; break;
  1157. case (unsigned)UNX_IFLNK: attribs[0] = 'l'; break;
  1158. case (unsigned)UNX_IFBLK: attribs[0] = 'b'; break;
  1159. case (unsigned)UNX_IFCHR: attribs[0] = 'c'; break;
  1160. case (unsigned)UNX_IFIFO: attribs[0] = 'p'; break;
  1161. case (unsigned)UNX_IFSOCK: attribs[0] = 's'; break;
  1162. default: attribs[0] = '?'; break;
  1163. }
  1164. attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
  1165. attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
  1166. attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
  1167. attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
  1168. attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
  1169. attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
  1170. if (xattr & UNX_IXUSR)
  1171. attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
  1172. else
  1173. attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S = undefined */
  1174. if (xattr & UNX_IXGRP)
  1175. attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
  1176. else
  1177. attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
  1178. if (xattr & UNX_IXOTH)
  1179. attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x'; /* "sticky bit" */
  1180. else
  1181. attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T = undefined */
  1182. attribs[10] = 0;
  1183. Info(slide, 0, ((char *)slide, LoadFarString(UnixFileAttributes), xattr,
  1184. attribs));
  1185. } else {
  1186. Info(slide, 0, ((char *)slide, LoadFarString(NonMSDOSFileAttributes),
  1187. G.crec.external_file_attributes >> 8));
  1188. } /* endif (hostnum: external attributes format) */
  1189. if ((xattr=(unsigned)(G.crec.external_file_attributes & 0xFF)) == 0)
  1190. Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributes),
  1191. xattr));
  1192. else if (xattr == 1)
  1193. Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesRO),
  1194. xattr));
  1195. else
  1196. Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesAlpha),
  1197. xattr, (xattr&1)? "rdo " : nullStr,
  1198. (xattr&2)? "hid " : nullStr,
  1199. (xattr&4)? "sys " : nullStr,
  1200. (xattr&8)? "lab " : nullStr,
  1201. (xattr&16)? "dir " : nullStr,
  1202. (xattr&32)? "arc " : nullStr,
  1203. (xattr&64)? "lnk " : nullStr,
  1204. (xattr&128)? "exe" : nullStr));
  1205. /*---------------------------------------------------------------------------
  1206. Analyze the extra field, if any, and print the file comment, if any (the
  1207. filename has already been printed, above). That finishes up this file
  1208. entry...
  1209. ---------------------------------------------------------------------------*/
  1210. if (G.crec.extra_field_length > 0) {
  1211. uch *ef_ptr = G.extra_field;
  1212. ush ef_len = G.crec.extra_field_length;
  1213. ush eb_id, eb_datalen;
  1214. ZCONST char Far *ef_fieldname;
  1215. if (error_in_archive > PK_WARN) /* fatal: can't continue */
  1216. /* delayed "fatal error" return from extra field reading */
  1217. return error_in_archive;
  1218. if (G.extra_field == (uch *)NULL)
  1219. return PK_ERR; /* not consistent with crec length */
  1220. Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields)));
  1221. while (ef_len >= EB_HEADSIZE) {
  1222. eb_id = makeword(&ef_ptr[EB_ID]);
  1223. eb_datalen = makeword(&ef_ptr[EB_LEN]);
  1224. ef_ptr += EB_HEADSIZE;
  1225. ef_len -= EB_HEADSIZE;
  1226. if (eb_datalen > (ush)ef_len) {
  1227. Info(slide, 0x421, ((char *)slide,
  1228. LoadFarString(ExtraFieldTrunc), eb_id, eb_datalen, ef_len));
  1229. eb_datalen = ef_len;
  1230. }
  1231. switch (eb_id) {
  1232. case EF_PKSZ64:
  1233. ef_fieldname = efPKSZ64;
  1234. if ((G.crec.relative_offset_local_header
  1235. & (~(zusz_t)0xFFFFFFFFL)) != 0) {
  1236. /* Subtract the size of the 64bit local offset from
  1237. the local e.f. size, local Z64 e.f. block has no
  1238. offset; when only local offset present, the entire
  1239. local PKSZ64 block is missing. */
  1240. *pEndprev -= (eb_datalen == 8 ? 12 : 8);
  1241. }
  1242. break;
  1243. case EF_AV:
  1244. ef_fieldname = efAV;
  1245. break;
  1246. case EF_OS2:
  1247. ef_fieldname = efOS2;
  1248. break;
  1249. case EF_ACL:
  1250. ef_fieldname = efACL;
  1251. break;
  1252. case EF_NTSD:
  1253. ef_fieldname = efNTSD;
  1254. break;
  1255. case EF_PKVMS:
  1256. ef_fieldname = efPKVMS;
  1257. break;
  1258. case EF_IZVMS:
  1259. ef_fieldname = efIZVMS;
  1260. break;
  1261. case EF_PKW32:
  1262. ef_fieldname = efPKWin32;
  1263. break;
  1264. case EF_PKUNIX:
  1265. ef_fieldname = efPKUnix;
  1266. break;
  1267. case EF_IZUNIX:
  1268. ef_fieldname = efIZUnix;
  1269. if (hostnum == UNIX_ && *pEndprev > 0L)
  1270. *pEndprev += 4L; /* also have UID/GID in local copy */
  1271. break;
  1272. case EF_IZUNIX2:
  1273. ef_fieldname = efIZUnix2;
  1274. if (*pEndprev > 0L)
  1275. *pEndprev += 4L; /* 4 byte UID/GID in local copy */
  1276. break;
  1277. case EF_IZUNIX3:
  1278. ef_fieldname = efIZUnix3;
  1279. #if 0
  1280. if (*pEndprev > 0L)
  1281. *pEndprev += 4L; /* 4 byte UID/GID in local copy */
  1282. #endif
  1283. break;
  1284. case EF_TIME:
  1285. ef_fieldname = efTime;
  1286. break;
  1287. case EF_UNIPATH:
  1288. ef_fieldname = efU8Path;
  1289. break;
  1290. case EF_UNICOMNT:
  1291. ef_fieldname = efU8Commnt;
  1292. break;
  1293. case EF_MAC3:
  1294. ef_fieldname = efMac3;
  1295. break;
  1296. case EF_JLMAC:
  1297. ef_fieldname = efJLMac;
  1298. break;
  1299. case EF_ZIPIT:
  1300. ef_fieldname = efZipIt;
  1301. break;
  1302. case EF_ZIPIT2:
  1303. ef_fieldname = efZipIt2;
  1304. break;
  1305. case EF_VMCMS:
  1306. ef_fieldname = efVMCMS;
  1307. break;
  1308. case EF_MVS:
  1309. ef_fieldname = efMVS;
  1310. break;
  1311. case EF_ATHEOS:
  1312. ef_fieldname = efAtheOS;
  1313. break;
  1314. case EF_BEOS:
  1315. ef_fieldname = efBeOS;
  1316. break;
  1317. case EF_QDOS:
  1318. ef_fieldname = efQDOS;
  1319. break;
  1320. case EF_AOSVS:
  1321. ef_fieldname = efAOSVS;
  1322. break;
  1323. case EF_SPARK: /* from RISC OS */
  1324. ef_fieldname = efSpark;
  1325. break;
  1326. case EF_MD5:
  1327. ef_fieldname = efMD5;
  1328. break;
  1329. case EF_ASIUNIX:
  1330. ef_fieldname = efASiUnix;
  1331. break;
  1332. case EF_TANDEM:
  1333. ef_fieldname = efTandem;
  1334. break;
  1335. case EF_SMARTZIP:
  1336. ef_fieldname = efSmartZip;
  1337. break;
  1338. case EF_THEOS:
  1339. #ifdef OLD_THEOS_EXTRA
  1340. case EF_THEOSO:
  1341. #endif
  1342. ef_fieldname = efTheos;
  1343. break;
  1344. default:
  1345. ef_fieldname = efUnknown;
  1346. break;
  1347. }
  1348. Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1349. eb_id, LoadFarStringSmall(ef_fieldname), eb_datalen));
  1350. /* additional, field-specific information: */
  1351. switch (eb_id) {
  1352. case EF_OS2:
  1353. case EF_ACL:
  1354. if (eb_datalen >= EB_OS2_HLEN) {
  1355. if (eb_id == EF_OS2)
  1356. ef_fieldname = OS2EAs;
  1357. else
  1358. ef_fieldname = ACLdata;
  1359. Info(slide, 0, ((char *)slide,
  1360. LoadFarString(ef_fieldname), makelong(ef_ptr)));
  1361. *pEndprev = 0L; /* no clue about csize of local */
  1362. } else {
  1363. goto ef_default_display;
  1364. }
  1365. break;
  1366. case EF_NTSD:
  1367. if (eb_datalen >= EB_NTSD_C_LEN) {
  1368. Info(slide, 0, ((char *)slide, LoadFarString(NTSDData),
  1369. makelong(ef_ptr)));
  1370. *pEndprev = 0L; /* no clue about csize of local */
  1371. } else {
  1372. goto ef_default_display;
  1373. }
  1374. break;
  1375. case EF_IZVMS:
  1376. if (eb_datalen >= 8) {
  1377. char *p, q[8];
  1378. unsigned compr = makeword(ef_ptr+EB_IZVMS_FLGS)
  1379. & EB_IZVMS_BCMASK;
  1380. *q = '\0';
  1381. if (compr > 3)
  1382. compr = 3;
  1383. switch (makelong(ef_ptr)) {
  1384. case 0x42414656: /* "VFAB" */
  1385. p = "FAB"; break;
  1386. case 0x4C4C4156: /* "VALL" */
  1387. p = "XABALL"; break;
  1388. case 0x43484656: /* "VFHC" */
  1389. p = "XABFHC"; break;
  1390. case 0x54414456: /* "VDAT" */
  1391. p = "XABDAT"; break;
  1392. case 0x54445256: /* "VRDT" */
  1393. p = "XABRDT"; break;
  1394. case 0x4F525056: /* "VPRO" */
  1395. p = "XABPRO"; break;
  1396. case 0x59454B56: /* "VKEY" */
  1397. p = "XABKEY"; break;
  1398. case 0x56534D56: /* "VMSV" */
  1399. p = "version";
  1400. if (eb_datalen >= 16) {
  1401. /* put termitation first, for A_TO_N() */
  1402. q[7] = '\0';
  1403. q[0] = ' ';
  1404. q[1] = '(';
  1405. strncpy(q+2,
  1406. (char *)ef_ptr+EB_IZVMS_HLEN, 4);
  1407. A_TO_N(q+2);
  1408. q[6] = ')';
  1409. }
  1410. break;
  1411. default:
  1412. p = "unknown";
  1413. }
  1414. Info(slide, 0, ((char *)slide,
  1415. LoadFarString(izVMSdata),
  1416. LoadFarStringSmall(izVMScomp[compr]),
  1417. makeword(ef_ptr+EB_IZVMS_UCSIZ), p, q));
  1418. } else {
  1419. goto ef_default_display;
  1420. }
  1421. break;
  1422. case EF_TIME:
  1423. if (eb_datalen > 0) {
  1424. char types[80];
  1425. int num = 0, len;
  1426. *types = '\0';
  1427. if (*ef_ptr & 1) {
  1428. strcpy(types, LoadFarString(UTmodification));
  1429. ++num;
  1430. }
  1431. if (*ef_ptr & 2) {
  1432. len = strlen(types);
  1433. if (num)
  1434. types[len++] = '/';
  1435. strcpy(types+len, LoadFarString(UTaccess));
  1436. ++num;
  1437. if (*pEndprev > 0L)
  1438. *pEndprev += 4L;
  1439. }
  1440. if (*ef_ptr & 4) {
  1441. len = strlen(types);
  1442. if (num)
  1443. types[len++] = '/';
  1444. strcpy(types+len, LoadFarString(UTcreation));
  1445. ++num;
  1446. if (*pEndprev > 0L)
  1447. *pEndprev += 4L;
  1448. }
  1449. if (num > 0)
  1450. Info(slide, 0, ((char *)slide,
  1451. LoadFarString(UTdata), types,
  1452. num == 1? nullStr : PlurSufx));
  1453. }
  1454. break;
  1455. case EF_UNIPATH:
  1456. case EF_UNICOMNT:
  1457. if (eb_datalen >= 5) {
  1458. unsigned i, n;
  1459. ulg name_crc = makelong(ef_ptr+1);
  1460. if (eb_datalen <= 29) {
  1461. Info(slide, 0, ((char *)slide,
  1462. LoadFarString(U8PthCmnComplete),
  1463. (unsigned)ef_ptr[0], name_crc));
  1464. n = eb_datalen;
  1465. } else {
  1466. Info(slide, 0, ((char *)slide,
  1467. LoadFarString(U8PthCmnF24),
  1468. (unsigned)ef_ptr[0], name_crc));
  1469. n = 29;
  1470. }
  1471. for (i = 5; i < n; ++i)
  1472. Info(slide, 0, ((char *)slide,
  1473. LoadFarString(efFormat), ef_ptr[i]));
  1474. } else {
  1475. goto ef_default_display;
  1476. }
  1477. break;
  1478. case EF_MAC3:
  1479. if (eb_datalen >= EB_MAC3_HLEN) {
  1480. ulg eb_uc = makelong(ef_ptr);
  1481. unsigned mac3_flgs = makeword(ef_ptr+EB_FLGS_OFFS);
  1482. unsigned eb_is_uc = mac3_flgs & EB_M3_FL_UNCMPR;
  1483. Info(slide, 0, ((char *)slide, LoadFarString(Mac3data),
  1484. eb_uc, eb_is_uc ? "un" : nullStr));
  1485. if (eb_is_uc) {
  1486. if (*pEndprev > 0L)
  1487. *pEndprev += makelong(ef_ptr);
  1488. } else {
  1489. *pEndprev = 0L; /* no clue about csize of local */
  1490. }
  1491. Info(slide, 0, ((char *)slide,
  1492. LoadFarString(MacOSMAC3flags),
  1493. LoadFarStringSmall(mac3_flgs & EB_M3_FL_DATFRK ?
  1494. MacOS_DF : MacOS_RF),
  1495. (mac3_flgs & EB_M3_FL_TIME64 ? 64 : 32)));
  1496. zi_showMacTypeCreator(__G__ &ef_ptr[6]);
  1497. } else {
  1498. goto ef_default_display;
  1499. }
  1500. break;
  1501. case EF_ZIPIT2:
  1502. if (eb_datalen >= 5 &&
  1503. makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
  1504. if (eb_datalen >= 12) {
  1505. zi_showMacTypeCreator(__G__ &ef_ptr[4]);
  1506. }
  1507. } else {
  1508. goto ef_default_display;
  1509. }
  1510. break;
  1511. case EF_ZIPIT:
  1512. if (eb_datalen >= 5 &&
  1513. makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
  1514. unsigned fnlen = ef_ptr[4];
  1515. if ((unsigned)eb_datalen >= fnlen + (5 + 8)) {
  1516. uch nullchar = ef_ptr[fnlen+5];
  1517. ef_ptr[fnlen+5] = '\0'; /* terminate filename */
  1518. A_TO_N(ef_ptr+5);
  1519. Info(slide, 0, ((char *)slide,
  1520. LoadFarString(ZipItFname), (char *)ef_ptr+5));
  1521. ef_ptr[fnlen+5] = nullchar;
  1522. zi_showMacTypeCreator(__G__ &ef_ptr[fnlen+5]);
  1523. }
  1524. } else {
  1525. goto ef_default_display;
  1526. }
  1527. break;
  1528. case EF_JLMAC:
  1529. if (eb_datalen >= 40 &&
  1530. makelong(ef_ptr) == 0x45454C4A /* "JLEE" */)
  1531. {
  1532. zi_showMacTypeCreator(__G__ &ef_ptr[4]);
  1533. Info(slide, 0, ((char *)slide,
  1534. LoadFarString(MacOSJLEEflags),
  1535. LoadFarStringSmall(ef_ptr[31] & 1 ?
  1536. MacOS_DF : MacOS_RF)));
  1537. } else {
  1538. goto ef_default_display;
  1539. }
  1540. break;
  1541. case EF_SMARTZIP:
  1542. if ((eb_datalen == EB_SMARTZIP_HLEN) &&
  1543. makelong(ef_ptr) == 0x70695A64 /* "dZip" */) {
  1544. char filenameBuf[32];
  1545. zi_showMacTypeCreator(__G__ &ef_ptr[4]);
  1546. memcpy(filenameBuf, &ef_ptr[33], 31);
  1547. filenameBuf[ef_ptr[32]] = '\0';
  1548. A_TO_N(filenameBuf);
  1549. Info(slide, 0, ((char *)slide,
  1550. LoadFarString(ZipItFname), filenameBuf));
  1551. } else {
  1552. goto ef_default_display;
  1553. }
  1554. break;
  1555. #ifdef CMS_MVS
  1556. case EF_VMCMS:
  1557. case EF_MVS:
  1558. {
  1559. char type[100];
  1560. Info(slide, 0, ((char *)slide,
  1561. LoadFarString(VmMvsExtraField),
  1562. (getVMMVSexfield(type, ef_ptr-EB_HEADSIZE,
  1563. (unsigned)eb_datalen) > 0)?
  1564. type : LoadFarStringSmall(VmMvsInvalid)));
  1565. }
  1566. break;
  1567. #endif /* CMS_MVS */
  1568. case EF_ATHEOS:
  1569. case EF_BEOS:
  1570. if (eb_datalen >= EB_BEOS_HLEN) {
  1571. ulg eb_uc = makelong(ef_ptr);
  1572. unsigned eb_is_uc =
  1573. *(ef_ptr+EB_FLGS_OFFS) & EB_BE_FL_UNCMPR;
  1574. if (eb_id == EF_ATHEOS)
  1575. ef_fieldname = AtheOSdata;
  1576. else
  1577. ef_fieldname = BeOSdata;
  1578. Info(slide, 0, ((char *)slide,
  1579. LoadFarString(ef_fieldname),
  1580. eb_uc, eb_is_uc ? "un" : nullStr));
  1581. if (eb_is_uc) {
  1582. if (*pEndprev > 0L)
  1583. *pEndprev += makelong(ef_ptr);
  1584. } else {
  1585. *pEndprev = 0L; /* no clue about csize of local */
  1586. }
  1587. } else {
  1588. goto ef_default_display;
  1589. }
  1590. break;
  1591. case EF_QDOS:
  1592. if (eb_datalen >= 4) {
  1593. Info(slide, 0, ((char *)slide, LoadFarString(QDOSdata),
  1594. ef_ptr[0], ef_ptr[1], ef_ptr[2], ef_ptr[3]));
  1595. } else {
  1596. goto ef_default_display;
  1597. }
  1598. break;
  1599. case EF_AOSVS:
  1600. if (eb_datalen >= 5) {
  1601. Info(slide, 0, ((char *)slide, LoadFarString(AOSVSdata),
  1602. ((int)(uch)ef_ptr[4])/10, ((int)(uch)ef_ptr[4])%10));
  1603. } else {
  1604. goto ef_default_display;
  1605. }
  1606. break;
  1607. case EF_TANDEM:
  1608. if (eb_datalen == 20) {
  1609. unsigned type, code;
  1610. type = (ef_ptr[18] & 0x60) >> 5;
  1611. code = makeword(ef_ptr);
  1612. /* Arrg..., Tandem e.f. uses BigEndian byte-order */
  1613. code = ((code << 8) & 0xff00) | ((code >> 8) & 0x00ff);
  1614. if (type == NSK_UNSTRUCTURED) {
  1615. if (code == NSK_EDITFILECODE)
  1616. type = 4;
  1617. else if (code == NSK_OBJECTFILECODE)
  1618. type = 5;
  1619. }
  1620. Info(slide, 0, ((char *)slide,
  1621. LoadFarString(Tandemdata),
  1622. LoadFarStringSmall(TandemFileformat[type]),
  1623. code));
  1624. } else {
  1625. goto ef_default_display;
  1626. }
  1627. break;
  1628. case EF_MD5:
  1629. if (eb_datalen >= 19) {
  1630. char md5[33];
  1631. int i;
  1632. for (i = 0; i < 16; ++i)
  1633. sprintf(&md5[i<<1], "%02x", ef_ptr[15-i]);
  1634. md5[32] = '\0';
  1635. Info(slide, 0, ((char *)slide, LoadFarString(MD5data),
  1636. md5));
  1637. break;
  1638. } /* else: fall through !! */
  1639. default:
  1640. ef_default_display:
  1641. if (eb_datalen > 0) {
  1642. unsigned i, n;
  1643. if (eb_datalen <= 24) {
  1644. Info(slide, 0, ((char *)slide,
  1645. LoadFarString(ColonIndent)));
  1646. n = eb_datalen;
  1647. } else {
  1648. Info(slide, 0, ((char *)slide,
  1649. LoadFarString(First20)));
  1650. n = 20;
  1651. }
  1652. for (i = 0; i < n; ++i)
  1653. Info(slide, 0, ((char *)slide,
  1654. LoadFarString(efFormat), ef_ptr[i]));
  1655. }
  1656. break;
  1657. }
  1658. (*G.message)((zvoid *)&G, (uch *)".", 1L, 0);
  1659. ef_ptr += eb_datalen;
  1660. ef_len -= eb_datalen;
  1661. }
  1662. (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
  1663. }
  1664. /* high bit == Unix/OS2/NT GMT times (mtime, atime); next bit == UID/GID */
  1665. if ((xattr = (unsigned)((G.crec.external_file_attributes & 0xC000) >> 12))
  1666. & 8)
  1667. {
  1668. if (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)
  1669. {
  1670. Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
  1671. "is", EF_IZUNIX, LoadFarStringSmall(efIZUnix),
  1672. (unsigned)(xattr&12), (xattr&4)? efIZuid : efIZnouid));
  1673. if (*pEndprev > 0L)
  1674. *pEndprev += (ulg)(xattr&12);
  1675. }
  1676. else if (hostnum == FS_FAT_ && !(xattr&4))
  1677. Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
  1678. "may be", EF_IZUNIX, LoadFarStringSmall(efIZUnix), 8,
  1679. efIZnouid));
  1680. }
  1681. if (!G.crec.file_comment_length)
  1682. Info(slide, 0, ((char *)slide, LoadFarString(NoFileComment)));
  1683. else {
  1684. Info(slide, 0, ((char *)slide, LoadFarString(FileCommBegin)));
  1685. if ((error = do_string(__G__ G.crec.file_comment_length, DISPL_8)) !=
  1686. PK_COOL)
  1687. {
  1688. error_in_archive = error; /* might be warning */
  1689. if (error > PK_WARN) /* fatal */
  1690. return error;
  1691. }
  1692. Info(slide, 0, ((char *)slide, LoadFarString(FileCommEnd)));
  1693. }
  1694. return error_in_archive;
  1695. } /* end function zi_long() */
  1696. /*************************/
  1697. /* Function zi_short() */
  1698. /*************************/
  1699. static int zi_short(__G) /* return PK-type error code */
  1700. __GDEF
  1701. {
  1702. #ifdef USE_EF_UT_TIME
  1703. iztimes z_utime;
  1704. time_t *z_modtim;
  1705. #endif
  1706. int k, error, error_in_archive=PK_COOL;
  1707. unsigned hostnum, hostver, methid, methnum, xattr;
  1708. char *p, workspace[12], attribs[16];
  1709. char methbuf[5];
  1710. static ZCONST char dtype[5]="NXFS"; /* normal, maximum, fast, superfast */
  1711. static ZCONST char Far os[NUM_HOSTS+1][4] = {
  1712. "fat", "ami", "vms", "unx", "cms", "atr", "hpf", "mac", "zzz",
  1713. "cpm", "t20", "ntf", "qds", "aco", "vft", "mvs", "be ", "nsk",
  1714. "ths", "osx", "???", "???", "???", "???", "???", "???", "???",
  1715. "???", "???", "???", "ath", "???"
  1716. };
  1717. #ifdef OLD_THEOS_EXTRA
  1718. static ZCONST char Far os_TheosOld[] = "tho";
  1719. #endif
  1720. static ZCONST char Far method[NUM_METHODS+1][5] = {
  1721. "stor", "shrk", "re:1", "re:2", "re:3", "re:4", "i#:#", "tokn",
  1722. "def#", "d64#", "dcli", "bzp2", "lzma", "ters", "lz77", "wavp",
  1723. "ppmd", "u###"
  1724. };
  1725. /*---------------------------------------------------------------------------
  1726. Print out various interesting things about the compressed file.
  1727. ---------------------------------------------------------------------------*/
  1728. methid = (unsigned)(G.crec.compression_method);
  1729. methnum = find_compr_idx(G.crec.compression_method);
  1730. hostnum = (unsigned)(G.pInfo->hostnum);
  1731. hostver = (unsigned)(G.pInfo->hostver);
  1732. /*
  1733. extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
  1734. extver = (unsigned)G.crec.version_needed_to_extract[0];
  1735. */
  1736. zfstrcpy(methbuf, method[methnum]);
  1737. if (methid == IMPLODED) {
  1738. methbuf[1] = (char)((G.crec.general_purpose_bit_flag & 2)? '8' : '4');
  1739. methbuf[3] = (char)((G.crec.general_purpose_bit_flag & 4)? '3' : '2');
  1740. } else if (methid == DEFLATED || methid == ENHDEFLATED) {
  1741. ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
  1742. methbuf[3] = dtype[dnum];
  1743. } else if (methnum >= NUM_METHODS) { /* unknown */
  1744. sprintf(&methbuf[1], "%03u", G.crec.compression_method);
  1745. }
  1746. for (k = 0; k < 15; ++k)
  1747. attribs[k] = ' ';
  1748. attribs[15] = 0;
  1749. xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
  1750. switch (hostnum) {
  1751. case VMS_:
  1752. { int i, j;
  1753. for (k = 0; k < 12; ++k)
  1754. workspace[k] = 0;
  1755. if (xattr & VMS_IRUSR)
  1756. workspace[0] = 'R';
  1757. if (xattr & VMS_IWUSR) {
  1758. workspace[1] = 'W';
  1759. workspace[3] = 'D';
  1760. }
  1761. if (xattr & VMS_IXUSR)
  1762. workspace[2] = 'E';
  1763. if (xattr & VMS_IRGRP)
  1764. workspace[4] = 'R';
  1765. if (xattr & VMS_IWGRP) {
  1766. workspace[5] = 'W';
  1767. workspace[7] = 'D';
  1768. }
  1769. if (xattr & VMS_IXGRP)
  1770. workspace[6] = 'E';
  1771. if (xattr & VMS_IROTH)
  1772. workspace[8] = 'R';
  1773. if (xattr & VMS_IWOTH) {
  1774. workspace[9] = 'W';
  1775. workspace[11] = 'D';
  1776. }
  1777. if (xattr & VMS_IXOTH)
  1778. workspace[10] = 'E';
  1779. p = attribs;
  1780. for (k = j = 0; j < 3; ++j) { /* groups of permissions */
  1781. for (i = 0; i < 4; ++i, ++k) /* perms within a group */
  1782. if (workspace[k])
  1783. *p++ = workspace[k];
  1784. *p++ = ','; /* group separator */
  1785. }
  1786. *--p = ' '; /* overwrite last comma */
  1787. if ((p - attribs) < 12)
  1788. sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
  1789. }
  1790. break;
  1791. case AMIGA_:
  1792. switch (xattr & AMI_IFMT) {
  1793. case AMI_IFDIR: attribs[0] = 'd'; break;
  1794. case AMI_IFREG: attribs[0] = '-'; break;
  1795. default: attribs[0] = '?'; break;
  1796. }
  1797. attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
  1798. attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
  1799. attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
  1800. attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
  1801. attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
  1802. attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
  1803. attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
  1804. attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
  1805. sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
  1806. break;
  1807. case THEOS_:
  1808. switch (xattr & THS_IFMT) {
  1809. case THS_IFLIB: *attribs = 'L'; break;
  1810. case THS_IFDIR: *attribs = 'D'; break;
  1811. case THS_IFCHR: *attribs = 'C'; break;
  1812. case THS_IFREG: *attribs = 'S'; break;
  1813. case THS_IFREL: *attribs = 'R'; break;
  1814. case THS_IFKEY: *attribs = 'K'; break;
  1815. case THS_IFIND: *attribs = 'I'; break;
  1816. case THS_IFR16: *attribs = 'P'; break;
  1817. case THS_IFP16: *attribs = '2'; break;
  1818. case THS_IFP32: *attribs = '3'; break;
  1819. default: *attribs = '?'; break;
  1820. }
  1821. attribs[1] = (xattr & THS_INHID) ? '.' : 'H';
  1822. attribs[2] = (xattr & THS_IMODF) ? '.' : 'M';
  1823. attribs[3] = (xattr & THS_IWOTH) ? '.' : 'W';
  1824. attribs[4] = (xattr & THS_IROTH) ? '.' : 'R';
  1825. attribs[5] = (xattr & THS_IEUSR) ? '.' : 'E';
  1826. attribs[6] = (xattr & THS_IXUSR) ? '.' : 'X';
  1827. attribs[7] = (xattr & THS_IWUSR) ? '.' : 'W';
  1828. attribs[8] = (xattr & THS_IRUSR) ? '.' : 'R';
  1829. sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
  1830. break;
  1831. case FS_VFAT_:
  1832. #ifdef OLD_THEOS_EXTRA
  1833. if (hostver == 20) {
  1834. switch (xattr & _THS_IFMT) {
  1835. case _THS_IFLIB: *attribs = 'L'; break;
  1836. case _THS_IFDIR: *attribs = 'd'; break;
  1837. case _THS_IFCHR: *attribs = 'c'; break;
  1838. case _THS_IFREG: *attribs = 'S'; break;
  1839. case _THS_IODRC: *attribs = 'D'; break;
  1840. case _THS_IOKEY: *attribs = 'K'; break;
  1841. case _THS_IOIND: *attribs = 'I'; break;
  1842. case _THS_IOPRG: *attribs = 'P'; break;
  1843. case _THS_IO286: *attribs = '2'; break;
  1844. case _THS_IO386: *attribs = '3'; break;
  1845. default: *attribs = '?'; break;
  1846. }
  1847. attribs[1] = (xattr & _THS_HIDDN) ? 'H' : '.';
  1848. attribs[2] = (xattr & _THS_IXOTH) ? '.' : 'X';
  1849. attribs[3] = (xattr & _THS_IWOTH) ? '.' : 'W';
  1850. attribs[4] = (xattr & _THS_IROTH) ? '.' : 'R';
  1851. attribs[5] = (xattr & _THS_IEUSR) ? '.' : 'E';
  1852. attribs[6] = (xattr & _THS_IXUSR) ? '.' : 'X';
  1853. attribs[7] = (xattr & _THS_IWUSR) ? '.' : 'W';
  1854. attribs[8] = (xattr & _THS_IRUSR) ? '.' : 'R';
  1855. sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
  1856. break;
  1857. } /* else: fall through! */
  1858. #endif /* OLD_THEOS_EXTRA */
  1859. case FS_FAT_:
  1860. case FS_HPFS_:
  1861. case FS_NTFS_:
  1862. case VM_CMS_:
  1863. case MVS_:
  1864. case ACORN_:
  1865. if (hostnum != FS_FAT_ ||
  1866. (unsigned)(xattr & 0700) !=
  1867. ((unsigned)0400 |
  1868. ((unsigned)!(G.crec.external_file_attributes & 1) << 7) |
  1869. ((unsigned)(G.crec.external_file_attributes & 0x10) << 2))
  1870. )
  1871. {
  1872. xattr = (unsigned)(G.crec.external_file_attributes & 0xFF);
  1873. sprintf(attribs, ".r.-... %u.%u", hostver/10, hostver%10);
  1874. attribs[2] = (xattr & 0x01)? '-' : 'w';
  1875. attribs[5] = (xattr & 0x02)? 'h' : '-';
  1876. attribs[6] = (xattr & 0x04)? 's' : '-';
  1877. attribs[4] = (xattr & 0x20)? 'a' : '-';
  1878. if (xattr & 0x10) {
  1879. attribs[0] = 'd';
  1880. attribs[3] = 'x';
  1881. } else
  1882. attribs[0] = '-';
  1883. if (IS_VOLID(xattr))
  1884. attribs[0] = 'V';
  1885. else if ((p = MBSRCHR(G.filename, '.')) != (char *)NULL) {
  1886. ++p;
  1887. if (STRNICMP(p, "com", 3) == 0 ||
  1888. STRNICMP(p, "exe", 3) == 0 ||
  1889. STRNICMP(p, "btm", 3) == 0 ||
  1890. STRNICMP(p, "cmd", 3) == 0 ||
  1891. STRNICMP(p, "bat", 3) == 0)
  1892. attribs[3] = 'x';
  1893. }
  1894. break;
  1895. } /* else: fall through! */
  1896. default: /* assume Unix-like */
  1897. switch ((unsigned)(xattr & UNX_IFMT)) {
  1898. case (unsigned)UNX_IFDIR: attribs[0] = 'd'; break;
  1899. case (unsigned)UNX_IFREG: attribs[0] = '-'; break;
  1900. case (unsigned)UNX_IFLNK: attribs[0] = 'l'; break;
  1901. case (unsigned)UNX_IFBLK: attribs[0] = 'b'; break;
  1902. case (unsigned)UNX_IFCHR: attribs[0] = 'c'; break;
  1903. case (unsigned)UNX_IFIFO: attribs[0] = 'p'; break;
  1904. case (unsigned)UNX_IFSOCK: attribs[0] = 's'; break;
  1905. default: attribs[0] = '?'; break;
  1906. }
  1907. attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
  1908. attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
  1909. attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
  1910. attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
  1911. attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
  1912. attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
  1913. if (xattr & UNX_IXUSR)
  1914. attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
  1915. else
  1916. attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S==undefined */
  1917. if (xattr & UNX_IXGRP)
  1918. attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
  1919. else
  1920. /* attribs[6] = (xattr & UNX_ISGID)? 'l' : '-'; real 4.3BSD */
  1921. attribs[6] = (xattr & UNX_ISGID)? 'S' : '-'; /* SunOS 4.1.x */
  1922. if (xattr & UNX_IXOTH)
  1923. attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x'; /* "sticky bit" */
  1924. else
  1925. attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T==undefined */
  1926. sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
  1927. break;
  1928. } /* end switch (hostnum: external attributes format) */
  1929. #ifdef OLD_THEOS_EXTRA
  1930. Info(slide, 0, ((char *)slide, "%s %s %s ", attribs,
  1931. LoadFarStringSmall(((hostnum == FS_VFAT_ && hostver == 20) ?
  1932. os_TheosOld :
  1933. os[hostnum])),
  1934. FmZofft(G.crec.ucsize, "8", "u")));
  1935. #else
  1936. Info(slide, 0, ((char *)slide, "%s %s %s ", attribs,
  1937. LoadFarStringSmall(os[hostnum]),
  1938. FmZofft(G.crec.ucsize, "8", "u")));
  1939. #endif
  1940. Info(slide, 0, ((char *)slide, "%c",
  1941. (G.crec.general_purpose_bit_flag & 1)?
  1942. ((G.crec.internal_file_attributes & 1)? 'T' : 'B') : /* encrypted */
  1943. ((G.crec.internal_file_attributes & 1)? 't' : 'b'))); /* plaintext */
  1944. k = (G.crec.extra_field_length ||
  1945. /* a local-only "UX" (old Unix/OS2/NT GMT times "IZUNIX") e.f.? */
  1946. ((G.crec.external_file_attributes & 0x8000) &&
  1947. (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)));
  1948. Info(slide, 0, ((char *)slide, "%c", k?
  1949. ((G.crec.general_purpose_bit_flag & 8)? 'X' : 'x') : /* extra field */
  1950. ((G.crec.general_purpose_bit_flag & 8)? 'l' : '-'))); /* no extra field */
  1951. /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extended local header or not */
  1952. if (uO.lflag == 4) {
  1953. zusz_t csiz = G.crec.csize;
  1954. if (G.crec.general_purpose_bit_flag & 1)
  1955. csiz -= 12; /* if encrypted, don't count encryption header */
  1956. Info(slide, 0, ((char *)slide, "%3d%%",
  1957. (ratio(G.crec.ucsize,csiz)+5)/10));
  1958. } else if (uO.lflag == 5)
  1959. Info(slide, 0, ((char *)slide, " %s",
  1960. FmZofft(G.crec.csize, "8", "u")));
  1961. /* For printing of date & time, a "char d_t_buf[16]" is required.
  1962. * To save stack space, we reuse the "char attribs[16]" buffer whose
  1963. * content is no longer needed.
  1964. */
  1965. # define d_t_buf attribs
  1966. #ifdef USE_EF_UT_TIME
  1967. z_modtim = G.extra_field &&
  1968. #ifdef IZ_CHECK_TZ
  1969. G.tz_is_valid &&
  1970. #endif
  1971. (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
  1972. G.crec.last_mod_dos_datetime, &z_utime, NULL)
  1973. & EB_UT_FL_MTIME)
  1974. ? &z_utime.mtime : NULL;
  1975. TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0 or Macintosh */
  1976. d_t_buf[0] = (char)0; /* signal "show local time" */
  1977. #else
  1978. # define z_modtim NULL
  1979. #endif
  1980. Info(slide, 0, ((char *)slide, " %s %s ", methbuf,
  1981. zi_time(__G__ &G.crec.last_mod_dos_datetime, z_modtim, d_t_buf)));
  1982. fnprint(__G);
  1983. /*---------------------------------------------------------------------------
  1984. Skip the file comment, if any (the filename has already been printed,
  1985. above). That finishes up this file entry...
  1986. ---------------------------------------------------------------------------*/
  1987. SKIP_(G.crec.file_comment_length)
  1988. return error_in_archive;
  1989. } /* end function zi_short() */
  1990. /**************************************/
  1991. /* Function zi_showMacTypeCreator() */
  1992. /**************************************/
  1993. static void zi_showMacTypeCreator(__G__ ebfield)
  1994. __GDEF
  1995. uch *ebfield;
  1996. {
  1997. /* not every Type / Creator character is printable */
  1998. if (isprint(native(ebfield[0])) && isprint(native(ebfield[1])) &&
  1999. isprint(native(ebfield[2])) && isprint(native(ebfield[3])) &&
  2000. isprint(native(ebfield[4])) && isprint(native(ebfield[5])) &&
  2001. isprint(native(ebfield[6])) && isprint(native(ebfield[7]))) {
  2002. Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata),
  2003. native(ebfield[0]), native(ebfield[1]),
  2004. native(ebfield[2]), native(ebfield[3]),
  2005. native(ebfield[4]), native(ebfield[5]),
  2006. native(ebfield[6]), native(ebfield[7])));
  2007. } else {
  2008. Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata1),
  2009. (((ulg)ebfield[0]) << 24) +
  2010. (((ulg)ebfield[1]) << 16) +
  2011. (((ulg)ebfield[2]) << 8) +
  2012. ((ulg)ebfield[3]),
  2013. (((ulg)ebfield[4]) << 24) +
  2014. (((ulg)ebfield[5]) << 16) +
  2015. (((ulg)ebfield[6]) << 8) +
  2016. ((ulg)ebfield[7])));
  2017. }
  2018. } /* end function zi_showMacTypeCreator() */
  2019. /************************/
  2020. /* Function zi_time() */
  2021. /************************/
  2022. static char *zi_time(__G__ datetimez, modtimez, d_t_str)
  2023. __GDEF
  2024. ZCONST ulg *datetimez;
  2025. ZCONST time_t *modtimez;
  2026. char *d_t_str;
  2027. {
  2028. unsigned yr, mo, dy, hh, mm, ss;
  2029. char monthbuf[4];
  2030. ZCONST char *monthstr;
  2031. static ZCONST char Far month[12][4] = {
  2032. "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  2033. "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  2034. };
  2035. #ifdef USE_EF_UT_TIME
  2036. struct tm *t;
  2037. #endif
  2038. /*---------------------------------------------------------------------------
  2039. Convert the file-modification date and time info to a string of the form
  2040. "1991 Feb 23 17:15:00", "23-Feb-91 17:15" or "19910223.171500", depending
  2041. on values of lflag and T_flag. If using Unix-time extra fields, convert
  2042. to local time or not, depending on value of first character in d_t_str[].
  2043. ---------------------------------------------------------------------------*/
  2044. #ifdef USE_EF_UT_TIME
  2045. if (modtimez != NULL) {
  2046. #ifndef NO_GMTIME
  2047. /* check for our secret message from above... */
  2048. t = (d_t_str[0] == (char)1)? gmtime(modtimez) : localtime(modtimez);
  2049. #else
  2050. t = localtime(modtimez);
  2051. #endif
  2052. if (uO.lflag > 9 && t == (struct tm *)NULL)
  2053. /* time conversion error in verbose listing format,
  2054. * return string with '?' instead of data
  2055. */
  2056. return (strcpy(d_t_str, LoadFarString(lngYMDHMSTimeError)));
  2057. } else
  2058. t = (struct tm *)NULL;
  2059. if (t != (struct tm *)NULL) {
  2060. mo = (unsigned)(t->tm_mon + 1);
  2061. dy = (unsigned)(t->tm_mday);
  2062. yr = (unsigned)(t->tm_year);
  2063. hh = (unsigned)(t->tm_hour);
  2064. mm = (unsigned)(t->tm_min);
  2065. ss = (unsigned)(t->tm_sec);
  2066. } else
  2067. #endif /* USE_EF_UT_TIME */
  2068. {
  2069. yr = ((unsigned)(*datetimez >> 25) & 0x7f) + 80;
  2070. mo = ((unsigned)(*datetimez >> 21) & 0x0f);
  2071. dy = ((unsigned)(*datetimez >> 16) & 0x1f);
  2072. hh = (((unsigned)*datetimez >> 11) & 0x1f);
  2073. mm = (((unsigned)*datetimez >> 5) & 0x3f);
  2074. ss = (((unsigned)*datetimez << 1) & 0x3e);
  2075. }
  2076. if (mo == 0 || mo > 12) {
  2077. sprintf(monthbuf, LoadFarString(BogusFmt), mo);
  2078. monthstr = monthbuf;
  2079. } else
  2080. monthstr = LoadFarStringSmall(month[mo-1]);
  2081. if (uO.lflag > 9) /* verbose listing format */
  2082. sprintf(d_t_str, LoadFarString(lngYMDHMSTime), yr+1900, monthstr, dy,
  2083. hh, mm, ss);
  2084. else if (uO.T_flag)
  2085. sprintf(d_t_str, LoadFarString(DecimalTime), yr+1900, mo, dy,
  2086. hh, mm, ss);
  2087. else /* was: if ((uO.lflag >= 3) && (uO.lflag <= 5)) */
  2088. sprintf(d_t_str, LoadFarString(shtYMDHMTime), yr%100, monthstr, dy,
  2089. hh, mm);
  2090. return d_t_str;
  2091. } /* end function zi_time() */
  2092. #endif /* !NO_ZIPINFO */