zip.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. /*
  2. zip.h - Zip 3
  3. /---------------------------------------------------------------------/
  4. Info-ZIP Licence
  5. This is version 2007-Mar-4 of the Info-ZIP license.
  6. The definitive version of this document should be available at
  7. ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
  8. a copy at http://www.info-zip.org/pub/infozip/license.html.
  9. Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
  10. For the purposes of this copyright and license, "Info-ZIP" is defined as
  11. the following set of individuals:
  12. Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
  13. Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
  14. Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
  15. David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
  16. Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
  17. Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
  18. Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
  19. Rich Wales, Mike White.
  20. This software is provided "as is," without warranty of any kind, express
  21. or implied. In no event shall Info-ZIP or its contributors be held liable
  22. for any direct, indirect, incidental, special or consequential damages
  23. arising out of the use of or inability to use this software.
  24. Permission is granted to anyone to use this software for any purpose,
  25. including commercial applications, and to alter it and redistribute it
  26. freely, subject to the above disclaimer and the following restrictions:
  27. 1. Redistributions of source code (in whole or in part) must retain
  28. the above copyright notice, definition, disclaimer, and this list
  29. of conditions.
  30. 2. Redistributions in binary form (compiled executables and libraries)
  31. must reproduce the above copyright notice, definition, disclaimer,
  32. and this list of conditions in documentation and/or other materials
  33. provided with the distribution. The sole exception to this condition
  34. is redistribution of a standard UnZipSFX binary (including SFXWiz) as
  35. part of a self-extracting archive; that is permitted without inclusion
  36. of this license, as long as the normal SFX banner has not been removed
  37. from the binary or disabled.
  38. 3. Altered versions--including, but not limited to, ports to new operating
  39. systems, existing ports with new graphical interfaces, versions with
  40. modified or added functionality, and dynamic, shared, or static library
  41. versions not from Info-ZIP--must be plainly marked as such and must not
  42. be misrepresented as being the original source or, if binaries,
  43. compiled from the original source. Such altered versions also must not
  44. be misrepresented as being Info-ZIP releases--including, but not
  45. limited to, labeling of the altered versions with the names "Info-ZIP"
  46. (or any variation thereof, including, but not limited to, different
  47. capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
  48. explicit permission of Info-ZIP. Such altered versions are further
  49. prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
  50. e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
  51. will provide support for the altered versions.
  52. 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
  53. "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
  54. own source and binary releases.
  55. /---------------------------------------------------------------------/
  56. */
  57. /*
  58. * zip.h by Mark Adler
  59. */
  60. #ifndef __zip_h
  61. #define __zip_h 1
  62. #define ZIP /* for crypt.c: include zip password functions, not unzip */
  63. /* Types centralized here for easy modification */
  64. #define local static /* More meaningful outside functions */
  65. typedef unsigned char uch; /* unsigned 8-bit value */
  66. typedef unsigned short ush; /* unsigned 16-bit value */
  67. typedef unsigned long ulg; /* unsigned 32-bit value */
  68. /* Set up portability */
  69. #include "tailor.h"
  70. #ifdef USE_ZLIB
  71. # include "zlib.h"
  72. #endif
  73. /* In the utilities, the crc32() function is only used for UNICODE_SUPPORT. */
  74. #if defined(UTIL) && !defined(UNICODE_SUPPORT)
  75. # define CRC_TABLE_ONLY
  76. #endif
  77. #define MIN_MATCH 3
  78. #define MAX_MATCH 258
  79. /* The minimum and maximum match lengths */
  80. #ifndef WSIZE
  81. # define WSIZE (0x8000)
  82. #endif
  83. /* Maximum window size = 32K. If you are really short of memory, compile
  84. * with a smaller WSIZE but this reduces the compression ratio for files
  85. * of size > WSIZE. WSIZE must be a power of two in the current implementation.
  86. */
  87. #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
  88. /* Minimum amount of lookahead, except at the end of the input file.
  89. * See deflate.c for comments about the MIN_MATCH+1.
  90. */
  91. #define MAX_DIST (WSIZE-MIN_LOOKAHEAD)
  92. /* In order to simplify the code, particularly on 16 bit machines, match
  93. * distances are limited to MAX_DIST instead of WSIZE.
  94. */
  95. /* Forget FILENAME_MAX (incorrectly = 14 on some System V) */
  96. #ifdef DOS
  97. # define FNMAX 256
  98. #else
  99. # define FNMAX 1024
  100. #endif
  101. #ifndef MATCH
  102. # define MATCH shmatch /* Default for pattern matching: UNIX style */
  103. #endif
  104. /* Structure carrying extended timestamp information */
  105. typedef struct iztimes {
  106. time_t atime; /* new access time */
  107. time_t mtime; /* new modification time */
  108. time_t ctime; /* new creation time (!= Unix st.ctime) */
  109. } iztimes;
  110. /* Lengths of headers after signatures in bytes */
  111. #define LOCHEAD 26
  112. #define CENHEAD 42
  113. #define ENDHEAD 18
  114. #define EC64LOC 16
  115. #define EC64REC 52
  116. /* Structures for in-memory file information */
  117. struct zlist {
  118. /* See central header in zipfile.c for what vem..off are */
  119. /* Do not rearrange these as less than smart coding in zipfile.c
  120. in scanzipf_reg() depends on u being set to ver and then stepping
  121. through as a byte array. Ack. Should be fixed. 5/25/2005 EG */
  122. /* All the new read code does not rely on this order. */
  123. ush vem, ver, flg, how;
  124. ulg tim, crc;
  125. uzoff_t siz, len; /* zip64 support 08/29/2003 R.Nausedat */
  126. /* changed from extent to ush 3/10/2005 EG */
  127. ush nam, ext, cext, com; /* offset of ext must be >= LOCHEAD */
  128. ulg dsk; /* disk number was ush but now ulg */
  129. ush att, lflg; /* offset of lflg must be >= LOCHEAD */
  130. uzoff_t off;
  131. ulg atx;
  132. char *name; /* File name in zip file */
  133. char *extra; /* Extra field (set only if ext != 0) */
  134. char *cextra; /* Extra in central (set only if cext != 0) */
  135. char *comment; /* Comment (set only if com != 0) */
  136. char *iname; /* Internal file name after cleanup (stored in archive) */
  137. char *zname; /* External version of internal name */
  138. char *oname; /* Display version of name used in messages */
  139. #ifdef UNICODE_SUPPORT
  140. /* Unicode support */
  141. char *uname; /* UTF-8 version of iname */
  142. /* if uname has chars not in local char set, zuname can be different than zname */
  143. char *zuname; /* Escaped Unicode zname from uname */
  144. char *ouname; /* Display version of zuname */
  145. # ifdef WIN32
  146. char *wuname; /* Converted back ouname for Win32 */
  147. wchar_t *namew; /* Windows wide character version of name */
  148. wchar_t *inamew; /* Windows wide character version of iname */
  149. wchar_t *znamew; /* Windows wide character version of zname */
  150. # endif
  151. #endif
  152. int mark; /* Marker for files to operate on */
  153. int trash; /* Marker for files to delete */
  154. int current; /* Marker for files that are current to what is on OS (filesync) */
  155. int dosflag; /* Set to force MSDOS file attributes */
  156. struct zlist far *nxt; /* Pointer to next header in list */
  157. };
  158. struct flist {
  159. char *name; /* Raw internal file name */
  160. char *iname; /* Internal file name after cleanup */
  161. char *zname; /* External version of internal name */
  162. char *oname; /* Display version of internal name */
  163. #ifdef UNICODE_SUPPORT
  164. char *uname; /* UTF-8 name */
  165. # ifdef WIN32
  166. wchar_t *namew; /* Windows wide character version of name */
  167. wchar_t *inamew; /* Windows wide character version of iname */
  168. wchar_t *znamew; /* Windows wide character version of zname */
  169. # endif
  170. #endif
  171. int dosflag; /* Set to force MSDOS file attributes */
  172. uzoff_t usize; /* usize from initial scan */
  173. struct flist far *far *lst; /* Pointer to link pointing here */
  174. struct flist far *nxt; /* Link to next name */
  175. };
  176. struct plist {
  177. char *zname; /* External version of internal name */
  178. int select; /* Selection flag ('i' or 'x') */
  179. };
  180. /* internal file attribute */
  181. #define UNKNOWN (-1)
  182. #define BINARY 0
  183. #define ASCII 1
  184. #define __EBCDIC 2
  185. /* extra field definitions */
  186. #define EF_VMCMS 0x4704 /* VM/CMS Extra Field ID ("G")*/
  187. #define EF_MVS 0x470f /* MVS Extra Field ID ("G") */
  188. #define EF_IZUNIX 0x5855 /* UNIX Extra Field ID ("UX") */
  189. #define EF_IZUNIX2 0x7855 /* Info-ZIP's new Unix ("Ux") */
  190. #define EF_TIME 0x5455 /* universal timestamp ("UT") */
  191. #define EF_OS2EA 0x0009 /* OS/2 Extra Field ID (extended attributes) */
  192. #define EF_ACL 0x4C41 /* ACL Extra Field ID (access control list, "AL") */
  193. #define EF_NTSD 0x4453 /* NT Security Descriptor Extra Field ID, ("SD") */
  194. #define EF_BEOS 0x6542 /* BeOS Extra Field ID ("Be") */
  195. #define EF_ATHEOS 0x7441 /* AtheOS Extra Field ID ("At") */
  196. #define EF_QDOS 0xfb4a /* SMS/QDOS ("J\373") */
  197. #define EF_AOSVS 0x5356 /* AOS/VS ("VS") */
  198. #define EF_SPARK 0x4341 /* David Pilling's Acorn/SparkFS ("AC") */
  199. #define EF_THEOS 0x6854 /* THEOS ("Th") */
  200. #define EF_TANDEM 0x4154 /* Tandem NSK ("TA") */
  201. /* Definitions for extra field handling: */
  202. #define EF_SIZE_MAX ((unsigned)0xFFFF) /* hard limit of total e.f. length */
  203. #define EB_HEADSIZE 4 /* length of a extra field block header */
  204. #define EB_ID 0 /* offset of block ID in header */
  205. #define EB_LEN 2 /* offset of data length field in header */
  206. #define EB_MEMCMPR_HSIZ 6 /* header length for memcompressed data */
  207. #define EB_DEFLAT_EXTRA 10 /* overhead for 64kByte "undeflatable" data */
  208. #define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */
  209. #define EB_UX_ATIME 0 /* offset of atime in "UX" extra field data */
  210. #define EB_UX_MTIME 4 /* offset of mtime in "UX" extra field data */
  211. #define EB_UX_FULLSIZE 12 /* full "UX" field (atime, mtime, uid, gid) */
  212. #define EB_UX_UID 8 /* byte offset of UID in "UX" field data */
  213. #define EB_UX_GID 10 /* byte offset of GID in "UX" field data */
  214. #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */
  215. #define EB_UT_FLAGS 0 /* byte offset of Flags field */
  216. #define EB_UT_TIME1 1 /* byte offset of 1st time value */
  217. #define EB_UT_FL_MTIME (1 << 0) /* mtime present */
  218. #define EB_UT_FL_ATIME (1 << 1) /* atime present */
  219. #define EB_UT_FL_CTIME (1 << 2) /* ctime present */
  220. #define EB_UT_LEN(n) (EB_UT_MINLEN + 4 * (n))
  221. #define EB_UX2_MINLEN 4 /* minimal Ux field contains UID/GID */
  222. #define EB_UX2_UID 0 /* byte offset of UID in "Ux" field data */
  223. #define EB_UX2_GID 2 /* byte offset of GID in "Ux" field data */
  224. #define EB_UX2_VALID (1 << 8) /* UID/GID present */
  225. /* ASCII definitions for line terminators in text files: */
  226. #define LF 10 /* '\n' on ASCII machines; must be 10 due to EBCDIC */
  227. #define CR 13 /* '\r' on ASCII machines; must be 13 due to EBCDIC */
  228. #define CTRLZ 26 /* DOS & OS/2 EOF marker (used in fileio.c, vms.c) */
  229. /* return codes of password fetches (negative: user abort; positive: error) */
  230. #define IZ_PW_ENTERED 0 /* got some PWD string, use/try it */
  231. #define IZ_PW_CANCEL -1 /* no password available (for this entry) */
  232. #define IZ_PW_CANCELALL -2 /* no password, skip any further PWD request */
  233. #define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */
  234. #define IZ_PW_SKIPVERIFY IZ_PW_CANCEL /* skip encrypt. passwd verification */
  235. /* mode flag values of password prompting function */
  236. #define ZP_PW_ENTER 0 /* request for encryption password */
  237. #define ZP_PW_VERIFY 1 /* request for reentering password */
  238. /* Error return codes and PERR macro */
  239. #include "ziperr.h"
  240. #if 0 /* Optimization: use the (const) result of crc32(0L,NULL,0) */
  241. # define CRCVAL_INITIAL crc32(0L, (uch *)NULL, 0)
  242. # if 00 /* not used, should be removed !! */
  243. # define ADLERVAL_INITIAL adler16(0U, (uch *)NULL, 0)
  244. # endif /* 00 */
  245. #else
  246. # define CRCVAL_INITIAL 0L
  247. # if 00 /* not used, should be removed !! */
  248. # define ADLERVAL_INITIAL 1
  249. # endif /* 00 */
  250. #endif
  251. #define DOSTIME_MINIMUM ((ulg)0x00210000L)
  252. #define DOSTIME_2038_01_18 ((ulg)0x74320000L)
  253. /* Public globals */
  254. extern uch upper[256]; /* Country dependent case map table */
  255. extern uch lower[256];
  256. #ifdef EBCDIC
  257. extern ZCONST uch ascii[256]; /* EBCDIC <--> ASCII translation tables */
  258. extern ZCONST uch ebcdic[256];
  259. #endif /* EBCDIC */
  260. #if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
  261. extern ZCONST ulg near *crc_32_tab;
  262. #else
  263. extern ZCONST ulg Far *crc_32_tab;
  264. #endif
  265. /* Are these ever used? 6/12/05 EG */
  266. #ifdef IZ_ISO2OEM_ARRAY /* ISO 8859-1 (Win CP 1252) --> OEM CP 850 */
  267. extern ZCONST uch Far iso2oem[128];
  268. #endif
  269. #ifdef IZ_OEM2ISO_ARRAY /* OEM CP 850 --> ISO 8859-1 (Win CP 1252) */
  270. extern ZCONST uch Far oem2iso[128];
  271. #endif
  272. extern char errbuf[FNMAX+4081]; /* Handy place to build error messages */
  273. extern int recurse; /* Recurse into directories encountered */
  274. extern int dispose; /* Remove files after put in zip file */
  275. extern int pathput; /* Store path with name */
  276. #ifdef RISCOS
  277. extern int scanimage; /* Scan through image files */
  278. #endif
  279. #define BEST -1 /* Use best method (deflation or store) */
  280. #define STORE 0 /* Store method */
  281. #define DEFLATE 8 /* Deflation method*/
  282. #define BZIP2 12 /* BZIP2 method */
  283. #ifdef BZIP2_SUPPORT
  284. #define LAST_KNOWN_COMPMETHOD BZIP2
  285. #else
  286. #define LAST_KNOWN_COMPMETHOD DEFLATE
  287. #endif
  288. extern int method; /* Restriction on compression method */
  289. extern ulg skip_this_disk;
  290. extern int des_good; /* Good data descriptor found */
  291. extern ulg des_crc; /* Data descriptor CRC */
  292. extern uzoff_t des_csize; /* Data descriptor csize */
  293. extern uzoff_t des_usize; /* Data descriptor usize */
  294. extern int dosify; /* Make new entries look like MSDOS */
  295. extern char *special; /* Don't compress special suffixes */
  296. extern int verbose; /* Report oddities in zip file structure */
  297. extern int fix; /* Fix the zip file */
  298. extern int filesync; /* 1=file sync, delete entries not on file system */
  299. extern int adjust; /* Adjust the unzipsfx'd zip file */
  300. extern int level; /* Compression level */
  301. extern int translate_eol; /* Translate end-of-line LF -> CR LF */
  302. #ifdef VMS
  303. extern int vmsver; /* Append VMS version number to file names */
  304. extern int vms_native; /* Store in VMS format */
  305. extern int vms_case_2; /* ODS2 file name case in VMS. -1: down. */
  306. extern int vms_case_5; /* ODS5 file name case in VMS. +1: preserve. */
  307. /* Accomodation for /NAMES = AS_IS with old header files. */
  308. # define cma$tis_errno_get_addr CMA$TIS_ERRNO_GET_ADDR
  309. # define lib$establish LIB$ESTABLISH
  310. # define lib$get_foreign LIB$GET_FOREIGN
  311. # define lib$get_input LIB$GET_INPUT
  312. # define lib$sig_to_ret LIB$SIG_TO_RET
  313. # define ots$cvt_tu_l OTS$CVT_TU_L
  314. # define str$concat STR$CONCAT
  315. # define str$find_first_substring STR$FIND_FIRST_SUBSTRING
  316. # define str$free1_dx STR$FREE1_DX
  317. # define sys$asctim SYS$ASCTIM
  318. # define sys$assign SYS$ASSIGN
  319. # define sys$bintim SYS$BINTIM
  320. # define sys$close SYS$CLOSE
  321. # define sys$connect SYS$CONNECT
  322. # define sys$dassgn SYS$DASSGN
  323. # define sys$display SYS$DISPLAY
  324. # define sys$getjpiw SYS$GETJPIW
  325. # define sys$open SYS$OPEN
  326. # define sys$parse SYS$PARSE
  327. # define sys$qiow SYS$QIOW
  328. # define sys$read SYS$READ
  329. # define sys$search SYS$SEARCH
  330. #endif /* VMS */
  331. #if defined(OS2) || defined(WIN32)
  332. extern int use_longname_ea; /* use the .LONGNAME EA as the file's name */
  333. #endif
  334. #if defined (QDOS) || defined(QLZIP)
  335. extern short qlflag;
  336. #endif
  337. /* 9/26/04 EG */
  338. extern int no_wild; /* wildcards are disabled */
  339. extern int allow_regex; /* 1 = allow [list] matching (regex) */
  340. extern int wild_stop_at_dir; /* wildcards do not include / in matches */
  341. #ifdef UNICODE_SUPPORT
  342. extern int using_utf8; /* 1 if current character set is UTF-8 */
  343. # ifdef WIN32
  344. extern int no_win32_wide; /* 1 = no wide functions, like GetFileAttributesW() */
  345. # endif
  346. #endif
  347. /* 10/20/04 */
  348. extern zoff_t dot_size; /* if not 0 then display dots every size buffers */
  349. extern zoff_t dot_count; /* if dot_size not 0 counts buffers */
  350. /* status 10/30/04 */
  351. extern int display_counts; /* display running file count */
  352. extern int display_bytes; /* display running bytes remaining */
  353. extern int display_globaldots; /* display dots for archive instead of for each file */
  354. extern int display_volume; /* display current input and output volume (disk) numbers */
  355. extern int display_usize; /* display uncompressed bytes */
  356. extern ulg files_so_far; /* files processed so far */
  357. extern ulg bad_files_so_far; /* files skipped so far */
  358. extern ulg files_total; /* files total to process */
  359. extern uzoff_t bytes_so_far; /* bytes processed so far (from initial scan) */
  360. extern uzoff_t good_bytes_so_far;/* good bytes read so far */
  361. extern uzoff_t bad_bytes_so_far;/* bad bytes skipped so far */
  362. extern uzoff_t bytes_total; /* total bytes to process (from initial scan) */
  363. /* logfile 6/5/05 */
  364. extern int logall; /* 0 = warnings/errors, 1 = all */
  365. extern FILE *logfile; /* pointer to open logfile or NULL */
  366. extern int logfile_append; /* append to existing logfile */
  367. extern char *logfile_path; /* pointer to path of logfile */
  368. #ifdef WIN32
  369. extern int nonlocal_name; /* Name has non-local characters */
  370. extern int nonlocal_path; /* Path has non-local characters */
  371. #endif
  372. #ifdef UNICODE_SUPPORT
  373. /* Unicode 10/12/05 */
  374. extern int use_wide_to_mb_default;/* use the default MB char instead of escape */
  375. #endif
  376. extern int hidden_files; /* process hidden and system files */
  377. extern int volume_label; /* add volume label */
  378. extern int dirnames; /* include directory names */
  379. extern int filter_match_case; /* 1=match case when filter() */
  380. extern int diff_mode; /* 1=require --out and only store changed and add */
  381. #if defined(WIN32)
  382. extern int only_archive_set; /* only include if DOS archive bit set */
  383. extern int clear_archive_bits; /* clear DOS archive bit of included files */
  384. #endif
  385. extern int linkput; /* Store symbolic links as such */
  386. extern int noisy; /* False for quiet operation */
  387. extern int extra_fields; /* 0=create minimum, 1=don't copy old, 2=keep old */
  388. #ifdef NTSD_EAS
  389. extern int use_privileges; /* use security privilege overrides */
  390. #endif
  391. extern int use_descriptors; /* use data descriptors (extended headings) */
  392. extern int allow_empty_archive; /* if no files, create empty archive anyway */
  393. extern int copy_only; /* 1 = copy archive with no changes */
  394. extern int zip_to_stdout; /* output to stdout */
  395. extern int output_seekable; /* 1 = output seekable 3/13/05 EG */
  396. #ifdef ZIP64_SUPPORT /* zip64 globals 10/4/03 E. Gordon */
  397. extern int force_zip64; /* force use of zip64 when streaming from stdin */
  398. extern int zip64_entry; /* current entry needs Zip64 */
  399. extern int zip64_archive; /* at least 1 entry needs zip64 */
  400. #endif
  401. extern int allow_fifo; /* Allow reading Unix FIFOs, waiting if pipe open */
  402. extern int show_files; /* show files to operate on and exit (=2 log only) */
  403. extern char *tempzip; /* temp file name */
  404. extern FILE *y; /* output file now global for splits */
  405. #ifdef UNICODE_SUPPORT
  406. extern int utf8_force; /* 1=store UTF-8 as standard per AppNote bit 11 */
  407. #endif
  408. extern int unicode_escape_all; /* 1=escape all non-ASCII characters in paths */
  409. extern int unicode_mismatch; /* unicode mismatch is 0=error, 1=warn, 2=ignore, 3=no */
  410. extern time_t scan_delay; /* seconds before display Scanning files message */
  411. extern time_t scan_dot_time; /* time in seconds between Scanning files dots */
  412. extern time_t scan_start; /* start of file scan */
  413. extern time_t scan_last; /* time of last message */
  414. extern int scan_started; /* scan has started */
  415. extern uzoff_t scan_count; /* Used for "Scanning files..." message */
  416. extern ulg before; /* 0=ignore, else exclude files before this time */
  417. extern ulg after; /* 0=ignore, else exclude files newer than this time */
  418. /* in split globals */
  419. extern ulg total_disks;
  420. extern ulg current_in_disk;
  421. extern uzoff_t current_in_offset;
  422. extern ulg skip_current_disk;
  423. /* out split globals */
  424. extern ulg current_local_disk; /* disk with current local header */
  425. extern ulg current_disk; /* current disk number */
  426. extern ulg cd_start_disk; /* central directory start disk */
  427. extern uzoff_t cd_start_offset; /* offset of start of cd on cd start disk */
  428. extern uzoff_t cd_entries_this_disk; /* cd entries this disk */
  429. extern uzoff_t total_cd_entries; /* total cd entries in new/updated archive */
  430. extern ulg zip64_eocd_disk; /* disk with Zip64 EOCD Record */
  431. extern uzoff_t zip64_eocd_offset; /* offset of Zip64 EOCD Record */
  432. /* for split method 1 (keep split with local header open and update) */
  433. extern char *current_local_tempname; /* name of temp file */
  434. extern FILE *current_local_file; /* file pointer for current local header */
  435. extern uzoff_t current_local_offset; /* offset to start of current local header */
  436. /* global */
  437. extern uzoff_t bytes_this_split; /* bytes written to current split */
  438. extern int read_split_archive; /* 1=scanzipf_reg detected spanning signature */
  439. extern int split_method; /* 0=no splits, 1=seekable, 2=data descs, -1=no */
  440. extern uzoff_t split_size; /* how big each split should be */
  441. extern int split_bell; /* when pause for next split ring bell */
  442. extern uzoff_t bytes_prev_splits; /* total bytes written to all splits before this */
  443. extern uzoff_t bytes_this_entry; /* bytes written for this entry across all splits */
  444. extern int noisy_splits; /* note when splits are being created */
  445. extern int mesg_line_started; /* 1=started writing a line to mesg */
  446. extern int logfile_line_started; /* 1=started writing a line to logfile */
  447. extern char *key; /* Scramble password or NULL */
  448. extern char *tempath; /* Path for temporary files */
  449. extern FILE *mesg; /* Where informational output goes */
  450. extern char *zipfile; /* New or existing zip archive (zip file) */
  451. extern FILE *in_file; /* Current input file for spits */
  452. extern char *in_path; /* Name of input archive, used to track reading splits */
  453. extern char *in_split_path; /* in split path */
  454. extern char *out_path; /* Name of output file, usually same as zipfile */
  455. extern int zip_attributes;
  456. /* zip64 support 08/31/2003 R.Nausedat */
  457. extern uzoff_t zipbeg; /* Starting offset of zip structures */
  458. extern uzoff_t cenbeg; /* Starting offset of central directory */
  459. extern uzoff_t tempzn; /* Count of bytes written to output zip file */
  460. /* NOTE: zcount and fcount cannot exceed "size_t" (resp. "extent") range.
  461. This is an internal limitation built into Zip's action handling:
  462. Zip keeps "{z|f}count * struct {z|f}list" arrays in (flat) memory,
  463. for sorting, file matching, and building the central-dir structures.
  464. */
  465. extern struct zlist far *zfiles;/* Pointer to list of files in zip file */
  466. extern extent zcount; /* Number of files in zip file */
  467. extern int zipfile_exists; /* 1 if zipfile exists */
  468. extern ush zcomlen; /* Length of zip file comment */
  469. extern char *zcomment; /* Zip file comment (not zero-terminated) */
  470. extern struct flist far **fsort;/* List of files sorted by name */
  471. extern struct zlist far **zsort;/* List of files sorted by name */
  472. #ifdef UNICODE_SUPPORT
  473. extern struct zlist far **zusort;/* List of files sorted by zuname */
  474. #endif
  475. extern struct flist far *found; /* List of names found */
  476. extern struct flist far *far *fnxt; /* Where to put next in found list */
  477. extern extent fcount; /* Count of names in found list */
  478. extern struct plist *patterns; /* List of patterns to be matched */
  479. extern unsigned pcount; /* number of patterns */
  480. extern unsigned icount; /* number of include only patterns */
  481. extern unsigned Rcount; /* number of -R include patterns */
  482. #ifdef IZ_CHECK_TZ
  483. extern int zp_tz_is_valid; /* signals "timezone info is available" */
  484. #endif
  485. #if (defined(MACOS) || defined(WINDLL))
  486. extern int zipstate; /* flag "zipfile has been stat()'ed */
  487. #endif
  488. /* Diagnostic functions */
  489. #ifdef DEBUG
  490. # ifdef MSDOS
  491. # undef stderr
  492. # define stderr stdout
  493. # endif
  494. # define diag(where) fprintf(stderr, "zip diagnostic: %s\n", where)
  495. # define Assert(cond,msg) {if(!(cond)) error(msg);}
  496. # ifdef THEOS
  497. # define Trace(x) _fprintf x
  498. # define Tracev(x) {if (verbose) _fprintf x ;}
  499. # define Tracevv(x) {if (verbose>1) _fprintf x ;}
  500. # define Tracec(c,x) {if (verbose && (c)) _fprintf x ;}
  501. # define Tracecv(c,x) {if (verbose>1 && (c)) _fprintf x ;}
  502. # else
  503. # define Trace(x) fprintf x
  504. # define Tracev(x) {if (verbose) fprintf x ;}
  505. # define Tracevv(x) {if (verbose>1) fprintf x ;}
  506. # define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  507. # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  508. # endif
  509. #else
  510. # define diag(where)
  511. # define Assert(cond,msg)
  512. # define Trace(x)
  513. # define Tracev(x)
  514. # define Tracevv(x)
  515. # define Tracec(c,x)
  516. # define Tracecv(c,x)
  517. #endif
  518. #ifdef DEBUGNAMES
  519. # define free(x) { int *v;Free(x); v=x;*v=0xdeadbeef;x=(void *)0xdeadbeef; }
  520. #endif
  521. /* Public function prototypes */
  522. #ifndef UTIL
  523. #ifdef USE_ZIPMAIN
  524. int zipmain OF((int, char **));
  525. #else
  526. int main OF((int, char **));
  527. #endif /* USE_ZIPMAIN */
  528. #endif
  529. #ifdef EBCDIC
  530. extern int aflag;
  531. #endif /* EBCDIC */
  532. #ifdef CMS_MVS
  533. extern int bflag;
  534. #endif /* CMS_MVS */
  535. void zipmessage_nl OF((ZCONST char *, int));
  536. void zipmessage OF((ZCONST char *, ZCONST char *));
  537. void zipwarn OF((ZCONST char *, ZCONST char *));
  538. void ziperr OF((int, ZCONST char *));
  539. #ifdef UTIL
  540. # define error(msg) ziperr(ZE_LOGIC, msg)
  541. #else
  542. void error OF((ZCONST char *));
  543. # ifdef VMSCLI
  544. void help OF((void));
  545. # endif
  546. int encr_passwd OF((int, char *, int, ZCONST char *));
  547. #endif
  548. /* in zipup.c */
  549. #ifndef UTIL
  550. /* zip64 support 08/31/2003 R.Nausedat */
  551. int percent OF((uzoff_t, uzoff_t));
  552. int zipup OF((struct zlist far *));
  553. # ifdef USE_ZLIB
  554. void zl_deflate_free OF((void));
  555. # else
  556. void flush_outbuf OF((char *, unsigned *));
  557. int seekable OF((void));
  558. extern unsigned (*read_buf) OF((char *, unsigned int));
  559. # endif /* !USE_ZLIB */
  560. # ifdef ZP_NEED_MEMCOMPR
  561. ulg memcompress OF((char *, ulg, char *, ulg));
  562. # endif
  563. # ifdef BZIP2_SUPPORT
  564. void bz_compress_free OF((void));
  565. # endif
  566. #endif /* !UTIL */
  567. /* in zipfile.c */
  568. #ifndef UTIL
  569. struct zlist far *zsearch OF((ZCONST char *));
  570. # ifdef USE_EF_UT_TIME
  571. int get_ef_ut_ztime OF((struct zlist far *, iztimes *));
  572. # endif /* USE_EF_UT_TIME */
  573. int trash OF((void));
  574. #endif /* !UTIL */
  575. char *ziptyp OF((char *));
  576. int readzipfile OF((void));
  577. int putlocal OF((struct zlist far *, int));
  578. int putextended OF((struct zlist far *));
  579. int putcentral OF((struct zlist far *));
  580. /* zip64 support 09/05/2003 R.Nausedat */
  581. int putend OF((uzoff_t, uzoff_t, uzoff_t, extent, char *));
  582. /* moved seekable to separate function 3/14/05 EG */
  583. int is_seekable OF((FILE *));
  584. int zipcopy OF((struct zlist far *));
  585. int readlocal OF((struct zlist far **, struct zlist far *));
  586. /* made global for handling extra fields */
  587. char *get_extra_field OF((ush, char *, unsigned));
  588. char *copy_nondup_extra_fields OF((char *, unsigned, char *, unsigned, unsigned *));
  589. /* in fileio.c */
  590. #ifndef UTIL
  591. char *getnam OF((FILE *));
  592. struct flist far *fexpel OF((struct flist far *));
  593. char *last OF((char *, int));
  594. # ifdef UNICODE_SUPPORT
  595. wchar_t *lastw OF((wchar_t *, wchar_t));
  596. # endif
  597. char *msname OF((char *));
  598. # ifdef UNICODE_SUPPORT
  599. wchar_t *msnamew OF((wchar_t *));
  600. # endif
  601. int check_dup OF((void));
  602. int filter OF((char *, int));
  603. int newname OF((char *, int, int));
  604. # ifdef UNICODE_SUPPORT
  605. # ifdef WIN32
  606. int newnamew OF((wchar_t *, int, int));
  607. # endif
  608. # endif
  609. /* used by copy mode */
  610. int proc_archive_name OF((char *, int));
  611. #endif /* !UTIL */
  612. #if (!defined(UTIL) || defined(W32_STATROOT_FIX))
  613. time_t dos2unixtime OF((ulg));
  614. #endif
  615. #ifndef UTIL
  616. ulg dostime OF((int, int, int, int, int, int));
  617. ulg unix2dostime OF((time_t *));
  618. int issymlnk OF((ulg a));
  619. # ifdef S_IFLNK
  620. # define rdsymlnk(p,b,n) readlink(p,b,n)
  621. /* extern int readlink OF((char *, char *, int)); */
  622. # else /* !S_IFLNK */
  623. # define rdsymlnk(p,b,n) (0)
  624. # endif /* !S_IFLNK */
  625. #endif /* !UTIL */
  626. int destroy OF((char *));
  627. int replace OF((char *, char *));
  628. int getfileattr OF((char *));
  629. int setfileattr OF((char *, int));
  630. char *tempname OF((char *));
  631. /* for splits */
  632. int close_split OF((ulg, FILE *, char *));
  633. int ask_for_split_read_path OF((ulg));
  634. int ask_for_split_write_path OF((ulg));
  635. char *get_in_split_path OF((char *, ulg));
  636. char *find_in_split_path OF((char *, ulg));
  637. char *get_out_split_path OF((char *, ulg));
  638. int rename_split OF((char *, char *));
  639. int set_filetype OF((char *));
  640. int bfcopy OF((uzoff_t));
  641. int fcopy OF((FILE *, FILE *, uzoff_t));
  642. #ifdef ZMEM
  643. char *memset OF((char *, int, unsigned int));
  644. char *memcpy OF((char *, char *, unsigned int));
  645. int memcmp OF((char *, char *, unsigned int));
  646. #endif /* ZMEM */
  647. /* in system dependent fileio code (<system>.c) */
  648. #ifndef UTIL
  649. # ifdef PROCNAME
  650. int wild OF((char *));
  651. # endif
  652. char *in2ex OF((char *));
  653. char *ex2in OF((char *, int, int *));
  654. #if defined(UNICODE_SUPPORT) && defined(WIN32)
  655. int has_win32_wide OF((void));
  656. wchar_t *in2exw OF((wchar_t *));
  657. wchar_t *ex2inw OF((wchar_t *, int, int *));
  658. int procnamew OF((wchar_t *, int));
  659. #endif
  660. int procname OF((char *, int));
  661. void stamp OF((char *, ulg));
  662. ulg filetime OF((char *, ulg *, zoff_t *, iztimes *));
  663. /* Windows Unicode */
  664. # ifdef UNICODE_SUPPORT
  665. # ifdef WIN32
  666. ulg filetimew OF((wchar_t *, ulg *, zoff_t *, iztimes *));
  667. char *get_win32_utf8path OF((char *));
  668. wchar_t *local_to_wchar_string OF ((char *));
  669. # endif
  670. # endif
  671. # if !(defined(VMS) && defined(VMS_PK_EXTRA))
  672. int set_extra_field OF((struct zlist far *, iztimes *));
  673. # endif /* ?(VMS && VMS_PK_EXTRA) */
  674. int deletedir OF((char *));
  675. # ifdef MY_ZCALLOC
  676. zvoid far *zcalloc OF((unsigned int, unsigned int));
  677. zvoid zcfree OF((zvoid far *));
  678. # endif /* MY_ZCALLOC */
  679. #endif /* !UTIL */
  680. void version_local OF((void));
  681. /* in util.c */
  682. #ifndef UTIL
  683. int fseekable OF((FILE *));
  684. char *isshexp OF((char *));
  685. #ifdef UNICODE_SUPPORT
  686. # ifdef WIN32
  687. wchar_t *isshexpw OF((wchar_t *));
  688. int dosmatchw OF((ZCONST wchar_t *, ZCONST wchar_t *, int));
  689. # endif
  690. #endif
  691. int shmatch OF((ZCONST char *, ZCONST char *, int));
  692. # if defined(DOS) || defined(WIN32)
  693. int dosmatch OF((ZCONST char *, ZCONST char *, int));
  694. # endif /* DOS || WIN32 */
  695. #endif /* !UTIL */
  696. /* functions to convert zoff_t to a string */
  697. char *zip_fuzofft OF((uzoff_t, char *, char*));
  698. char *zip_fzofft OF((zoff_t, char *, char*));
  699. /* read and write number strings like 10M */
  700. int DisplayNumString OF ((FILE *file, uzoff_t i));
  701. int WriteNumString OF((uzoff_t num, char *outstring));
  702. uzoff_t ReadNumString OF((char *numstring));
  703. /* returns true if abbrev is abbreviation for string */
  704. int abbrevmatch OF((char *, char *, int, int));
  705. void init_upper OF((void));
  706. int namecmp OF((ZCONST char *string1, ZCONST char *string2));
  707. #ifdef EBCDIC
  708. char *strtoasc OF((char *str1, ZCONST char *str2));
  709. char *strtoebc OF((char *str1, ZCONST char *str2));
  710. char *memtoasc OF((char *mem1, ZCONST char *mem2, unsigned len));
  711. char *memtoebc OF((char *mem1, ZCONST char *mem2, unsigned len));
  712. #endif /* EBCDIC */
  713. #ifdef IZ_ISO2OEM_ARRAY
  714. char *str_iso_to_oem OF((char *dst, ZCONST char *src));
  715. #endif
  716. #ifdef IZ_OEM2ISO_ARRAY
  717. char *str_oem_to_iso OF((char *dst, ZCONST char *src));
  718. #endif
  719. zvoid far **search OF((ZCONST zvoid *, ZCONST zvoid far **, extent,
  720. int (*)(ZCONST zvoid *, ZCONST zvoid far *)));
  721. void envargs OF((int *, char ***, char *, char *));
  722. void expand_args OF((int *, char ***));
  723. int is_text_buf OF((ZCONST char *buf_ptr, unsigned buf_size));
  724. /* this is no longer used ...
  725. unsigned int adler16 OF((unsigned int, ZCONST uch *, extent));
  726. */
  727. /* crc functions are now declared in crc32.h */
  728. #ifndef UTIL
  729. #ifndef USE_ZLIB
  730. /* in deflate.c */
  731. void lm_init OF((int, ush *));
  732. void lm_free OF((void));
  733. uzoff_t deflate OF((void));
  734. /* in trees.c */
  735. void ct_init OF((ush *, int *));
  736. int ct_tally OF((int, int));
  737. uzoff_t flush_block OF((char far *, ulg, int));
  738. void bi_init OF((char *, unsigned int, int));
  739. #endif /* !USE_ZLIB */
  740. #endif /* !UTIL */
  741. /* in system specific assembler code, replacing C code in trees.c */
  742. #if defined(ASMV) && defined(RISCOS)
  743. void send_bits OF((int, int));
  744. unsigned bi_reverse OF((unsigned int, int));
  745. #endif /* ASMV && RISCOS */
  746. /*---------------------------------------------------------------------------
  747. VMS-only functions:
  748. ---------------------------------------------------------------------------*/
  749. #ifdef VMS
  750. int vms_stat OF((char *, stat_t *)); /* vms.c */
  751. void vms_exit OF((int)); /* vms.c */
  752. #ifndef UTIL
  753. #ifdef VMSCLI
  754. ulg vms_zip_cmdline OF((int *, char ***)); /* cmdline.c */
  755. void VMSCLI_help OF((void)); /* cmdline.c */
  756. #endif /* VMSCLI */
  757. #endif /* !UTIL */
  758. #endif /* VMS */
  759. /*
  760. #ifdef ZIP64_SUPPORT
  761. update_local_Zip64_extra_field OF((struct zlist far *, FILE *));
  762. #endif
  763. */
  764. /*---------------------------------------------------------------------------
  765. WIN32-only functions:
  766. ---------------------------------------------------------------------------*/
  767. #ifdef WIN32
  768. int ZipIsWinNT OF((void)); /* win32.c */
  769. int ClearArchiveBit OF((char *)); /* win32.c */
  770. # ifdef UNICODE_SUPPORT
  771. int ClearArchiveBitW OF((wchar_t *)); /* win32.c */
  772. # endif
  773. #endif /* WIN32 */
  774. #if (defined(WINDLL) || defined(DLL_ZIPAPI))
  775. /*---------------------------------------------------------------------------
  776. Prototypes for public Zip API (DLL) functions.
  777. ---------------------------------------------------------------------------*/
  778. #include "api.h"
  779. #endif /* WINDLL || DLL_ZIPAPI */
  780. /* WIN32_OEM */
  781. #ifdef WIN32
  782. /*
  783. # if defined(UNICODE_SUPPORT) || defined(WIN32_OEM)
  784. */
  785. /* convert oem to ansi string */
  786. char *oem_to_local_string OF((char *, char *));
  787. /*
  788. # endif
  789. */
  790. #endif
  791. #ifdef WIN32
  792. /*
  793. # if defined(UNICODE_SUPPORT) || defined(WIN32_OEM)
  794. */
  795. /* convert local string to oem string */
  796. char *local_to_oem_string OF((char *, char *));
  797. /*
  798. # endif
  799. */
  800. #endif
  801. /*---------------------------------------------------------------------
  802. Unicode Support
  803. 28 August 2005
  804. ---------------------------------------------------------------------*/
  805. #ifdef UNICODE_SUPPORT
  806. /* Default character when a zwchar too big for wchar_t */
  807. # define zwchar_to_wchar_t_default_char '_'
  808. /* Default character string when wchar_t does not convert to mb */
  809. # define wide_to_mb_default_string "_"
  810. /* wide character type */
  811. typedef unsigned long zwchar;
  812. /* check if string is all ASCII */
  813. int is_ascii_string OF((char *));
  814. #ifdef WIN32
  815. int is_ascii_stringw OF((wchar_t *));
  816. zwchar *wchar_to_wide_string OF((wchar_t *));
  817. #endif
  818. /* convert UTF-8 string to multi-byte string */
  819. char *utf8_to_local_string OF((char *));
  820. char *utf8_to_escape_string OF((char *));
  821. /* convert UTF-8 string to wide string */
  822. zwchar *utf8_to_wide_string OF((char *));
  823. /* convert wide string to multi-byte string */
  824. char *wide_to_local_string OF((zwchar *));
  825. char *wide_to_escape_string OF((zwchar *));
  826. char *local_to_escape_string OF((char *));
  827. #ifdef WIN32
  828. /* convert UTF-8 to wchar */
  829. wchar_t *utf8_to_wchar_string OF ((char *));
  830. char *wchar_to_local_string OF((wchar_t *));
  831. #endif
  832. /* convert local string to multi-byte display string */
  833. char *local_to_display_string OF((char *));
  834. /* convert wide character to escape string */
  835. char *wide_char_to_escape_string OF((unsigned long));
  836. #if 0
  837. /* convert escape string to wide character */
  838. unsigned long escape_string_to_wide OF((char *));
  839. #endif
  840. /* convert local to UTF-8 */
  841. char *local_to_utf8_string OF ((char *));
  842. /* convert local to wide string */
  843. zwchar *local_to_wide_string OF ((char *));
  844. /* convert wide string to UTF-8 */
  845. char *wide_to_utf8_string OF((zwchar *));
  846. #ifdef WIN32
  847. char *wchar_to_utf8_string OF((wchar_t *));
  848. #endif
  849. #endif /* UNICODE_SUPPORT */
  850. /*---------------------------------------------------
  851. * Split archives
  852. *
  853. * 10/20/05 EG
  854. */
  855. #define BFWRITE_DATA 0
  856. #define BFWRITE_LOCALHEADER 1
  857. #define BFWRITE_CENTRALHEADER 2
  858. #define BFWRITE_HEADER 3 /* data descriptor or end records */
  859. size_t bfwrite OF((ZCONST void *buffer, size_t size, size_t count,
  860. int));
  861. /* for putlocal() */
  862. #define PUTLOCAL_WRITE 0
  863. #define PUTLOCAL_REWRITE 1
  864. /*--------------------------------------------------------------------
  865. Long option support
  866. 23 August 2003
  867. See fileio.c
  868. --------------------------------------------------------------------*/
  869. /* The below is for use in the caller-provided options table */
  870. /* value_type - value is always returned as a string. */
  871. #define o_NO_VALUE 0 /* this option does not take a value */
  872. #define o_REQUIRED_VALUE 1 /* this option requires a value */
  873. #define o_OPTIONAL_VALUE 2 /* value is optional (see get_option() for details) */
  874. #define o_VALUE_LIST 3 /* this option takes a list of values */
  875. #define o_ONE_CHAR_VALUE 4 /* next char is value (does not end short opt string) */
  876. #define o_NUMBER_VALUE 5 /* value is integer (does not end short opt string) */
  877. /* negatable - a dash following the option (but before any value) sets negated. */
  878. #define o_NOT_NEGATABLE 0 /* trailing '-' to negate either starts value or generates error */
  879. #define o_NEGATABLE 1 /* trailing '-' sets negated to TRUE */
  880. /* option_num can be this when option not in options table */
  881. #define o_NO_OPTION_MATCH -1
  882. /* special values returned by get_option - do not use these as option IDs */
  883. #define o_NON_OPTION_ARG ((unsigned long) 0xFFFF) /* returned for non-option
  884. args */
  885. #define o_ARG_FILE_ERR ((unsigned long) 0xFFFE) /* internal recursion
  886. return (user never sees) */
  887. /* options array is set in zip.c */
  888. struct option_struct {
  889. char *shortopt; /* char * to sequence of char that is short option */
  890. char Far *longopt; /* char * to long option string */
  891. int value_type; /* from above */
  892. int negatable; /* from above */
  893. unsigned long option_ID; /* value returned by get_option when this option is found */
  894. char Far *name; /* optional string for option returned on some errors */
  895. };
  896. extern struct option_struct far options[];
  897. /* moved here from fileio.c to make global - 10/6/05 EG */
  898. /* If will support wide for Unicode then need to add */
  899. /* multi-byte */
  900. #ifdef _MBCS
  901. # ifndef MULTIBYTE_GETOPTNS
  902. # define MULTIBYTE_GETOPTNS
  903. # endif
  904. #endif
  905. #ifdef MULTIBYTE_GETOPTNS
  906. int mb_clen OF((ZCONST char *));
  907. # define MB_CLEN(ptr) mb_clen(ptr)
  908. # define MB_NEXTCHAR(ptr) ((ptr) += MB_CLEN(ptr))
  909. #else
  910. /* no multi-byte */
  911. # define MB_CLEN(ptr) (1)
  912. # define MB_NEXTCHAR(ptr) ((ptr)++)
  913. #endif
  914. /* function prototypes */
  915. /* get the next option from args */
  916. unsigned long get_option OF((char ***pargs, int *argc, int *argnum, int *optchar,
  917. char **value, int *negated, int *first_nonopt_arg,
  918. int *option_num, int recursion_depth));
  919. /* copy args - copy an args array, allocating space as needed */
  920. char **copy_args OF((char **args, int max_args));
  921. /* free args - free args created with one of these functions */
  922. int free_args OF ((char **args));
  923. /* insert arg - copy an arg into args */
  924. int insert_arg OF ((char ***args, ZCONST char *arg, int insert_at,
  925. int free_args));
  926. /*--------------------------------------------------------------------
  927. End of Long option support
  928. --------------------------------------------------------------------*/
  929. #endif /* !__zip_h */
  930. /* end of zip.h */