0000: 2f 2a 0d 0a 20 2a 20 20 46 44 49 2e 48 20 2d 2d /*.. * FDI.H --
0010: 20 46 69 6c 65 20 44 65 63 6f 6d 70 72 65 73 73 File Decompress
0020: 69 6f 6e 20 49 6e 74 65 72 66 61 63 65 0d 0a 20 ion Interface..
0030: 2a 0d 0a 20 2a 20 20 43 6f 70 79 72 69 67 68 74 *.. * Copyright
0040: 20 28 43 29 20 4d 69 63 72 6f 73 6f 66 74 20 43 (C) Microsoft C
0050: 6f 72 70 6f 72 61 74 69 6f 6e 20 31 39 39 33 2d orporation 1993-
0060: 31 39 39 37 0d 0a 20 2a 20 20 41 6c 6c 20 52 69 1997.. * All Ri
0070: 67 68 74 73 20 52 65 73 65 72 76 65 64 2e 0d 0a ghts Reserved...
0080: 20 2a 2f 0d 0a 0d 0a 23 69 66 64 65 66 20 20 5f */....#ifdef _
0090: 5f 63 70 6c 75 73 70 6c 75 73 0d 0a 65 78 74 65 _cplusplus..exte
00a0: 72 6e 20 22 43 22 20 7b 0d 0a 23 65 6e 64 69 66 rn "C" {..#endif
00b0: 0d 0a 0d 0a 23 69 66 6e 64 65 66 20 49 4e 43 4c ....#ifndef INCL
00c0: 55 44 45 44 5f 54 59 50 45 53 5f 46 43 49 5f 46 UDED_TYPES_FCI_F
00d0: 44 49 0d 0a 23 64 65 66 69 6e 65 20 49 4e 43 4c DI..#define INCL
00e0: 55 44 45 44 5f 54 59 50 45 53 5f 46 43 49 5f 46 UDED_TYPES_FCI_F
00f0: 44 49 20 31 0d 0a 0d 0a 23 69 66 6e 64 65 66 20 DI 1....#ifndef
0100: 48 55 47 45 0d 0a 23 64 65 66 69 6e 65 20 48 55 HUGE..#define HU
0110: 47 45 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 23 69 GE..#endif....#i
0120: 66 6e 64 65 66 20 46 41 52 0d 0a 23 64 65 66 69 fndef FAR..#defi
0130: 6e 65 20 46 41 52 0d 0a 23 65 6e 64 69 66 0d 0a ne FAR..#endif..
0140: 0d 0a 23 69 66 6e 64 65 66 20 44 49 41 4d 4f 4e ..#ifndef DIAMON
0150: 44 41 50 49 0d 0a 23 64 65 66 69 6e 65 20 44 49 DAPI..#define DI
0160: 41 4d 4f 4e 44 41 50 49 20 5f 5f 63 64 65 63 6c AMONDAPI __cdecl
0170: 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 0d 0a 2f 2f ..#endif......//
0180: 2a 2a 20 53 70 65 63 69 66 79 20 73 74 72 75 63 ** Specify struc
0190: 74 75 72 65 20 70 61 63 6b 69 6e 67 20 65 78 70 ture packing exp
01a0: 6c 69 63 69 74 6c 79 20 66 6f 72 20 63 6c 69 65 licitly for clie
01b0: 6e 74 73 20 6f 66 20 46 44 49 0d 0a 23 70 72 61 nts of FDI..#pra
01c0: 67 6d 61 20 70 61 63 6b 28 34 29 0d 0a 0d 0a 2f gma pack(4)..../
01d0: 2f 2a 2a 20 44 6f 6e 27 74 20 72 65 64 65 66 69 /** Don't redefi
01e0: 6e 65 20 74 79 70 65 73 20 64 65 66 69 6e 65 64 ne types defined
01f0: 20 69 6e 20 57 69 6e 31 36 20 57 49 4e 44 4f 57 in Win16 WINDOW
0200: 53 2e 48 20 28 5f 49 4e 43 5f 57 49 4e 44 4f 57 S.H (_INC_WINDOW
0210: 53 29 0d 0a 2f 2f 20 20 20 6f 72 20 57 69 6e 33 S)..// or Win3
0220: 32 20 57 49 4e 44 4f 57 53 2e 48 20 28 5f 57 49 2 WINDOWS.H (_WI
0230: 4e 44 4f 57 53 5f 29 0d 0a 2f 2f 0d 0a 23 69 66 NDOWS_)..//..#if
0240: 20 21 64 65 66 69 6e 65 64 28 5f 49 4e 43 5f 57 !defined(_INC_W
0250: 49 4e 44 4f 57 53 29 20 26 26 20 21 64 65 66 69 INDOWS) && !defi
0260: 6e 65 64 28 5f 57 49 4e 44 4f 57 53 5f 29 0d 0a ned(_WINDOWS_)..
0270: 74 79 70 65 64 65 66 20 69 6e 74 20 20 20 20 20 typedef int
0280: 20 20 20 20 20 20 20 42 4f 4f 4c 3b 20 20 20 20 BOOL;
0290: 20 2f 2a 20 66 20 2a 2f 0d 0a 74 79 70 65 64 65 /* f */..typede
02a0: 66 20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 f unsigned char
02b0: 20 42 59 54 45 3b 20 20 20 20 20 2f 2a 20 62 20 BYTE; /* b
02c0: 2a 2f 0d 0a 74 79 70 65 64 65 66 20 75 6e 73 69 */..typedef unsi
02d0: 67 6e 65 64 20 69 6e 74 20 20 20 55 49 4e 54 3b gned int UINT;
02e0: 20 20 20 20 20 2f 2a 20 75 69 20 2a 2f 0d 0a 74 /* ui */..t
02f0: 79 70 65 64 65 66 20 75 6e 73 69 67 6e 65 64 20 ypedef unsigned
0300: 73 68 6f 72 74 20 55 53 48 4f 52 54 3b 20 20 20 short USHORT;
0310: 2f 2a 20 75 73 20 2a 2f 0d 0a 74 79 70 65 64 65 /* us */..typede
0320: 66 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 f unsigned long
0330: 20 55 4c 4f 4e 47 3b 20 20 20 20 2f 2a 20 75 6c ULONG; /* ul
0340: 20 2a 2f 0d 0a 23 65 6e 64 69 66 20 20 20 2f 2f */..#endif //
0350: 20 5f 49 4e 43 5f 57 49 4e 44 4f 57 53 0d 0a 0d _INC_WINDOWS...
0360: 0a 74 79 70 65 64 65 66 20 75 6e 73 69 67 6e 65 .typedef unsigne
0370: 64 20 6c 6f 6e 67 20 20 43 48 45 43 4b 53 55 4d d long CHECKSUM
0380: 3b 20 2f 2a 20 63 73 75 6d 20 2a 2f 0d 0a 0d 0a ; /* csum */....
0390: 74 79 70 65 64 65 66 20 75 6e 73 69 67 6e 65 64 typedef unsigned
03a0: 20 6c 6f 6e 67 20 20 55 4f 46 46 3b 20 20 20 20 long UOFF;
03b0: 20 2f 2a 20 75 6f 66 66 20 2d 20 75 6e 63 6f 6d /* uoff - uncom
03c0: 70 72 65 73 73 65 64 20 6f 66 66 73 65 74 20 2a pressed offset *
03d0: 2f 0d 0a 74 79 70 65 64 65 66 20 75 6e 73 69 67 /..typedef unsig
03e0: 6e 65 64 20 6c 6f 6e 67 20 20 43 4f 46 46 3b 20 ned long COFF;
03f0: 20 20 20 20 2f 2a 20 63 6f 66 66 20 2d 20 63 61 /* coff - ca
0400: 62 69 6e 65 74 20 66 69 6c 65 20 6f 66 66 73 65 binet file offse
0410: 74 20 2a 2f 0d 0a 0d 0a 0d 0a 23 69 66 6e 64 65 t */......#ifnde
0420: 66 20 54 52 55 45 0d 0a 23 64 65 66 69 6e 65 20 f TRUE..#define
0430: 54 52 55 45 20 20 20 20 31 0d 0a 23 65 6e 64 69 TRUE 1..#endi
0440: 66 0d 0a 0d 0a 23 69 66 6e 64 65 66 20 46 41 4c f....#ifndef FAL
0450: 53 45 0d 0a 23 64 65 66 69 6e 65 20 46 41 4c 53 SE..#define FALS
0460: 45 20 20 20 30 0d 0a 23 65 6e 64 69 66 0d 0a 0d E 0..#endif...
0470: 0a 23 69 66 6e 64 65 66 20 4e 55 4c 4c 0d 0a 23 .#ifndef NULL..#
0480: 64 65 66 69 6e 65 20 4e 55 4c 4c 20 20 20 20 30 define NULL 0
0490: 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 0d 0a 2f 2a ..#endif....../*
04a0: 2a 2a 20 20 20 20 45 52 46 20 2d 20 45 72 72 6f ** ERF - Erro
04b0: 72 20 73 74 72 75 63 74 75 72 65 0d 0a 20 2a 0d r structure.. *.
04c0: 0a 20 2a 20 20 54 68 69 73 20 73 74 72 75 63 74 . * This struct
04d0: 75 72 65 20 72 65 74 75 72 6e 73 20 65 72 72 6f ure returns erro
04e0: 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 72 r information fr
04f0: 6f 6d 20 46 43 49 2f 46 44 49 2e 20 20 54 68 65 om FCI/FDI. The
0500: 20 63 61 6c 6c 65 72 20 73 68 6f 75 6c 64 0d 0a caller should..
0510: 20 2a 20 20 6e 6f 74 20 6d 6f 64 69 66 79 20 74 * not modify t
0520: 68 69 73 20 73 74 72 75 63 74 75 72 65 2e 0d 0a his structure...
0530: 20 2a 2f 0d 0a 74 79 70 65 64 65 66 20 73 74 72 */..typedef str
0540: 75 63 74 20 7b 0d 0a 20 20 20 20 69 6e 74 20 20 uct {.. int
0550: 20 20 20 65 72 66 4f 70 65 72 3b 20 20 20 20 20 erfOper;
0560: 20 20 20 20 20 20 20 2f 2f 20 46 43 49 2f 46 44 // FCI/FD
0570: 49 20 65 72 72 6f 72 20 63 6f 64 65 20 2d 2d 20 I error code --
0580: 73 65 65 20 46 44 49 45 52 52 4f 52 5f 58 58 58 see FDIERROR_XXX
0590: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
05a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
05b0: 20 20 2f 2f 20 20 61 6e 64 20 46 43 49 45 52 52 // and FCIERR
05c0: 5f 58 58 58 20 65 71 75 61 74 65 73 20 66 6f 72 _XXX equates for
05d0: 20 64 65 74 61 69 6c 73 2e 0d 0a 0d 0a 20 20 20 details.....
05e0: 20 69 6e 74 20 20 20 20 20 65 72 66 54 79 70 65 int erfType
05f0: 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 ; //
0600: 4f 70 74 69 6f 6e 61 6c 20 65 72 72 6f 72 20 76 Optional error v
0610: 61 6c 75 65 20 66 69 6c 6c 65 64 20 69 6e 20 62 alue filled in b
0620: 79 20 46 43 49 2f 46 44 49 2e 0d 0a 20 20 20 20 y FCI/FDI...
0630: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0640: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 // F
0650: 6f 72 20 46 43 49 2c 20 74 68 69 73 20 69 73 20 or FCI, this is
0660: 75 73 75 61 6c 6c 79 20 74 68 65 20 43 20 72 75 usually the C ru
0670: 6e 2d 74 69 6d 65 0d 0a 20 20 20 20 20 20 20 20 n-time..
0680: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0690: 20 20 20 20 20 20 20 20 2f 2f 20 2a 65 72 72 6e // *errn
06a0: 6f 2a 20 76 61 6c 75 65 2e 0d 0a 0d 0a 20 20 20 o* value.....
06b0: 20 42 4f 4f 4c 20 20 20 20 66 45 72 72 6f 72 3b BOOL fError;
06c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
06d0: 54 52 55 45 20 3d 3e 20 65 72 72 6f 72 20 70 72 TRUE => error pr
06e0: 65 73 65 6e 74 0d 0a 7d 20 45 52 46 3b 20 20 20 esent..} ERF;
06f0: 20 20 20 2f 2a 20 65 72 66 20 2a 2f 0d 0a 74 79 /* erf */..ty
0700: 70 65 64 65 66 20 45 52 46 20 46 41 52 20 2a 50 pedef ERF FAR *P
0710: 45 52 46 3b 20 20 2f 2a 20 70 65 72 66 20 2a 2f ERF; /* perf */
0720: 0d 0a 0d 0a 23 69 66 64 65 66 20 5f 44 45 42 55 ....#ifdef _DEBU
0730: 47 0d 0a 2f 2f 20 64 6f 6e 27 74 20 68 69 64 65 G..// don't hide
0740: 20 73 74 61 74 69 63 73 20 66 72 6f 6d 20 6d 61 statics from ma
0750: 70 20 64 75 72 69 6e 67 20 64 65 62 75 67 67 69 p during debuggi
0760: 6e 67 0d 0a 23 64 65 66 69 6e 65 20 53 54 41 54 ng..#define STAT
0770: 49 43 20 20 20 20 20 20 0d 0a 23 65 6c 73 65 20 IC ..#else
0780: 2f 2f 20 21 44 45 42 55 47 0d 0a 23 64 65 66 69 // !DEBUG..#defi
0790: 6e 65 20 53 54 41 54 49 43 20 73 74 61 74 69 63 ne STATIC static
07a0: 0d 0a 23 65 6e 64 69 66 20 2f 2f 20 21 44 45 42 ..#endif // !DEB
07b0: 55 47 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 43 42 UG....#define CB
07c0: 5f 4d 41 58 5f 43 48 55 4e 4b 20 20 20 20 20 20 _MAX_CHUNK
07d0: 20 20 20 20 20 20 33 32 37 36 38 55 0d 0a 23 64 32768U..#d
07e0: 65 66 69 6e 65 20 43 42 5f 4d 41 58 5f 44 49 53 efine CB_MAX_DIS
07f0: 4b 20 20 20 20 20 20 20 20 30 78 37 66 66 66 66 K 0x7ffff
0800: 66 66 66 4c 0d 0a 23 64 65 66 69 6e 65 20 43 42 fffL..#define CB
0810: 5f 4d 41 58 5f 46 49 4c 45 4e 41 4d 45 20 20 20 _MAX_FILENAME
0820: 20 20 20 20 20 20 20 20 20 32 35 36 0d 0a 23 64 256..#d
0830: 65 66 69 6e 65 20 43 42 5f 4d 41 58 5f 43 41 42 efine CB_MAX_CAB
0840: 49 4e 45 54 5f 4e 41 4d 45 20 20 20 20 20 20 20 INET_NAME
0850: 20 32 35 36 0d 0a 23 64 65 66 69 6e 65 20 43 42 256..#define CB
0860: 5f 4d 41 58 5f 43 41 42 5f 50 41 54 48 20 20 20 _MAX_CAB_PATH
0870: 20 20 20 20 20 20 20 20 20 32 35 36 0d 0a 23 64 256..#d
0880: 65 66 69 6e 65 20 43 42 5f 4d 41 58 5f 44 49 53 efine CB_MAX_DIS
0890: 4b 5f 4e 41 4d 45 20 20 20 20 20 20 20 20 20 20 K_NAME
08a0: 20 32 35 36 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 256..../***
08b0: 74 63 6f 6d 70 58 58 58 20 2d 20 43 6f 6d 70 72 tcompXXX - Compr
08c0: 65 73 73 69 6f 6e 20 74 79 70 65 73 0d 0a 20 2a ession types.. *
08d0: 0d 0a 20 2a 20 20 54 68 65 73 65 20 61 72 65 20 .. * These are
08e0: 70 61 73 73 65 64 20 74 6f 20 46 43 49 41 64 64 passed to FCIAdd
08f0: 46 69 6c 65 28 29 2c 20 61 6e 64 20 61 72 65 20 File(), and are
0900: 61 6c 73 6f 20 73 74 6f 72 65 64 20 69 6e 20 74 also stored in t
0910: 68 65 20 43 46 46 4f 4c 44 45 52 0d 0a 20 2a 20 he CFFOLDER.. *
0920: 20 73 74 72 75 63 74 75 72 65 73 20 69 6e 20 63 structures in c
0930: 61 62 69 6e 65 74 20 66 69 6c 65 73 2e 0d 0a 20 abinet files...
0940: 2a 0d 0a 20 2a 20 20 4e 4f 54 45 3a 20 57 65 20 *.. * NOTE: We
0950: 72 65 73 65 72 76 65 20 62 69 74 73 20 66 6f 72 reserve bits for
0960: 20 74 68 65 20 54 59 50 45 2c 20 51 55 41 4e 54 the TYPE, QUANT
0970: 55 4d 5f 4c 45 56 45 4c 2c 20 61 6e 64 20 51 55 UM_LEVEL, and QU
0980: 41 4e 54 55 4d 5f 4d 45 4d 0d 0a 20 2a 20 20 20 ANTUM_MEM.. *
0990: 20 20 20 20 20 74 6f 20 70 72 6f 76 69 64 65 20 to provide
09a0: 72 6f 6f 6d 20 66 6f 72 20 66 75 74 75 72 65 20 room for future
09b0: 65 78 70 61 6e 73 69 6f 6e 2e 20 20 53 69 6e 63 expansion. Sinc
09c0: 65 20 74 68 69 73 20 76 61 6c 75 65 20 69 73 20 e this value is
09d0: 73 74 6f 72 65 64 0d 0a 20 2a 20 20 20 20 20 20 stored.. *
09e0: 20 20 69 6e 20 74 68 65 20 43 46 44 41 54 41 20 in the CFDATA
09f0: 72 65 63 6f 72 64 73 20 69 6e 20 74 68 65 20 63 records in the c
0a00: 61 62 69 6e 65 74 20 66 69 6c 65 2c 20 77 65 20 abinet file, we
0a10: 64 6f 6e 27 74 20 77 61 6e 74 20 74 6f 0d 0a 20 don't want to..
0a20: 2a 20 20 20 20 20 20 20 20 68 61 76 65 20 74 6f * have to
0a30: 20 63 68 61 6e 67 65 20 74 68 65 20 66 6f 72 6d change the form
0a40: 61 74 20 66 6f 72 20 65 78 69 73 74 69 6e 67 20 at for existing
0a50: 63 6f 6d 70 72 65 73 73 69 6f 6e 20 63 6f 6e 66 compression conf
0a60: 69 67 75 72 61 74 69 6f 6e 73 0d 0a 20 2a 20 20 igurations.. *
0a70: 20 20 20 20 20 20 69 66 20 77 65 20 61 64 64 20 if we add
0a80: 6e 65 77 20 6f 6e 65 73 20 69 6e 20 74 68 65 20 new ones in the
0a90: 66 75 74 75 72 65 2e 20 20 54 68 69 73 20 77 69 future. This wi
0aa0: 6c 6c 20 61 6c 6c 6f 77 73 20 75 73 20 74 6f 20 ll allows us to
0ab0: 72 65 61 64 0d 0a 20 2a 20 20 20 20 20 20 20 20 read.. *
0ac0: 6f 6c 64 20 63 61 62 69 6e 65 74 20 66 69 6c 65 old cabinet file
0ad0: 73 20 69 6e 20 74 68 65 20 66 75 74 75 72 65 2e s in the future.
0ae0: 0d 0a 20 2a 2f 0d 0a 0d 0a 74 79 70 65 64 65 66 .. */....typedef
0af0: 20 75 6e 73 69 67 6e 65 64 20 73 68 6f 72 74 20 unsigned short
0b00: 54 43 4f 4d 50 3b 20 2f 2a 20 74 63 6f 6d 70 20 TCOMP; /* tcomp
0b10: 2a 2f 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 74 63 */....#define tc
0b20: 6f 6d 70 4d 41 53 4b 5f 54 59 50 45 20 20 20 20 ompMASK_TYPE
0b30: 20 20 20 20 20 20 30 78 30 30 30 46 20 20 2f 2f 0x000F //
0b40: 20 4d 61 73 6b 20 66 6f 72 20 63 6f 6d 70 72 65 Mask for compre
0b50: 73 73 69 6f 6e 20 74 79 70 65 0d 0a 23 64 65 66 ssion type..#def
0b60: 69 6e 65 20 74 63 6f 6d 70 54 59 50 45 5f 4e 4f ine tcompTYPE_NO
0b70: 4e 45 20 20 20 20 20 20 20 20 20 20 30 78 30 30 NE 0x00
0b80: 30 30 20 20 2f 2f 20 4e 6f 20 63 6f 6d 70 72 65 00 // No compre
0b90: 73 73 69 6f 6e 0d 0a 23 64 65 66 69 6e 65 20 74 ssion..#define t
0ba0: 63 6f 6d 70 54 59 50 45 5f 4d 53 5a 49 50 20 20 compTYPE_MSZIP
0bb0: 20 20 20 20 20 20 20 30 78 30 30 30 31 20 20 2f 0x0001 /
0bc0: 2f 20 4d 53 5a 49 50 0d 0a 23 64 65 66 69 6e 65 / MSZIP..#define
0bd0: 20 74 63 6f 6d 70 54 59 50 45 5f 51 55 41 4e 54 tcompTYPE_QUANT
0be0: 55 4d 20 20 20 20 20 20 20 30 78 30 30 30 32 20 UM 0x0002
0bf0: 20 2f 2f 20 51 75 61 6e 74 75 6d 0d 0a 23 64 65 // Quantum..#de
0c00: 66 69 6e 65 20 74 63 6f 6d 70 54 59 50 45 5f 4c fine tcompTYPE_L
0c10: 5a 58 20 20 20 20 20 20 20 20 20 20 20 30 78 30 ZX 0x0
0c20: 30 30 33 20 20 2f 2f 20 4c 5a 58 0d 0a 23 64 65 003 // LZX..#de
0c30: 66 69 6e 65 20 74 63 6f 6d 70 42 41 44 20 20 20 fine tcompBAD
0c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 30 78 30 0x0
0c50: 30 30 46 20 20 2f 2f 20 55 6e 73 70 65 63 69 66 00F // Unspecif
0c60: 69 65 64 20 63 6f 6d 70 72 65 73 73 69 6f 6e 20 ied compression
0c70: 74 79 70 65 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 type....#define
0c80: 74 63 6f 6d 70 4d 41 53 4b 5f 4c 5a 58 5f 57 49 tcompMASK_LZX_WI
0c90: 4e 44 4f 57 20 20 20 20 30 78 31 46 30 30 20 20 NDOW 0x1F00
0ca0: 2f 2f 20 4d 61 73 6b 20 66 6f 72 20 4c 5a 58 20 // Mask for LZX
0cb0: 43 6f 6d 70 72 65 73 73 69 6f 6e 20 4d 65 6d 6f Compression Memo
0cc0: 72 79 0d 0a 23 64 65 66 69 6e 65 20 74 63 6f 6d ry..#define tcom
0cd0: 70 4c 5a 58 5f 57 49 4e 44 4f 57 5f 4c 4f 20 20 pLZX_WINDOW_LO
0ce0: 20 20 20 20 30 78 30 46 30 30 20 20 2f 2f 20 4c 0x0F00 // L
0cf0: 6f 77 65 73 74 20 4c 5a 58 20 4d 65 6d 6f 72 79 owest LZX Memory
0d00: 20 28 31 35 29 0d 0a 23 64 65 66 69 6e 65 20 74 (15)..#define t
0d10: 63 6f 6d 70 4c 5a 58 5f 57 49 4e 44 4f 57 5f 48 compLZX_WINDOW_H
0d20: 49 20 20 20 20 20 20 30 78 31 35 30 30 20 20 2f I 0x1500 /
0d30: 2f 20 48 69 67 68 65 73 74 20 4c 5a 58 20 4d 65 / Highest LZX Me
0d40: 6d 6f 72 79 20 28 32 31 29 0d 0a 23 64 65 66 69 mory (21)..#defi
0d50: 6e 65 20 74 63 6f 6d 70 53 48 49 46 54 5f 4c 5a ne tcompSHIFT_LZ
0d60: 58 5f 57 49 4e 44 4f 57 20 20 20 20 20 20 20 20 X_WINDOW
0d70: 38 20 20 2f 2f 20 41 6d 6f 75 6e 74 20 74 6f 20 8 // Amount to
0d80: 73 68 69 66 74 20 6f 76 65 72 20 74 6f 20 67 65 shift over to ge
0d90: 74 20 69 6e 74 0d 0a 0d 0a 23 64 65 66 69 6e 65 t int....#define
0da0: 20 74 63 6f 6d 70 4d 41 53 4b 5f 51 55 41 4e 54 tcompMASK_QUANT
0db0: 55 4d 5f 4c 45 56 45 4c 20 30 78 30 30 46 30 20 UM_LEVEL 0x00F0
0dc0: 20 2f 2f 20 4d 61 73 6b 20 66 6f 72 20 51 75 61 // Mask for Qua
0dd0: 6e 74 75 6d 20 43 6f 6d 70 72 65 73 73 69 6f 6e ntum Compression
0de0: 20 4c 65 76 65 6c 0d 0a 23 64 65 66 69 6e 65 20 Level..#define
0df0: 74 63 6f 6d 70 51 55 41 4e 54 55 4d 5f 4c 45 56 tcompQUANTUM_LEV
0e00: 45 4c 5f 4c 4f 20 20 20 30 78 30 30 31 30 20 20 EL_LO 0x0010
0e10: 2f 2f 20 4c 6f 77 65 73 74 20 51 75 61 6e 74 75 // Lowest Quantu
0e20: 6d 20 4c 65 76 65 6c 20 28 31 29 0d 0a 23 64 65 m Level (1)..#de
0e30: 66 69 6e 65 20 74 63 6f 6d 70 51 55 41 4e 54 55 fine tcompQUANTU
0e40: 4d 5f 4c 45 56 45 4c 5f 48 49 20 20 20 30 78 30 M_LEVEL_HI 0x0
0e50: 30 37 30 20 20 2f 2f 20 48 69 67 68 65 73 74 20 070 // Highest
0e60: 51 75 61 6e 74 75 6d 20 4c 65 76 65 6c 20 28 37 Quantum Level (7
0e70: 29 0d 0a 23 64 65 66 69 6e 65 20 74 63 6f 6d 70 )..#define tcomp
0e80: 53 48 49 46 54 5f 51 55 41 4e 54 55 4d 5f 4c 45 SHIFT_QUANTUM_LE
0e90: 56 45 4c 20 20 20 20 20 34 20 20 2f 2f 20 41 6d VEL 4 // Am
0ea0: 6f 75 6e 74 20 74 6f 20 73 68 69 66 74 20 6f 76 ount to shift ov
0eb0: 65 72 20 74 6f 20 67 65 74 20 69 6e 74 0d 0a 0d er to get int...
0ec0: 0a 23 64 65 66 69 6e 65 20 74 63 6f 6d 70 4d 41 .#define tcompMA
0ed0: 53 4b 5f 51 55 41 4e 54 55 4d 5f 4d 45 4d 20 20 SK_QUANTUM_MEM
0ee0: 20 30 78 31 46 30 30 20 20 2f 2f 20 4d 61 73 6b 0x1F00 // Mask
0ef0: 20 66 6f 72 20 51 75 61 6e 74 75 6d 20 43 6f 6d for Quantum Com
0f00: 70 72 65 73 73 69 6f 6e 20 4d 65 6d 6f 72 79 0d pression Memory.
0f10: 0a 23 64 65 66 69 6e 65 20 74 63 6f 6d 70 51 55 .#define tcompQU
0f20: 41 4e 54 55 4d 5f 4d 45 4d 5f 4c 4f 20 20 20 20 ANTUM_MEM_LO
0f30: 20 30 78 30 41 30 30 20 20 2f 2f 20 4c 6f 77 65 0x0A00 // Lowe
0f40: 73 74 20 51 75 61 6e 74 75 6d 20 4d 65 6d 6f 72 st Quantum Memor
0f50: 79 20 28 31 30 29 0d 0a 23 64 65 66 69 6e 65 20 y (10)..#define
0f60: 74 63 6f 6d 70 51 55 41 4e 54 55 4d 5f 4d 45 4d tcompQUANTUM_MEM
0f70: 5f 48 49 20 20 20 20 20 30 78 31 35 30 30 20 20 _HI 0x1500
0f80: 2f 2f 20 48 69 67 68 65 73 74 20 51 75 61 6e 74 // Highest Quant
0f90: 75 6d 20 4d 65 6d 6f 72 79 20 28 32 31 29 0d 0a um Memory (21)..
0fa0: 23 64 65 66 69 6e 65 20 74 63 6f 6d 70 53 48 49 #define tcompSHI
0fb0: 46 54 5f 51 55 41 4e 54 55 4d 5f 4d 45 4d 20 20 FT_QUANTUM_MEM
0fc0: 20 20 20 20 20 38 20 20 2f 2f 20 41 6d 6f 75 6e 8 // Amoun
0fd0: 74 20 74 6f 20 73 68 69 66 74 20 6f 76 65 72 20 t to shift over
0fe0: 74 6f 20 67 65 74 20 69 6e 74 0d 0a 0d 0a 23 64 to get int....#d
0ff0: 65 66 69 6e 65 20 74 63 6f 6d 70 4d 41 53 4b 5f efine tcompMASK_
1000: 52 45 53 45 52 56 45 44 20 20 20 20 20 20 30 78 RESERVED 0x
1010: 45 30 30 30 20 20 2f 2f 20 52 65 73 65 72 76 65 E000 // Reserve
1020: 64 20 62 69 74 73 20 28 68 69 67 68 20 33 20 62 d bits (high 3 b
1030: 69 74 73 29 0d 0a 0d 0a 0d 0a 0d 0a 23 64 65 66 its)........#def
1040: 69 6e 65 20 43 6f 6d 70 72 65 73 73 69 6f 6e 54 ine CompressionT
1050: 79 70 65 46 72 6f 6d 54 43 4f 4d 50 28 74 63 29 ypeFromTCOMP(tc)
1060: 20 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 \..
1070: 28 28 74 63 29 20 26 20 74 63 6f 6d 70 4d 41 53 ((tc) & tcompMAS
1080: 4b 5f 54 59 50 45 29 0d 0a 0d 0a 23 64 65 66 69 K_TYPE)....#defi
1090: 6e 65 20 43 6f 6d 70 72 65 73 73 69 6f 6e 4c 65 ne CompressionLe
10a0: 76 65 6c 46 72 6f 6d 54 43 4f 4d 50 28 74 63 29 velFromTCOMP(tc)
10b0: 20 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 \..
10c0: 28 28 28 74 63 29 20 26 20 74 63 6f 6d 70 4d 41 (((tc) & tcompMA
10d0: 53 4b 5f 51 55 41 4e 54 55 4d 5f 4c 45 56 45 4c SK_QUANTUM_LEVEL
10e0: 29 20 3e 3e 20 74 63 6f 6d 70 53 48 49 46 54 5f ) >> tcompSHIFT_
10f0: 51 55 41 4e 54 55 4d 5f 4c 45 56 45 4c 29 0d 0a QUANTUM_LEVEL)..
1100: 0d 0a 23 64 65 66 69 6e 65 20 43 6f 6d 70 72 65 ..#define Compre
1110: 73 73 69 6f 6e 4d 65 6d 6f 72 79 46 72 6f 6d 54 ssionMemoryFromT
1120: 43 4f 4d 50 28 74 63 29 20 5c 0d 0a 20 20 20 20 COMP(tc) \..
1130: 20 20 20 20 20 20 20 20 28 28 28 74 63 29 20 26 (((tc) &
1140: 20 74 63 6f 6d 70 4d 41 53 4b 5f 51 55 41 4e 54 tcompMASK_QUANT
1150: 55 4d 5f 4d 45 4d 29 20 3e 3e 20 74 63 6f 6d 70 UM_MEM) >> tcomp
1160: 53 48 49 46 54 5f 51 55 41 4e 54 55 4d 5f 4d 45 SHIFT_QUANTUM_ME
1170: 4d 29 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 54 43 M)....#define TC
1180: 4f 4d 50 66 72 6f 6d 54 79 70 65 4c 65 76 65 6c OMPfromTypeLevel
1190: 4d 65 6d 6f 72 79 28 74 2c 6c 2c 6d 29 20 20 20 Memory(t,l,m)
11a0: 20 20 20 20 20 20 20 20 5c 0d 0a 20 20 20 20 20 \..
11b0: 20 20 20 20 20 20 20 28 28 28 6d 29 20 3c 3c 20 (((m) <<
11c0: 74 63 6f 6d 70 53 48 49 46 54 5f 51 55 41 4e 54 tcompSHIFT_QUANT
11d0: 55 4d 5f 4d 45 4d 20 20 29 20 7c 20 20 5c 0d 0a UM_MEM ) | \..
11e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 28 6c ((l
11f0: 29 20 3c 3c 20 74 63 6f 6d 70 53 48 49 46 54 5f ) << tcompSHIFT_
1200: 51 55 41 4e 54 55 4d 5f 4c 45 56 45 4c 29 20 7c QUANTUM_LEVEL) |
1210: 20 20 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 \..
1220: 20 20 28 20 74 20 20 20 20 20 20 20 20 20 20 20 ( t
1230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1240: 20 20 29 29 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 ))....#define
1250: 4c 5a 58 43 6f 6d 70 72 65 73 73 69 6f 6e 57 69 LZXCompressionWi
1260: 6e 64 6f 77 46 72 6f 6d 54 43 4f 4d 50 28 74 63 ndowFromTCOMP(tc
1270: 29 20 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ) \..
1280: 20 28 28 28 74 63 29 20 26 20 74 63 6f 6d 70 4d (((tc) & tcompM
1290: 41 53 4b 5f 4c 5a 58 5f 57 49 4e 44 4f 57 29 20 ASK_LZX_WINDOW)
12a0: 3e 3e 20 74 63 6f 6d 70 53 48 49 46 54 5f 4c 5a >> tcompSHIFT_LZ
12b0: 58 5f 57 49 4e 44 4f 57 29 0d 0a 0d 0a 23 64 65 X_WINDOW)....#de
12c0: 66 69 6e 65 20 54 43 4f 4d 50 66 72 6f 6d 4c 5a fine TCOMPfromLZ
12d0: 58 57 69 6e 64 6f 77 28 77 29 20 20 20 20 20 20 XWindow(w)
12e0: 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 28 \.. (
12f0: 28 28 77 29 20 3c 3c 20 74 63 6f 6d 70 53 48 49 ((w) << tcompSHI
1300: 46 54 5f 4c 5a 58 5f 57 49 4e 44 4f 57 20 29 20 FT_LZX_WINDOW )
1310: 7c 20 20 5c 0d 0a 20 20 20 20 20 20 20 20 20 20 | \..
1320: 20 20 20 28 20 74 63 6f 6d 70 54 59 50 45 5f 4c ( tcompTYPE_L
1330: 5a 58 20 29 29 0d 0a 0d 0a 0d 0a 2f 2f 2a 2a 20 ZX ))......//**
1340: 52 65 76 65 72 74 20 74 6f 20 64 65 66 61 75 6c Revert to defaul
1350: 74 20 73 74 72 75 63 74 75 72 65 20 70 61 63 6b t structure pack
1360: 69 6e 67 0d 0a 23 70 72 61 67 6d 61 20 70 61 63 ing..#pragma pac
1370: 6b 28 29 0d 0a 0d 0a 23 65 6e 64 69 66 20 2f 2f k()....#endif //
1380: 20 21 49 4e 43 4c 55 44 45 44 5f 54 59 50 45 53 !INCLUDED_TYPES
1390: 5f 46 43 49 5f 46 44 49 0d 0a 0d 0a 2f 2a 0d 0a _FCI_FDI..../*..
13a0: 20 2a 20 20 43 6f 6e 63 65 70 74 73 3a 0d 0a 20 * Concepts:..
13b0: 2a 20 20 20 20 20 20 41 20 2a 63 61 62 69 6e 65 * A *cabine
13c0: 74 2a 20 66 69 6c 65 20 63 6f 6e 74 61 69 6e 73 t* file contains
13d0: 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 2a 66 6f one or more *fo
13e0: 6c 64 65 72 73 2a 2e 20 20 41 20 66 6f 6c 64 65 lders*. A folde
13f0: 72 20 63 6f 6e 74 61 69 6e 73 0d 0a 20 2a 20 20 r contains.. *
1400: 20 20 20 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 one or more
1410: 28 70 69 65 63 65 73 20 6f 66 29 20 2a 66 69 6c (pieces of) *fil
1420: 65 73 2a 2e 20 20 41 20 66 6f 6c 64 65 72 20 69 es*. A folder i
1430: 73 20 62 79 20 64 65 66 69 6e 69 74 69 6f 6e 20 s by definition
1440: 61 0d 0a 20 2a 20 20 20 20 20 20 64 65 63 6f 6d a.. * decom
1450: 70 72 65 73 73 69 6f 6e 20 75 6e 69 74 2c 20 69 pression unit, i
1460: 2e 65 2e 2c 20 74 6f 20 65 78 74 72 61 63 74 20 .e., to extract
1470: 61 20 66 69 6c 65 20 66 72 6f 6d 20 61 20 66 6f a file from a fo
1480: 6c 64 65 72 2c 20 61 6c 6c 20 6f 66 0d 0a 20 2a lder, all of.. *
1490: 20 20 20 20 20 20 74 68 65 20 64 61 74 61 20 66 the data f
14a0: 72 6f 6d 20 74 68 65 20 73 74 61 72 74 20 6f 66 rom the start of
14b0: 20 74 68 65 20 66 6f 6c 64 65 72 20 75 70 20 74 the folder up t
14c0: 68 72 6f 75 67 68 20 61 6e 64 20 69 6e 63 6c 75 hrough and inclu
14d0: 64 69 6e 67 20 74 68 65 0d 0a 20 2a 20 20 20 20 ding the.. *
14e0: 20 20 64 65 73 69 72 65 64 20 66 69 6c 65 20 6d desired file m
14f0: 75 73 74 20 62 65 20 72 65 61 64 20 61 6e 64 20 ust be read and
1500: 64 65 63 6f 6d 70 72 65 73 73 65 64 2e 0d 0a 20 decompressed...
1510: 2a 0d 0a 20 2a 20 20 20 20 20 20 41 20 66 6f 6c *.. * A fol
1520: 64 65 72 20 63 61 6e 20 73 70 61 6e 20 6f 6e 65 der can span one
1530: 20 28 6f 72 20 6d 6f 72 65 29 20 63 61 62 69 6e (or more) cabin
1540: 65 74 20 62 6f 75 6e 64 61 72 69 65 73 2c 20 61 et boundaries, a
1550: 6e 64 20 62 79 20 69 6d 70 6c 69 63 61 74 69 6f nd by implicatio
1560: 6e 0d 0a 20 2a 20 20 20 20 20 20 61 20 66 69 6c n.. * a fil
1570: 65 20 63 61 6e 20 61 6c 73 6f 20 73 70 61 6e 20 e can also span
1580: 6f 6e 65 20 28 6f 72 20 6d 6f 72 65 29 20 63 61 one (or more) ca
1590: 62 69 6e 65 74 20 62 6f 75 6e 64 61 72 69 65 73 binet boundaries
15a0: 2e 20 20 49 6e 64 65 65 64 2c 20 6d 6f 72 65 0d . Indeed, more.
15b0: 0a 20 2a 20 20 20 20 20 20 74 68 61 6e 20 6f 6e . * than on
15c0: 65 20 66 69 6c 65 20 63 61 6e 20 73 70 61 6e 20 e file can span
15d0: 61 20 63 61 62 69 6e 65 74 20 62 6f 75 6e 64 61 a cabinet bounda
15e0: 72 79 2c 20 73 69 6e 63 65 20 46 43 49 20 63 6f ry, since FCI co
15f0: 6e 63 61 74 65 6e 61 74 65 73 0d 0a 20 2a 20 20 ncatenates.. *
1600: 20 20 20 20 66 69 6c 65 73 20 74 6f 67 65 74 68 files togeth
1610: 65 72 20 69 6e 74 6f 20 61 20 73 69 6e 67 6c 65 er into a single
1620: 20 64 61 74 61 20 73 74 72 65 61 6d 20 62 65 66 data stream bef
1630: 6f 72 65 20 63 6f 6d 70 72 65 73 73 69 6e 67 20 ore compressing
1640: 28 61 63 74 75 61 6c 6c 79 2c 0d 0a 20 2a 20 20 (actually,.. *
1650: 20 20 20 20 61 74 20 6d 6f 73 74 20 6f 6e 65 20 at most one
1660: 66 69 6c 65 20 77 69 6c 6c 20 73 70 61 6e 20 61 file will span a
1670: 6e 79 20 6f 6e 65 20 63 61 62 69 6e 65 74 20 62 ny one cabinet b
1680: 6f 75 6e 64 61 72 79 2c 20 62 75 74 20 46 43 49 oundary, but FCI
1690: 20 64 6f 65 73 0d 0a 20 2a 20 20 20 20 20 20 6e does.. * n
16a0: 6f 74 20 6b 6e 6f 77 20 77 68 69 63 68 20 66 69 ot know which fi
16b0: 6c 65 20 74 68 69 73 20 69 73 2c 20 73 69 6e 63 le this is, sinc
16c0: 65 20 74 68 65 20 6d 61 70 70 69 6e 67 20 66 72 e the mapping fr
16d0: 6f 6d 20 75 6e 63 6f 6d 70 72 65 73 73 65 64 20 om uncompressed
16e0: 62 79 74 65 73 0d 0a 20 2a 20 20 20 20 20 20 74 bytes.. * t
16f0: 6f 20 63 6f 6d 70 72 65 73 73 65 64 20 62 79 74 o compressed byt
1700: 65 73 20 69 73 20 70 72 65 74 74 79 20 6f 62 73 es is pretty obs
1710: 63 75 72 65 2e 20 20 41 6c 73 6f 2c 20 73 69 6e cure. Also, sin
1720: 63 65 20 46 43 49 20 63 6f 6d 70 72 65 73 73 65 ce FCI compresse
1730: 73 0d 0a 20 2a 20 20 20 20 20 20 69 6e 20 62 6c s.. * in bl
1740: 6f 63 6b 73 20 6f 66 20 33 32 4b 20 28 61 74 20 ocks of 32K (at
1750: 70 72 65 73 65 6e 74 29 2c 20 61 6e 79 20 66 69 present), any fi
1760: 6c 65 73 20 77 69 74 68 20 64 61 74 61 20 69 6e les with data in
1770: 20 61 20 33 32 4b 20 62 6c 6f 63 6b 20 74 68 61 a 32K block tha
1780: 74 0d 0a 20 2a 20 20 20 20 20 20 73 70 61 6e 73 t.. * spans
1790: 20 61 20 63 61 62 69 6e 65 74 20 62 6f 75 6e 64 a cabinet bound
17a0: 61 72 79 20 72 65 71 75 69 72 65 20 46 44 49 20 ary require FDI
17b0: 74 6f 20 72 65 61 64 20 62 6f 74 68 20 63 61 62 to read both cab
17c0: 69 6e 65 74 20 66 69 6c 65 73 0d 0a 20 2a 20 20 inet files.. *
17d0: 20 20 20 20 74 6f 20 67 65 74 20 74 68 65 20 74 to get the t
17e0: 77 6f 20 68 61 6c 76 65 73 20 6f 66 20 74 68 65 wo halves of the
17f0: 20 63 6f 6d 70 72 65 73 73 65 64 20 62 6c 6f 63 compressed bloc
1800: 6b 29 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 4f 76 65 k)... *.. * Ove
1810: 72 76 69 65 77 3a 0d 0a 20 2a 20 20 20 20 20 20 rview:.. *
1820: 54 68 65 20 46 69 6c 65 20 44 65 63 6f 6d 70 72 The File Decompr
1830: 65 73 73 69 6f 6e 20 49 6e 74 65 72 66 61 63 65 ession Interface
1840: 20 69 73 20 75 73 65 64 20 74 6f 20 73 69 6d 70 is used to simp
1850: 6c 69 66 79 20 74 68 65 20 72 65 61 64 69 6e 67 lify the reading
1860: 20 6f 66 0d 0a 20 2a 20 20 20 20 20 20 63 61 62 of.. * cab
1870: 69 6e 65 74 20 66 69 6c 65 73 2e 20 20 41 20 73 inet files. A s
1880: 65 74 75 70 20 70 72 6f 67 72 61 6d 20 77 69 6c etup program wil
1890: 6c 20 70 72 6f 63 65 65 64 20 69 6e 20 61 20 6d l proceed in a m
18a0: 61 6e 6e 65 72 20 76 65 72 79 0d 0a 20 2a 20 20 anner very.. *
18b0: 20 20 20 20 73 69 6d 69 6c 61 72 20 74 6f 20 74 similar to t
18c0: 68 65 20 70 73 65 75 64 6f 20 63 6f 64 65 20 62 he pseudo code b
18d0: 65 6c 6f 77 2e 20 20 41 6e 20 46 44 49 20 63 6f elow. An FDI co
18e0: 6e 74 65 78 74 20 69 73 20 63 72 65 61 74 65 64 ntext is created
18f0: 2c 20 74 68 65 0d 0a 20 2a 20 20 20 20 20 20 73 , the.. * s
1900: 65 74 75 70 20 70 72 6f 67 72 61 6d 20 63 61 6c etup program cal
1910: 6c 73 20 46 44 49 43 6f 70 79 28 29 20 66 6f 72 ls FDICopy() for
1920: 20 65 61 63 68 20 63 61 62 69 6e 65 74 20 74 6f each cabinet to
1930: 20 62 65 20 70 72 6f 63 65 73 73 65 64 2e 20 20 be processed.
1940: 46 6f 72 0d 0a 20 2a 20 20 20 20 20 20 65 61 63 For.. * eac
1950: 68 20 66 69 6c 65 20 69 6e 20 74 68 65 20 63 61 h file in the ca
1960: 62 69 6e 65 74 2c 20 46 44 49 43 6f 70 79 28 29 binet, FDICopy()
1970: 20 63 61 6c 6c 73 20 61 20 6e 6f 74 69 66 69 63 calls a notific
1980: 61 74 69 6f 6e 20 63 61 6c 6c 62 61 63 6b 0d 0a ation callback..
1990: 20 2a 20 20 20 20 20 20 72 6f 75 74 69 6e 65 2c * routine,
19a0: 20 61 73 6b 69 6e 67 20 74 68 65 20 73 65 74 75 asking the setu
19b0: 70 20 70 72 6f 67 72 61 6d 20 69 66 20 74 68 65 p program if the
19c0: 20 66 69 6c 65 20 73 68 6f 75 6c 64 20 62 65 20 file should be
19d0: 63 6f 70 69 65 64 2e 0d 0a 20 2a 20 20 20 20 20 copied... *
19e0: 20 54 68 69 73 20 63 61 6c 6c 2d 62 61 63 6b 20 This call-back
19f0: 61 70 70 72 6f 61 63 68 20 69 73 20 67 72 65 61 approach is grea
1a00: 74 20 62 65 63 61 75 73 65 20 69 74 20 61 6c 6c t because it all
1a10: 6f 77 73 20 74 68 65 20 63 61 62 69 6e 65 74 20 ows the cabinet
1a20: 66 69 6c 65 0d 0a 20 2a 20 20 20 20 20 20 74 6f file.. * to
1a30: 20 62 65 20 72 65 61 64 20 61 6e 64 20 64 65 63 be read and dec
1a40: 6f 6d 70 72 65 73 73 65 64 20 69 6e 20 61 6e 20 ompressed in an
1a50: 6f 70 74 69 6d 61 6c 20 6d 61 6e 6e 65 72 2c 20 optimal manner,
1a60: 61 6e 64 20 61 6c 73 6f 20 6d 61 6b 65 73 20 46 and also makes F
1a70: 44 49 0d 0a 20 2a 20 20 20 20 20 20 69 6e 64 65 DI.. * inde
1a80: 70 65 6e 64 65 6e 74 20 6f 66 20 74 68 65 20 72 pendent of the r
1a90: 75 6e 2d 74 69 6d 65 20 65 6e 76 69 72 6f 6e 6d un-time environm
1aa0: 65 6e 74 20 2d 2d 20 46 44 49 20 6d 61 6b 65 73 ent -- FDI makes
1ab0: 20 2a 6e 6f 2a 20 43 20 72 75 6e 2d 74 69 6d 65 *no* C run-time
1ac0: 0d 0a 20 2a 20 20 20 20 20 20 63 61 6c 6c 73 20 .. * calls
1ad0: 77 68 61 74 73 6f 65 76 65 72 2e 20 20 41 6c 6c whatsoever. All
1ae0: 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 memory allocati
1af0: 6f 6e 20 61 6e 64 20 66 69 6c 65 20 49 2f 4f 20 on and file I/O
1b00: 66 75 6e 63 74 69 6f 6e 73 20 61 72 65 0d 0a 20 functions are..
1b10: 2a 20 20 20 20 20 20 70 61 73 73 65 64 20 69 6e * passed in
1b20: 74 6f 20 46 44 49 20 62 79 20 74 68 65 20 63 6c to FDI by the cl
1b30: 69 65 6e 74 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 20 ient... *.. *
1b40: 20 20 20 6d 61 69 6e 28 2e 2e 2e 29 0d 0a 20 2a main(...).. *
1b50: 20 20 20 20 20 20 7b 0d 0a 20 2a 20 20 20 20 20 {.. *
1b60: 20 20 20 20 20 2f 2f 20 52 65 61 64 20 49 4e 46 // Read INF
1b70: 20 66 69 6c 65 20 74 6f 20 63 6f 6e 73 74 72 75 file to constru
1b80: 63 74 20 6c 69 73 74 20 6f 66 20 64 65 73 69 72 ct list of desir
1b90: 65 64 20 66 69 6c 65 73 2e 20 20 20 0d 0a 20 2a ed files. .. *
1ba0: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 49 64 // Id
1bb0: 65 61 6c 6c 79 2c 20 74 68 65 73 65 20 77 6f 75 eally, these wou
1bc0: 6c 64 20 62 65 20 73 6f 72 74 65 64 20 69 6e 20 ld be sorted in
1bd0: 74 68 65 20 73 61 6d 65 20 6f 72 64 65 72 20 61 the same order a
1be0: 73 20 74 68 65 0d 0a 20 2a 20 20 20 20 20 20 20 s the.. *
1bf0: 20 20 20 2f 2f 20 20 66 69 6c 65 73 20 61 70 70 // files app
1c00: 65 61 72 20 69 6e 20 74 68 65 20 63 61 62 69 6e ear in the cabin
1c10: 65 74 73 2c 20 73 6f 20 74 68 61 74 20 79 6f 75 ets, so that you
1c20: 20 63 61 6e 20 6a 75 73 74 20 77 61 6c 6b 0d 0a can just walk..
1c30: 20 2a 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 * //
1c40: 64 6f 77 6e 20 74 68 65 20 6c 69 73 74 20 69 6e down the list in
1c50: 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 66 64 69 response to fdi
1c60: 6e 74 43 4f 50 59 5f 46 49 4c 45 20 6e 6f 74 69 ntCOPY_FILE noti
1c70: 66 69 63 61 74 69 6f 6e 73 2e 0d 0a 20 2a 0d 0a fications... *..
1c80: 20 2a 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 * // C
1c90: 6f 6e 73 74 72 75 63 74 20 6c 69 73 74 20 6f 66 onstruct list of
1ca0: 20 72 65 71 75 69 72 65 64 20 63 61 62 69 6e 65 required cabine
1cb0: 74 73 2e 20 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 ts. .. *.. *
1cc0: 20 20 20 20 20 20 68 66 64 69 20 3d 20 46 44 49 hfdi = FDI
1cd0: 43 72 65 61 74 65 28 2e 2e 2e 29 3b 20 20 20 20 Create(...);
1ce0: 20 20 20 20 20 20 2f 2f 20 43 72 65 61 74 65 20 // Create
1cf0: 46 44 49 20 63 6f 6e 74 65 78 74 0d 0a 20 2a 20 FDI context.. *
1d00: 20 20 20 20 20 20 20 20 20 46 6f 72 20 28 63 61 For (ca
1d10: 62 69 6e 65 74 20 69 6e 20 4c 69 73 74 20 6f 66 binet in List of
1d20: 20 43 61 62 69 6e 65 74 73 29 20 7b 0d 0a 20 2a Cabinets) {.. *
1d30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46 44 FD
1d40: 49 43 6f 70 79 28 68 66 64 69 2c 63 61 62 69 6e ICopy(hfdi,cabin
1d50: 65 74 2c 66 64 69 4e 6f 74 69 66 79 2c 2e 2e 2e et,fdiNotify,...
1d60: 29 3b 20 20 2f 2f 20 50 72 6f 63 65 73 73 20 65 ); // Process e
1d70: 61 63 68 20 63 61 62 69 6e 65 74 0d 0a 20 2a 20 ach cabinet.. *
1d80: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 2a 20 20 }.. *
1d90: 20 20 20 20 20 20 20 20 46 44 49 44 65 73 74 72 FDIDestr
1da0: 6f 79 28 68 66 64 69 29 3b 0d 0a 20 2a 20 20 20 oy(hfdi);.. *
1db0: 20 20 20 20 20 20 20 2e 2e 2e 0d 0a 20 2a 20 20 ..... *
1dc0: 20 20 20 20 7d 0d 0a 20 2a 0d 0a 20 2a 20 20 20 }.. *.. *
1dd0: 20 20 20 2f 2f 20 4e 6f 74 69 66 69 63 61 74 69 // Notificati
1de0: 6f 6e 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 on callback func
1df0: 74 69 6f 6e 20 0d 0a 20 2a 20 20 20 20 20 20 66 tion .. * f
1e00: 64 69 4e 6f 74 69 66 79 28 66 64 69 6e 74 2c 2e diNotify(fdint,.
1e10: 2e 2e 29 0d 0a 20 2a 20 20 20 20 20 20 7b 0d 0a ..).. * {..
1e20: 20 2a 20 20 20 20 20 20 20 20 20 20 49 66 20 28 * If (
1e30: 55 73 65 72 20 41 62 6f 72 74 65 64 29 20 20 20 User Aborted)
1e40: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 50 // P
1e50: 65 72 6d 69 74 20 63 61 6e 63 65 6c 6c 61 74 69 ermit cancellati
1e60: 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 on.. *
1e70: 20 20 20 20 69 66 20 28 66 64 69 6e 74 20 3d 3d if (fdint ==
1e80: 20 66 64 69 6e 74 43 4c 4f 53 45 5f 46 49 4c 45 fdintCLOSE_FILE
1e90: 5f 49 4e 46 4f 29 0d 0a 20 2a 20 20 20 20 20 20 _INFO).. *
1ea0: 20 20 20 20 20 20 20 20 20 20 20 20 63 6c 6f 73 clos
1eb0: 65 20 6f 70 65 6e 20 66 69 6c 65 0d 0a 20 2a 20 e open file.. *
1ec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ret
1ed0: 75 72 6e 20 2d 31 3b 0d 0a 20 2a 20 20 20 20 20 urn -1;.. *
1ee0: 20 20 20 20 20 73 77 69 74 63 68 20 28 66 64 69 switch (fdi
1ef0: 6e 74 29 20 7b 0d 0a 20 2a 20 20 20 20 20 20 20 nt) {.. *
1f00: 20 20 20 20 20 20 20 63 61 73 65 20 66 64 69 6e case fdin
1f10: 74 43 4f 50 59 5f 46 49 4c 45 3a 20 20 20 20 20 tCOPY_FILE:
1f20: 20 20 20 2f 2f 20 46 69 6c 65 20 74 6f 20 63 6f // File to co
1f30: 70 79 2c 20 6d 61 79 62 65 0d 0a 20 2a 20 20 20 py, maybe.. *
1f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
1f50: 2f 20 43 68 65 63 6b 20 66 69 6c 65 20 61 67 61 / Check file aga
1f60: 69 6e 73 74 20 6c 69 73 74 20 6f 66 20 64 65 73 inst list of des
1f70: 69 72 65 64 20 66 69 6c 65 73 20 0d 0a 20 2a 20 ired files .. *
1f80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f90: 20 69 66 20 77 61 6e 74 20 74 6f 20 63 6f 70 79 if want to copy
1fa0: 20 66 69 6c 65 0d 0a 20 2a 20 20 20 20 20 20 20 file.. *
1fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f o
1fc0: 70 65 6e 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 pen destination
1fd0: 66 69 6c 65 20 61 6e 64 20 72 65 74 75 72 6e 20 file and return
1fe0: 68 61 6e 64 6c 65 0d 0a 20 2a 20 20 20 20 20 20 handle.. *
1ff0: 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 else
2000: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 .. *
2010: 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
2020: 20 4e 55 4c 4c 3b 20 20 20 20 20 20 20 20 2f 2f NULL; //
2030: 20 53 6b 69 70 20 66 69 6c 65 0d 0a 20 2a 20 20 Skip file.. *
2040: 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
2050: 20 66 64 69 6e 74 43 4c 4f 53 45 5f 46 49 4c 45 fdintCLOSE_FILE
2060: 5f 49 4e 46 4f 3a 0d 0a 20 2a 20 20 20 20 20 20 _INFO:.. *
2070: 20 20 20 20 20 20 20 20 20 20 20 20 63 6c 6f 73 clos
2080: 65 20 66 69 6c 65 0d 0a 20 2a 20 20 20 20 20 20 e file.. *
2090: 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20 set
20a0: 64 61 74 65 2c 20 74 69 6d 65 2c 20 61 6e 64 20 date, time, and
20b0: 61 74 74 72 69 62 75 74 65 73 0d 0a 20 2a 0d 0a attributes.. *..
20c0: 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 *
20d0: 63 61 73 65 20 66 64 69 6e 74 4e 45 58 54 5f 43 case fdintNEXT_C
20e0: 41 42 49 4e 45 54 3a 0d 0a 20 2a 20 20 20 20 20 ABINET:.. *
20f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
2100: 6e 6f 74 20 61 6e 20 65 72 72 6f 72 20 63 61 6c not an error cal
2110: 6c 62 61 63 6b 0d 0a 20 2a 20 20 20 20 20 20 20 lback.. *
2120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 T
2130: 65 6c 6c 20 46 44 49 20 74 6f 20 75 73 65 20 73 ell FDI to use s
2140: 75 67 67 65 73 74 65 64 20 64 69 72 65 63 74 6f uggested directo
2150: 72 79 20 6e 61 6d 65 0d 0a 20 2a 20 20 20 20 20 ry name.. *
2160: 20 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 els
2170: 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 e.. *
2180: 20 20 20 20 20 20 20 20 20 20 20 54 65 6c 6c 20 Tell
2190: 75 73 65 72 20 77 68 61 74 20 74 68 65 20 70 72 user what the pr
21a0: 6f 62 6c 65 6d 20 77 61 73 2c 20 61 6e 64 20 70 oblem was, and p
21b0: 72 6f 6d 70 74 0d 0a 20 2a 20 20 20 20 20 20 20 rompt.. *
21c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
21d0: 20 20 20 66 6f 72 20 61 20 6e 65 77 20 64 69 73 for a new dis
21e0: 6b 20 61 6e 64 2f 6f 72 20 70 61 74 68 2e 0d 0a k and/or path...
21f0: 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 *
2200: 20 20 20 20 20 20 20 20 69 66 20 75 73 65 72 20 if user
2210: 61 62 6f 72 74 73 0d 0a 20 2a 20 20 20 20 20 20 aborts.. *
2220: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2230: 20 20 20 20 54 65 6c 6c 20 46 44 49 20 74 6f 20 Tell FDI to
2240: 61 62 6f 72 74 0d 0a 20 2a 20 20 20 20 20 20 20 abort.. *
2250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 e
2260: 6c 73 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 lse.. *
2270: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2280: 20 72 65 74 75 72 6e 20 74 6f 20 46 44 49 20 74 return to FDI t
2290: 6f 20 74 72 79 20 61 6e 6f 74 68 65 72 20 63 61 o try another ca
22a0: 62 69 6e 65 74 0d 0a 20 2a 0d 0a 20 2a 20 20 20 binet.. *.. *
22b0: 20 20 20 20 20 20 20 20 20 20 20 64 65 66 61 75 defau
22c0: 6c 74 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 lt:.. *
22d0: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
22e0: 30 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0;
22f0: 20 2f 2f 20 6d 6f 72 65 20 6d 65 73 73 61 67 65 // more message
2300: 73 20 6d 61 79 20 62 65 20 64 65 66 69 6e 65 64 s may be defined
2310: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 .. *
2320: 20 20 2e 2e 2e 0d 0a 20 2a 20 20 20 20 20 20 7d ..... * }
2330: 0d 0a 20 2a 0d 0a 20 2a 20 20 45 72 72 6f 72 20 .. *.. * Error
2340: 48 61 6e 64 6c 69 6e 67 20 53 75 67 67 65 73 74 Handling Suggest
2350: 69 6f 6e 73 3a 0d 0a 20 2a 20 20 20 20 20 20 53 ions:.. * S
2360: 69 6e 63 65 20 79 6f 75 20 74 68 65 20 63 6c 69 ince you the cli
2370: 65 6e 74 20 68 61 76 65 20 70 61 73 73 65 64 20 ent have passed
2380: 69 6e 20 2a 61 6c 6c 2a 20 6f 66 20 74 68 65 20 in *all* of the
2390: 66 75 6e 63 74 69 6f 6e 73 20 74 68 61 74 0d 0a functions that..
23a0: 20 2a 20 20 20 20 20 20 46 44 49 20 75 73 65 73 * FDI uses
23b0: 20 74 6f 20 69 6e 74 65 72 61 63 74 20 77 69 74 to interact wit
23c0: 68 20 74 68 65 20 22 6f 75 74 73 69 64 65 22 20 h the "outside"
23d0: 77 6f 72 6c 64 2c 20 79 6f 75 20 61 72 65 20 69 world, you are i
23e0: 6e 20 70 72 69 6d 65 0d 0a 20 2a 20 20 20 20 20 n prime.. *
23f0: 20 70 6f 73 69 74 69 6f 6e 20 74 6f 20 75 6e 64 position to und
2400: 65 72 73 74 61 6e 64 20 61 6e 64 20 64 65 61 6c erstand and deal
2410: 20 77 69 74 68 20 65 72 72 6f 72 73 2e 0d 0a 20 with errors...
2420: 2a 0d 0a 20 2a 20 20 20 20 20 20 54 68 65 20 67 *.. * The g
2430: 65 6e 65 72 61 6c 20 70 68 69 6c 6f 73 6f 70 68 eneral philosoph
2440: 79 20 6f 66 20 46 44 49 20 69 73 20 74 6f 20 70 y of FDI is to p
2450: 61 73 73 20 61 6c 6c 20 65 72 72 6f 72 73 20 62 ass all errors b
2460: 61 63 6b 20 75 70 20 74 6f 0d 0a 20 2a 20 20 20 ack up to.. *
2470: 20 20 20 74 68 65 20 63 6c 69 65 6e 74 2e 20 20 the client.
2480: 46 44 49 20 72 65 74 75 72 6e 73 20 66 61 69 72 FDI returns fair
2490: 6c 79 20 67 65 6e 65 72 69 63 20 65 72 72 6f 72 ly generic error
24a0: 20 63 6f 64 65 73 20 69 6e 20 74 68 65 20 63 61 codes in the ca
24b0: 73 65 0d 0a 20 2a 20 20 20 20 20 20 77 68 65 72 se.. * wher
24c0: 65 20 6f 6e 65 20 6f 66 20 74 68 65 20 63 61 6c e one of the cal
24d0: 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 73 20 lback functions
24e0: 28 50 46 4e 4f 50 45 4e 2c 20 50 46 4e 52 45 41 (PFNOPEN, PFNREA
24f0: 44 2c 20 65 74 63 2e 29 20 66 61 69 6c 2c 0d 0a D, etc.) fail,..
2500: 20 2a 20 20 20 20 20 20 73 69 6e 63 65 20 69 74 * since it
2510: 20 61 73 73 75 6d 65 73 20 74 68 61 74 20 74 68 assumes that th
2520: 65 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 e callback funct
2530: 69 6f 6e 20 77 69 6c 6c 20 73 61 76 65 20 65 6e ion will save en
2540: 6f 75 67 68 0d 0a 20 2a 20 20 20 20 20 20 69 6e ough.. * in
2550: 66 6f 72 6d 61 74 69 6f 6e 20 69 6e 20 61 20 73 formation in a s
2560: 74 61 74 69 63 2f 67 6c 6f 62 61 6c 20 73 6f 20 tatic/global so
2570: 74 68 61 74 20 77 68 65 6e 20 46 44 49 43 6f 70 that when FDICop
2580: 79 28 29 20 72 65 74 75 72 6e 73 0d 0a 20 2a 20 y() returns.. *
2590: 20 20 20 20 20 66 61 69 6c 2c 20 74 68 65 20 63 fail, the c
25a0: 6c 69 65 6e 74 20 63 61 6e 20 65 78 61 6d 69 6e lient can examin
25b0: 65 20 74 68 69 73 20 69 6e 66 6f 72 6d 61 74 69 e this informati
25c0: 6f 6e 20 61 6e 64 20 72 65 70 6f 72 74 20 65 6e on and report en
25d0: 6f 75 67 68 0d 0a 20 2a 20 20 20 20 20 20 64 65 ough.. * de
25e0: 74 61 69 6c 20 61 62 6f 75 74 20 74 68 65 20 70 tail about the p
25f0: 72 6f 62 6c 65 6d 20 74 68 61 74 20 74 68 65 20 roblem that the
2600: 75 73 65 72 20 63 61 6e 20 74 61 6b 65 20 63 6f user can take co
2610: 72 72 65 63 74 69 76 65 20 61 63 74 69 6f 6e 2e rrective action.
2620: 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 46 6f .. *.. * Fo
2630: 72 20 76 65 72 79 20 73 70 65 63 69 66 69 63 20 r very specific
2640: 65 72 72 6f 72 73 20 28 43 4f 52 52 55 50 54 5f errors (CORRUPT_
2650: 43 41 42 49 4e 45 54 2c 20 66 6f 72 20 65 78 61 CABINET, for exa
2660: 6d 70 6c 65 29 2c 20 46 44 49 20 72 65 74 75 72 mple), FDI retur
2670: 6e 73 0d 0a 20 2a 20 20 20 20 20 20 76 65 72 79 ns.. * very
2680: 20 73 70 65 63 69 66 69 63 20 65 72 72 6f 72 20 specific error
2690: 63 6f 64 65 73 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 codes... *.. *
26a0: 20 20 20 20 54 48 45 20 42 45 53 54 20 50 4f 4c THE BEST POL
26b0: 49 43 59 20 49 53 20 46 4f 52 20 59 4f 55 52 20 ICY IS FOR YOUR
26c0: 43 41 4c 4c 42 41 43 4b 20 52 4f 55 54 49 4e 45 CALLBACK ROUTINE
26d0: 53 20 54 4f 20 41 56 4f 49 44 20 52 45 54 55 52 S TO AVOID RETUR
26e0: 4e 49 4e 47 0d 0a 20 2a 20 20 20 20 20 20 45 52 NING.. * ER
26f0: 52 4f 52 53 20 54 4f 20 46 44 49 21 0d 0a 20 2a RORS TO FDI!.. *
2700: 0d 0a 20 2a 20 20 20 20 20 20 45 78 61 6d 70 6c .. * Exampl
2710: 65 73 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 es:.. *
2720: 20 28 31 29 20 49 66 20 74 68 65 20 64 69 73 6b (1) If the disk
2730: 20 69 73 20 67 65 74 74 69 6e 67 20 66 75 6c 6c is getting full
2740: 2c 20 69 6e 73 74 65 61 64 20 6f 66 20 72 65 74 , instead of ret
2750: 75 72 6e 69 6e 67 20 61 6e 20 65 72 72 6f 72 0d urning an error.
2760: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 . *
2770: 20 66 72 6f 6d 20 79 6f 75 72 20 50 46 4e 57 52 from your PFNWR
2780: 49 54 45 20 66 75 6e 63 74 69 6f 6e 2c 20 79 6f ITE function, yo
2790: 75 20 73 68 6f 75 6c 64 20 2d 2d 20 69 6e 73 69 u should -- insi
27a0: 64 65 20 79 6f 75 72 0d 0a 20 2a 20 20 20 20 20 de your.. *
27b0: 20 20 20 20 20 20 20 20 20 50 46 4e 57 52 49 54 PFNWRIT
27c0: 45 20 66 75 6e 63 74 69 6f 6e 20 2d 2d 20 70 75 E function -- pu
27d0: 74 20 75 70 20 61 20 64 69 61 6c 6f 67 20 74 65 t up a dialog te
27e0: 6c 6c 69 6e 67 20 74 68 65 20 75 73 65 72 20 74 lling the user t
27f0: 6f 20 66 72 65 65 0d 0a 20 2a 20 20 20 20 20 20 o free.. *
2800: 20 20 20 20 20 20 20 20 73 6f 6d 65 20 64 69 73 some dis
2810: 6b 20 73 70 61 63 65 2e 0d 0a 20 2a 20 20 20 20 k space... *
2820: 20 20 20 20 20 20 28 32 29 20 57 68 65 6e 20 79 (2) When y
2830: 6f 75 20 67 65 74 20 74 68 65 20 66 64 69 6e 74 ou get the fdint
2840: 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 6e 6f 74 NEXT_CABINET not
2850: 69 66 69 63 61 74 69 6f 6e 2c 20 79 6f 75 20 73 ification, you s
2860: 68 6f 75 6c 64 0d 0a 20 2a 20 20 20 20 20 20 20 hould.. *
2870: 20 20 20 20 20 20 20 76 65 72 69 66 79 20 74 68 verify th
2880: 61 74 20 74 68 65 20 63 61 62 69 6e 65 74 20 79 at the cabinet y
2890: 6f 75 20 72 65 74 75 72 6e 20 69 73 20 74 68 65 ou return is the
28a0: 20 63 6f 72 72 65 63 74 20 6f 6e 65 20 28 63 61 correct one (ca
28b0: 6c 6c 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 ll.. *
28c0: 20 20 20 20 46 44 49 49 73 43 61 62 69 6e 65 74 FDIIsCabinet
28d0: 28 29 2c 20 61 6e 64 20 6d 61 6b 65 20 73 75 72 (), and make sur
28e0: 65 20 74 68 65 20 73 65 74 49 44 20 6d 61 74 63 e the setID matc
28f0: 68 65 73 20 74 68 65 20 6f 6e 65 20 66 6f 72 0d hes the one for.
2900: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 . *
2910: 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 61 62 the current cab
2920: 69 6e 65 74 20 73 70 65 63 69 66 69 65 64 20 69 inet specified i
2930: 6e 20 74 68 65 20 66 64 69 6e 74 43 41 42 49 4e n the fdintCABIN
2940: 45 54 5f 49 4e 46 4f 2c 20 61 6e 64 0d 0a 20 2a ET_INFO, and.. *
2950: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 th
2960: 61 74 20 74 68 65 20 64 69 73 6b 20 6e 75 6d 62 at the disk numb
2970: 65 72 20 69 73 20 6f 6e 65 20 67 72 65 61 74 65 er is one greate
2980: 72 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 r... *.. *
2990: 20 20 20 20 20 20 20 20 4e 4f 54 45 3a 20 46 44 NOTE: FD
29a0: 49 20 77 69 6c 6c 20 63 6f 6e 74 69 6e 75 65 20 I will continue
29b0: 74 6f 20 63 61 6c 6c 20 66 64 69 6e 74 4e 45 58 to call fdintNEX
29c0: 54 5f 43 41 42 49 4e 45 54 20 75 6e 74 69 6c 20 T_CABINET until
29d0: 69 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 it.. *
29e0: 20 20 20 20 20 20 20 20 20 20 67 65 74 73 20 74 gets t
29f0: 68 65 20 63 61 62 69 6e 65 74 20 69 74 20 77 61 he cabinet it wa
2a00: 6e 74 73 2c 20 6f 72 20 75 6e 74 69 6c 20 79 6f nts, or until yo
2a10: 75 20 72 65 74 75 72 6e 20 2d 31 0d 0a 20 2a 20 u return -1.. *
2a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a30: 20 20 20 74 6f 20 61 62 6f 72 74 20 74 68 65 20 to abort the
2a40: 46 44 49 43 6f 70 79 28 29 20 63 61 6c 6c 2e 0d FDICopy() call..
2a50: 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 54 68 65 . *.. * The
2a60: 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 62 documentation b
2a70: 65 6c 6f 77 20 6f 6e 20 74 68 65 20 46 44 49 20 elow on the FDI
2a80: 65 72 72 6f 72 20 63 6f 64 65 73 20 70 72 6f 76 error codes prov
2a90: 69 64 65 73 20 65 78 70 6c 69 63 69 74 0d 0a 20 ides explicit..
2aa0: 2a 20 20 20 20 20 20 67 75 69 64 61 6e 63 65 20 * guidance
2ab0: 6f 6e 20 68 6f 77 20 74 6f 20 61 76 6f 69 64 20 on how to avoid
2ac0: 65 61 63 68 20 65 72 72 6f 72 2e 0d 0a 20 2a 0d each error... *.
2ad0: 0a 20 2a 20 20 20 20 20 20 49 66 20 79 6f 75 20 . * If you
2ae0: 66 69 6e 64 20 79 6f 75 20 6d 75 73 74 20 72 65 find you must re
2af0: 74 75 72 6e 20 61 20 66 61 69 6c 75 72 65 20 74 turn a failure t
2b00: 6f 20 46 44 49 20 66 72 6f 6d 20 6f 6e 65 20 6f o FDI from one o
2b10: 66 20 79 6f 75 72 0d 0a 20 2a 20 20 20 20 20 20 f your.. *
2b20: 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f callback functio
2b30: 6e 73 2c 20 74 68 65 6e 20 46 44 49 43 6f 70 79 ns, then FDICopy
2b40: 28 29 20 66 72 65 65 73 20 61 6c 6c 20 72 65 73 () frees all res
2b50: 6f 75 72 63 65 73 20 69 74 20 61 6c 6c 6f 63 61 ources it alloca
2b60: 74 65 64 0d 0a 20 2a 20 20 20 20 20 20 61 6e 64 ted.. * and
2b70: 20 63 6c 6f 73 65 73 20 61 6c 6c 20 66 69 6c 65 closes all file
2b80: 73 2e 20 20 49 66 20 79 6f 75 20 63 61 6e 20 66 s. If you can f
2b90: 69 67 75 72 65 20 6f 75 74 20 68 6f 77 20 74 6f igure out how to
2ba0: 20 6f 76 65 72 63 6f 6d 65 20 74 68 65 0d 0a 20 overcome the..
2bb0: 2a 20 20 20 20 20 20 70 72 6f 62 6c 65 6d 2c 20 * problem,
2bc0: 79 6f 75 20 63 61 6e 20 63 61 6c 6c 20 46 44 49 you can call FDI
2bd0: 43 6f 70 79 28 29 20 61 67 61 69 6e 20 6f 6e 20 Copy() again on
2be0: 74 68 65 20 6c 61 73 74 20 63 61 62 69 6e 65 74 the last cabinet
2bf0: 2c 20 61 6e 64 0d 0a 20 2a 20 20 20 20 20 20 73 , and.. * s
2c00: 6b 69 70 20 61 6e 79 20 66 69 6c 65 73 20 74 68 kip any files th
2c10: 61 74 20 79 6f 75 20 61 6c 72 65 61 64 79 20 63 at you already c
2c20: 6f 70 69 65 64 2e 20 20 42 75 74 2c 20 6e 6f 74 opied. But, not
2c30: 65 20 74 68 61 74 20 46 44 49 20 64 6f 65 73 0d e that FDI does.
2c40: 0a 20 2a 20 20 20 20 20 20 2a 6e 6f 74 2a 20 6d . * *not* m
2c50: 61 69 6e 74 61 69 6e 20 61 6e 79 20 73 74 61 74 aintain any stat
2c60: 65 20 62 65 74 77 65 65 6e 20 46 44 49 43 6f 70 e between FDICop
2c70: 79 28 29 20 63 61 6c 6c 73 2c 20 6f 74 68 65 72 y() calls, other
2c80: 20 74 68 61 6e 20 70 6f 73 73 69 62 6c 79 0d 0a than possibly..
2c90: 20 2a 20 20 20 20 20 20 6d 65 6d 6f 72 79 20 61 * memory a
2ca0: 6c 6c 6f 63 61 74 65 64 20 66 6f 72 20 74 68 65 llocated for the
2cb0: 20 64 65 63 6f 6d 70 72 65 73 73 6f 72 2e 0d 0a decompressor...
2cc0: 20 2a 0d 0a 20 2a 20 20 20 20 20 20 53 65 65 20 *.. * See
2cd0: 46 44 49 45 52 52 4f 52 20 66 6f 72 20 64 65 74 FDIERROR for det
2ce0: 61 69 6c 73 20 6f 6e 20 46 44 49 20 65 72 72 6f ails on FDI erro
2cf0: 72 20 63 6f 64 65 73 20 61 6e 64 20 72 65 63 6f r codes and reco
2d00: 6d 6d 65 6e 64 65 64 20 61 63 74 69 6f 6e 73 2e mmended actions.
2d10: 0d 0a 20 2a 0d 0a 20 2a 0d 0a 20 2a 20 20 50 72 .. *.. *.. * Pr
2d20: 6f 67 72 65 73 73 20 49 6e 64 69 63 61 74 6f 72 ogress Indicator
2d30: 20 53 75 67 67 65 73 74 69 6f 6e 73 3a 0d 0a 20 Suggestions:..
2d40: 2a 20 20 20 20 20 20 41 73 20 61 62 6f 76 65 2c * As above,
2d50: 20 61 6c 6c 20 6f 66 20 74 68 65 20 66 69 6c 65 all of the file
2d60: 20 49 2f 4f 20 66 75 6e 63 74 69 6f 6e 73 20 61 I/O functions a
2d70: 72 65 20 73 75 70 70 6c 69 65 64 20 62 79 20 79 re supplied by y
2d80: 6f 75 2e 20 20 53 6f 2c 0d 0a 20 2a 20 20 20 20 ou. So,.. *
2d90: 20 20 75 70 64 61 74 69 6e 67 20 61 20 70 72 6f updating a pro
2da0: 67 72 65 73 73 20 69 6e 64 69 63 61 74 6f 72 20 gress indicator
2db0: 69 73 20 76 65 72 79 20 73 69 6d 70 6c 65 2e 20 is very simple.
2dc0: 20 59 6f 75 20 6b 65 65 70 20 74 72 61 63 6b 20 You keep track
2dd0: 6f 66 0d 0a 20 2a 20 20 20 20 20 20 74 68 65 20 of.. * the
2de0: 74 61 72 67 65 74 20 66 69 6c 65 73 20 68 61 6e target files han
2df0: 64 6c 65 73 20 79 6f 75 20 68 61 76 65 20 6f 70 dles you have op
2e00: 65 6e 65 64 2c 20 61 6c 6f 6e 67 20 77 69 74 68 ened, along with
2e10: 20 74 68 65 20 75 6e 63 6f 6d 70 72 65 73 73 65 the uncompresse
2e20: 64 0d 0a 20 2a 20 20 20 20 20 20 73 69 7a 65 20 d.. * size
2e30: 6f 66 20 74 68 65 20 74 61 72 67 65 74 20 66 69 of the target fi
2e40: 6c 65 2e 20 20 57 68 65 6e 20 79 6f 75 20 73 65 le. When you se
2e50: 65 20 77 72 69 74 65 73 20 74 6f 20 74 68 65 20 e writes to the
2e60: 68 61 6e 64 6c 65 20 6f 66 20 61 0d 0a 20 2a 20 handle of a.. *
2e70: 20 20 20 20 20 74 61 72 67 65 74 20 66 69 6c 65 target file
2e80: 2c 20 79 6f 75 20 75 73 65 20 74 68 65 20 77 72 , you use the wr
2e90: 69 74 65 20 63 6f 75 6e 74 20 74 6f 20 75 70 64 ite count to upd
2ea0: 61 74 65 20 79 6f 75 72 20 73 74 61 74 75 73 21 ate your status!
2eb0: 0d 0a 20 2a 20 20 20 20 20 20 53 69 6e 63 65 20 .. * Since
2ec0: 74 68 69 73 20 6d 65 74 68 6f 64 20 69 73 20 61 this method is a
2ed0: 76 61 69 6c 61 62 6c 65 2c 20 74 68 65 72 65 20 vailable, there
2ee0: 69 73 20 6e 6f 20 73 65 70 61 72 61 74 65 20 63 is no separate c
2ef0: 61 6c 6c 62 61 63 6b 20 66 72 6f 6d 0d 0a 20 2a allback from.. *
2f00: 20 20 20 20 20 20 46 44 49 20 6a 75 73 74 20 66 FDI just f
2f10: 6f 72 20 70 72 6f 67 65 73 73 20 69 6e 64 69 63 or progess indic
2f20: 61 74 69 6f 6e 2e 0d 0a 20 2a 2f 0d 0a 0d 0a 23 ation... */....#
2f30: 69 66 6e 64 65 66 20 49 4e 43 4c 55 44 45 44 5f ifndef INCLUDED_
2f40: 46 44 49 0d 0a 23 64 65 66 69 6e 65 20 49 4e 43 FDI..#define INC
2f50: 4c 55 44 45 44 5f 46 44 49 20 20 20 20 31 0d 0a LUDED_FDI 1..
2f60: 0d 0a 2f 2f 2a 2a 20 53 70 65 63 69 66 79 20 73 ..//** Specify s
2f70: 74 72 75 63 74 75 72 65 20 70 61 63 6b 69 6e 67 tructure packing
2f80: 20 65 78 70 6c 69 63 69 74 6c 79 20 66 6f 72 20 explicitly for
2f90: 63 6c 69 65 6e 74 73 20 6f 66 20 46 44 49 0d 0a clients of FDI..
2fa0: 23 70 72 61 67 6d 61 20 70 61 63 6b 28 34 29 0d #pragma pack(4).
2fb0: 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 44 49 ...../*** FDI
2fc0: 45 52 52 4f 52 20 2d 20 45 72 72 6f 72 20 63 6f ERROR - Error co
2fd0: 64 65 73 20 72 65 74 75 72 6e 65 64 20 69 6e 20 des returned in
2fe0: 65 72 66 2e 65 72 66 4f 70 65 72 20 66 69 65 6c erf.erfOper fiel
2ff0: 64 0d 0a 20 2a 0d 0a 20 2a 20 20 49 6e 20 67 65 d.. *.. * In ge
3000: 6e 65 72 61 6c 2c 20 46 44 49 20 77 69 6c 6c 20 neral, FDI will
3010: 6f 6e 6c 79 20 66 61 69 6c 20 69 66 20 6f 6e 65 only fail if one
3020: 20 6f 66 20 74 68 65 20 70 61 73 73 65 64 20 69 of the passed i
3030: 6e 20 6d 65 6d 6f 72 79 20 6f 72 0d 0a 20 2a 20 n memory or.. *
3040: 20 66 69 6c 65 20 49 2f 4f 20 66 75 6e 63 74 69 file I/O functi
3050: 6f 6e 73 20 66 61 69 6c 73 2e 20 20 4f 74 68 65 ons fails. Othe
3060: 72 20 65 72 72 6f 72 73 20 61 72 65 20 70 72 65 r errors are pre
3070: 74 74 79 20 75 6e 6c 69 6b 65 6c 79 2c 20 61 6e tty unlikely, an
3080: 64 20 61 72 65 0d 0a 20 2a 20 20 63 61 75 73 65 d are.. * cause
3090: 64 20 62 79 20 63 6f 72 72 75 70 74 65 64 20 63 d by corrupted c
30a0: 61 62 69 6e 65 74 20 66 69 6c 65 73 2c 20 70 61 abinet files, pa
30b0: 73 73 69 6e 67 20 69 6e 20 61 20 66 69 6c 65 20 ssing in a file
30c0: 77 68 69 63 68 20 69 73 20 6e 6f 74 20 61 0d 0a which is not a..
30d0: 20 2a 20 20 63 61 62 69 6e 65 74 20 66 69 6c 65 * cabinet file
30e0: 2c 20 6f 72 20 63 61 62 69 6e 65 74 20 66 69 6c , or cabinet fil
30f0: 65 73 20 6f 75 74 20 6f 66 20 6f 72 64 65 72 2e es out of order.
3100: 0d 0a 20 2a 0d 0a 20 2a 20 20 44 65 73 63 72 69 .. *.. * Descri
3110: 70 74 69 6f 6e 3a 20 20 20 20 53 75 6d 6d 61 72 ption: Summar
3120: 79 20 6f 66 20 65 72 72 6f 72 2e 0d 0a 20 2a 20 y of error... *
3130: 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 20 20 Cause:
3140: 20 4c 69 73 74 20 6f 66 20 70 6f 73 73 69 62 6c List of possibl
3150: 65 20 63 61 75 73 65 73 20 6f 66 20 74 68 69 73 e causes of this
3160: 20 65 72 72 6f 72 2e 0d 0a 20 2a 20 20 52 65 73 error... * Res
3170: 70 6f 6e 73 65 3a 20 20 20 20 20 20 20 48 6f 77 ponse: How
3180: 20 63 6c 69 65 6e 74 20 6d 69 67 68 74 20 72 65 client might re
3190: 73 70 6f 6e 64 20 74 6f 20 74 68 69 73 20 65 72 spond to this er
31a0: 72 6f 72 2c 20 6f 72 20 61 76 6f 69 64 20 69 74 ror, or avoid it
31b0: 20 69 6e 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 in.. *
31c0: 20 20 20 20 20 20 20 20 20 74 68 65 20 66 69 72 the fir
31d0: 73 74 20 70 6c 61 63 65 2e 0d 0a 20 2a 2f 0d 0a st place... */..
31e0: 74 79 70 65 64 65 66 20 65 6e 75 6d 20 7b 0d 0a typedef enum {..
31f0: 20 20 20 20 46 44 49 45 52 52 4f 52 5f 4e 4f 4e FDIERROR_NON
3200: 45 2c 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 44 E,.. // D
3210: 65 73 63 72 69 70 74 69 6f 6e 3a 20 4e 6f 20 65 escription: No e
3220: 72 72 6f 72 0d 0a 20 20 20 20 20 20 20 20 2f 2f rror.. //
3230: 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 46 75 Cause: Fu
3240: 6e 63 74 69 6f 6e 20 77 61 73 20 73 75 63 63 65 nction was succe
3250: 73 73 66 75 6c 6c 2e 0d 0a 20 20 20 20 20 20 20 ssfull...
3260: 20 2f 2f 20 52 65 73 70 6f 6e 73 65 3a 20 20 20 // Response:
3270: 20 4b 65 65 70 20 67 6f 69 6e 67 21 0d 0a 0d 0a Keep going!....
3280: 20 20 20 20 46 44 49 45 52 52 4f 52 5f 43 41 42 FDIERROR_CAB
3290: 49 4e 45 54 5f 4e 4f 54 5f 46 4f 55 4e 44 2c 0d INET_NOT_FOUND,.
32a0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 . // Desc
32b0: 72 69 70 74 69 6f 6e 3a 20 43 61 62 69 6e 65 74 ription: Cabinet
32c0: 20 6e 6f 74 20 66 6f 75 6e 64 0d 0a 20 20 20 20 not found..
32d0: 20 20 20 20 2f 2f 20 43 61 75 73 65 3a 20 20 20 // Cause:
32e0: 20 20 20 20 42 61 64 20 66 69 6c 65 20 6e 61 6d Bad file nam
32f0: 65 20 6f 72 20 70 61 74 68 20 70 61 73 73 65 64 e or path passed
3300: 20 74 6f 20 46 44 49 43 6f 70 79 28 29 2c 20 6f to FDICopy(), o
3310: 72 20 72 65 74 75 72 6e 65 64 0d 0a 20 20 20 20 r returned..
3320: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
3330: 20 20 20 20 74 6f 20 66 64 69 6e 74 4e 45 58 54 to fdintNEXT
3340: 5f 43 41 42 49 4e 45 54 2e 0d 0a 20 20 20 20 20 _CABINET...
3350: 20 20 20 2f 2f 20 52 65 73 70 6f 6e 73 65 3a 20 // Response:
3360: 20 20 20 54 6f 20 70 72 65 76 65 6e 74 20 74 68 To prevent th
3370: 69 73 20 65 72 72 6f 72 2c 20 76 61 6c 69 64 61 is error, valida
3380: 74 65 20 74 68 65 20 65 78 69 73 74 65 6e 63 65 te the existence
3390: 20 6f 66 20 74 68 65 0d 0a 20 20 20 20 20 20 20 of the..
33a0: 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 //
33b0: 20 74 68 65 20 63 61 62 69 6e 65 74 20 2a 62 65 the cabinet *be
33c0: 66 6f 72 65 2a 20 70 61 73 73 69 6e 67 20 74 68 fore* passing th
33d0: 65 20 70 61 74 68 20 74 6f 20 46 44 49 2e 0d 0a e path to FDI...
33e0: 0d 0a 20 20 20 20 46 44 49 45 52 52 4f 52 5f 4e .. FDIERROR_N
33f0: 4f 54 5f 41 5f 43 41 42 49 4e 45 54 2c 0d 0a 20 OT_A_CABINET,..
3400: 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 72 69 // Descri
3410: 70 74 69 6f 6e 3a 20 43 61 62 69 6e 65 74 20 66 ption: Cabinet f
3420: 69 6c 65 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 ile does not hav
3430: 65 20 74 68 65 20 63 6f 72 72 65 63 74 20 66 6f e the correct fo
3440: 72 6d 61 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f rmat.. //
3450: 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 46 69 Cause: Fi
3460: 6c 65 20 70 61 73 73 65 64 20 74 6f 20 74 6f 20 le passed to to
3470: 46 44 49 43 6f 70 79 28 29 2c 20 6f 72 20 72 65 FDICopy(), or re
3480: 74 75 72 6e 65 64 20 74 6f 0d 0a 20 20 20 20 20 turned to..
3490: 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 //
34a0: 20 20 20 66 64 69 6e 74 4e 45 58 54 5f 43 41 42 fdintNEXT_CAB
34b0: 49 4e 45 54 2c 20 69 73 20 74 6f 6f 20 73 6d 61 INET, is too sma
34c0: 6c 6c 20 74 6f 20 62 65 20 61 20 63 61 62 69 6e ll to be a cabin
34d0: 65 74 20 66 69 6c 65 2c 0d 0a 20 20 20 20 20 20 et file,..
34e0: 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 //
34f0: 20 20 6f 72 20 64 6f 65 73 20 6e 6f 74 20 68 61 or does not ha
3500: 76 65 20 74 68 65 20 63 61 62 69 6e 65 74 20 73 ve the cabinet s
3510: 69 67 6e 61 74 75 72 65 20 69 6e 20 69 74 73 20 ignature in its
3520: 66 69 72 73 74 0d 0a 20 20 20 20 20 20 20 20 2f first.. /
3530: 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 / f
3540: 6f 75 72 20 62 79 74 65 73 2e 0d 0a 20 20 20 20 our bytes...
3550: 20 20 20 20 2f 2f 20 52 65 73 70 6f 6e 73 65 3a // Response:
3560: 20 20 20 20 54 6f 20 70 72 65 76 65 6e 74 20 74 To prevent t
3570: 68 69 73 20 65 72 72 6f 72 2c 20 63 61 6c 6c 20 his error, call
3580: 46 44 49 49 73 43 61 62 69 6e 65 74 28 29 20 74 FDIIsCabinet() t
3590: 6f 20 63 68 65 63 6b 20 61 0d 0a 20 20 20 20 20 o check a..
35a0: 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 //
35b0: 20 20 20 63 61 62 69 6e 65 74 20 62 65 66 6f 72 cabinet befor
35c0: 65 20 63 61 6c 6c 69 6e 67 20 46 44 49 43 6f 70 e calling FDICop
35d0: 79 28 29 20 6f 72 20 72 65 74 75 72 6e 69 6e 67 y() or returning
35e0: 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f the.. //
35f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 ca
3600: 62 69 6e 65 74 20 70 61 74 68 20 74 6f 20 66 64 binet path to fd
3610: 69 6e 74 4e 45 58 54 5f 43 41 42 49 4e 45 54 2e intNEXT_CABINET.
3620: 0d 0a 0d 0a 20 20 20 20 46 44 49 45 52 52 4f 52 .... FDIERROR
3630: 5f 55 4e 4b 4e 4f 57 4e 5f 43 41 42 49 4e 45 54 _UNKNOWN_CABINET
3640: 5f 56 45 52 53 49 4f 4e 2c 0d 0a 20 20 20 20 20 _VERSION,..
3650: 20 20 20 2f 2f 20 44 65 73 63 72 69 70 74 69 6f // Descriptio
3660: 6e 3a 20 43 61 62 69 6e 65 74 20 66 69 6c 65 20 n: Cabinet file
3670: 68 61 73 20 61 6e 20 75 6e 6b 6e 6f 77 6e 20 76 has an unknown v
3680: 65 72 73 69 6f 6e 20 6e 75 6d 62 65 72 2e 0d 0a ersion number...
3690: 20 20 20 20 20 20 20 20 2f 2f 20 43 61 75 73 65 // Cause
36a0: 3a 20 20 20 20 20 20 20 46 69 6c 65 20 70 61 73 : File pas
36b0: 73 65 64 20 74 6f 20 74 6f 20 46 44 49 43 6f 70 sed to to FDICop
36c0: 79 28 29 2c 20 6f 72 20 72 65 74 75 72 6e 65 64 y(), or returned
36d0: 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 to.. //
36e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 66 64 69 fdi
36f0: 6e 74 4e 45 58 54 5f 43 41 42 49 4e 45 54 2c 20 ntNEXT_CABINET,
3700: 68 61 73 20 77 68 61 74 20 6c 6f 6f 6b 73 20 6c has what looks l
3710: 69 6b 65 20 61 20 63 61 62 69 6e 65 74 20 66 69 ike a cabinet fi
3720: 6c 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 le.. //
3730: 20 20 20 20 20 20 20 20 20 20 20 20 68 65 61 64 head
3740: 65 72 2c 20 62 75 74 20 74 68 65 20 76 65 72 73 er, but the vers
3750: 69 6f 6e 20 6f 66 20 74 68 65 20 63 61 62 69 6e ion of the cabin
3760: 65 74 20 66 69 6c 65 20 66 6f 72 6d 61 74 0d 0a et file format..
3770: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
3780: 20 20 20 20 20 20 20 20 69 73 20 6e 6f 74 20 6f is not o
3790: 6e 65 20 75 6e 64 65 72 73 74 6f 6f 64 20 62 79 ne understood by
37a0: 20 74 68 69 73 20 76 65 72 73 69 6f 6e 20 6f 66 this version of
37b0: 20 46 44 49 2e 20 20 54 68 65 0d 0a 20 20 20 20 FDI. The..
37c0: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
37d0: 20 20 20 20 65 72 66 2e 65 72 66 54 79 70 65 20 erf.erfType
37e0: 66 69 65 6c 64 20 69 73 20 66 69 6c 6c 65 64 20 field is filled
37f0: 69 6e 20 77 69 74 68 20 74 68 65 20 76 65 72 73 in with the vers
3800: 69 6f 6e 20 6e 75 6d 62 65 72 0d 0a 20 20 20 20 ion number..
3810: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
3820: 20 20 20 20 66 6f 75 6e 64 20 69 6e 20 74 68 65 found in the
3830: 20 63 61 62 69 6e 65 74 20 66 69 6c 65 2e 0d 0a cabinet file...
3840: 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 70 6f // Respo
3850: 6e 73 65 3a 20 20 20 20 54 6f 20 70 72 65 76 65 nse: To preve
3860: 6e 74 20 74 68 69 73 20 65 72 72 6f 72 2c 20 63 nt this error, c
3870: 61 6c 6c 20 46 44 49 49 73 43 61 62 69 6e 65 74 all FDIIsCabinet
3880: 28 29 20 74 6f 20 63 68 65 63 6b 20 61 0d 0a 20 () to check a..
3890: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
38a0: 20 20 20 20 20 20 20 63 61 62 69 6e 65 74 20 62 cabinet b
38b0: 65 66 6f 72 65 20 63 61 6c 6c 69 6e 67 20 46 44 efore calling FD
38c0: 49 43 6f 70 79 28 29 20 6f 72 20 72 65 74 75 72 ICopy() or retur
38d0: 6e 69 6e 67 20 74 68 65 0d 0a 20 20 20 20 20 20 ning the..
38e0: 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 //
38f0: 20 20 63 61 62 69 6e 65 74 20 70 61 74 68 20 74 cabinet path t
3900: 6f 20 66 64 69 6e 74 4e 45 58 54 5f 43 41 42 49 o fdintNEXT_CABI
3910: 4e 45 54 2e 0d 0a 0d 0a 20 20 20 20 46 44 49 45 NET..... FDIE
3920: 52 52 4f 52 5f 43 4f 52 52 55 50 54 5f 43 41 42 RROR_CORRUPT_CAB
3930: 49 4e 45 54 2c 0d 0a 20 20 20 20 20 20 20 20 2f INET,.. /
3940: 2f 20 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 43 / Description: C
3950: 61 62 69 6e 65 74 20 66 69 6c 65 20 69 73 20 63 abinet file is c
3960: 6f 72 72 75 70 74 0d 0a 20 20 20 20 20 20 20 20 orrupt..
3970: 2f 2f 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 // Cause:
3980: 46 44 49 20 72 65 74 75 72 6e 73 20 74 68 69 73 FDI returns this
3990: 20 65 72 72 6f 72 20 61 6e 79 20 74 69 6d 65 20 error any time
39a0: 69 74 20 66 69 6e 64 73 20 61 20 70 72 6f 62 6c it finds a probl
39b0: 65 6d 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 em.. //
39c0: 20 20 20 20 20 20 20 20 20 20 20 20 77 69 74 68 with
39d0: 20 74 68 65 20 6c 6f 67 69 63 61 6c 20 66 6f 72 the logical for
39e0: 6d 61 74 20 6f 66 20 61 20 63 61 62 69 6e 65 74 mat of a cabinet
39f0: 20 66 69 6c 65 2c 20 61 6e 64 20 61 6e 79 0d 0a file, and any..
3a00: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
3a10: 20 20 20 20 20 20 20 20 74 69 6d 65 20 6f 6e 65 time one
3a20: 20 6f 66 20 74 68 65 20 70 61 73 73 65 64 2d 69 of the passed-i
3a30: 6e 20 66 69 6c 65 20 49 2f 4f 20 63 61 6c 6c 73 n file I/O calls
3a40: 20 66 61 69 6c 73 20 77 68 65 6e 0d 0a 20 20 20 fails when..
3a50: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 //
3a60: 20 20 20 20 20 6f 70 65 72 61 74 69 6e 67 20 6f operating o
3a70: 6e 20 61 20 63 61 62 69 6e 65 74 20 28 50 46 4e n a cabinet (PFN
3a80: 4f 50 45 4e 2c 20 50 46 4e 53 45 45 4b 2c 20 50 OPEN, PFNSEEK, P
3a90: 46 4e 52 45 41 44 2c 0d 0a 20 20 20 20 20 20 20 FNREAD,..
3aa0: 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 //
3ab0: 20 6f 72 20 50 46 4e 43 4c 4f 53 45 29 2e 20 20 or PFNCLOSE).
3ac0: 54 68 65 20 63 6c 69 65 6e 74 20 63 61 6e 20 64 The client can d
3ad0: 69 73 74 69 6e 67 75 69 73 68 20 74 68 65 73 65 istinguish these
3ae0: 20 74 77 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f two.. //
3af0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 ca
3b00: 73 65 73 20 62 61 73 65 64 20 75 70 6f 6e 20 77 ses based upon w
3b10: 68 65 74 68 65 72 20 74 68 65 20 6c 61 73 74 20 hether the last
3b20: 66 69 6c 65 20 49 2f 4f 20 63 61 6c 6c 0d 0a 20 file I/O call..
3b30: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
3b40: 20 20 20 20 20 20 20 66 61 69 6c 65 64 20 6f 72 failed or
3b50: 20 6e 6f 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f not... /
3b60: 2f 20 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 41 / Response: A
3b70: 73 73 75 6d 69 6e 67 20 74 68 69 73 20 69 73 20 ssuming this is
3b80: 6e 6f 74 20 61 20 72 65 61 6c 20 63 6f 72 72 75 not a real corru
3b90: 70 74 69 6f 6e 20 70 72 6f 62 6c 65 6d 20 69 6e ption problem in
3ba0: 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 .. //
3bb0: 20 20 20 20 20 20 20 20 20 20 61 20 63 61 62 69 a cabi
3bc0: 6e 65 74 20 66 69 6c 65 2c 20 74 68 65 20 66 69 net file, the fi
3bd0: 6c 65 20 49 2f 4f 20 66 75 6e 63 74 69 6f 6e 73 le I/O functions
3be0: 20 63 6f 75 6c 64 20 61 74 74 65 6d 70 74 0d 0a could attempt..
3bf0: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
3c00: 20 20 20 20 20 20 20 20 74 6f 20 64 6f 20 72 65 to do re
3c10: 74 72 69 65 73 20 6f 6e 20 66 61 69 6c 75 72 65 tries on failure
3c20: 20 28 66 6f 72 20 65 78 61 6d 70 6c 65 2c 20 69 (for example, i
3c30: 66 20 74 68 65 72 65 20 69 73 20 61 0d 0a 20 20 f there is a..
3c40: 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 //
3c50: 20 20 20 20 20 20 74 65 6d 70 6f 72 61 72 79 20 temporary
3c60: 6e 65 74 77 6f 72 6b 20 63 6f 6e 6e 65 63 74 69 network connecti
3c70: 6f 6e 20 70 72 6f 62 6c 65 6d 29 2e 20 20 49 66 on problem). If
3c80: 20 74 68 69 73 20 64 6f 65 73 0d 0a 20 20 20 20 this does..
3c90: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
3ca0: 20 20 20 20 6e 6f 74 20 77 6f 72 6b 2c 20 61 6e not work, an
3cb0: 64 20 74 68 65 20 66 69 6c 65 20 49 2f 4f 20 63 d the file I/O c
3cc0: 61 6c 6c 20 68 61 73 20 74 6f 20 66 61 69 6c 2c all has to fail,
3cd0: 20 74 68 65 6e 20 74 68 65 0d 0a 20 20 20 20 20 then the..
3ce0: 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 //
3cf0: 20 20 20 46 44 49 20 63 6c 69 65 6e 74 20 77 69 FDI client wi
3d00: 6c 6c 20 68 61 76 65 20 74 6f 20 63 6c 65 61 6e ll have to clean
3d10: 20 75 70 20 61 6e 64 20 63 61 6c 6c 20 74 68 65 up and call the
3d20: 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 .. //
3d30: 20 20 20 20 20 20 20 20 20 20 46 44 49 43 6f 70 FDICop
3d40: 79 28 29 20 66 75 6e 63 74 69 6f 6e 20 61 67 61 y() function aga
3d50: 69 6e 2e 0d 0a 0d 0a 20 20 20 20 46 44 49 45 52 in..... FDIER
3d60: 52 4f 52 5f 41 4c 4c 4f 43 5f 46 41 49 4c 2c 0d ROR_ALLOC_FAIL,.
3d70: 0a 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 . // Desc
3d80: 72 69 70 74 69 6f 6e 3a 20 43 6f 75 6c 64 20 6e ription: Could n
3d90: 6f 74 20 61 6c 6c 6f 63 61 74 65 20 65 6e 6f 75 ot allocate enou
3da0: 67 68 20 6d 65 6d 6f 72 79 0d 0a 20 20 20 20 20 gh memory..
3db0: 20 20 20 2f 2f 20 43 61 75 73 65 3a 20 20 20 20 // Cause:
3dc0: 20 20 20 46 44 49 20 74 72 69 65 64 20 74 6f 20 FDI tried to
3dd0: 61 6c 6c 6f 63 61 74 65 20 6d 65 6d 6f 72 79 20 allocate memory
3de0: 77 69 74 68 20 74 68 65 20 50 46 4e 41 4c 4c 4f with the PFNALLO
3df0: 43 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 C.. //
3e00: 20 20 20 20 20 20 20 20 20 20 20 66 75 6e 63 74 funct
3e10: 69 6f 6e 2c 20 62 75 74 20 69 74 20 66 61 69 6c ion, but it fail
3e20: 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 ed... //
3e30: 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 49 66 20 Response: If
3e40: 70 6f 73 73 69 62 6c 65 2c 20 50 46 4e 41 4c 4c possible, PFNALL
3e50: 4f 43 20 73 68 6f 75 6c 64 20 74 61 6b 65 20 77 OC should take w
3e60: 68 61 74 65 76 65 72 20 73 74 65 70 73 0d 0a 20 hatever steps..
3e70: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
3e80: 20 20 20 20 20 20 20 61 72 65 20 70 6f 73 73 69 are possi
3e90: 62 6c 65 20 74 6f 20 61 6c 6c 6f 63 61 74 65 20 ble to allocate
3ea0: 74 68 65 20 6d 65 6d 6f 72 79 20 72 65 71 75 65 the memory reque
3eb0: 73 74 65 64 2e 20 20 49 66 0d 0a 20 20 20 20 20 sted. If..
3ec0: 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 //
3ed0: 20 20 20 6d 65 6d 6f 72 79 20 69 73 20 6e 6f 74 memory is not
3ee0: 20 69 6d 6d 65 64 69 61 74 65 6c 79 20 61 76 61 immediately ava
3ef0: 69 6c 61 62 6c 65 2c 20 69 74 20 6d 69 67 68 74 ilable, it might
3f00: 20 70 6f 73 74 20 61 0d 0a 20 20 20 20 20 20 20 post a..
3f10: 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 //
3f20: 20 64 69 61 6c 6f 67 20 61 73 6b 69 6e 67 20 74 dialog asking t
3f30: 68 65 20 75 73 65 72 20 74 6f 20 66 72 65 65 20 he user to free
3f40: 6d 65 6d 6f 72 79 2c 20 66 6f 72 20 65 78 61 6d memory, for exam
3f50: 70 6c 65 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f ple... //
3f60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4e 6f No
3f70: 74 65 20 74 68 61 74 20 74 68 65 20 62 75 6c 6b te that the bulk
3f80: 20 6f 66 20 46 44 49 27 73 20 6d 65 6d 6f 72 79 of FDI's memory
3f90: 20 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 61 72 65 allocations are
3fa0: 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 .. //
3fb0: 20 20 20 20 20 20 20 20 20 20 6d 61 64 65 20 61 made a
3fc0: 74 20 46 44 49 43 72 65 61 74 65 28 29 20 74 69 t FDICreate() ti
3fd0: 6d 65 20 61 6e 64 20 77 68 65 6e 20 74 68 65 20 me and when the
3fe0: 66 69 72 73 74 20 63 61 62 69 6e 65 74 0d 0a 20 first cabinet..
3ff0: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
4000: 20 20 20 20 20 20 20 66 69 6c 65 20 69 73 20 6f file is o
4010: 70 65 6e 65 64 20 64 75 72 69 6e 67 20 46 44 49 pened during FDI
4020: 43 6f 70 79 28 29 2e 0d 0a 0d 0a 20 20 20 20 46 Copy()..... F
4030: 44 49 45 52 52 4f 52 5f 42 41 44 5f 43 4f 4d 50 DIERROR_BAD_COMP
4040: 52 5f 54 59 50 45 2c 0d 0a 20 20 20 20 20 20 20 R_TYPE,..
4050: 20 2f 2f 20 44 65 73 63 72 69 70 74 69 6f 6e 3a // Description:
4060: 20 55 6e 6b 6e 6f 77 6e 20 63 6f 6d 70 72 65 73 Unknown compres
4070: 73 69 6f 6e 20 74 79 70 65 20 69 6e 20 61 20 63 sion type in a c
4080: 61 62 69 6e 65 74 20 66 6f 6c 64 65 72 0d 0a 20 abinet folder..
4090: 20 20 20 20 20 20 20 2f 2f 20 43 61 75 73 65 3a // Cause:
40a0: 20 20 20 20 20 20 20 5b 53 68 6f 75 6c 64 20 6e [Should n
40b0: 65 76 65 72 20 68 61 70 70 65 6e 2e 5d 20 20 41 ever happen.] A
40c0: 20 66 6f 6c 64 65 72 20 69 6e 20 61 20 63 61 62 folder in a cab
40d0: 69 6e 65 74 20 68 61 73 20 61 6e 0d 0a 20 20 20 inet has an..
40e0: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 //
40f0: 20 20 20 20 20 75 6e 6b 6e 6f 77 6e 20 63 6f 6d unknown com
4100: 70 72 65 73 73 69 6f 6e 20 74 79 70 65 2e 20 20 pression type.
4110: 54 68 69 73 20 69 73 20 70 72 6f 62 61 62 6c 79 This is probably
4120: 20 63 61 75 73 65 64 20 62 79 0d 0a 20 20 20 20 caused by..
4130: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
4140: 20 20 20 20 61 20 6d 69 73 6d 61 74 63 68 20 62 a mismatch b
4150: 65 74 77 65 65 6e 20 74 68 65 20 76 65 72 73 69 etween the versi
4160: 6f 6e 20 6f 66 20 46 43 49 2e 4c 49 42 20 75 73 on of FCI.LIB us
4170: 65 64 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f ed to.. /
4180: 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 / c
4190: 72 65 61 74 65 20 74 68 65 20 63 61 62 69 6e 65 reate the cabine
41a0: 74 20 61 6e 64 20 74 68 65 20 46 44 49 2e 4c 49 t and the FDI.LI
41b0: 42 20 75 73 65 64 20 74 6f 20 72 65 61 64 20 74 B used to read t
41c0: 68 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 he.. //
41d0: 20 20 20 20 20 20 20 20 20 20 20 20 63 61 62 69 cabi
41e0: 6e 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f net... //
41f0: 20 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 41 62 Response: Ab
4200: 6f 72 74 2e 0d 0a 0d 0a 20 20 20 20 46 44 49 45 ort..... FDIE
4210: 52 52 4f 52 5f 4d 44 49 5f 46 41 49 4c 2c 0d 0a RROR_MDI_FAIL,..
4220: 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 72 // Descr
4230: 69 70 74 69 6f 6e 3a 20 46 61 69 6c 75 72 65 20 iption: Failure
4240: 64 65 63 6f 6d 70 72 65 73 73 69 6e 67 20 64 61 decompressing da
4250: 74 61 20 66 72 6f 6d 20 61 20 63 61 62 69 6e 65 ta from a cabine
4260: 74 20 66 69 6c 65 0d 0a 20 20 20 20 20 20 20 20 t file..
4270: 2f 2f 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 // Cause:
4280: 54 68 65 20 64 65 63 6f 6d 70 72 65 73 73 6f 72 The decompressor
4290: 20 66 6f 75 6e 64 20 61 6e 20 65 72 72 6f 72 20 found an error
42a0: 69 6e 20 74 68 65 20 64 61 74 61 20 63 6f 6d 69 in the data comi
42b0: 6e 67 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 ng.. //
42c0: 20 20 20 20 20 20 20 20 20 20 20 20 66 72 6f 6d from
42d0: 20 74 68 65 20 66 69 6c 65 20 63 61 62 69 6e 65 the file cabine
42e0: 74 2e 20 20 54 68 65 20 63 61 62 69 6e 65 74 20 t. The cabinet
42f0: 66 69 6c 65 20 77 61 73 20 63 6f 72 72 75 70 74 file was corrupt
4300: 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 ed... //
4310: 20 20 20 20 20 20 20 20 20 20 20 20 20 5b 31 31 [11
4320: 2d 41 70 72 2d 31 39 39 34 20 62 65 6e 73 20 57 -Apr-1994 bens W
4330: 68 65 6e 20 63 68 65 63 6b 73 75 6d 69 6e 67 20 hen checksuming
4340: 69 73 20 74 75 72 6e 65 64 20 6f 6e 2c 20 74 68 is turned on, th
4350: 69 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 is.. //
4360: 20 20 20 20 20 20 20 20 20 20 20 20 65 72 72 6f erro
4370: 72 20 73 68 6f 75 6c 64 20 6e 65 76 65 72 20 6f r should never o
4380: 63 63 75 72 2e 5d 0d 0a 20 20 20 20 20 20 20 20 ccur.]..
4390: 2f 2f 20 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 // Response:
43a0: 50 72 6f 62 61 62 6c 79 20 73 68 6f 75 6c 64 20 Probably should
43b0: 61 62 6f 72 74 3b 20 6f 6e 6c 79 20 6f 74 68 65 abort; only othe
43c0: 72 20 63 68 6f 69 63 65 20 69 73 20 74 6f 20 63 r choice is to c
43d0: 6c 65 61 6e 75 70 0d 0a 20 20 20 20 20 20 20 20 leanup..
43e0: 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 //
43f0: 61 6e 64 20 63 61 6c 6c 20 46 44 49 43 6f 70 79 and call FDICopy
4400: 28 29 20 61 67 61 69 6e 2c 20 61 6e 64 20 68 6f () again, and ho
4410: 70 65 20 74 68 65 72 65 20 77 61 73 20 73 6f 6d pe there was som
4420: 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 e.. //
4430: 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 65 72 inter
4440: 6d 69 74 74 65 6e 74 20 64 61 74 61 20 65 72 72 mittent data err
4450: 6f 72 20 74 68 61 74 20 77 69 6c 6c 20 6e 6f 74 or that will not
4460: 20 72 65 6f 63 63 75 72 2e 0d 0a 0d 0a 20 20 20 reoccur.....
4470: 20 46 44 49 45 52 52 4f 52 5f 54 41 52 47 45 54 FDIERROR_TARGET
4480: 5f 46 49 4c 45 2c 0d 0a 20 20 20 20 20 20 20 20 _FILE,..
4490: 2f 2f 20 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 // Description:
44a0: 46 61 69 6c 75 72 65 20 77 72 69 74 69 6e 67 20 Failure writing
44b0: 74 6f 20 74 61 72 67 65 74 20 66 69 6c 65 0d 0a to target file..
44c0: 20 20 20 20 20 20 20 20 2f 2f 20 43 61 75 73 65 // Cause
44d0: 3a 20 20 20 20 20 20 20 46 44 49 20 72 65 74 75 : FDI retu
44e0: 72 6e 73 20 74 68 69 73 20 65 72 72 6f 72 20 61 rns this error a
44f0: 6e 79 20 74 69 6d 65 20 69 74 20 67 65 74 73 20 ny time it gets
4500: 61 6e 20 65 72 72 6f 72 20 62 61 63 6b 0d 0a 20 an error back..
4510: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
4520: 20 20 20 20 20 20 20 66 72 6f 6d 20 6f 6e 65 20 from one
4530: 6f 66 20 74 68 65 20 70 61 73 73 65 64 2d 69 6e of the passed-in
4540: 20 66 69 6c 65 20 49 2f 4f 20 63 61 6c 6c 73 20 file I/O calls
4550: 66 61 69 6c 73 20 77 68 65 6e 0d 0a 20 20 20 20 fails when..
4560: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
4570: 20 20 20 20 77 72 69 74 69 6e 67 20 74 6f 20 61 writing to a
4580: 20 66 69 6c 65 20 62 65 69 6e 67 20 65 78 74 72 file being extr
4590: 61 63 74 65 64 20 66 72 6f 6d 20 61 20 63 61 62 acted from a cab
45a0: 69 6e 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f inet... /
45b0: 2f 20 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 54 / Response: T
45c0: 6f 20 61 76 6f 69 64 20 6f 72 20 6d 69 6e 69 6d o avoid or minim
45d0: 69 7a 65 20 74 68 69 73 20 65 72 72 6f 72 2c 20 ize this error,
45e0: 74 68 65 20 66 69 6c 65 20 49 2f 4f 20 66 75 6e the file I/O fun
45f0: 63 74 69 6f 6e 73 0d 0a 20 20 20 20 20 20 20 20 ctions..
4600: 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 //
4610: 63 6f 75 6c 64 20 61 74 74 65 6d 70 74 20 74 6f could attempt to
4620: 20 61 76 6f 69 64 20 66 61 69 6c 69 6e 67 2e 20 avoid failing.
4630: 20 41 20 63 6f 6d 6d 6f 6e 20 63 61 75 73 65 20 A common cause
4640: 6d 69 67 68 74 0d 0a 20 20 20 20 20 20 20 20 2f might.. /
4650: 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 / b
4660: 65 20 64 69 73 6b 20 66 75 6c 6c 20 2d 2d 20 69 e disk full -- i
4670: 6e 20 74 68 69 73 20 63 61 73 65 2c 20 74 68 65 n this case, the
4680: 20 50 46 4e 57 52 49 54 45 20 66 75 6e 63 74 69 PFNWRITE functi
4690: 6f 6e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 on.. //
46a0: 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 75 6c coul
46b0: 64 20 68 61 76 65 20 61 20 63 68 65 63 6b 20 66 d have a check f
46c0: 6f 72 20 66 72 65 65 20 73 70 61 63 65 2c 20 61 or free space, a
46d0: 6e 64 20 70 75 74 20 75 70 20 61 20 64 69 61 6c nd put up a dial
46e0: 6f 67 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 og.. //
46f0: 20 20 20 20 20 20 20 20 20 20 20 20 61 73 6b 69 aski
4700: 6e 67 20 74 68 65 20 75 73 65 72 20 74 6f 20 66 ng the user to f
4710: 72 65 65 20 73 6f 6d 65 20 64 69 73 6b 20 73 70 ree some disk sp
4720: 61 63 65 2e 0d 0a 0d 0a 20 20 20 20 46 44 49 45 ace..... FDIE
4730: 52 52 4f 52 5f 52 45 53 45 52 56 45 5f 4d 49 53 RROR_RESERVE_MIS
4740: 4d 41 54 43 48 2c 0d 0a 20 20 20 20 20 20 20 20 MATCH,..
4750: 2f 2f 20 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 // Description:
4760: 43 61 62 69 6e 65 74 73 20 69 6e 20 61 20 73 65 Cabinets in a se
4770: 74 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 74 68 t do not have th
4780: 65 20 73 61 6d 65 20 52 45 53 45 52 56 45 20 73 e same RESERVE s
4790: 69 7a 65 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f izes.. //
47a0: 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 5b 53 Cause: [S
47b0: 68 6f 75 6c 64 20 6e 65 76 65 72 20 68 61 70 70 hould never happ
47c0: 65 6e 5d 2e 20 46 44 49 20 72 65 71 75 69 72 65 en]. FDI require
47d0: 73 20 74 68 61 74 20 74 68 65 20 73 69 7a 65 73 s that the sizes
47e0: 20 6f 66 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 of.. //
47f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 65 the
4800: 20 70 65 72 2d 63 61 62 69 6e 65 74 2c 20 70 65 per-cabinet, pe
4810: 72 2d 66 6f 6c 64 65 72 2c 20 61 6e 64 20 70 65 r-folder, and pe
4820: 72 2d 64 61 74 61 20 62 6c 6f 63 6b 0d 0a 20 20 r-data block..
4830: 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 //
4840: 20 20 20 20 20 20 52 45 53 45 52 56 45 20 73 65 RESERVE se
4850: 63 74 69 6f 6e 73 20 62 65 20 63 6f 6e 73 69 73 ctions be consis
4860: 74 65 6e 74 20 61 63 72 6f 73 73 20 61 6c 6c 20 tent across all
4870: 74 68 65 20 63 61 62 69 6e 65 74 73 0d 0a 20 20 the cabinets..
4880: 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 //
4890: 20 20 20 20 20 20 69 6e 20 61 20 73 65 74 2e 0d in a set..
48a0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 70 . // Resp
48b0: 6f 6e 73 65 3a 20 20 20 20 41 62 6f 72 74 2e 0d onse: Abort..
48c0: 0a 0d 0a 20 20 20 20 46 44 49 45 52 52 4f 52 5f ... FDIERROR_
48d0: 57 52 4f 4e 47 5f 43 41 42 49 4e 45 54 2c 0d 0a WRONG_CABINET,..
48e0: 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 72 // Descr
48f0: 69 70 74 69 6f 6e 3a 20 43 61 62 69 6e 65 74 20 iption: Cabinet
4900: 72 65 74 75 72 6e 65 64 20 6f 6e 20 66 64 69 6e returned on fdin
4910: 74 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 69 73 tNEXT_CABINET is
4920: 20 69 6e 63 6f 72 72 65 63 74 0d 0a 20 20 20 20 incorrect..
4930: 20 20 20 20 2f 2f 20 43 61 75 73 65 3a 20 20 20 // Cause:
4940: 20 20 20 20 4e 4f 54 45 3a 20 54 48 49 53 20 45 NOTE: THIS E
4950: 52 52 4f 52 20 49 53 20 4e 45 56 45 52 20 52 45 RROR IS NEVER RE
4960: 54 55 52 4e 45 44 20 42 59 20 46 44 49 43 6f 70 TURNED BY FDICop
4970: 79 28 29 21 0d 0a 20 20 20 20 20 20 20 20 2f 2f y()!.. //
4980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 61 Ra
4990: 74 68 65 72 2c 20 46 44 49 43 6f 70 79 28 29 20 ther, FDICopy()
49a0: 6b 65 65 70 73 20 63 61 6c 6c 69 6e 67 20 74 68 keeps calling th
49b0: 65 20 66 64 69 6e 74 4e 45 58 54 5f 43 41 42 49 e fdintNEXT_CABI
49c0: 4e 45 54 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 NET.. //
49d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 6c cal
49e0: 6c 62 61 63 6b 20 75 6e 74 69 6c 20 65 69 74 68 lback until eith
49f0: 65 72 20 74 68 65 20 63 6f 72 72 65 63 74 20 63 er the correct c
4a00: 61 62 69 6e 65 74 20 69 73 20 73 70 65 63 69 66 abinet is specif
4a10: 69 65 64 2c 0d 0a 20 20 20 20 20 20 20 20 2f 2f ied,.. //
4a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 72 or
4a30: 20 79 6f 75 20 72 65 74 75 72 6e 20 41 42 4f 52 you return ABOR
4a40: 54 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 T... //
4a50: 20 20 20 20 20 20 20 20 20 20 20 20 57 68 65 6e When
4a60: 20 46 44 49 43 6f 70 79 28 29 20 69 73 20 65 78 FDICopy() is ex
4a70: 74 72 61 63 74 69 6e 67 20 61 20 66 69 6c 65 20 tracting a file
4a80: 74 68 61 74 20 63 72 6f 73 73 65 73 20 61 0d 0a that crosses a..
4a90: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
4aa0: 20 20 20 20 20 20 20 20 63 61 62 69 6e 65 74 20 cabinet
4ab0: 62 6f 75 6e 64 61 72 79 2c 20 69 74 20 63 61 6c boundary, it cal
4ac0: 6c 73 20 66 64 69 6e 74 4e 45 58 54 5f 43 41 42 ls fdintNEXT_CAB
4ad0: 49 4e 45 54 20 74 6f 20 61 73 6b 0d 0a 20 20 20 INET to ask..
4ae0: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 //
4af0: 20 20 20 20 20 66 6f 72 20 74 68 65 20 70 61 74 for the pat
4b00: 68 20 74 6f 20 74 68 65 20 6e 65 78 74 20 63 61 h to the next ca
4b10: 62 69 6e 65 74 2e 20 20 4e 6f 74 20 62 65 69 6e binet. Not bein
4b20: 67 20 76 65 72 79 0d 0a 20 20 20 20 20 20 20 20 g very..
4b30: 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 //
4b40: 74 72 75 73 74 69 6e 67 2c 20 46 44 49 20 74 68 trusting, FDI th
4b50: 65 6e 20 63 68 65 63 6b 73 20 74 6f 20 6d 61 6b en checks to mak
4b60: 65 20 73 75 72 65 20 74 68 61 74 20 74 68 65 0d e sure that the.
4b70: 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 . //
4b80: 20 20 20 20 20 20 20 20 20 63 6f 72 72 65 63 74 correct
4b90: 20 63 6f 6e 74 69 6e 75 61 74 69 6f 6e 20 63 61 continuation ca
4ba0: 62 69 6e 65 74 20 77 61 73 20 73 75 70 70 6c 69 binet was suppli
4bb0: 65 64 21 20 20 49 74 20 64 6f 65 73 0d 0a 20 20 ed! It does..
4bc0: 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 //
4bd0: 20 20 20 20 20 20 74 68 69 73 20 62 79 20 63 68 this by ch
4be0: 65 63 6b 69 6e 67 20 74 68 65 20 22 73 65 74 49 ecking the "setI
4bf0: 44 22 20 61 6e 64 20 22 69 43 61 62 69 6e 65 74 D" and "iCabinet
4c00: 22 20 66 69 65 6c 64 73 0d 0a 20 20 20 20 20 20 " fields..
4c10: 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 //
4c20: 20 20 69 6e 20 74 68 65 20 63 61 62 69 6e 65 74 in the cabinet
4c30: 2e 20 20 57 68 65 6e 20 4d 41 4b 45 43 41 42 2e . When MAKECAB.
4c40: 45 58 45 20 63 72 65 61 74 65 73 20 61 20 73 65 EXE creates a se
4c50: 74 20 6f 66 0d 0a 20 20 20 20 20 20 20 20 2f 2f t of.. //
4c60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 ca
4c70: 62 69 6e 65 74 73 2c 20 69 74 20 63 6f 6e 73 74 binets, it const
4c80: 72 75 63 74 73 20 74 68 65 20 22 73 65 74 49 44 ructs the "setID
4c90: 22 20 75 73 69 6e 67 20 74 68 65 20 73 75 6d 0d " using the sum.
4ca0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 . //
4cb0: 20 20 20 20 20 20 20 20 20 6f 66 20 74 68 65 20 of the
4cc0: 62 79 74 65 73 20 6f 66 20 61 6c 6c 20 74 68 65 bytes of all the
4cd0: 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 66 69 6c destination fil
4ce0: 65 20 6e 61 6d 65 73 20 69 6e 0d 0a 20 20 20 20 e names in..
4cf0: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 //
4d00: 20 20 20 20 74 68 65 20 63 61 62 69 6e 65 74 20 the cabinet
4d10: 73 65 74 2e 20 20 46 44 49 20 6d 61 6b 65 73 20 set. FDI makes
4d20: 73 75 72 65 20 74 68 61 74 20 74 68 65 20 31 36 sure that the 16
4d30: 2d 62 69 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f -bit.. //
4d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 65 se
4d50: 74 49 44 20 6f 66 20 74 68 65 20 63 6f 6e 74 69 tID of the conti
4d60: 6e 75 61 74 69 6f 6e 20 63 61 62 69 6e 65 74 20 nuation cabinet
4d70: 6d 61 74 63 68 65 73 20 74 68 65 0d 0a 20 20 20 matches the..
4d80: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 //
4d90: 20 20 20 20 20 63 61 62 69 6e 65 74 20 66 69 6c cabinet fil
4da0: 65 20 6a 75 73 74 20 70 72 6f 63 65 73 73 65 64 e just processed
4db0: 2e 20 20 46 44 49 20 74 68 65 6e 20 63 68 65 63 . FDI then chec
4dc0: 6b 73 20 74 68 61 74 0d 0a 20 20 20 20 20 20 20 ks that..
4dd0: 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 //
4de0: 20 74 68 65 20 63 61 62 69 6e 65 74 20 6e 75 6d the cabinet num
4df0: 62 65 72 20 28 69 43 61 62 69 6e 65 74 29 20 69 ber (iCabinet) i
4e00: 73 20 6f 6e 65 20 6d 6f 72 65 20 74 68 61 6e 20 s one more than
4e10: 74 68 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 the.. //
4e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 62 cab
4e30: 69 6e 65 74 20 6e 75 6d 62 65 72 20 66 6f 72 20 inet number for
4e40: 74 68 65 20 63 61 62 69 6e 65 74 20 6a 75 73 74 the cabinet just
4e50: 20 70 72 6f 63 65 73 73 65 64 2e 0d 0a 20 20 20 processed...
4e60: 20 20 20 20 20 2f 2f 20 52 65 73 70 6f 6e 73 65 // Response
4e70: 3a 20 20 20 20 59 6f 75 20 6e 65 65 64 20 63 6f : You need co
4e80: 64 65 20 69 6e 20 79 6f 75 72 20 66 64 69 6e 74 de in your fdint
4e90: 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 28 73 65 NEXT_CABINET (se
4ea0: 65 20 62 65 6c 6f 77 29 0d 0a 20 20 20 20 20 20 e below)..
4eb0: 20 20 2f 2f 20 20 20 20 20 20 20 20 20 20 20 20 //
4ec0: 20 20 68 61 6e 64 6c 65 72 20 74 6f 20 64 6f 20 handler to do
4ed0: 72 65 74 72 69 65 73 20 69 66 20 79 6f 75 20 67 retries if you g
4ee0: 65 74 20 72 65 63 61 6c 6c 65 64 20 77 69 74 68 et recalled with
4ef0: 20 74 68 69 73 0d 0a 20 20 20 20 20 20 20 20 2f this.. /
4f00: 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 / e
4f10: 72 72 6f 72 2e 20 20 53 65 65 20 74 68 65 20 73 rror. See the s
4f20: 61 6d 70 6c 65 20 63 6f 64 65 20 28 45 58 54 52 ample code (EXTR
4f30: 41 43 54 2e 43 29 20 74 6f 20 73 65 65 20 68 6f ACT.C) to see ho
4f40: 77 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 w.. //
4f50: 20 20 20 20 20 20 20 20 20 20 20 74 68 69 73 20 this
4f60: 73 68 6f 75 6c 64 20 62 65 20 68 61 6e 64 6c 65 should be handle
4f70: 64 2e 0d 0a 0d 0a 20 20 20 20 46 44 49 45 52 52 d..... FDIERR
4f80: 4f 52 5f 55 53 45 52 5f 41 42 4f 52 54 2c 0d 0a OR_USER_ABORT,..
4f90: 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 63 72 // Descr
4fa0: 69 70 74 69 6f 6e 3a 20 46 44 49 20 61 62 6f 72 iption: FDI abor
4fb0: 74 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f ted... //
4fc0: 20 43 61 75 73 65 3a 20 20 20 20 20 20 20 41 6e Cause: An
4fd0: 20 46 44 49 20 63 61 6c 6c 62 61 63 6b 20 72 65 FDI callback re
4fe0: 74 75 72 6e 64 20 2d 31 20 28 75 73 75 61 6c 6c turnd -1 (usuall
4ff0: 79 29 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 y)... //
5000: 52 65 73 70 6f 6e 73 65 3a 20 20 20 20 55 70 20 Response: Up
5010: 74 6f 20 63 6c 69 65 6e 74 2e 0d 0a 0d 0a 7d 20 to client.....}
5020: 46 44 49 45 52 52 4f 52 3b 0d 0a 0d 0a 0d 0a 2f FDIERROR;....../
5030: 2a 0d 0a 20 2a 20 46 41 54 20 66 69 6c 65 20 61 *.. * FAT file a
5040: 74 74 72 69 62 75 74 65 20 66 6c 61 67 20 75 73 ttribute flag us
5050: 65 64 20 62 79 20 46 43 49 2f 46 44 49 20 74 6f ed by FCI/FDI to
5060: 20 69 6e 64 69 63 61 74 65 20 74 68 61 74 0d 0a indicate that..
5070: 20 2a 20 74 68 65 20 66 69 6c 65 6e 61 6d 65 20 * the filename
5080: 69 6e 20 74 68 65 20 43 41 42 20 69 73 20 61 20 in the CAB is a
5090: 55 54 46 20 73 74 72 69 6e 67 0d 0a 20 2a 2f 0d UTF string.. */.
50a0: 0a 23 69 66 6e 64 65 66 20 5f 41 5f 4e 41 4d 45 .#ifndef _A_NAME
50b0: 5f 49 53 5f 55 54 46 0d 0a 23 64 65 66 69 6e 65 _IS_UTF..#define
50c0: 20 5f 41 5f 4e 41 4d 45 5f 49 53 5f 55 54 46 20 _A_NAME_IS_UTF
50d0: 20 30 78 38 30 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0x80..#endif...
50e0: 0a 2f 2a 0d 0a 20 2a 20 46 41 54 20 66 69 6c 65 ./*.. * FAT file
50f0: 20 61 74 74 72 69 62 75 74 65 20 66 6c 61 67 20 attribute flag
5100: 75 73 65 64 20 62 79 20 46 43 49 2f 46 44 49 20 used by FCI/FDI
5110: 74 6f 20 69 6e 64 69 63 61 74 65 20 74 68 61 74 to indicate that
5120: 0d 0a 20 2a 20 74 68 65 20 66 69 6c 65 20 73 68 .. * the file sh
5130: 6f 75 6c 64 20 62 65 20 65 78 65 63 75 74 65 64 ould be executed
5140: 20 61 66 74 65 72 20 65 78 74 72 61 63 74 69 6f after extractio
5150: 6e 0d 0a 20 2a 2f 0d 0a 23 69 66 6e 64 65 66 20 n.. */..#ifndef
5160: 5f 41 5f 45 58 45 43 0d 0a 23 64 65 66 69 6e 65 _A_EXEC..#define
5170: 20 5f 41 5f 45 58 45 43 20 20 20 20 20 20 20 20 _A_EXEC
5180: 20 30 78 34 30 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0x40..#endif...
5190: 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 48 46 44 49 20 .../*** HFDI
51a0: 2d 20 48 61 6e 64 6c 65 20 74 6f 20 61 6e 20 46 - Handle to an F
51b0: 44 49 20 63 6f 6e 74 65 78 74 0d 0a 20 2a 0d 0a DI context.. *..
51c0: 20 2a 20 20 46 44 49 43 72 65 61 74 65 28 29 20 * FDICreate()
51d0: 63 72 65 61 74 65 73 20 74 68 69 73 2c 20 61 6e creates this, an
51e0: 64 20 69 74 20 6d 75 73 74 20 62 65 20 70 61 73 d it must be pas
51f0: 73 65 64 20 74 6f 20 61 6c 6c 20 6f 74 68 65 72 sed to all other
5200: 20 46 44 49 0d 0a 20 2a 20 20 66 75 6e 63 74 69 FDI.. * functi
5210: 6f 6e 73 2e 0d 0a 20 2a 2f 0d 0a 74 79 70 65 64 ons... */..typed
5220: 65 66 20 76 6f 69 64 20 46 41 52 20 2a 48 46 44 ef void FAR *HFD
5230: 49 3b 20 2f 2a 20 68 66 64 69 20 2a 2f 0d 0a 0d I; /* hfdi */...
5240: 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 44 49 43 41 .../*** FDICA
5250: 42 49 4e 45 54 49 4e 46 4f 20 2d 20 49 6e 66 6f BINETINFO - Info
5260: 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 61 20 rmation about a
5270: 63 61 62 69 6e 65 74 0d 0a 20 2a 0d 0a 20 2a 2f cabinet.. *.. */
5280: 0d 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 ..typedef struct
5290: 20 7b 0d 0a 20 20 20 20 6c 6f 6e 67 20 20 20 20 {.. long
52a0: 20 20 20 20 63 62 43 61 62 69 6e 65 74 3b 20 20 cbCabinet;
52b0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 // T
52c0: 6f 74 61 6c 20 6c 65 6e 67 74 68 20 6f 66 20 63 otal length of c
52d0: 61 62 69 6e 65 74 20 66 69 6c 65 0d 0a 20 20 20 abinet file..
52e0: 20 55 53 48 4f 52 54 20 20 20 20 20 20 63 46 6f USHORT cFo
52f0: 6c 64 65 72 73 3b 20 20 20 20 20 20 20 20 20 20 lders;
5300: 20 20 20 20 20 2f 2f 20 43 6f 75 6e 74 20 6f 66 // Count of
5310: 20 66 6f 6c 64 65 72 73 20 69 6e 20 63 61 62 69 folders in cabi
5320: 6e 65 74 0d 0a 20 20 20 20 55 53 48 4f 52 54 20 net.. USHORT
5330: 20 20 20 20 20 63 46 69 6c 65 73 3b 20 20 20 20 cFiles;
5340: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
5350: 43 6f 75 6e 74 20 6f 66 20 66 69 6c 65 73 20 69 Count of files i
5360: 6e 20 63 61 62 69 6e 65 74 0d 0a 20 20 20 20 55 n cabinet.. U
5370: 53 48 4f 52 54 20 20 20 20 20 20 73 65 74 49 44 SHORT setID
5380: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
5390: 20 20 20 2f 2f 20 43 61 62 69 6e 65 74 20 73 65 // Cabinet se
53a0: 74 20 49 44 0d 0a 20 20 20 20 55 53 48 4f 52 54 t ID.. USHORT
53b0: 20 20 20 20 20 20 69 43 61 62 69 6e 65 74 3b 20 iCabinet;
53c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
53d0: 20 43 61 62 69 6e 65 74 20 6e 75 6d 62 65 72 20 Cabinet number
53e0: 69 6e 20 73 65 74 20 28 30 20 62 61 73 65 64 29 in set (0 based)
53f0: 0d 0a 20 20 20 20 42 4f 4f 4c 20 20 20 20 20 20 .. BOOL
5400: 20 20 66 52 65 73 65 72 76 65 3b 20 20 20 20 20 fReserve;
5410: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 52 55 // TRU
5420: 45 20 3d 3e 20 52 45 53 45 52 56 45 20 70 72 65 E => RESERVE pre
5430: 73 65 6e 74 20 69 6e 20 63 61 62 69 6e 65 74 0d sent in cabinet.
5440: 0a 20 20 20 20 42 4f 4f 4c 20 20 20 20 20 20 20 . BOOL
5450: 20 68 61 73 70 72 65 76 3b 20 20 20 20 20 20 20 hasprev;
5460: 20 20 20 20 20 20 20 20 20 2f 2f 20 54 52 55 45 // TRUE
5470: 20 3d 3e 20 43 61 62 69 6e 65 74 20 69 73 20 63 => Cabinet is c
5480: 68 61 69 6e 65 64 20 70 72 65 76 0d 0a 20 20 20 hained prev..
5490: 20 42 4f 4f 4c 20 20 20 20 20 20 20 20 68 61 73 BOOL has
54a0: 6e 65 78 74 3b 20 20 20 20 20 20 20 20 20 20 20 next;
54b0: 20 20 20 20 20 2f 2f 20 54 52 55 45 20 3d 3e 20 // TRUE =>
54c0: 43 61 62 69 6e 65 74 20 69 73 20 63 68 61 69 6e Cabinet is chain
54d0: 65 64 20 6e 65 78 74 0d 0a 7d 20 46 44 49 43 41 ed next..} FDICA
54e0: 42 49 4e 45 54 49 4e 46 4f 3b 20 2f 2a 20 66 64 BINETINFO; /* fd
54f0: 69 63 69 20 2a 2f 0d 0a 74 79 70 65 64 65 66 20 ici */..typedef
5500: 46 44 49 43 41 42 49 4e 45 54 49 4e 46 4f 20 46 FDICABINETINFO F
5510: 41 52 20 2a 50 46 44 49 43 41 42 49 4e 45 54 49 AR *PFDICABINETI
5520: 4e 46 4f 3b 20 2f 2a 20 70 66 64 69 63 69 20 2a NFO; /* pfdici *
5530: 2f 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 /....../*** F
5540: 44 49 44 45 43 52 59 50 54 54 59 50 45 20 2d 20 DIDECRYPTTYPE -
5550: 50 46 4e 46 44 49 44 45 43 52 59 50 54 20 63 6f PFNFDIDECRYPT co
5560: 6d 6d 61 6e 64 20 74 79 70 65 73 0d 0a 20 2a 0d mmand types.. *.
5570: 0a 20 2a 2f 0d 0a 74 79 70 65 64 65 66 20 65 6e . */..typedef en
5580: 75 6d 20 7b 0d 0a 20 20 20 20 66 64 69 64 74 4e um {.. fdidtN
5590: 45 57 5f 43 41 42 49 4e 45 54 2c 20 20 20 20 20 EW_CABINET,
55a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
55b0: 20 4e 65 77 20 63 61 62 69 6e 65 74 0d 0a 20 20 New cabinet..
55c0: 20 20 66 64 69 64 74 4e 45 57 5f 46 4f 4c 44 45 fdidtNEW_FOLDE
55d0: 52 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 R,
55e0: 20 20 20 20 20 20 2f 2f 20 4e 65 77 20 66 6f 6c // New fol
55f0: 64 65 72 0d 0a 20 20 20 20 66 64 69 64 74 44 45 der.. fdidtDE
5600: 43 52 59 50 54 2c 20 20 20 20 20 20 20 20 20 20 CRYPT,
5610: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
5620: 44 65 63 72 79 70 74 20 61 20 64 61 74 61 20 62 Decrypt a data b
5630: 6c 6f 63 6b 0d 0a 7d 20 46 44 49 44 45 43 52 59 lock..} FDIDECRY
5640: 50 54 54 59 50 45 3b 20 2f 2a 20 66 64 69 64 74 PTTYPE; /* fdidt
5650: 20 2a 2f 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 */....../***
5660: 20 46 44 49 44 45 43 52 59 50 54 20 2d 20 44 61 FDIDECRYPT - Da
5670: 74 61 20 66 6f 72 20 50 46 4e 46 44 49 44 45 43 ta for PFNFDIDEC
5680: 52 59 50 54 20 66 75 6e 63 74 69 6f 6e 0d 0a 20 RYPT function..
5690: 2a 0d 0a 20 2a 2f 0d 0a 74 79 70 65 64 65 66 20 *.. */..typedef
56a0: 73 74 72 75 63 74 20 7b 0d 0a 20 20 20 20 46 44 struct {.. FD
56b0: 49 44 45 43 52 59 50 54 54 59 50 45 20 20 20 20 IDECRYPTTYPE
56c0: 66 64 69 64 74 3b 20 20 20 20 20 20 20 20 20 20 fdidt;
56d0: 20 20 2f 2f 20 43 6f 6d 6d 61 6e 64 20 74 79 70 // Command typ
56e0: 65 20 28 73 65 6c 65 63 74 73 20 75 6e 69 6f 6e e (selects union
56f0: 20 62 65 6c 6f 77 29 0d 0a 20 20 20 20 76 6f 69 below).. voi
5700: 64 20 46 41 52 20 20 20 20 20 20 20 20 20 2a 70 d FAR *p
5710: 76 55 73 65 72 3b 20 20 20 20 20 20 20 20 20 20 vUser;
5720: 20 2f 2f 20 44 65 63 72 79 70 74 69 6f 6e 20 63 // Decryption c
5730: 6f 6e 74 65 78 74 0d 0a 20 20 20 20 75 6e 69 6f ontext.. unio
5740: 6e 20 7b 0d 0a 20 20 20 20 20 20 20 20 73 74 72 n {.. str
5750: 75 63 74 20 7b 20 20 20 20 20 20 20 20 20 20 20 uct {
5760: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
5770: 66 64 69 64 74 4e 45 57 5f 43 41 42 49 4e 45 54 fdidtNEW_CABINET
5780: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 6f .. vo
5790: 69 64 20 46 41 52 20 2a 70 48 65 61 64 65 72 52 id FAR *pHeaderR
57a0: 65 73 65 72 76 65 3b 20 20 20 2f 2f 20 52 45 53 eserve; // RES
57b0: 45 52 56 45 20 73 65 63 74 69 6f 6e 20 66 72 6f ERVE section fro
57c0: 6d 20 43 46 48 45 41 44 45 52 0d 0a 20 20 20 20 m CFHEADER..
57d0: 20 20 20 20 20 20 20 20 55 53 48 4f 52 54 20 20 USHORT
57e0: 20 20 63 62 48 65 61 64 65 72 52 65 73 65 72 76 cbHeaderReserv
57f0: 65 3b 20 20 2f 2f 20 53 69 7a 65 20 6f 66 20 70 e; // Size of p
5800: 48 65 61 64 65 72 52 65 73 65 72 76 65 0d 0a 20 HeaderReserve..
5810: 20 20 20 20 20 20 20 20 20 20 20 55 53 48 4f 52 USHOR
5820: 54 20 20 20 20 73 65 74 49 44 3b 20 20 20 20 20 T setID;
5830: 20 20 20 20 20 20 20 2f 2f 20 43 61 62 69 6e 65 // Cabine
5840: 74 20 73 65 74 20 49 44 0d 0a 20 20 20 20 20 20 t set ID..
5850: 20 20 20 20 20 20 69 6e 74 20 20 20 20 20 20 20 int
5860: 69 43 61 62 69 6e 65 74 3b 20 20 20 20 20 20 20 iCabinet;
5870: 20 20 2f 2f 20 43 61 62 69 6e 65 74 20 6e 75 6d // Cabinet num
5880: 62 65 72 20 69 6e 20 73 65 74 20 28 30 20 62 61 ber in set (0 ba
5890: 73 65 64 29 0d 0a 20 20 20 20 20 20 20 20 7d 20 sed).. }
58a0: 63 61 62 69 6e 65 74 3b 0d 0a 0d 0a 20 20 20 20 cabinet;....
58b0: 20 20 20 20 73 74 72 75 63 74 20 7b 20 20 20 20 struct {
58c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
58d0: 20 20 20 20 2f 2f 20 66 64 69 64 74 4e 45 57 5f // fdidtNEW_
58e0: 46 4f 4c 44 45 52 0d 0a 20 20 20 20 20 20 20 20 FOLDER..
58f0: 20 20 20 20 76 6f 69 64 20 46 41 52 20 2a 70 46 void FAR *pF
5900: 6f 6c 64 65 72 52 65 73 65 72 76 65 3b 20 20 20 olderReserve;
5910: 2f 2f 20 52 45 53 45 52 56 45 20 73 65 63 74 69 // RESERVE secti
5920: 6f 6e 20 66 72 6f 6d 20 43 46 46 4f 4c 44 45 52 on from CFFOLDER
5930: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 55 53 .. US
5940: 48 4f 52 54 20 20 20 20 63 62 46 6f 6c 64 65 72 HORT cbFolder
5950: 52 65 73 65 72 76 65 3b 20 20 2f 2f 20 53 69 7a Reserve; // Siz
5960: 65 20 6f 66 20 70 46 6f 6c 64 65 72 52 65 73 65 e of pFolderRese
5970: 72 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 rve..
5980: 20 55 53 48 4f 52 54 20 20 20 20 69 46 6f 6c 64 USHORT iFold
5990: 65 72 3b 20 20 20 20 20 20 20 20 20 20 2f 2f 20 er; //
59a0: 46 6f 6c 64 65 72 20 6e 75 6d 62 65 72 20 69 6e Folder number in
59b0: 20 63 61 62 69 6e 65 74 20 28 30 20 62 61 73 65 cabinet (0 base
59c0: 64 29 0d 0a 20 20 20 20 20 20 20 20 7d 20 66 6f d).. } fo
59d0: 6c 64 65 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 lder;....
59e0: 20 73 74 72 75 63 74 20 7b 20 20 20 20 20 20 20 struct {
59f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5a00: 20 2f 2f 20 66 64 69 64 74 44 45 43 52 59 50 54 // fdidtDECRYPT
5a10: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 6f .. vo
5a20: 69 64 20 46 41 52 20 2a 70 44 61 74 61 52 65 73 id FAR *pDataRes
5a30: 65 72 76 65 3b 20 20 20 20 20 2f 2f 20 52 45 53 erve; // RES
5a40: 45 52 56 45 20 73 65 63 74 69 6f 6e 20 66 72 6f ERVE section fro
5a50: 6d 20 43 46 44 41 54 41 0d 0a 20 20 20 20 20 20 m CFDATA..
5a60: 20 20 20 20 20 20 55 53 48 4f 52 54 20 20 20 20 USHORT
5a70: 63 62 44 61 74 61 52 65 73 65 72 76 65 3b 20 20 cbDataReserve;
5a80: 20 20 2f 2f 20 53 69 7a 65 20 6f 66 20 70 44 61 // Size of pDa
5a90: 74 61 52 65 73 65 72 76 65 0d 0a 20 20 20 20 20 taReserve..
5aa0: 20 20 20 20 20 20 20 76 6f 69 64 20 46 41 52 20 void FAR
5ab0: 2a 70 62 44 61 74 61 3b 20 20 20 20 20 20 20 20 *pbData;
5ac0: 20 20 20 2f 2f 20 44 61 74 61 20 62 75 66 66 65 // Data buffe
5ad0: 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 55 r.. U
5ae0: 53 48 4f 52 54 20 20 20 20 63 62 44 61 74 61 3b SHORT cbData;
5af0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 69 // Si
5b00: 7a 65 20 6f 66 20 64 61 74 61 20 62 75 66 66 65 ze of data buffe
5b10: 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 42 r.. B
5b20: 4f 4f 4c 20 20 20 20 20 20 66 53 70 6c 69 74 3b OOL fSplit;
5b30: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 52 // TR
5b40: 55 45 20 69 66 20 74 68 69 73 20 69 73 20 61 20 UE if this is a
5b50: 73 70 6c 69 74 20 64 61 74 61 20 62 6c 6f 63 6b split data block
5b60: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 55 53 .. US
5b70: 48 4f 52 54 20 20 20 20 63 62 50 61 72 74 69 61 HORT cbPartia
5b80: 6c 3b 20 20 20 20 20 20 20 20 2f 2f 20 30 20 69 l; // 0 i
5b90: 66 20 74 68 69 73 20 69 73 20 6e 6f 74 20 61 20 f this is not a
5ba0: 73 70 6c 69 74 20 62 6c 6f 63 6b 2c 20 6f 72 0d split block, or.
5bb0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
5bc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5bd0: 20 20 20 20 20 20 20 20 20 2f 2f 20 20 74 68 65 // the
5be0: 20 66 69 72 73 74 20 70 69 65 63 65 20 6f 66 20 first piece of
5bf0: 61 20 73 70 6c 69 74 20 62 6c 6f 63 6b 3b 0d 0a a split block;..
5c00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5c20: 20 20 20 20 20 20 20 20 2f 2f 20 47 72 65 61 74 // Great
5c30: 65 72 20 74 68 61 6e 20 30 20 69 66 20 74 68 69 er than 0 if thi
5c40: 73 20 69 73 20 74 68 65 0d 0a 20 20 20 20 20 20 s is the..
5c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5c60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5c70: 20 20 2f 2f 20 20 73 65 63 6f 6e 64 20 70 69 65 // second pie
5c80: 63 65 20 6f 66 20 61 20 73 70 6c 69 74 20 62 6c ce of a split bl
5c90: 6f 63 6b 2e 0d 0a 20 20 20 20 20 20 20 20 7d 20 ock... }
5ca0: 64 65 63 72 79 70 74 3b 0d 0a 20 20 20 20 7d 3b decrypt;.. };
5cb0: 0d 0a 7d 20 46 44 49 44 45 43 52 59 50 54 3b 20 ..} FDIDECRYPT;
5cc0: 2f 2a 20 66 64 69 64 20 2a 2f 0d 0a 74 79 70 65 /* fdid */..type
5cd0: 64 65 66 20 46 44 49 44 45 43 52 59 50 54 20 46 def FDIDECRYPT F
5ce0: 41 52 20 2a 50 46 44 49 44 45 43 52 59 50 54 3b AR *PFDIDECRYPT;
5cf0: 20 2f 2a 20 70 66 64 69 64 20 2a 2f 0d 0a 0d 0a /* pfdid */....
5d00: 0d 0a 2f 2a 2a 2a 20 20 20 20 46 4e 41 4c 4c 4f ../*** FNALLO
5d10: 43 20 2d 20 4d 65 6d 6f 72 79 20 41 6c 6c 6f 63 C - Memory Alloc
5d20: 61 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 46 ation.. * F
5d30: 4e 46 52 45 45 20 20 2d 20 4d 65 6d 6f 72 79 20 NFREE - Memory
5d40: 46 72 65 65 0d 0a 20 2a 0d 0a 20 2a 20 20 54 68 Free.. *.. * Th
5d50: 65 73 65 20 61 72 65 20 6d 6f 64 65 6c 65 64 20 ese are modeled
5d60: 61 66 74 65 72 20 74 68 65 20 43 20 72 75 6e 2d after the C run-
5d70: 74 69 6d 65 20 72 6f 75 74 69 6e 65 73 20 6d 61 time routines ma
5d80: 6c 6c 6f 63 28 29 20 61 6e 64 20 66 72 65 65 28 lloc() and free(
5d90: 29 0d 0a 20 2a 20 20 46 44 49 20 65 78 70 65 63 ).. * FDI expec
5da0: 74 73 20 65 72 72 6f 72 20 68 61 6e 64 6c 69 6e ts error handlin
5db0: 67 20 74 6f 20 62 65 20 69 64 65 6e 74 69 63 61 g to be identica
5dc0: 6c 20 74 6f 20 74 68 65 73 65 20 43 20 72 75 6e l to these C run
5dd0: 2d 74 69 6d 65 20 72 6f 75 74 69 6e 65 73 2e 0d -time routines..
5de0: 0a 20 2a 0d 0a 20 2a 20 20 41 73 20 6c 6f 6e 67 . *.. * As long
5df0: 20 61 73 20 79 6f 75 20 66 61 69 74 68 66 75 6c as you faithful
5e00: 6c 79 20 63 6f 70 79 20 74 68 65 20 73 65 6d 61 ly copy the sema
5e10: 6e 74 69 63 73 20 6f 66 20 6d 61 6c 6c 6f 63 28 ntics of malloc(
5e20: 29 20 61 6e 64 20 66 72 65 65 28 29 2c 0d 0a 20 ) and free(),..
5e30: 2a 20 20 79 6f 75 20 63 61 6e 20 73 75 70 70 6c * you can suppl
5e40: 79 20 61 6e 79 20 66 75 6e 63 74 69 6f 6e 73 20 y any functions
5e50: 79 6f 75 20 6c 69 6b 65 21 0d 0a 20 2a 0d 0a 20 you like!.. *..
5e60: 2a 20 20 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 * WARNING: You
5e70: 73 68 6f 75 6c 64 20 6e 65 76 65 72 20 61 73 73 should never ass
5e80: 75 6d 65 20 61 6e 79 74 68 69 6e 67 20 61 62 6f ume anything abo
5e90: 75 74 20 74 68 65 20 73 65 71 75 65 6e 63 65 20 ut the sequence
5ea0: 6f 66 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 of.. *
5eb0: 20 50 46 4e 41 4c 4c 4f 43 20 61 6e 64 20 50 46 PFNALLOC and PF
5ec0: 4e 46 52 45 45 20 63 61 6c 6c 73 20 2d 2d 20 69 NFREE calls -- i
5ed0: 6e 63 72 65 6d 65 6e 74 61 6c 20 72 65 6c 65 61 ncremental relea
5ee0: 73 65 73 20 6f 66 0d 0a 20 2a 20 20 20 20 20 20 ses of.. *
5ef0: 20 20 20 20 20 46 44 49 20 6d 61 79 20 68 61 76 FDI may hav
5f00: 65 20 72 61 64 69 63 61 6c 6c 79 20 64 69 66 66 e radically diff
5f10: 65 72 65 6e 74 20 6e 75 6d 62 65 72 73 20 6f 66 erent numbers of
5f20: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 50 .. * P
5f30: 46 4e 41 4c 4c 4f 43 20 63 61 6c 6c 73 20 61 6e FNALLOC calls an
5f40: 64 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 73 69 7a d allocation siz
5f50: 65 73 21 0d 0a 20 2a 2f 0d 0a 2f 2f 2a 2a 20 4d es!.. */..//** M
5f60: 65 6d 6f 72 79 20 66 75 6e 63 74 69 6f 6e 73 20 emory functions
5f70: 66 6f 72 20 46 44 49 0d 0a 74 79 70 65 64 65 66 for FDI..typedef
5f80: 20 76 6f 69 64 20 48 55 47 45 20 2a 20 28 46 41 void HUGE * (FA
5f90: 52 20 44 49 41 4d 4f 4e 44 41 50 49 20 2a 50 46 R DIAMONDAPI *PF
5fa0: 4e 41 4c 4c 4f 43 29 28 55 4c 4f 4e 47 20 63 62 NALLOC)(ULONG cb
5fb0: 29 3b 20 2f 2a 20 70 66 6e 61 20 2a 2f 0d 0a 23 ); /* pfna */..#
5fc0: 64 65 66 69 6e 65 20 46 4e 41 4c 4c 4f 43 28 66 define FNALLOC(f
5fd0: 6e 29 20 76 6f 69 64 20 48 55 47 45 20 2a 20 46 n) void HUGE * F
5fe0: 41 52 20 44 49 41 4d 4f 4e 44 41 50 49 20 66 6e AR DIAMONDAPI fn
5ff0: 28 55 4c 4f 4e 47 20 63 62 29 0d 0a 0d 0a 74 79 (ULONG cb)....ty
6000: 70 65 64 65 66 20 76 6f 69 64 20 28 46 41 52 20 pedef void (FAR
6010: 44 49 41 4d 4f 4e 44 41 50 49 20 2a 50 46 4e 46 DIAMONDAPI *PFNF
6020: 52 45 45 29 28 76 6f 69 64 20 48 55 47 45 20 2a REE)(void HUGE *
6030: 70 76 29 3b 20 2f 2a 20 70 66 6e 66 20 2a 2f 0d pv); /* pfnf */.
6040: 0a 23 64 65 66 69 6e 65 20 46 4e 46 52 45 45 28 .#define FNFREE(
6050: 66 6e 29 20 76 6f 69 64 20 46 41 52 20 44 49 41 fn) void FAR DIA
6060: 4d 4f 4e 44 41 50 49 20 66 6e 28 76 6f 69 64 20 MONDAPI fn(void
6070: 48 55 47 45 20 2a 70 76 29 0d 0a 0d 0a 0d 0a 2f HUGE *pv)....../
6080: 2a 2a 2a 20 20 20 20 50 46 4e 4f 50 45 4e 20 20 *** PFNOPEN
6090: 2d 20 46 69 6c 65 20 49 2f 4f 20 63 61 6c 6c 62 - File I/O callb
60a0: 61 63 6b 73 20 66 6f 72 20 46 44 49 0d 0a 20 2a acks for FDI.. *
60b0: 20 20 20 20 20 20 50 46 4e 52 45 41 44 0d 0a 20 PFNREAD..
60c0: 2a 20 20 20 20 20 20 50 46 4e 57 52 49 54 45 0d * PFNWRITE.
60d0: 0a 20 2a 20 20 20 20 20 20 50 46 4e 43 4c 4f 53 . * PFNCLOS
60e0: 45 0d 0a 20 2a 20 20 20 20 20 20 50 46 4e 53 45 E.. * PFNSE
60f0: 45 4b 0d 0a 20 2a 0d 0a 20 2a 20 20 54 68 65 73 EK.. *.. * Thes
6100: 65 20 61 72 65 20 6d 6f 64 65 6c 65 64 20 61 66 e are modeled af
6110: 74 65 72 20 74 68 65 20 43 20 72 75 6e 2d 74 69 ter the C run-ti
6120: 6d 65 20 72 6f 75 74 69 6e 65 73 20 5f 6f 70 65 me routines _ope
6130: 6e 2c 20 5f 72 65 61 64 2c 0d 0a 20 2a 20 20 5f n, _read,.. * _
6140: 77 72 69 74 65 2c 20 5f 63 6c 6f 73 65 2c 20 61 write, _close, a
6150: 6e 64 20 5f 6c 73 65 65 6b 2e 20 20 54 68 65 20 nd _lseek. The
6160: 76 61 6c 75 65 73 20 66 6f 72 20 74 68 65 20 50 values for the P
6170: 46 4e 4f 50 45 4e 20 6f 66 6c 61 67 0d 0a 20 2a FNOPEN oflag.. *
6180: 20 20 61 6e 64 20 70 6d 6f 64 65 20 63 61 6c 6c and pmode call
6190: 73 20 61 72 65 20 74 68 6f 73 65 20 64 65 66 69 s are those defi
61a0: 6e 65 64 20 66 6f 72 20 5f 6f 70 65 6e 2e 20 20 ned for _open.
61b0: 46 44 49 20 65 78 70 65 63 74 73 20 65 72 72 6f FDI expects erro
61c0: 72 0d 0a 20 2a 20 20 68 61 6e 64 6c 69 6e 67 20 r.. * handling
61d0: 74 6f 20 62 65 20 69 64 65 6e 74 69 63 61 6c 20 to be identical
61e0: 74 6f 20 74 68 65 73 65 20 43 20 72 75 6e 2d 74 to these C run-t
61f0: 69 6d 65 20 72 6f 75 74 69 6e 65 73 2e 0d 0a 20 ime routines...
6200: 2a 0d 0a 20 2a 20 20 41 73 20 6c 6f 6e 67 20 61 *.. * As long a
6210: 73 20 79 6f 75 20 66 61 69 74 68 66 75 6c 6c 79 s you faithfully
6220: 20 63 6f 70 79 20 74 68 65 73 65 20 61 73 70 65 copy these aspe
6230: 63 74 73 2c 20 79 6f 75 20 63 61 6e 20 73 75 70 cts, you can sup
6240: 70 6c 79 0d 0a 20 2a 20 20 61 6e 79 20 66 75 6e ply.. * any fun
6250: 63 74 69 6f 6e 73 20 79 6f 75 20 6c 69 6b 65 21 ctions you like!
6260: 0d 0a 20 2a 0d 0a 20 2a 20 20 57 41 52 4e 49 4e .. *.. * WARNIN
6270: 47 3a 20 59 6f 75 20 73 68 6f 75 6c 64 20 6e 65 G: You should ne
6280: 76 65 72 20 61 73 73 75 6d 65 20 79 6f 75 20 6b ver assume you k
6290: 6e 6f 77 20 77 68 61 74 20 66 69 6c 65 20 69 73 now what file is
62a0: 20 62 65 69 6e 67 0d 0a 20 2a 20 20 20 20 20 20 being.. *
62b0: 20 20 20 20 20 6f 70 65 6e 65 64 20 61 74 20 61 opened at a
62c0: 6e 79 20 6f 6e 65 20 70 6f 69 6e 74 20 69 6e 20 ny one point in
62d0: 74 69 6d 65 21 20 20 46 44 49 20 77 69 6c 6c 20 time! FDI will
62e0: 75 73 75 61 6c 6c 79 0d 0a 20 2a 20 20 20 20 20 usually.. *
62f0: 20 20 20 20 20 20 73 74 69 63 6b 20 74 6f 20 6f stick to o
6300: 70 65 6e 69 6e 67 20 63 61 62 69 6e 65 74 20 66 pening cabinet f
6310: 69 6c 65 73 2c 20 62 75 74 20 69 74 20 69 73 20 iles, but it is
6320: 70 6f 73 73 69 62 6c 65 0d 0a 20 2a 20 20 20 20 possible.. *
6330: 20 20 20 20 20 20 20 74 68 61 74 20 69 6e 20 61 that in a
6340: 20 66 75 74 75 72 65 20 69 6d 70 6c 65 6d 65 6e future implemen
6350: 74 61 74 69 6f 6e 20 69 74 20 6d 61 79 20 6f 70 tation it may op
6360: 65 6e 20 74 65 6d 70 6f 72 61 72 79 0d 0a 20 2a en temporary.. *
6370: 20 20 20 20 20 20 20 20 20 20 20 66 69 6c 65 73 files
6380: 20 6f 72 20 6f 70 65 6e 20 63 61 62 69 6e 65 74 or open cabinet
6390: 20 66 69 6c 65 73 20 69 6e 20 61 20 64 69 66 66 files in a diff
63a0: 65 72 65 6e 74 20 6f 72 64 65 72 2e 0d 0a 20 2a erent order... *
63b0: 0d 0a 20 2a 20 20 4e 6f 74 65 73 20 66 6f 72 20 .. * Notes for
63c0: 4d 65 6d 6f 72 79 20 4d 61 70 70 65 64 20 46 69 Memory Mapped Fi
63d0: 6c 65 20 66 61 6e 73 3a 0d 0a 20 2a 20 20 20 20 le fans:.. *
63e0: 20 20 59 6f 75 20 63 61 6e 20 77 72 69 74 65 20 You can write
63f0: 77 72 61 70 70 65 72 20 72 6f 75 74 69 6e 65 73 wrapper routines
6400: 20 74 6f 20 61 6c 6c 6f 77 20 46 44 49 20 74 6f to allow FDI to
6410: 20 77 6f 72 6b 20 6f 6e 20 6d 65 6d 6f 72 79 0d work on memory.
6420: 0a 20 2a 20 20 20 20 20 20 6d 61 70 70 65 64 20 . * mapped
6430: 66 69 6c 65 73 2e 20 20 59 6f 75 27 6c 6c 20 68 files. You'll h
6440: 61 76 65 20 74 6f 20 63 72 65 61 74 65 20 79 6f ave to create yo
6450: 75 72 20 6f 77 6e 20 22 68 61 6e 64 6c 65 22 20 ur own "handle"
6460: 74 79 70 65 20 73 6f 20 74 68 61 74 0d 0a 20 2a type so that.. *
6470: 20 20 20 20 20 20 79 6f 75 20 63 61 6e 20 73 74 you can st
6480: 6f 72 65 20 74 68 65 20 62 61 73 65 20 6d 65 6d ore the base mem
6490: 6f 72 79 20 61 64 64 72 65 73 73 20 6f 66 20 74 ory address of t
64a0: 68 65 20 66 69 6c 65 20 61 6e 64 20 74 68 65 20 he file and the
64b0: 63 75 72 72 65 6e 74 0d 0a 20 2a 20 20 20 20 20 current.. *
64c0: 20 73 65 65 6b 20 70 6f 73 69 74 69 6f 6e 2c 20 seek position,
64d0: 61 6e 64 20 74 68 65 6e 20 79 6f 75 27 6c 6c 20 and then you'll
64e0: 61 6c 6c 6f 63 61 74 65 20 61 6e 64 20 66 69 6c allocate and fil
64f0: 6c 20 69 6e 20 6f 6e 65 20 6f 66 20 74 68 65 73 l in one of thes
6500: 65 0d 0a 20 2a 20 20 20 20 20 20 73 74 72 75 63 e.. * struc
6510: 74 75 72 65 73 20 61 6e 64 20 72 65 74 75 72 6e tures and return
6520: 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 69 74 a pointer to it
6530: 20 69 6e 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 in response to
6540: 74 68 65 20 50 46 4e 4f 50 45 4e 0d 0a 20 2a 20 the PFNOPEN.. *
6550: 20 20 20 20 20 63 61 6c 6c 20 61 6e 64 20 74 68 call and th
6560: 65 20 66 64 69 6e 74 43 4f 50 59 5f 46 49 4c 45 e fdintCOPY_FILE
6570: 20 63 61 6c 6c 2e 20 20 59 6f 75 72 20 50 46 4e call. Your PFN
6580: 52 45 41 44 20 61 6e 64 20 50 46 4e 57 52 49 54 READ and PFNWRIT
6590: 45 0d 0a 20 2a 20 20 20 20 20 20 66 75 6e 63 74 E.. * funct
65a0: 69 6f 6e 73 20 77 69 6c 6c 20 64 6f 20 6d 65 6d ions will do mem
65b0: 63 6f 70 79 28 29 2c 20 61 6e 64 20 75 70 64 61 copy(), and upda
65c0: 74 65 20 74 68 65 20 73 65 65 6b 20 70 6f 73 69 te the seek posi
65d0: 74 69 6f 6e 20 69 6e 20 79 6f 75 72 0d 0a 20 2a tion in your.. *
65e0: 20 20 20 20 20 20 22 68 61 6e 64 6c 65 22 20 73 "handle" s
65f0: 74 72 75 63 74 75 72 65 2e 20 20 50 46 4e 53 45 tructure. PFNSE
6600: 45 4b 20 77 69 6c 6c 20 6a 75 73 74 20 63 68 61 EK will just cha
6610: 6e 67 65 20 74 68 65 20 73 65 65 6b 20 70 6f 73 nge the seek pos
6620: 69 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 69 ition.. * i
6630: 6e 20 79 6f 75 72 20 22 68 61 6e 64 6c 65 22 20 n your "handle"
6640: 73 74 72 75 63 74 75 72 65 2e 0d 0a 20 2a 2f 0d structure... */.
6650: 0a 2f 2f 2a 2a 20 46 69 6c 65 20 49 2f 4f 20 66 .//** File I/O f
6660: 75 6e 63 74 69 6f 6e 73 20 66 6f 72 20 46 44 49 unctions for FDI
6670: 0d 0a 74 79 70 65 64 65 66 20 69 6e 74 20 20 28 ..typedef int (
6680: 46 41 52 20 44 49 41 4d 4f 4e 44 41 50 49 20 2a FAR DIAMONDAPI *
6690: 50 46 4e 4f 50 45 4e 29 20 28 63 68 61 72 20 46 PFNOPEN) (char F
66a0: 41 52 20 2a 70 73 7a 46 69 6c 65 2c 20 69 6e 74 AR *pszFile, int
66b0: 20 6f 66 6c 61 67 2c 20 69 6e 74 20 70 6d 6f 64 oflag, int pmod
66c0: 65 29 3b 0d 0a 74 79 70 65 64 65 66 20 55 49 4e e);..typedef UIN
66d0: 54 20 28 46 41 52 20 44 49 41 4d 4f 4e 44 41 50 T (FAR DIAMONDAP
66e0: 49 20 2a 50 46 4e 52 45 41 44 29 20 28 69 6e 74 I *PFNREAD) (int
66f0: 20 68 66 2c 20 76 6f 69 64 20 46 41 52 20 2a 70 hf, void FAR *p
6700: 76 2c 20 55 49 4e 54 20 63 62 29 3b 0d 0a 74 79 v, UINT cb);..ty
6710: 70 65 64 65 66 20 55 49 4e 54 20 28 46 41 52 20 pedef UINT (FAR
6720: 44 49 41 4d 4f 4e 44 41 50 49 20 2a 50 46 4e 57 DIAMONDAPI *PFNW
6730: 52 49 54 45 29 28 69 6e 74 20 68 66 2c 20 76 6f RITE)(int hf, vo
6740: 69 64 20 46 41 52 20 2a 70 76 2c 20 55 49 4e 54 id FAR *pv, UINT
6750: 20 63 62 29 3b 0d 0a 74 79 70 65 64 65 66 20 69 cb);..typedef i
6760: 6e 74 20 20 28 46 41 52 20 44 49 41 4d 4f 4e 44 nt (FAR DIAMOND
6770: 41 50 49 20 2a 50 46 4e 43 4c 4f 53 45 29 28 69 API *PFNCLOSE)(i
6780: 6e 74 20 68 66 29 3b 0d 0a 74 79 70 65 64 65 66 nt hf);..typedef
6790: 20 6c 6f 6e 67 20 28 46 41 52 20 44 49 41 4d 4f long (FAR DIAMO
67a0: 4e 44 41 50 49 20 2a 50 46 4e 53 45 45 4b 29 20 NDAPI *PFNSEEK)
67b0: 28 69 6e 74 20 68 66 2c 20 6c 6f 6e 67 20 64 69 (int hf, long di
67c0: 73 74 2c 20 69 6e 74 20 73 65 65 6b 74 79 70 65 st, int seektype
67d0: 29 3b 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 46 4e );....#define FN
67e0: 4f 50 45 4e 28 66 6e 29 20 69 6e 74 20 46 41 52 OPEN(fn) int FAR
67f0: 20 44 49 41 4d 4f 4e 44 41 50 49 20 66 6e 28 63 DIAMONDAPI fn(c
6800: 68 61 72 20 46 41 52 20 2a 70 73 7a 46 69 6c 65 har FAR *pszFile
6810: 2c 20 69 6e 74 20 6f 66 6c 61 67 2c 20 69 6e 74 , int oflag, int
6820: 20 70 6d 6f 64 65 29 0d 0a 23 64 65 66 69 6e 65 pmode)..#define
6830: 20 46 4e 52 45 41 44 28 66 6e 29 20 55 49 4e 54 FNREAD(fn) UINT
6840: 20 46 41 52 20 44 49 41 4d 4f 4e 44 41 50 49 20 FAR DIAMONDAPI
6850: 66 6e 28 69 6e 74 20 68 66 2c 20 76 6f 69 64 20 fn(int hf, void
6860: 46 41 52 20 2a 70 76 2c 20 55 49 4e 54 20 63 62 FAR *pv, UINT cb
6870: 29 0d 0a 23 64 65 66 69 6e 65 20 46 4e 57 52 49 )..#define FNWRI
6880: 54 45 28 66 6e 29 20 55 49 4e 54 20 46 41 52 20 TE(fn) UINT FAR
6890: 44 49 41 4d 4f 4e 44 41 50 49 20 66 6e 28 69 6e DIAMONDAPI fn(in
68a0: 74 20 68 66 2c 20 76 6f 69 64 20 46 41 52 20 2a t hf, void FAR *
68b0: 70 76 2c 20 55 49 4e 54 20 63 62 29 0d 0a 23 64 pv, UINT cb)..#d
68c0: 65 66 69 6e 65 20 46 4e 43 4c 4f 53 45 28 66 6e efine FNCLOSE(fn
68d0: 29 20 69 6e 74 20 46 41 52 20 44 49 41 4d 4f 4e ) int FAR DIAMON
68e0: 44 41 50 49 20 66 6e 28 69 6e 74 20 68 66 29 0d DAPI fn(int hf).
68f0: 0a 23 64 65 66 69 6e 65 20 46 4e 53 45 45 4b 28 .#define FNSEEK(
6900: 66 6e 29 20 6c 6f 6e 67 20 46 41 52 20 44 49 41 fn) long FAR DIA
6910: 4d 4f 4e 44 41 50 49 20 66 6e 28 69 6e 74 20 68 MONDAPI fn(int h
6920: 66 2c 20 6c 6f 6e 67 20 64 69 73 74 2c 20 69 6e f, long dist, in
6930: 74 20 73 65 65 6b 74 79 70 65 29 0d 0a 0d 0a 0d t seektype).....
6940: 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 50 46 4e 46 44 .../*** PFNFD
6950: 49 44 45 43 52 59 50 54 20 2d 20 46 44 49 20 44 IDECRYPT - FDI D
6960: 65 63 72 79 70 74 69 6f 6e 20 63 61 6c 6c 62 61 ecryption callba
6970: 63 6b 0d 0a 20 2a 0d 0a 20 2a 20 20 49 66 20 74 ck.. *.. * If t
6980: 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 his function is
6990: 70 61 73 73 65 64 20 6f 6e 20 74 68 65 20 46 44 passed on the FD
69a0: 49 43 6f 70 79 28 29 20 63 61 6c 6c 2c 20 74 68 ICopy() call, th
69b0: 65 6e 20 46 44 49 20 63 61 6c 6c 73 20 69 74 0d en FDI calls it.
69c0: 0a 20 2a 20 20 61 74 20 76 61 72 69 6f 75 73 20 . * at various
69d0: 74 69 6d 65 73 20 74 6f 20 75 70 64 61 74 65 20 times to update
69e0: 74 68 65 20 64 65 63 72 79 70 74 69 6f 6e 20 73 the decryption s
69f0: 74 61 74 65 20 61 6e 64 20 74 6f 20 64 65 63 72 tate and to decr
6a00: 79 70 74 20 46 43 44 41 54 41 0d 0a 20 2a 20 20 ypt FCDATA.. *
6a10: 62 6c 6f 63 6b 73 2e 0d 0a 20 2a 0d 0a 20 2a 20 blocks... *.. *
6a20: 20 43 6f 6d 6d 6f 6e 20 45 6e 74 72 79 20 43 6f Common Entry Co
6a30: 6e 64 69 74 69 6f 6e 73 3a 0d 0a 20 2a 20 20 20 nditions:.. *
6a40: 20 20 20 70 66 64 69 64 2d 3e 66 64 69 64 74 20 pfdid->fdidt
6a50: 20 2d 20 43 6f 6d 6d 61 6e 64 20 74 79 70 65 0d - Command type.
6a60: 0a 20 2a 20 20 20 20 20 20 70 66 64 69 64 2d 3e . * pfdid->
6a70: 70 76 55 73 65 72 20 2d 20 70 76 55 73 65 72 20 pvUser - pvUser
6a80: 76 61 6c 75 65 20 66 72 6f 6d 20 46 44 49 43 6f value from FDICo
6a90: 70 79 28 29 20 63 61 6c 6c 0d 0a 20 2a 0d 0a 20 py() call.. *..
6aa0: 2a 20 20 66 64 69 64 74 4e 45 57 5f 43 41 42 49 * fdidtNEW_CABI
6ab0: 4e 45 54 3a 20 20 20 2f 2f 2a 2a 20 4e 6f 74 69 NET: //** Noti
6ac0: 66 69 63 61 74 69 6f 6e 20 6f 66 20 61 20 6e 65 fication of a ne
6ad0: 77 20 63 61 62 69 6e 65 74 0d 0a 20 2a 20 20 20 w cabinet.. *
6ae0: 20 20 20 45 6e 74 72 79 3a 0d 0a 20 2a 20 20 20 Entry:.. *
6af0: 20 20 20 20 20 70 66 64 69 64 2d 3e 63 61 62 69 pfdid->cabi
6b00: 6e 65 74 2e 0d 0a 20 2a 20 20 20 20 20 20 20 20 net... *
6b10: 20 20 70 48 65 61 64 65 72 52 65 73 65 72 76 65 pHeaderReserve
6b20: 20 20 2d 20 52 45 53 45 52 56 45 20 73 65 63 74 - RESERVE sect
6b30: 69 6f 6e 20 66 72 6f 6d 20 43 46 48 45 41 44 45 ion from CFHEADE
6b40: 52 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 63 R.. * c
6b50: 62 48 65 61 64 65 72 52 65 73 65 72 76 65 20 2d bHeaderReserve -
6b60: 20 53 69 7a 65 20 6f 66 20 70 48 65 61 64 65 72 Size of pHeader
6b70: 52 65 73 65 72 76 65 0d 0a 20 2a 20 20 20 20 20 Reserve.. *
6b80: 20 20 20 20 20 73 65 74 49 44 20 20 20 20 20 20 setID
6b90: 20 20 20 20 20 2d 20 43 61 62 69 6e 65 74 20 73 - Cabinet s
6ba0: 65 74 20 49 44 0d 0a 20 2a 20 20 20 20 20 20 20 et ID.. *
6bb0: 20 20 20 69 43 61 62 69 6e 65 74 20 20 20 20 20 iCabinet
6bc0: 20 20 20 2d 20 43 61 62 69 6e 65 74 20 6e 75 6d - Cabinet num
6bd0: 62 65 72 20 69 6e 20 73 65 74 20 28 30 20 62 61 ber in set (0 ba
6be0: 73 65 64 29 0d 0a 20 2a 20 20 20 20 20 20 45 78 sed).. * Ex
6bf0: 69 74 2d 53 75 63 63 65 73 73 3a 0d 0a 20 2a 20 it-Success:.. *
6c00: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 73 returns
6c10: 20 61 6e 79 74 68 69 6e 67 20 62 75 74 20 2d 31 anything but -1
6c20: 3b 0d 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d ;.. * Exit-
6c30: 46 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 Failure:.. *
6c40: 20 20 20 20 20 20 72 65 74 75 72 6e 73 20 2d 31 returns -1
6c50: 3b 20 46 44 49 43 6f 70 79 28 29 20 69 73 20 61 ; FDICopy() is a
6c60: 62 6f 72 74 65 64 2e 0d 0a 20 2a 20 20 20 20 20 borted... *
6c70: 20 4e 6f 74 65 73 3a 0d 0a 20 2a 20 20 20 20 20 Notes:.. *
6c80: 20 28 31 29 20 54 68 69 73 20 63 61 6c 6c 20 61 (1) This call a
6c90: 6c 6c 6f 77 73 20 74 68 65 20 64 65 63 72 79 70 llows the decryp
6ca0: 74 69 6f 6e 20 63 6f 64 65 20 74 6f 20 70 69 63 tion code to pic
6cb0: 6b 20 6f 75 74 20 61 6e 79 20 69 6e 66 6f 72 6d k out any inform
6cc0: 61 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 20 ation.. *
6cd0: 20 20 20 66 72 6f 6d 20 74 68 65 20 63 61 62 69 from the cabi
6ce0: 6e 65 74 20 68 65 61 64 65 72 20 72 65 73 65 72 net header reser
6cf0: 76 65 64 20 61 72 65 61 20 28 70 6c 61 63 65 64 ved area (placed
6d00: 20 74 68 65 72 65 20 62 79 20 44 49 41 43 52 59 there by DIACRY
6d10: 50 54 29 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 PT).. *
6d20: 20 6e 65 65 64 65 64 20 74 6f 20 70 65 72 66 6f needed to perfo
6d30: 72 6d 20 64 65 63 72 79 70 74 69 6f 6e 2e 20 20 rm decryption.
6d40: 49 66 20 74 68 65 72 65 20 69 73 20 6e 6f 20 73 If there is no s
6d50: 75 63 68 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c uch information,
6d60: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 74 68 .. * th
6d70: 69 73 20 63 61 6c 6c 20 77 6f 75 6c 64 20 70 72 is call would pr
6d80: 65 73 75 6d 61 62 6c 79 20 62 65 20 69 67 6e 6f esumably be igno
6d90: 72 65 64 2e 0d 0a 20 2a 20 20 20 20 20 20 28 32 red... * (2
6da0: 29 20 54 68 69 73 20 63 61 6c 6c 20 69 73 20 6d ) This call is m
6db0: 61 64 65 20 76 65 72 79 20 73 6f 6f 6e 20 61 66 ade very soon af
6dc0: 74 65 72 20 66 64 69 6e 74 43 41 42 49 4e 45 54 ter fdintCABINET
6dd0: 5f 49 4e 46 4f 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 _INFO... *.. *
6de0: 66 64 69 64 74 4e 45 57 5f 46 4f 4c 44 45 52 3a fdidtNEW_FOLDER:
6df0: 20 20 20 20 2f 2f 2a 2a 20 4e 6f 74 69 66 69 63 //** Notific
6e00: 61 74 69 6f 6e 20 6f 66 20 61 20 6e 65 77 20 66 ation of a new f
6e10: 6f 6c 64 65 72 0d 0a 20 2a 20 20 20 20 20 20 45 older.. * E
6e20: 6e 74 72 79 3a 0d 0a 20 2a 20 20 20 20 20 20 20 ntry:.. *
6e30: 20 70 66 64 69 64 2d 3e 66 6f 6c 64 65 72 2e 0d pfdid->folder..
6e40: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 46 6f . * pFo
6e50: 6c 64 65 72 52 65 73 65 72 76 65 20 20 2d 20 52 lderReserve - R
6e60: 45 53 45 52 56 45 20 73 65 63 74 69 6f 6e 20 66 ESERVE section f
6e70: 72 6f 6d 20 43 46 46 4f 4c 44 45 52 0d 0a 20 2a rom CFFOLDER.. *
6e80: 20 20 20 20 20 20 20 20 20 20 63 62 46 6f 6c 64 cbFold
6e90: 65 72 52 65 73 65 72 76 65 20 2d 20 53 69 7a 65 erReserve - Size
6ea0: 20 6f 66 20 70 46 6f 6c 64 65 72 52 65 73 65 72 of pFolderReser
6eb0: 76 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 ve.. *
6ec0: 69 46 6f 6c 64 65 72 20 20 20 20 20 20 20 20 20 iFolder
6ed0: 2d 20 46 6f 6c 64 65 72 20 6e 75 6d 62 65 72 20 - Folder number
6ee0: 69 6e 20 63 61 62 69 6e 65 74 20 28 30 20 62 61 in cabinet (0 ba
6ef0: 73 65 64 29 0d 0a 20 2a 20 20 20 20 20 20 45 78 sed).. * Ex
6f00: 69 74 2d 53 75 63 63 65 73 73 3a 0d 0a 20 2a 20 it-Success:.. *
6f10: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 73 returns
6f20: 20 61 6e 79 74 68 69 6e 67 20 62 75 74 20 2d 31 anything but -1
6f30: 3b 0d 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d ;.. * Exit-
6f40: 46 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 Failure:.. *
6f50: 20 20 20 20 20 20 72 65 74 75 72 6e 73 20 2d 31 returns -1
6f60: 3b 20 46 44 49 43 6f 70 79 28 29 20 69 73 20 61 ; FDICopy() is a
6f70: 62 6f 72 74 65 64 2e 0d 0a 20 2a 20 20 20 20 20 borted... *
6f80: 20 4e 6f 74 65 73 3a 0d 0a 20 2a 20 20 20 20 20 Notes:.. *
6f90: 20 20 20 20 20 54 68 69 73 20 63 61 6c 6c 20 61 This call a
6fa0: 6c 6c 6f 77 73 20 74 68 65 20 64 65 63 72 79 70 llows the decryp
6fb0: 74 69 6f 6e 20 63 6f 64 65 20 74 6f 20 70 69 63 tion code to pic
6fc0: 6b 20 6f 75 74 20 61 6e 79 20 69 6e 66 6f 72 6d k out any inform
6fd0: 61 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 20 ation.. *
6fe0: 20 20 20 66 72 6f 6d 20 74 68 65 20 66 6f 6c 64 from the fold
6ff0: 65 72 20 72 65 73 65 72 76 65 64 20 61 72 65 61 er reserved area
7000: 20 28 70 6c 61 63 65 64 20 74 68 65 72 65 20 62 (placed there b
7010: 79 20 44 49 41 43 52 59 50 54 29 20 6e 65 65 64 y DIACRYPT) need
7020: 65 64 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 ed.. *
7030: 74 6f 20 70 65 72 66 6f 72 6d 20 64 65 63 72 79 to perform decry
7040: 70 74 69 6f 6e 2e 20 20 49 66 20 74 68 65 72 65 ption. If there
7050: 20 69 73 20 6e 6f 20 73 75 63 68 20 69 6e 66 6f is no such info
7060: 72 6d 61 74 69 6f 6e 2c 20 74 68 69 73 0d 0a 20 rmation, this..
7070: 2a 20 20 20 20 20 20 20 20 20 20 63 61 6c 6c 20 * call
7080: 77 6f 75 6c 64 20 70 72 65 73 75 6d 61 62 6c 79 would presumably
7090: 20 62 65 20 69 67 6e 6f 72 65 64 2e 0d 0a 20 2a be ignored... *
70a0: 0d 0a 20 2a 20 20 66 64 69 64 74 44 45 43 52 59 .. * fdidtDECRY
70b0: 50 54 3a 20 20 20 20 20 20 20 2f 2f 2a 2a 20 44 PT: //** D
70c0: 65 63 72 79 70 74 20 61 20 64 61 74 61 20 62 75 ecrypt a data bu
70d0: 66 66 65 72 0d 0a 20 2a 20 20 20 20 20 20 45 6e ffer.. * En
70e0: 74 72 79 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 try:.. *
70f0: 70 66 64 69 64 2d 3e 66 6f 6c 64 65 72 2e 0d 0a pfdid->folder...
7100: 20 2a 20 20 20 20 20 20 20 20 20 20 70 44 61 74 * pDat
7110: 61 52 65 73 65 72 76 65 20 20 2d 20 52 45 53 45 aReserve - RESE
7120: 52 56 45 20 73 65 63 74 69 6f 6e 20 66 6f 72 20 RVE section for
7130: 74 68 69 73 20 43 46 44 41 54 41 20 62 6c 6f 63 this CFDATA bloc
7140: 6b 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 63 k.. * c
7150: 62 44 61 74 61 52 65 73 65 72 76 65 20 2d 20 53 bDataReserve - S
7160: 69 7a 65 20 6f 66 20 70 44 61 74 61 52 65 73 65 ize of pDataRese
7170: 72 76 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 rve.. *
7180: 20 70 62 44 61 74 61 20 20 20 20 20 20 20 20 2d pbData -
7190: 20 44 61 74 61 20 62 75 66 66 65 72 0d 0a 20 2a Data buffer.. *
71a0: 20 20 20 20 20 20 20 20 20 20 63 62 44 61 74 61 cbData
71b0: 20 20 20 20 20 20 20 20 2d 20 53 69 7a 65 20 6f - Size o
71c0: 66 20 64 61 74 61 20 62 75 66 66 65 72 0d 0a 20 f data buffer..
71d0: 2a 20 20 20 20 20 20 20 20 20 20 66 53 70 6c 69 * fSpli
71e0: 74 20 20 20 20 20 20 20 20 2d 20 54 52 55 45 20 t - TRUE
71f0: 69 66 20 74 68 69 73 20 69 73 20 61 20 73 70 6c if this is a spl
7200: 69 74 20 64 61 74 61 20 62 6c 6f 63 6b 0d 0a 20 it data block..
7210: 2a 20 20 20 20 20 20 20 20 20 20 63 62 50 61 72 * cbPar
7220: 74 69 61 6c 20 20 20 20 20 2d 20 30 20 69 66 20 tial - 0 if
7230: 74 68 69 73 20 69 73 20 6e 6f 74 20 61 20 73 70 this is not a sp
7240: 6c 69 74 20 62 6c 6f 63 6b 2c 20 6f 72 20 74 68 lit block, or th
7250: 65 20 66 69 72 73 74 0d 0a 20 2a 20 20 20 20 20 e first.. *
7260: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7270: 20 20 20 20 20 20 20 20 20 70 69 65 63 65 20 6f piece o
7280: 66 20 61 20 73 70 6c 69 74 20 62 6c 6f 63 6b 3b f a split block;
7290: 20 47 72 65 61 74 65 72 20 74 68 61 6e 20 30 20 Greater than 0
72a0: 69 66 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 if.. *
72b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
72c0: 20 20 20 20 74 68 69 73 20 69 73 20 74 68 65 20 this is the
72d0: 73 65 63 6f 6e 64 20 70 69 65 63 65 20 6f 66 20 second piece of
72e0: 61 20 73 70 6c 69 74 20 62 6c 6f 63 6b 2e 0d 0a a split block...
72f0: 20 2a 20 20 20 20 20 20 45 78 69 74 2d 53 75 63 * Exit-Suc
7300: 63 65 73 73 3a 0d 0a 20 2a 20 20 20 20 20 20 20 cess:.. *
7310: 20 20 20 72 65 74 75 72 6e 73 20 54 52 55 45 3b returns TRUE;
7320: 0d 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d 46 .. * Exit-F
7330: 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 20 ailure:.. *
7340: 20 20 20 20 20 72 65 74 75 72 6e 73 20 46 41 4c returns FAL
7350: 53 45 3b 20 65 72 72 6f 72 20 64 75 72 69 6e 67 SE; error during
7360: 20 64 65 63 72 79 70 74 0d 0a 20 2a 20 20 20 20 decrypt.. *
7370: 20 20 20 20 20 20 72 65 74 75 72 6e 73 20 2d 31 returns -1
7380: 3b 20 46 44 49 43 6f 70 79 28 29 20 69 73 20 61 ; FDICopy() is a
7390: 62 6f 72 74 65 64 2e 0d 0a 20 2a 20 20 20 20 20 borted... *
73a0: 20 4e 6f 74 65 73 3a 0d 0a 20 2a 20 20 20 20 20 Notes:.. *
73b0: 20 20 20 20 20 46 43 49 20 77 69 6c 6c 20 73 70 FCI will sp
73c0: 6c 69 74 20 43 46 44 41 54 41 20 62 6c 6f 63 6b lit CFDATA block
73d0: 73 20 61 63 72 6f 73 73 20 63 61 62 69 6e 65 74 s across cabinet
73e0: 20 62 6f 75 6e 64 61 72 69 65 73 20 69 66 0d 0a boundaries if..
73f0: 20 2a 20 20 20 20 20 20 20 20 20 20 6e 65 63 65 * nece
7400: 73 73 61 72 79 2e 20 20 54 6f 20 70 72 6f 76 69 ssary. To provi
7410: 64 65 20 6d 61 78 69 6d 75 6d 20 66 6c 65 78 69 de maximum flexi
7420: 62 69 6c 69 74 79 2c 20 46 44 49 20 77 69 6c 6c bility, FDI will
7430: 20 63 61 6c 6c 20 74 68 65 0d 0a 20 2a 20 20 20 call the.. *
7440: 20 20 20 20 20 20 20 66 64 69 64 74 44 45 43 52 fdidtDECR
7450: 59 50 54 20 66 75 6e 63 74 69 6f 6e 20 74 77 69 YPT function twi
7460: 63 65 20 6f 6e 20 73 75 63 68 20 73 70 6c 69 74 ce on such split
7470: 20 62 6c 6f 63 6b 73 2c 20 6f 6e 63 65 20 77 68 blocks, once wh
7480: 65 6e 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 en.. *
7490: 74 68 65 20 66 69 72 73 74 20 70 6f 72 74 69 6f the first portio
74a0: 6e 20 69 73 20 72 65 61 64 2c 20 61 6e 64 20 61 n is read, and a
74b0: 67 61 69 6e 20 77 68 65 6e 20 74 68 65 20 73 65 gain when the se
74c0: 63 6f 6e 64 20 70 6f 72 74 69 6f 6e 0d 0a 20 2a cond portion.. *
74d0: 20 20 20 20 20 20 20 20 20 20 69 73 20 72 65 61 is rea
74e0: 64 2e 20 20 41 6e 64 2c 20 6f 66 20 63 6f 75 72 d. And, of cour
74f0: 73 65 2c 20 6d 6f 73 74 20 64 61 74 61 20 62 6c se, most data bl
7500: 6f 63 6b 73 20 77 69 6c 6c 20 6e 6f 74 20 62 65 ocks will not be
7510: 20 73 70 6c 69 74 2e 0d 0a 20 2a 20 20 20 20 20 split... *
7520: 20 20 20 20 20 53 6f 2c 20 74 68 65 72 65 20 61 So, there a
7530: 72 65 20 74 68 72 65 65 20 63 61 73 65 73 3a 0d re three cases:.
7540: 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 . *.. *
7550: 20 20 31 29 20 66 53 70 6c 69 74 20 3d 3d 20 46 1) fSplit == F
7560: 41 4c 53 45 0d 0a 20 2a 20 20 20 20 20 20 20 20 ALSE.. *
7570: 20 20 20 20 20 20 59 6f 75 20 68 61 76 65 20 74 You have t
7580: 68 65 20 65 6e 74 69 72 65 20 64 61 74 61 20 62 he entire data b
7590: 6c 6f 63 6b 2c 20 73 6f 20 64 65 63 72 79 70 74 lock, so decrypt
75a0: 20 69 74 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 it... *.. *
75b0: 20 20 20 20 20 20 20 32 29 20 66 53 70 6c 69 74 2) fSplit
75c0: 20 3d 3d 20 54 52 55 45 2c 20 63 62 50 61 72 74 == TRUE, cbPart
75d0: 69 61 6c 20 3d 3d 20 30 0d 0a 20 2a 20 20 20 20 ial == 0.. *
75e0: 20 20 20 20 20 20 20 20 20 20 54 68 69 73 20 69 This i
75f0: 73 20 74 68 65 20 66 69 72 73 74 20 70 6f 72 74 s the first port
7600: 69 6f 6e 20 6f 66 20 61 20 73 70 6c 69 74 20 64 ion of a split d
7610: 61 74 61 20 62 6c 6f 63 6b 2c 20 73 6f 20 63 62 ata block, so cb
7620: 44 61 74 61 0d 0a 20 2a 20 20 20 20 20 20 20 20 Data.. *
7630: 20 20 20 20 20 20 69 73 20 74 68 65 20 73 69 7a is the siz
7640: 65 20 6f 66 20 74 68 69 73 20 70 6f 72 74 69 6f e of this portio
7650: 6e 2e 20 20 59 6f 75 20 63 61 6e 20 65 69 74 68 n. You can eith
7660: 65 72 20 63 68 6f 6f 73 65 20 74 6f 20 64 65 63 er choose to dec
7670: 72 79 70 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 rypt.. *
7680: 20 20 20 20 20 20 74 68 69 73 20 70 69 65 63 65 this piece
7690: 2c 20 6f 72 20 69 67 6e 6f 72 65 20 74 68 69 73 , or ignore this
76a0: 20 63 61 6c 6c 20 61 6e 64 20 64 65 63 72 79 70 call and decryp
76b0: 74 20 74 68 65 20 66 75 6c 6c 20 43 46 44 41 54 t the full CFDAT
76c0: 41 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 A.. *
76d0: 20 20 20 62 6c 6f 63 6b 20 6f 6e 20 74 68 65 20 block on the
76e0: 6e 65 78 74 20 28 73 65 63 6f 6e 64 29 20 66 64 next (second) fd
76f0: 69 64 74 44 45 43 52 59 50 54 20 63 61 6c 6c 2e idtDECRYPT call.
7700: 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 20 20 .. *.. *
7710: 20 20 20 33 29 20 66 53 70 6c 69 74 20 3d 3d 20 3) fSplit ==
7720: 54 52 55 45 2c 20 63 62 50 61 72 74 69 61 6c 20 TRUE, cbPartial
7730: 3e 20 30 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 > 0.. *
7740: 20 20 20 20 20 54 68 69 73 20 69 73 20 74 68 65 This is the
7750: 20 73 65 63 6f 6e 64 20 70 6f 72 74 69 6f 6e 20 second portion
7760: 6f 66 20 61 20 73 70 6c 69 74 20 64 61 74 61 20 of a split data
7770: 62 6c 6f 63 6b 20 28 69 6e 64 65 65 64 2c 0d 0a block (indeed,..
7780: 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 *
7790: 63 62 50 61 72 74 69 61 6c 20 77 69 6c 6c 20 68 cbPartial will h
77a0: 61 76 65 20 74 68 65 20 73 61 6d 65 20 76 61 6c ave the same val
77b0: 75 65 20 61 73 20 63 62 44 61 74 61 20 64 69 64 ue as cbData did
77c0: 20 6f 6e 20 74 68 65 0d 0a 20 2a 20 20 20 20 20 on the.. *
77d0: 20 20 20 20 20 20 20 20 20 69 6d 6d 65 64 69 61 immedia
77e0: 74 65 6c 79 20 70 72 65 63 65 65 64 69 6e 67 20 tely preceeding
77f0: 66 64 69 64 74 44 45 43 52 59 50 54 20 63 61 6c fdidtDECRYPT cal
7800: 6c 21 29 2e 20 20 49 66 20 79 6f 75 20 64 65 63 l!). If you dec
7810: 72 79 70 74 65 64 0d 0a 20 2a 20 20 20 20 20 20 rypted.. *
7820: 20 20 20 20 20 20 20 20 74 68 65 20 66 69 72 73 the firs
7830: 74 20 70 6f 72 74 69 6f 6e 20 6f 6e 20 74 68 65 t portion on the
7840: 20 66 69 72 73 74 20 63 61 6c 6c 2c 20 74 68 65 first call, the
7850: 6e 20 79 6f 75 20 63 61 6e 20 64 65 63 72 79 70 n you can decryp
7860: 74 20 74 68 65 0d 0a 20 2a 20 20 20 20 20 20 20 t the.. *
7870: 20 20 20 20 20 20 20 73 65 63 6f 6e 64 20 70 6f second po
7880: 72 74 69 6f 6e 20 6e 6f 77 2e 20 20 49 66 20 79 rtion now. If y
7890: 6f 75 20 69 67 6e 6f 72 65 64 20 74 68 65 20 66 ou ignored the f
78a0: 69 72 73 74 20 63 61 6c 6c 2c 20 74 68 65 6e 20 irst call, then
78b0: 79 6f 75 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 you.. *
78c0: 20 20 20 20 20 63 61 6e 20 64 65 63 72 79 70 74 can decrypt
78d0: 20 74 68 65 20 65 6e 74 69 72 65 20 62 75 66 66 the entire buff
78e0: 65 72 2e 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 er... *
78f0: 20 20 20 20 20 4e 4f 54 45 3a 20 70 62 44 61 74 NOTE: pbDat
7900: 61 20 70 6f 69 6e 74 73 20 74 6f 20 74 68 65 20 a points to the
7910: 73 65 63 6f 6e 64 20 70 6f 72 74 69 6f 6e 20 6f second portion o
7920: 66 20 74 68 65 20 73 70 6c 69 74 20 64 61 74 61 f the split data
7930: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 .. *
7940: 20 20 20 20 20 20 20 20 62 6c 6f 63 6b 20 69 6e block in
7950: 20 74 68 69 73 20 63 61 73 65 2c 20 2a 6e 6f 74 this case, *not
7960: 2a 20 74 68 65 20 65 6e 74 69 72 65 20 64 61 74 * the entire dat
7970: 61 20 62 6c 6f 63 6b 2e 20 20 49 66 0d 0a 20 2a a block. If.. *
7980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7990: 20 20 20 20 79 6f 75 20 77 61 6e 74 20 74 6f 20 you want to
79a0: 77 61 69 74 20 75 6e 74 69 6c 20 74 68 65 20 73 wait until the s
79b0: 65 63 6f 6e 64 20 70 69 65 63 65 20 74 6f 20 64 econd piece to d
79c0: 65 63 72 79 70 74 20 74 68 65 0d 0a 20 2a 20 20 ecrypt the.. *
79d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
79e0: 20 20 2a 65 6e 74 69 72 65 2a 20 62 6c 6f 63 6b *entire* block
79f0: 2c 20 70 62 44 61 74 61 2d 63 62 50 61 72 74 69 , pbData-cbParti
7a00: 61 6c 20 69 73 20 74 68 65 20 61 64 64 72 65 73 al is the addres
7a10: 73 20 6f 66 20 74 68 65 0d 0a 20 2a 20 20 20 20 s of the.. *
7a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7a30: 73 74 61 72 74 20 6f 66 20 74 68 65 20 77 68 6f start of the who
7a40: 6c 65 20 62 6c 6f 63 6b 2c 20 61 6e 64 20 63 62 le block, and cb
7a50: 44 61 74 61 2b 63 62 50 61 72 74 69 61 6c 20 69 Data+cbPartial i
7a60: 73 20 69 74 73 0d 0a 20 2a 20 20 20 20 20 20 20 s its.. *
7a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 7a siz
7a80: 65 2e 0d 0a 20 2a 2f 0d 0a 74 79 70 65 64 65 66 e... */..typedef
7a90: 20 69 6e 74 20 28 46 41 52 20 44 49 41 4d 4f 4e int (FAR DIAMON
7aa0: 44 41 50 49 20 2a 50 46 4e 46 44 49 44 45 43 52 DAPI *PFNFDIDECR
7ab0: 59 50 54 29 28 50 46 44 49 44 45 43 52 59 50 54 YPT)(PFDIDECRYPT
7ac0: 20 70 66 64 69 64 29 3b 20 2f 2a 20 70 66 6e 66 pfdid); /* pfnf
7ad0: 64 69 64 20 2a 2f 0d 0a 23 64 65 66 69 6e 65 20 did */..#define
7ae0: 46 4e 46 44 49 44 45 43 52 59 50 54 28 66 6e 29 FNFDIDECRYPT(fn)
7af0: 20 69 6e 74 20 46 41 52 20 44 49 41 4d 4f 4e 44 int FAR DIAMOND
7b00: 41 50 49 20 66 6e 28 50 46 44 49 44 45 43 52 59 API fn(PFDIDECRY
7b10: 50 54 20 70 66 64 69 64 29 0d 0a 0d 0a 0d 0a 2f PT pfdid)....../
7b20: 2a 2a 2a 20 20 20 20 46 44 49 4e 4f 54 49 46 49 *** FDINOTIFI
7b30: 43 41 54 49 4f 4e 20 2d 20 4e 6f 74 69 66 69 63 CATION - Notific
7b40: 61 74 69 6f 6e 20 73 74 72 75 63 74 75 72 65 20 ation structure
7b50: 66 6f 72 20 50 46 4e 46 44 49 4e 4f 54 49 46 59 for PFNFDINOTIFY
7b60: 0d 0a 20 2a 0d 0a 20 2a 20 20 53 65 65 20 74 68 .. *.. * See th
7b70: 65 20 46 44 49 4e 4f 54 49 46 49 43 41 54 49 4f e FDINOTIFICATIO
7b80: 4e 54 59 50 45 20 64 65 66 69 6e 69 74 69 6f 6e NTYPE definition
7b90: 20 66 6f 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e for information
7ba0: 20 6f 6e 20 75 73 61 67 65 20 61 6e 64 0d 0a 20 on usage and..
7bb0: 2a 20 20 6d 65 61 6e 69 6e 67 20 6f 66 20 74 68 * meaning of th
7bc0: 65 73 65 20 66 69 65 6c 64 73 2e 0d 0a 20 2a 2f ese fields... */
7bd0: 0d 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 ..typedef struct
7be0: 20 7b 0d 0a 2f 2f 20 6c 6f 6e 67 20 66 69 65 6c {..// long fiel
7bf0: 64 73 0d 0a 20 20 20 20 6c 6f 6e 67 20 20 20 20 ds.. long
7c00: 20 20 63 62 3b 0d 0a 20 20 20 20 63 68 61 72 20 cb;.. char
7c10: 46 41 52 20 2a 70 73 7a 31 3b 0d 0a 20 20 20 20 FAR *psz1;..
7c20: 63 68 61 72 20 46 41 52 20 2a 70 73 7a 32 3b 0d char FAR *psz2;.
7c30: 0a 20 20 20 20 63 68 61 72 20 46 41 52 20 2a 70 . char FAR *p
7c40: 73 7a 33 3b 20 20 20 20 20 20 20 20 20 20 20 20 sz3;
7c50: 20 20 20 20 20 20 20 20 20 2f 2f 20 50 6f 69 6e // Poin
7c60: 74 73 20 74 6f 20 61 20 32 35 36 20 63 68 61 72 ts to a 256 char
7c70: 61 63 74 65 72 20 62 75 66 66 65 72 0d 0a 20 20 acter buffer..
7c80: 20 20 76 6f 69 64 20 46 41 52 20 2a 70 76 3b 20 void FAR *pv;
7c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7ca0: 20 20 20 20 20 20 2f 2f 20 56 61 6c 75 65 20 66 // Value f
7cb0: 6f 72 20 63 6c 69 65 6e 74 0d 0a 0d 0a 2f 2f 20 or client....//
7cc0: 69 6e 74 20 66 69 65 6c 64 73 0d 0a 20 20 20 20 int fields..
7cd0: 69 6e 74 20 20 20 20 20 20 20 68 66 3b 0d 0a 0d int hf;...
7ce0: 0a 2f 2f 20 73 68 6f 72 74 20 66 69 65 6c 64 73 .// short fields
7cf0: 0d 0a 20 20 20 20 55 53 48 4f 52 54 20 20 20 20 .. USHORT
7d00: 64 61 74 65 3b 0d 0a 20 20 20 20 55 53 48 4f 52 date;.. USHOR
7d10: 54 20 20 20 20 74 69 6d 65 3b 0d 0a 20 20 20 20 T time;..
7d20: 55 53 48 4f 52 54 20 20 20 20 61 74 74 72 69 62 USHORT attrib
7d30: 73 3b 0d 0a 0d 0a 20 20 20 20 55 53 48 4f 52 54 s;.... USHORT
7d40: 20 20 20 20 73 65 74 49 44 3b 20 20 20 20 20 20 setID;
7d50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
7d60: 20 43 61 62 69 6e 65 74 20 73 65 74 20 49 44 0d Cabinet set ID.
7d70: 0a 20 20 20 20 55 53 48 4f 52 54 20 20 20 20 69 . USHORT i
7d80: 43 61 62 69 6e 65 74 3b 20 20 20 20 20 20 20 20 Cabinet;
7d90: 20 20 20 20 20 20 20 20 20 2f 2f 20 43 61 62 69 // Cabi
7da0: 6e 65 74 20 6e 75 6d 62 65 72 20 28 30 2d 62 61 net number (0-ba
7db0: 73 65 64 29 0d 0a 20 20 20 20 55 53 48 4f 52 54 sed).. USHORT
7dc0: 20 20 20 20 69 46 6f 6c 64 65 72 3b 20 20 20 20 iFolder;
7dd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
7de0: 20 46 6f 6c 64 65 72 20 6e 75 6d 62 65 72 20 28 Folder number (
7df0: 30 2d 62 61 73 65 64 29 0d 0a 0d 0a 20 20 20 20 0-based)....
7e00: 46 44 49 45 52 52 4f 52 20 20 66 64 69 65 3b 0d FDIERROR fdie;.
7e10: 0a 7d 20 46 44 49 4e 4f 54 49 46 49 43 41 54 49 .} FDINOTIFICATI
7e20: 4f 4e 2c 20 46 41 52 20 2a 50 46 44 49 4e 4f 54 ON, FAR *PFDINOT
7e30: 49 46 49 43 41 54 49 4f 4e 3b 20 20 2f 2a 20 66 IFICATION; /* f
7e40: 64 69 6e 2c 20 70 66 64 69 6e 20 2a 2f 0d 0a 0d din, pfdin */...
7e50: 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 44 49 4e 4f .../*** FDINO
7e60: 54 49 46 49 43 41 54 49 4f 4e 54 59 50 45 20 2d TIFICATIONTYPE -
7e70: 20 46 44 49 43 6f 70 79 20 6e 6f 74 69 66 69 63 FDICopy notific
7e80: 61 74 69 6f 6e 20 74 79 70 65 73 0d 0a 20 2a 0d ation types.. *.
7e90: 0a 20 2a 20 20 54 68 65 20 6e 6f 74 69 66 69 63 . * The notific
7ea0: 61 74 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 20 66 ation function f
7eb0: 6f 72 20 46 44 49 43 6f 70 79 20 63 61 6e 20 62 or FDICopy can b
7ec0: 65 20 63 61 6c 6c 65 64 20 77 69 74 68 20 74 68 e called with th
7ed0: 65 20 66 6f 6c 6c 6f 77 69 6e 67 0d 0a 20 2a 20 e following.. *
7ee0: 20 76 61 6c 75 65 73 20 66 6f 72 20 74 68 65 20 values for the
7ef0: 66 64 69 6e 74 20 70 61 72 61 6d 65 74 65 72 2e fdint parameter.
7f00: 20 20 49 6e 20 61 6c 6c 20 63 61 73 65 73 2c 20 In all cases,
7f10: 74 68 65 20 70 66 64 69 6e 2d 3e 70 76 20 66 69 the pfdin->pv fi
7f20: 65 6c 64 20 69 73 0d 0a 20 2a 20 20 66 69 6c 6c eld is.. * fill
7f30: 65 64 20 69 6e 20 77 69 74 68 20 74 68 65 20 76 ed in with the v
7f40: 61 6c 75 65 20 6f 66 20 74 68 65 20 70 76 55 73 alue of the pvUs
7f50: 65 72 20 61 72 67 75 6d 65 6e 74 20 70 61 73 73 er argument pass
7f60: 65 64 20 69 6e 20 74 6f 20 46 44 49 43 6f 70 79 ed in to FDICopy
7f70: 28 29 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 41 20 74 ()... *.. * A t
7f80: 79 70 69 63 61 6c 20 73 65 71 75 65 6e 63 65 20 ypical sequence
7f90: 6f 66 20 63 61 6c 6c 73 20 77 69 6c 6c 20 62 65 of calls will be
7fa0: 20 73 6f 6d 65 74 68 69 6e 67 20 6c 69 6b 65 20 something like
7fb0: 74 68 69 73 3a 0d 0a 20 2a 20 20 20 20 20 20 66 this:.. * f
7fc0: 64 69 6e 74 43 41 42 49 4e 45 54 5f 49 4e 46 4f dintCABINET_INFO
7fd0: 20 20 20 20 20 2f 2f 20 49 6e 66 6f 20 61 62 6f // Info abo
7fe0: 75 74 20 74 68 65 20 63 61 62 69 6e 65 74 0d 0a ut the cabinet..
7ff0: 20 2a 20 20 20 20 20 20 66 64 69 6e 74 45 4e 55 * fdintENU
8000: 4d 45 52 41 54 45 20 20 20 20 20 20 20 20 2f 2f MERATE //
8010: 20 53 74 61 72 74 69 6e 67 20 65 6e 75 6d 65 72 Starting enumer
8020: 61 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 66 ation.. * f
8030: 64 69 6e 74 50 41 52 54 49 41 4c 5f 46 49 4c 45 dintPARTIAL_FILE
8040: 20 20 20 20 20 2f 2f 20 4f 6e 6c 79 20 69 66 20 // Only if
8050: 74 68 69 73 20 69 73 20 6e 6f 74 20 74 68 65 20 this is not the
8060: 66 69 72 73 74 20 63 61 62 69 6e 65 74 2c 20 61 first cabinet, a
8070: 6e 64 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 nd.. *
8080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
8090: 20 20 2f 2f 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 // one or more
80a0: 20 66 69 6c 65 73 20 77 65 72 65 20 63 6f 6e 74 files were cont
80b0: 69 6e 75 65 64 20 66 72 6f 6d 20 74 68 65 0d 0a inued from the..
80c0: 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 *
80d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
80e0: 20 70 72 65 76 69 6f 75 73 20 63 61 62 69 6e 65 previous cabine
80f0: 74 2e 0d 0a 20 2a 20 20 20 20 20 20 2e 2e 2e 0d t... * ....
8100: 0a 20 2a 20 20 20 20 20 20 66 64 69 6e 74 50 41 . * fdintPA
8110: 52 54 49 41 4c 5f 46 49 4c 45 0d 0a 20 2a 20 20 RTIAL_FILE.. *
8120: 20 20 20 20 66 64 69 6e 74 43 4f 50 59 5f 46 49 fdintCOPY_FI
8130: 4c 45 20 20 20 20 20 20 20 20 2f 2f 20 54 68 65 LE // The
8140: 20 66 69 72 73 74 20 66 69 6c 65 20 74 68 61 74 first file that
8150: 20 73 74 61 72 74 73 20 69 6e 20 74 68 69 73 20 starts in this
8160: 63 61 62 69 6e 65 74 0d 0a 20 2a 20 20 20 20 20 cabinet.. *
8170: 20 2e 2e 2e 0d 0a 20 2a 20 20 20 20 20 20 66 64 ..... * fd
8180: 69 6e 74 43 4f 50 59 5f 46 49 4c 45 20 20 20 20 intCOPY_FILE
8190: 20 20 20 20 2f 2f 20 4e 6f 77 20 6c 65 74 27 73 // Now let's
81a0: 20 61 73 73 75 6d 65 20 79 6f 75 20 77 61 6e 74 assume you want
81b0: 20 74 68 69 73 20 66 69 6c 65 2e 2e 2e 0d 0a 20 this file.....
81c0: 2a 20 20 20 20 20 20 2f 2f 20 50 46 4e 57 52 49 * // PFNWRI
81d0: 54 45 20 63 61 6c 6c 65 64 20 6d 75 6c 74 69 70 TE called multip
81e0: 6c 65 20 74 69 6d 65 73 20 74 6f 20 77 72 69 74 le times to writ
81f0: 65 20 74 6f 20 74 68 69 73 20 66 69 6c 65 2e 0d e to this file..
8200: 0a 20 2a 20 20 20 20 20 20 66 64 69 6e 74 43 4c . * fdintCL
8210: 4f 53 45 5f 46 49 4c 45 5f 49 4e 46 4f 20 20 2f OSE_FILE_INFO /
8220: 2f 20 46 69 6c 65 20 64 6f 6e 65 2c 20 73 65 74 / File done, set
8230: 20 64 61 74 65 2f 74 69 6d 65 2f 61 74 74 72 69 date/time/attri
8240: 62 75 74 65 73 0d 0a 20 2a 0d 0a 20 2a 20 20 20 butes.. *.. *
8250: 20 20 20 66 64 69 6e 74 43 4f 50 59 5f 46 49 4c fdintCOPY_FIL
8260: 45 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 77 20 E // Now
8270: 6c 65 74 27 73 20 61 73 73 75 6d 65 20 79 6f 75 let's assume you
8280: 20 77 61 6e 74 20 74 68 69 73 20 66 69 6c 65 2e want this file.
8290: 2e 2e 0d 0a 20 2a 20 20 20 20 20 20 2f 2f 20 50 .... * // P
82a0: 46 4e 57 52 49 54 45 20 63 61 6c 6c 65 64 20 6d FNWRITE called m
82b0: 75 6c 74 69 70 6c 65 20 74 69 6d 65 73 20 74 6f ultiple times to
82c0: 20 77 72 69 74 65 20 74 6f 20 74 68 69 73 20 66 write to this f
82d0: 69 6c 65 2e 0d 0a 20 2a 20 20 20 20 20 20 66 64 ile... * fd
82e0: 69 6e 74 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 intNEXT_CABINET
82f0: 20 20 20 20 2f 2f 20 46 69 6c 65 20 77 61 73 20 // File was
8300: 63 6f 6e 74 69 6e 75 65 64 20 74 6f 20 6e 65 78 continued to nex
8310: 74 20 63 61 62 69 6e 65 74 21 0d 0a 20 2a 20 20 t cabinet!.. *
8320: 20 20 20 20 66 64 69 6e 74 43 41 42 49 4e 45 54 fdintCABINET
8330: 5f 49 4e 46 4f 20 20 20 20 20 2f 2f 20 49 6e 66 _INFO // Inf
8340: 6f 20 61 62 6f 75 74 20 74 68 65 20 6e 65 77 20 o about the new
8350: 63 61 62 69 6e 65 74 0d 0a 20 2a 20 20 20 20 20 cabinet.. *
8360: 20 2f 2f 20 50 46 4e 57 52 49 54 45 20 63 61 6c // PFNWRITE cal
8370: 6c 65 64 20 6d 75 6c 74 69 70 6c 65 20 74 69 6d led multiple tim
8380: 65 73 20 74 6f 20 77 72 69 74 65 20 74 6f 20 74 es to write to t
8390: 68 69 73 20 66 69 6c 65 2e 0d 0a 20 2a 20 20 20 his file... *
83a0: 20 20 20 66 64 69 6e 74 43 4c 4f 53 45 5f 46 49 fdintCLOSE_FI
83b0: 4c 45 5f 49 4e 46 4f 20 20 2f 2f 20 46 69 6c 65 LE_INFO // File
83c0: 20 64 6f 6e 65 2c 20 73 65 74 20 64 61 74 65 2f done, set date/
83d0: 74 69 6d 65 2f 61 74 74 72 69 62 75 74 65 73 0d time/attributes.
83e0: 0a 20 2a 20 20 20 20 20 20 2e 2e 2e 0d 0a 20 2a . * ..... *
83f0: 20 20 20 20 20 20 66 64 69 6e 74 45 4e 55 4d 45 fdintENUME
8400: 52 41 54 45 20 20 20 20 20 20 20 20 2f 2f 20 45 RATE // E
8410: 6e 64 69 6e 67 20 65 6e 75 6d 65 72 61 74 69 6f nding enumeratio
8420: 6e 0d 0a 20 2a 0d 0a 20 2a 20 20 66 64 69 6e 74 n.. *.. * fdint
8430: 43 41 42 49 4e 45 54 5f 49 4e 46 4f 3a 0d 0a 20 CABINET_INFO:..
8440: 2a 20 20 20 20 20 20 20 20 43 61 6c 6c 65 64 20 * Called
8450: 65 78 61 63 74 6c 79 20 6f 6e 63 65 20 66 6f 72 exactly once for
8460: 20 65 61 63 68 20 63 61 62 69 6e 65 74 20 6f 70 each cabinet op
8470: 65 6e 65 64 20 62 79 20 46 44 49 43 6f 70 79 28 ened by FDICopy(
8480: 29 2c 20 69 6e 63 6c 75 64 69 6e 67 0d 0a 20 2a ), including.. *
8490: 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 61 continua
84a0: 74 69 6f 6e 20 63 61 62 69 6e 65 74 73 20 6f 70 tion cabinets op
84b0: 65 6e 65 64 20 64 75 65 20 74 6f 20 66 69 6c 65 ened due to file
84c0: 28 73 29 20 73 70 61 6e 6e 69 6e 67 20 63 61 62 (s) spanning cab
84d0: 69 6e 65 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 inet.. *
84e0: 62 6f 75 6e 64 61 72 69 65 73 2e 20 50 72 69 6d boundaries. Prim
84f0: 61 72 69 6c 79 20 69 6e 74 65 6e 64 65 64 20 74 arily intended t
8500: 6f 20 70 65 72 6d 69 74 20 45 58 54 52 41 43 54 o permit EXTRACT
8510: 2e 45 58 45 20 74 6f 0d 0a 20 2a 20 20 20 20 20 .EXE to.. *
8520: 20 20 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 automatically
8530: 20 73 65 6c 65 63 74 20 74 68 65 20 6e 65 78 74 select the next
8540: 20 63 61 62 69 6e 65 74 20 69 6e 20 61 20 63 61 cabinet in a ca
8550: 62 69 6e 65 74 20 73 65 71 75 65 6e 63 65 20 65 binet sequence e
8560: 76 65 6e 20 69 66 0d 0a 20 2a 20 20 20 20 20 20 ven if.. *
8570: 20 20 6e 6f 74 20 63 6f 70 79 69 6e 67 20 66 69 not copying fi
8580: 6c 65 73 20 74 68 61 74 20 73 70 61 6e 20 63 61 les that span ca
8590: 62 69 6e 65 74 20 62 6f 75 6e 64 61 72 69 65 73 binet boundaries
85a0: 2e 0d 0a 20 2a 20 20 20 20 20 20 45 6e 74 72 79 ... * Entry
85b0: 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 :.. * p
85c0: 66 64 69 6e 2d 3e 70 73 7a 31 20 20 20 20 20 3d fdin->psz1 =
85d0: 20 6e 61 6d 65 20 6f 66 20 6e 65 78 74 20 63 61 name of next ca
85e0: 62 69 6e 65 74 0d 0a 20 2a 20 20 20 20 20 20 20 binet.. *
85f0: 20 20 20 70 66 64 69 6e 2d 3e 70 73 7a 32 20 20 pfdin->psz2
8600: 20 20 20 3d 20 6e 61 6d 65 20 6f 66 20 6e 65 78 = name of nex
8610: 74 20 64 69 73 6b 0d 0a 20 2a 20 20 20 20 20 20 t disk.. *
8620: 20 20 20 20 70 66 64 69 6e 2d 3e 70 73 7a 33 20 pfdin->psz3
8630: 20 20 20 20 3d 20 63 61 62 69 6e 65 74 20 70 61 = cabinet pa
8640: 74 68 20 6e 61 6d 65 0d 0a 20 2a 20 20 20 20 20 th name.. *
8650: 20 20 20 20 20 70 66 64 69 6e 2d 3e 73 65 74 49 pfdin->setI
8660: 44 20 20 20 20 3d 20 63 61 62 69 6e 65 74 20 73 D = cabinet s
8670: 65 74 20 49 44 20 28 61 20 72 61 6e 64 6f 6d 20 et ID (a random
8680: 31 36 2d 62 69 74 20 6e 75 6d 62 65 72 29 0d 0a 16-bit number)..
8690: 20 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 * pfdi
86a0: 6e 2d 3e 69 43 61 62 69 6e 65 74 20 3d 20 43 61 n->iCabinet = Ca
86b0: 62 69 6e 65 74 20 6e 75 6d 62 65 72 20 77 69 74 binet number wit
86c0: 68 69 6e 20 63 61 62 69 6e 65 74 20 73 65 74 20 hin cabinet set
86d0: 28 30 2d 62 61 73 65 64 29 0d 0a 20 2a 20 20 20 (0-based).. *
86e0: 20 20 20 45 78 69 74 2d 53 75 63 63 65 73 73 3a Exit-Success:
86f0: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 52 65 .. * Re
8700: 74 75 72 6e 20 61 6e 79 74 68 69 6e 67 20 62 75 turn anything bu
8710: 74 20 2d 31 0d 0a 20 2a 20 20 20 20 20 20 45 78 t -1.. * Ex
8720: 69 74 2d 46 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 it-Failure:.. *
8730: 20 20 20 20 20 20 20 20 20 52 65 74 75 72 6e 73 Returns
8740: 20 2d 31 20 3d 3e 20 41 62 6f 72 74 20 46 44 49 -1 => Abort FDI
8750: 43 6f 70 79 28 29 20 63 61 6c 6c 0d 0a 20 2a 20 Copy() call.. *
8760: 20 20 20 20 20 4e 6f 74 65 73 3a 0d 0a 20 2a 20 Notes:.. *
8770: 20 20 20 20 20 20 20 20 20 54 68 69 73 20 63 61 This ca
8780: 6c 6c 20 69 73 20 6d 61 64 65 20 2a 65 76 65 72 ll is made *ever
8790: 79 2a 20 74 69 6d 65 20 61 20 6e 65 77 20 63 61 y* time a new ca
87a0: 62 69 6e 65 74 20 69 73 20 65 78 61 6d 69 6e 65 binet is examine
87b0: 64 20 62 79 0d 0a 20 2a 20 20 20 20 20 20 20 20 d by.. *
87c0: 20 20 46 44 49 43 6f 70 79 28 29 2e 20 20 53 6f FDICopy(). So
87d0: 20 69 66 20 22 66 6f 6f 32 2e 63 61 62 22 20 69 if "foo2.cab" i
87e0: 73 20 65 78 61 6d 69 6e 65 64 20 62 65 63 61 75 s examined becau
87f0: 73 65 20 61 20 66 69 6c 65 20 69 73 0d 0a 20 2a se a file is.. *
8800: 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e contin
8810: 75 65 64 20 66 72 6f 6d 20 22 66 6f 6f 31 2e 63 ued from "foo1.c
8820: 61 62 22 2c 20 61 6e 64 20 74 68 65 6e 20 79 6f ab", and then yo
8830: 75 20 63 61 6c 6c 20 46 44 49 43 6f 70 79 28 29 u call FDICopy()
8840: 20 61 67 61 69 6e 0d 0a 20 2a 20 20 20 20 20 20 again.. *
8850: 20 20 20 20 6f 6e 20 22 66 6f 6f 32 2e 63 61 62 on "foo2.cab
8860: 22 2c 20 79 6f 75 20 77 69 6c 6c 20 67 65 74 20 ", you will get
8870: 2a 74 77 6f 2a 20 66 64 69 6e 74 43 41 42 49 4e *two* fdintCABIN
8880: 45 54 5f 49 4e 46 4f 20 63 61 6c 6c 73 20 61 6c ET_INFO calls al
8890: 6c 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 74 l.. * t
88a0: 6f 6c 64 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 66 64 old... *.. * fd
88b0: 69 6e 74 43 4f 50 59 5f 46 49 4c 45 3a 0d 0a 20 intCOPY_FILE:..
88c0: 2a 20 20 20 20 20 20 20 20 43 61 6c 6c 65 64 20 * Called
88d0: 66 6f 72 20 65 61 63 68 20 66 69 6c 65 20 74 68 for each file th
88e0: 61 74 20 2a 73 74 61 72 74 73 2a 20 69 6e 20 74 at *starts* in t
88f0: 68 65 20 63 75 72 72 65 6e 74 20 63 61 62 69 6e he current cabin
8900: 65 74 2c 20 67 69 76 69 6e 67 0d 0a 20 2a 20 20 et, giving.. *
8910: 20 20 20 20 20 20 74 68 65 20 63 6c 69 65 6e 74 the client
8920: 20 74 68 65 20 6f 70 70 6f 72 74 75 6e 69 74 79 the opportunity
8930: 20 74 6f 20 72 65 71 75 65 73 74 20 74 68 61 74 to request that
8940: 20 74 68 65 20 66 69 6c 65 20 62 65 20 63 6f 70 the file be cop
8950: 69 65 64 20 6f 72 0d 0a 20 2a 20 20 20 20 20 20 ied or.. *
8960: 20 20 73 6b 69 70 70 65 64 2e 0d 0a 20 2a 20 20 skipped... *
8970: 20 20 20 20 45 6e 74 72 79 3a 0d 0a 20 2a 20 20 Entry:.. *
8980: 20 20 20 20 20 20 20 20 70 66 64 69 6e 2d 3e 70 pfdin->p
8990: 73 7a 31 20 20 20 20 3d 20 66 69 6c 65 20 6e 61 sz1 = file na
89a0: 6d 65 20 69 6e 20 63 61 62 69 6e 65 74 0d 0a 20 me in cabinet..
89b0: 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e * pfdin
89c0: 2d 3e 63 62 20 20 20 20 20 20 3d 20 75 6e 63 6f ->cb = unco
89d0: 6d 70 72 65 73 73 65 64 20 73 69 7a 65 20 6f 66 mpressed size of
89e0: 20 66 69 6c 65 0d 0a 20 2a 20 20 20 20 20 20 20 file.. *
89f0: 20 20 20 70 66 64 69 6e 2d 3e 64 61 74 65 20 20 pfdin->date
8a00: 20 20 3d 20 66 69 6c 65 20 64 61 74 65 0d 0a 20 = file date..
8a10: 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e * pfdin
8a20: 2d 3e 74 69 6d 65 20 20 20 20 3d 20 66 69 6c 65 ->time = file
8a30: 20 74 69 6d 65 0d 0a 20 2a 20 20 20 20 20 20 20 time.. *
8a40: 20 20 20 70 66 64 69 6e 2d 3e 61 74 74 72 69 62 pfdin->attrib
8a50: 73 20 3d 20 66 69 6c 65 20 61 74 74 72 69 62 75 s = file attribu
8a60: 74 65 73 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 tes.. *
8a70: 20 70 66 64 69 6e 2d 3e 69 46 6f 6c 64 65 72 20 pfdin->iFolder
8a80: 3d 20 66 69 6c 65 27 73 20 66 6f 6c 64 65 72 20 = file's folder
8a90: 69 6e 64 65 78 0d 0a 20 2a 20 20 20 20 20 20 45 index.. * E
8aa0: 78 69 74 2d 53 75 63 63 65 73 73 3a 0d 0a 20 2a xit-Success:.. *
8ab0: 20 20 20 20 20 20 20 20 20 20 52 65 74 75 72 6e Return
8ac0: 20 6e 6f 6e 2d 7a 65 72 6f 20 66 69 6c 65 20 68 non-zero file h
8ad0: 61 6e 64 6c 65 20 66 6f 72 20 64 65 73 74 69 6e andle for destin
8ae0: 61 74 69 6f 6e 20 66 69 6c 65 3b 20 46 44 49 20 ation file; FDI
8af0: 77 72 69 74 65 73 0d 0a 20 2a 20 20 20 20 20 20 writes.. *
8b00: 20 20 20 20 64 61 74 61 20 74 6f 20 74 68 69 73 data to this
8b10: 20 66 69 6c 65 20 75 73 65 20 74 68 65 20 50 46 file use the PF
8b20: 4e 57 52 49 54 45 20 66 75 6e 63 74 69 6f 6e 20 NWRITE function
8b30: 73 75 70 70 6c 69 65 64 20 74 6f 20 46 44 49 43 supplied to FDIC
8b40: 72 65 61 74 65 2c 0d 0a 20 2a 20 20 20 20 20 20 reate,.. *
8b50: 20 20 20 20 61 6e 64 20 74 68 65 6e 20 63 61 6c and then cal
8b60: 6c 73 20 66 64 69 6e 74 43 4c 4f 53 45 5f 46 49 ls fdintCLOSE_FI
8b70: 4c 45 5f 49 4e 46 4f 20 74 6f 20 63 6c 6f 73 65 LE_INFO to close
8b80: 20 74 68 65 20 66 69 6c 65 20 61 6e 64 20 73 65 the file and se
8b90: 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 74 t.. * t
8ba0: 68 65 20 64 61 74 65 2c 20 74 69 6d 65 2c 20 61 he date, time, a
8bb0: 6e 64 20 61 74 74 72 69 62 75 74 65 73 2e 20 20 nd attributes.
8bc0: 4e 4f 54 45 3a 20 54 68 69 73 20 66 69 6c 65 20 NOTE: This file
8bd0: 68 61 6e 64 6c 65 20 72 65 74 75 72 6e 65 64 0d handle returned.
8be0: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 6d 75 73 . * mus
8bf0: 74 20 61 6c 73 6f 20 62 65 20 63 6c 6f 73 65 61 t also be closea
8c00: 62 6c 65 20 62 79 20 74 68 65 20 50 46 4e 43 4c ble by the PFNCL
8c10: 4f 53 45 20 66 75 6e 63 74 69 6f 6e 20 73 75 70 OSE function sup
8c20: 70 6c 69 65 64 20 74 6f 0d 0a 20 2a 20 20 20 20 plied to.. *
8c30: 20 20 20 20 20 20 46 44 49 43 72 65 61 74 65 2c FDICreate,
8c40: 20 73 69 6e 63 65 20 69 66 20 61 6e 20 65 72 72 since if an err
8c50: 6f 72 20 6f 63 63 75 72 73 20 77 68 69 6c 65 20 or occurs while
8c60: 77 72 69 74 69 6e 67 20 74 6f 20 74 68 69 73 20 writing to this
8c70: 68 61 6e 64 6c 65 2c 0d 0a 20 2a 20 20 20 20 20 handle,.. *
8c80: 20 20 20 20 20 46 44 49 20 77 69 6c 6c 20 75 73 FDI will us
8c90: 65 20 74 68 65 20 50 46 4e 43 4c 4f 53 45 20 66 e the PFNCLOSE f
8ca0: 75 6e 63 74 69 6f 6e 20 74 6f 20 63 6c 6f 73 65 unction to close
8cb0: 20 74 68 65 20 66 69 6c 65 20 73 6f 20 74 68 61 the file so tha
8cc0: 74 20 74 68 65 0d 0a 20 2a 20 20 20 20 20 20 20 t the.. *
8cd0: 20 20 20 63 6c 69 65 6e 74 20 6d 61 79 20 64 65 client may de
8ce0: 6c 65 74 65 20 69 74 2e 0d 0a 20 2a 20 20 20 20 lete it... *
8cf0: 20 20 45 78 69 74 2d 46 61 69 6c 75 72 65 3a 0d Exit-Failure:.
8d00: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 52 65 74 . * Ret
8d10: 75 72 6e 73 20 30 20 20 3d 3e 20 53 6b 69 70 20 urns 0 => Skip
8d20: 66 69 6c 65 2c 20 64 6f 20 6e 6f 74 20 63 6f 70 file, do not cop
8d30: 79 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 52 y.. * R
8d40: 65 74 75 72 6e 73 20 2d 31 20 3d 3e 20 41 62 6f eturns -1 => Abo
8d50: 72 74 20 46 44 49 43 6f 70 79 28 29 20 63 61 6c rt FDICopy() cal
8d60: 6c 0d 0a 20 2a 0d 0a 20 2a 20 20 66 64 69 6e 74 l.. *.. * fdint
8d70: 43 4c 4f 53 45 5f 46 49 4c 45 5f 49 4e 46 4f 3a CLOSE_FILE_INFO:
8d80: 0d 0a 20 2a 20 20 20 20 20 20 20 20 43 61 6c 6c .. * Call
8d90: 65 64 20 61 66 74 65 72 20 61 6c 6c 20 6f 66 20 ed after all of
8da0: 74 68 65 20 64 61 74 61 20 68 61 73 20 62 65 65 the data has bee
8db0: 6e 20 77 72 69 74 74 65 6e 20 74 6f 20 61 20 74 n written to a t
8dc0: 61 72 67 65 74 20 66 69 6c 65 2e 0d 0a 20 2a 20 arget file... *
8dd0: 20 20 20 20 20 20 20 54 68 69 73 20 66 75 6e 63 This func
8de0: 74 69 6f 6e 20 6d 75 73 74 20 63 6c 6f 73 65 20 tion must close
8df0: 74 68 65 20 66 69 6c 65 20 61 6e 64 20 73 65 74 the file and set
8e00: 20 74 68 65 20 66 69 6c 65 20 64 61 74 65 2c 20 the file date,
8e10: 74 69 6d 65 2c 0d 0a 20 2a 20 20 20 20 20 20 20 time,.. *
8e20: 20 61 6e 64 20 61 74 74 72 69 62 75 74 65 73 2e and attributes.
8e30: 0d 0a 20 2a 20 20 20 20 20 20 45 6e 74 72 79 3a .. * Entry:
8e40: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 66 .. * pf
8e50: 64 69 6e 2d 3e 70 73 7a 31 20 20 20 20 3d 20 66 din->psz1 = f
8e60: 69 6c 65 20 6e 61 6d 65 20 69 6e 20 63 61 62 69 ile name in cabi
8e70: 6e 65 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 net.. *
8e80: 20 70 66 64 69 6e 2d 3e 68 66 20 20 20 20 20 20 pfdin->hf
8e90: 3d 20 66 69 6c 65 20 68 61 6e 64 6c 65 0d 0a 20 = file handle..
8ea0: 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e * pfdin
8eb0: 2d 3e 64 61 74 65 20 20 20 20 3d 20 66 69 6c 65 ->date = file
8ec0: 20 64 61 74 65 0d 0a 20 2a 20 20 20 20 20 20 20 date.. *
8ed0: 20 20 20 70 66 64 69 6e 2d 3e 74 69 6d 65 20 20 pfdin->time
8ee0: 20 20 3d 20 66 69 6c 65 20 74 69 6d 65 0d 0a 20 = file time..
8ef0: 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e * pfdin
8f00: 2d 3e 61 74 74 72 69 62 73 20 3d 20 66 69 6c 65 ->attribs = file
8f10: 20 61 74 74 72 69 62 75 74 65 73 0d 0a 20 2a 20 attributes.. *
8f20: 20 20 20 20 20 20 20 20 20 70 66 64 69 6e 2d 3e pfdin->
8f30: 69 46 6f 6c 64 65 72 20 3d 20 66 69 6c 65 27 73 iFolder = file's
8f40: 20 66 6f 6c 64 65 72 20 69 6e 64 65 78 0d 0a 20 folder index..
8f50: 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e * pfdin
8f60: 2d 3e 63 62 20 20 20 20 20 20 3d 20 52 75 6e 20 ->cb = Run
8f70: 41 66 74 65 72 20 45 78 74 72 61 63 74 20 28 30 After Extract (0
8f80: 20 2d 20 64 6f 6e 27 74 20 72 75 6e 2c 20 31 20 - don't run, 1
8f90: 52 75 6e 29 0d 0a 20 2a 20 20 20 20 20 20 45 78 Run).. * Ex
8fa0: 69 74 2d 53 75 63 63 65 73 73 3a 0d 0a 20 2a 20 it-Success:.. *
8fb0: 20 20 20 20 20 20 20 20 20 52 65 74 75 72 6e 73 Returns
8fc0: 20 54 52 55 45 0d 0a 20 2a 20 20 20 20 20 20 45 TRUE.. * E
8fd0: 78 69 74 2d 46 61 69 6c 75 72 65 3a 0d 0a 20 2a xit-Failure:.. *
8fe0: 20 20 20 20 20 20 20 20 20 20 52 65 74 75 72 6e Return
8ff0: 73 20 46 41 4c 53 45 2c 20 6f 72 20 2d 31 20 74 s FALSE, or -1 t
9000: 6f 20 61 62 6f 72 74 3b 0d 0a 20 2a 0d 0a 20 2a o abort;.. *.. *
9010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 4d IM
9020: 50 4f 52 54 41 4e 54 20 4e 4f 54 45 20 49 4d 50 PORTANT NOTE IMP
9030: 4f 52 54 41 4e 54 3a 0d 0a 20 2a 20 20 20 20 20 ORTANT:.. *
9040: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 66 64 pfd
9050: 69 6e 2d 3e 63 62 20 69 73 20 6f 76 65 72 6c 6f in->cb is overlo
9060: 61 64 65 64 20 74 6f 20 6e 6f 20 6c 6f 6e 67 65 aded to no longe
9070: 72 20 62 65 20 74 68 65 20 73 69 7a 65 20 6f 66 r be the size of
9080: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 .. *
9090: 20 20 20 20 20 20 74 68 65 20 66 69 6c 65 20 62 the file b
90a0: 75 74 20 74 6f 20 62 65 20 61 20 62 69 6e 61 72 ut to be a binar
90b0: 79 20 69 6e 64 69 63 61 74 65 64 20 72 75 6e 20 y indicated run
90c0: 6f 72 20 6e 6f 74 0d 0a 20 2a 0d 0a 20 2a 20 20 or not.. *.. *
90d0: 20 20 20 20 20 20 20 20 20 20 20 20 49 4d 50 4f IMPO
90e0: 52 54 41 4e 54 20 4e 4f 54 45 3a 0d 0a 20 2a 20 RTANT NOTE:.. *
90f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
9100: 20 46 44 49 20 61 73 73 75 6d 65 73 20 74 68 61 FDI assumes tha
9110: 74 20 74 68 65 20 74 61 72 67 65 74 20 66 69 6c t the target fil
9120: 65 20 77 61 73 20 63 6c 6f 73 65 64 2c 20 65 76 e was closed, ev
9130: 65 6e 20 69 66 20 74 68 69 73 0d 0a 20 2a 20 20 en if this.. *
9140: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
9150: 63 61 6c 6c 62 61 63 6b 20 72 65 74 75 72 6e 73 callback returns
9160: 20 66 61 69 6c 75 72 65 2e 20 20 46 44 49 20 77 failure. FDI w
9170: 69 6c 6c 20 4e 4f 54 20 61 74 74 65 6d 70 74 20 ill NOT attempt
9180: 74 6f 20 75 73 65 0d 0a 20 2a 20 20 20 20 20 20 to use.. *
9190: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 65 20 the
91a0: 50 46 4e 43 4c 4f 53 45 20 66 75 6e 63 74 69 6f PFNCLOSE functio
91b0: 6e 20 73 75 70 70 6c 69 65 64 20 6f 6e 20 46 44 n supplied on FD
91c0: 49 43 72 65 61 74 65 28 29 20 74 6f 20 63 6c 6f ICreate() to clo
91d0: 73 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 se.. *
91e0: 20 20 20 20 20 20 20 20 74 68 65 20 66 69 6c 65 the file
91f0: 21 0d 0a 20 2a 0d 0a 20 2a 20 20 66 64 69 6e 74 !.. *.. * fdint
9200: 50 41 52 54 49 41 4c 5f 46 49 4c 45 3a 0d 0a 20 PARTIAL_FILE:..
9210: 2a 20 20 20 20 20 20 20 20 43 61 6c 6c 65 64 20 * Called
9220: 66 6f 72 20 66 69 6c 65 73 20 61 74 20 74 68 65 for files at the
9230: 20 66 72 6f 6e 74 20 6f 66 20 74 68 65 20 63 61 front of the ca
9240: 62 69 6e 65 74 20 74 68 61 74 20 61 72 65 20 43 binet that are C
9250: 4f 4e 54 49 4e 55 45 44 0d 0a 20 2a 20 20 20 20 ONTINUED.. *
9260: 20 20 20 20 66 72 6f 6d 20 61 20 70 72 65 76 69 from a previ
9270: 6f 75 73 20 63 61 62 69 6e 65 74 2e 20 20 54 68 ous cabinet. Th
9280: 69 73 20 63 61 6c 6c 62 61 63 6b 20 6f 63 63 75 is callback occu
9290: 72 73 20 6f 6e 6c 79 20 77 68 65 6e 20 46 44 49 rs only when FDI
92a0: 43 6f 70 79 20 69 73 0d 0a 20 2a 20 20 20 20 20 Copy is.. *
92b0: 20 20 20 73 74 61 72 74 65 64 20 6f 6e 20 73 65 started on se
92c0: 63 6f 6e 64 20 6f 72 20 73 75 62 73 65 71 75 65 cond or subseque
92d0: 6e 74 20 63 61 62 69 6e 65 74 20 69 6e 20 61 20 nt cabinet in a
92e0: 73 65 72 69 65 73 20 74 68 61 74 20 68 61 73 20 series that has
92f0: 66 69 6c 65 73 0d 0a 20 2a 20 20 20 20 20 20 20 files.. *
9300: 20 63 6f 6e 74 69 6e 75 65 64 20 66 72 6f 6d 20 continued from
9310: 61 20 70 72 65 76 69 6f 75 73 20 63 61 62 69 6e a previous cabin
9320: 65 74 2e 0d 0a 20 2a 20 20 20 20 20 20 45 6e 74 et... * Ent
9330: 72 79 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 ry:.. *
9340: 20 70 66 64 69 6e 2d 3e 70 73 7a 31 20 3d 20 66 pfdin->psz1 = f
9350: 69 6c 65 20 6e 61 6d 65 20 6f 66 20 66 69 6c 65 ile name of file
9360: 20 43 4f 4e 54 49 4e 55 45 44 20 66 72 6f 6d 20 CONTINUED from
9370: 61 20 50 52 45 56 49 4f 55 53 20 63 61 62 69 6e a PREVIOUS cabin
9380: 65 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 et.. *
9390: 70 66 64 69 6e 2d 3e 70 73 7a 32 20 3d 20 6e 61 pfdin->psz2 = na
93a0: 6d 65 20 6f 66 20 63 61 62 69 6e 65 74 20 77 68 me of cabinet wh
93b0: 65 72 65 20 66 69 6c 65 20 73 74 61 72 74 73 0d ere file starts.
93c0: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 . * pfd
93d0: 69 6e 2d 3e 70 73 7a 33 20 3d 20 6e 61 6d 65 20 in->psz3 = name
93e0: 6f 66 20 64 69 73 6b 20 77 68 65 72 65 20 66 69 of disk where fi
93f0: 6c 65 20 73 74 61 72 74 73 0d 0a 20 2a 20 20 20 le starts.. *
9400: 20 20 20 45 78 69 74 2d 53 75 63 63 65 73 73 3a Exit-Success:
9410: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 52 65 .. * Re
9420: 74 75 72 6e 20 61 6e 79 74 68 69 6e 67 20 6f 74 turn anything ot
9430: 68 65 72 20 74 68 61 6e 20 2d 31 3b 20 65 6e 75 her than -1; enu
9440: 6d 65 72 61 74 69 6f 6e 20 63 6f 6e 74 69 6e 75 meration continu
9450: 65 73 0d 0a 20 2a 20 20 20 20 20 20 45 78 69 74 es.. * Exit
9460: 2d 46 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 -Failure:.. *
9470: 20 20 20 20 20 20 20 52 65 74 75 72 6e 73 20 2d Returns -
9480: 31 20 3d 3e 20 41 62 6f 72 74 20 46 44 49 43 6f 1 => Abort FDICo
9490: 70 79 28 29 20 63 61 6c 6c 0d 0a 20 2a 0d 0a 20 py() call.. *..
94a0: 2a 20 20 66 64 69 6e 74 45 4e 55 4d 45 52 41 54 * fdintENUMERAT
94b0: 45 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 43 61 E:.. * Ca
94c0: 6c 6c 65 64 20 6f 6e 63 65 20 61 66 74 65 72 20 lled once after
94d0: 61 20 63 61 6c 6c 20 74 6f 20 46 44 49 43 6f 70 a call to FDICop
94e0: 79 28 29 20 73 74 61 72 74 73 20 73 63 61 6e 6e y() starts scann
94f0: 69 6e 67 20 61 20 43 41 42 27 73 0d 0a 20 2a 20 ing a CAB's.. *
9500: 20 20 20 20 20 20 20 43 46 46 49 4c 45 20 65 6e CFFILE en
9510: 74 72 69 65 73 2c 20 61 6e 64 20 61 67 61 69 6e tries, and again
9520: 20 77 68 65 6e 20 74 68 65 72 65 20 61 72 65 20 when there are
9530: 6e 6f 20 6d 6f 72 65 20 43 46 46 49 4c 45 20 65 no more CFFILE e
9540: 6e 74 72 69 65 73 2e 0d 0a 20 2a 20 20 20 20 20 ntries... *
9550: 20 20 20 49 66 20 43 41 42 20 73 70 61 6e 6e 69 If CAB spanni
9560: 6e 67 20 6f 63 63 75 72 73 2c 20 61 6e 20 61 64 ng occurs, an ad
9570: 64 69 74 69 6f 6e 61 6c 20 63 61 6c 6c 20 77 69 ditional call wi
9580: 6c 6c 20 6f 63 63 75 72 20 61 66 74 65 72 20 74 ll occur after t
9590: 68 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 66 69 he.. * fi
95a0: 72 73 74 20 73 70 61 6e 6e 65 64 20 66 69 6c 65 rst spanned file
95b0: 20 69 73 20 63 6f 6d 70 6c 65 74 65 64 2e 20 20 is completed.
95c0: 49 66 20 74 68 65 20 70 66 64 69 6e 2d 3e 69 46 If the pfdin->iF
95d0: 6f 6c 64 65 72 20 76 61 6c 75 65 20 69 73 0d 0a older value is..
95e0: 20 2a 20 20 20 20 20 20 20 20 63 68 61 6e 67 65 * change
95f0: 64 20 66 72 6f 6d 20 7a 65 72 6f 2c 20 61 64 64 d from zero, add
9600: 69 74 69 6f 6e 61 6c 20 63 61 6c 6c 73 20 77 69 itional calls wi
9610: 6c 6c 20 6f 63 63 75 72 20 6e 65 78 74 20 74 69 ll occur next ti
9620: 6d 65 20 69 74 20 72 65 61 63 68 65 73 0d 0a 20 me it reaches..
9630: 2a 20 20 20 20 20 20 20 20 7a 65 72 6f 2e 20 20 * zero.
9640: 49 66 20 69 46 6f 6c 64 65 72 20 69 73 20 63 68 If iFolder is ch
9650: 61 6e 67 65 64 20 74 6f 20 7a 65 72 6f 2c 20 46 anged to zero, F
9660: 44 49 43 6f 70 79 20 77 69 6c 6c 20 74 65 72 6d DICopy will term
9670: 69 6e 61 74 65 2c 20 61 73 20 69 66 0d 0a 20 2a inate, as if.. *
9680: 20 20 20 20 20 20 20 20 74 68 65 72 65 20 77 65 there we
9690: 72 65 20 6e 6f 20 6d 6f 72 65 20 43 46 46 49 4c re no more CFFIL
96a0: 45 20 65 6e 74 72 69 65 73 2e 20 20 50 72 69 6d E entries. Prim
96b0: 61 72 69 6c 79 20 69 6e 74 65 6e 64 65 64 20 74 arily intended t
96c0: 6f 20 61 6c 6c 6f 77 20 61 6e 0d 0a 20 2a 20 20 o allow an.. *
96d0: 20 20 20 20 20 20 61 70 70 6c 69 63 61 74 69 6f applicatio
96e0: 6e 20 77 69 74 68 20 69 74 27 73 20 6f 77 6e 20 n with it's own
96f0: 66 69 6c 65 20 6c 69 73 74 20 74 6f 20 68 65 6c file list to hel
9700: 70 20 46 44 49 20 61 64 76 61 6e 63 65 20 71 75 p FDI advance qu
9710: 69 63 6b 6c 79 20 74 6f 0d 0a 20 2a 20 20 20 20 ickly to.. *
9720: 20 20 20 20 61 20 43 46 46 49 4c 45 20 65 6e 74 a CFFILE ent
9730: 72 79 20 6f 66 20 69 6e 74 65 72 65 73 74 2e 20 ry of interest.
9740: 20 43 61 6e 20 61 6c 73 6f 20 62 65 20 75 73 65 Can also be use
9750: 64 20 74 6f 20 61 6c 6c 6f 77 20 61 6e 0d 0a 20 d to allow an..
9760: 2a 20 20 20 20 20 20 20 20 61 70 70 6c 69 63 61 * applica
9770: 74 69 6f 6e 20 74 6f 20 64 65 74 65 72 6d 69 6e tion to determin
9780: 65 20 74 68 65 20 63 62 20 76 61 6c 75 65 73 20 e the cb values
9790: 66 6f 72 20 65 61 63 68 20 66 69 6c 65 20 69 6e for each file in
97a0: 20 74 68 65 20 43 41 42 2e 0d 0a 20 2a 20 20 20 the CAB... *
97b0: 20 20 20 45 6e 74 72 79 3a 0d 0a 20 2a 20 20 20 Entry:.. *
97c0: 20 20 20 20 20 70 66 64 69 6e 2d 3e 63 62 20 20 pfdin->cb
97d0: 20 20 20 20 20 20 3d 20 63 75 72 72 65 6e 74 20 = current
97e0: 43 46 46 49 4c 45 20 70 6f 73 69 74 69 6f 6e 0d CFFILE position.
97f0: 0a 20 2a 20 20 20 20 20 20 20 20 70 66 64 69 6e . * pfdin
9800: 2d 3e 69 46 6f 6c 64 65 72 20 20 20 3d 20 6e 75 ->iFolder = nu
9810: 6d 62 65 72 20 6f 66 20 66 69 6c 65 73 20 72 65 mber of files re
9820: 6d 61 69 6e 69 6e 67 0d 0a 20 2a 20 20 20 20 20 maining.. *
9830: 20 20 20 70 66 64 69 6e 2d 3e 73 65 74 49 44 20 pfdin->setID
9840: 20 20 20 20 3d 20 63 75 72 72 65 6e 74 20 43 41 = current CA
9850: 42 27 73 20 73 65 74 49 44 20 76 61 6c 75 65 0d B's setID value.
9860: 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d 44 6f . * Exit-Do
9870: 6e 27 74 20 43 61 72 65 3a 0d 0a 20 2a 20 20 20 n't Care:.. *
9880: 20 20 20 20 20 44 6f 6e 27 74 20 63 68 61 6e 67 Don't chang
9890: 65 20 61 6e 79 74 68 69 6e 67 2e 0d 0a 20 2a 20 e anything... *
98a0: 20 20 20 20 20 20 20 52 65 74 75 72 6e 20 61 6e Return an
98b0: 79 74 68 69 6e 67 20 62 75 74 20 2d 31 2e 0d 0a ything but -1...
98c0: 20 2a 20 20 20 20 20 20 45 78 69 74 2d 46 6f 72 * Exit-For
98d0: 63 69 6e 67 20 61 20 73 6b 69 70 3a 0d 0a 20 2a cing a skip:.. *
98e0: 20 20 20 20 20 20 20 20 70 66 64 69 6e 2d 3e 63 pfdin->c
98f0: 62 20 20 20 20 20 20 20 20 3d 20 64 65 73 69 72 b = desir
9900: 65 64 20 43 46 46 49 4c 45 20 70 6f 73 69 74 69 ed CFFILE positi
9910: 6f 6e 0d 0a 20 2a 20 20 20 20 20 20 20 20 70 66 on.. * pf
9920: 64 69 6e 2d 3e 69 46 6f 6c 64 65 72 20 20 20 3d din->iFolder =
9930: 20 64 65 73 69 72 65 64 20 23 20 6f 66 20 66 69 desired # of fi
9940: 6c 65 73 20 72 65 6d 61 69 6e 69 6e 67 0d 0a 20 les remaining..
9950: 2a 20 20 20 20 20 20 20 20 52 65 74 75 72 6e 20 * Return
9960: 61 6e 79 74 68 69 6e 67 20 62 75 74 20 2d 31 2e anything but -1.
9970: 0d 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d 53 .. * Exit-S
9980: 74 6f 70 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 top:.. *
9990: 70 66 64 69 6e 2d 3e 69 46 6f 6c 64 65 72 20 20 pfdin->iFolder
99a0: 20 20 3d 20 73 65 74 20 74 6f 20 30 0d 0a 20 2a = set to 0.. *
99b0: 20 20 20 20 20 20 20 20 52 65 74 75 72 6e 20 61 Return a
99c0: 6e 79 74 68 69 6e 67 20 62 75 74 20 2d 31 2e 0d nything but -1..
99d0: 0a 20 2a 20 20 20 20 20 20 45 78 69 74 2d 46 61 . * Exit-Fa
99e0: 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 20 20 ilure:.. *
99f0: 20 20 52 65 74 75 72 6e 20 2d 31 20 3d 3e 20 41 Return -1 => A
9a00: 62 6f 72 74 20 46 44 49 43 6f 70 79 20 63 61 6c bort FDICopy cal
9a10: 6c 20 28 22 75 73 65 72 20 61 62 6f 72 74 65 64 l ("user aborted
9a20: 22 2e 29 0d 0a 20 2a 20 20 20 20 20 20 4e 6f 74 ".).. * Not
9a30: 65 73 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 54 es:.. * T
9a40: 68 69 73 20 63 61 6c 6c 20 63 61 6e 20 62 65 20 his call can be
9a50: 69 67 6e 6f 72 65 64 20 62 79 20 61 70 70 6c 69 ignored by appli
9a60: 63 61 74 69 6f 6e 73 20 77 68 69 63 68 20 77 61 cations which wa
9a70: 6e 74 20 6e 6f 72 6d 61 6c 20 66 69 6c 65 0d 0a nt normal file..
9a80: 20 2a 20 20 20 20 20 20 20 20 73 65 61 72 63 68 * search
9a90: 69 6e 67 2e 20 20 54 68 65 20 61 70 70 6c 69 63 ing. The applic
9aa0: 61 74 69 6f 6e 20 63 61 6e 20 61 64 6a 75 73 74 ation can adjust
9ab0: 20 74 68 65 20 73 75 70 70 6c 69 65 64 20 76 61 the supplied va
9ac0: 6c 75 65 73 20 74 6f 0d 0a 20 2a 20 20 20 20 20 lues to.. *
9ad0: 20 20 20 66 6f 72 63 65 20 46 44 49 43 6f 70 79 force FDICopy
9ae0: 28 29 20 74 6f 20 63 6f 6e 74 69 6e 75 65 20 69 () to continue i
9af0: 74 27 73 20 73 65 61 72 63 68 20 61 74 20 61 6e t's search at an
9b00: 6f 74 68 65 72 20 6c 6f 63 61 74 69 6f 6e 2c 20 other location,
9b10: 6f 72 0d 0a 20 2a 20 20 20 20 20 20 20 20 74 6f or.. * to
9b20: 20 66 6f 72 63 65 20 46 44 49 43 6f 70 79 28 29 force FDICopy()
9b30: 20 74 6f 20 74 65 72 6d 69 6e 61 74 65 20 74 68 to terminate th
9b40: 65 20 73 65 61 72 63 68 2c 20 62 79 20 73 65 74 e search, by set
9b50: 74 69 6e 67 20 69 46 6f 6c 64 65 72 20 74 6f 20 ting iFolder to
9b60: 30 2e 0d 0a 20 2a 20 20 20 20 20 20 20 20 28 46 0... * (F
9b70: 44 49 43 6f 70 79 28 29 20 77 69 6c 6c 20 72 65 DICopy() will re
9b80: 70 6f 72 74 20 6e 6f 20 65 72 72 6f 72 20 77 68 port no error wh
9b90: 65 6e 20 74 65 72 6d 69 6e 61 74 65 64 20 74 68 en terminated th
9ba0: 69 73 20 77 61 79 2e 29 0d 0a 20 2a 20 20 20 20 is way.).. *
9bb0: 20 20 20 20 46 44 49 20 68 61 73 20 6e 6f 20 6d FDI has no m
9bc0: 65 61 6e 73 20 74 6f 20 76 65 72 69 66 79 20 74 eans to verify t
9bd0: 68 65 20 73 75 70 70 6c 69 65 64 20 63 62 20 6f he supplied cb o
9be0: 72 20 69 46 6f 6c 64 65 72 20 76 61 6c 75 65 73 r iFolder values
9bf0: 2e 0d 0a 20 2a 20 20 20 20 20 20 20 20 41 72 62 ... * Arb
9c00: 69 74 72 61 72 79 20 76 61 6c 75 65 73 20 61 72 itrary values ar
9c10: 65 20 6c 69 6b 65 6c 79 20 74 6f 20 63 61 75 73 e likely to caus
9c20: 65 20 75 6e 64 65 73 69 72 61 62 6c 65 20 72 65 e undesirable re
9c30: 73 75 6c 74 73 2e 20 20 41 6e 0d 0a 20 2a 20 20 sults. An.. *
9c40: 20 20 20 20 20 20 61 70 70 6c 69 63 61 74 69 6f applicatio
9c50: 6e 20 73 68 6f 75 6c 64 20 63 72 6f 73 73 2d 63 n should cross-c
9c60: 68 65 63 6b 20 70 66 64 69 6e 2d 3e 73 65 74 49 heck pfdin->setI
9c70: 44 20 74 6f 20 62 65 20 63 65 72 74 61 69 6e 20 D to be certain
9c80: 74 68 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 65 the.. * e
9c90: 78 74 65 72 6e 61 6c 20 64 61 74 61 62 61 73 65 xternal database
9ca0: 20 69 73 20 69 6e 20 73 79 6e 63 20 77 69 74 68 is in sync with
9cb0: 20 74 68 65 20 43 41 42 2e 20 20 52 65 76 65 72 the CAB. Rever
9cc0: 73 65 2d 73 6b 69 70 73 20 61 72 65 20 4f 4b 0d se-skips are OK.
9cd0: 0a 20 2a 20 20 20 20 20 20 20 20 28 62 75 74 20 . * (but
9ce0: 6d 61 79 20 62 65 20 69 6e 65 66 66 69 63 69 65 may be inefficie
9cf0: 6e 74 29 20 75 6e 6c 65 73 73 20 66 64 69 6e 74 nt) unless fdint
9d00: 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 68 61 73 NEXT_CABINET has
9d10: 20 62 65 65 6e 20 63 61 6c 6c 65 64 2e 0d 0a 20 been called...
9d20: 2a 0d 0a 20 2a 20 20 66 64 69 6e 74 4e 45 58 54 *.. * fdintNEXT
9d30: 5f 43 41 42 49 4e 45 54 3a 0d 0a 20 2a 20 20 20 _CABINET:.. *
9d40: 20 20 20 20 20 54 68 69 73 20 66 75 6e 63 74 69 This functi
9d50: 6f 6e 20 69 73 20 2a 6f 6e 6c 79 2a 20 63 61 6c on is *only* cal
9d60: 6c 65 64 20 77 68 65 6e 20 66 64 69 6e 74 43 4f led when fdintCO
9d70: 50 59 5f 46 49 4c 45 20 77 61 73 20 74 6f 6c 64 PY_FILE was told
9d80: 20 74 6f 20 63 6f 70 79 0d 0a 20 2a 20 20 20 20 to copy.. *
9d90: 20 20 20 20 61 20 66 69 6c 65 20 69 6e 20 74 68 a file in th
9da0: 65 20 63 75 72 72 65 6e 74 20 63 61 62 69 6e 65 e current cabine
9db0: 74 20 74 68 61 74 20 69 73 20 63 6f 6e 74 69 6e t that is contin
9dc0: 75 65 64 20 74 6f 20 61 20 73 75 62 73 65 71 75 ued to a subsequ
9dd0: 65 6e 74 0d 0a 20 2a 20 20 20 20 20 20 20 20 63 ent.. * c
9de0: 61 62 69 6e 65 74 20 66 69 6c 65 2e 20 20 49 74 abinet file. It
9df0: 20 69 73 20 69 6d 70 6f 72 74 61 6e 74 20 74 68 is important th
9e00: 61 74 20 74 68 65 20 63 61 62 69 6e 65 74 20 70 at the cabinet p
9e10: 61 74 68 20 6e 61 6d 65 20 28 70 73 7a 33 29 0d ath name (psz3).
9e20: 0a 20 2a 20 20 20 20 20 20 20 20 62 65 20 76 61 . * be va
9e30: 6c 69 64 61 74 65 64 20 62 65 66 6f 72 65 20 72 lidated before r
9e40: 65 74 75 72 6e 69 6e 67 21 20 20 54 68 69 73 20 eturning! This
9e50: 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 function should
9e60: 65 6e 73 75 72 65 20 74 68 61 74 0d 0a 20 2a 20 ensure that.. *
9e70: 20 20 20 20 20 20 20 74 68 65 20 63 61 62 69 6e the cabin
9e80: 65 74 20 65 78 69 73 74 73 20 61 6e 64 20 69 73 et exists and is
9e90: 20 72 65 61 64 61 62 6c 65 20 62 65 66 6f 72 65 readable before
9ea0: 20 72 65 74 75 72 6e 69 6e 67 2e 20 20 53 6f 2c returning. So,
9eb0: 20 74 68 69 73 0d 0a 20 2a 20 20 20 20 20 20 20 this.. *
9ec0: 20 69 73 20 74 68 65 20 66 75 6e 63 74 69 6f 6e is the function
9ed0: 20 74 68 61 74 20 73 68 6f 75 6c 64 2c 20 66 6f that should, fo
9ee0: 72 20 65 78 61 6d 70 6c 65 2c 20 69 73 73 75 65 r example, issue
9ef0: 20 61 20 64 69 73 6b 20 63 68 61 6e 67 65 0d 0a a disk change..
9f00: 20 2a 20 20 20 20 20 20 20 20 70 72 6f 6d 70 74 * prompt
9f10: 20 61 6e 64 20 6d 61 6b 65 20 73 75 72 65 20 74 and make sure t
9f20: 68 65 20 63 61 62 69 6e 65 74 20 66 69 6c 65 20 he cabinet file
9f30: 65 78 69 73 74 73 2e 0d 0a 20 2a 0d 0a 20 2a 20 exists... *.. *
9f40: 20 20 20 20 20 20 20 57 68 65 6e 20 74 68 69 73 When this
9f50: 20 66 75 6e 63 74 69 6f 6e 20 72 65 74 75 72 6e function return
9f60: 73 20 74 6f 20 46 44 49 2c 20 46 44 49 20 77 69 s to FDI, FDI wi
9f70: 6c 6c 20 63 68 65 63 6b 20 74 68 61 74 20 74 68 ll check that th
9f80: 65 20 73 65 74 49 44 0d 0a 20 2a 20 20 20 20 20 e setID.. *
9f90: 20 20 20 61 6e 64 20 69 43 61 62 69 6e 65 74 20 and iCabinet
9fa0: 6d 61 74 63 68 20 74 68 65 20 65 78 70 65 63 74 match the expect
9fb0: 65 64 20 76 61 6c 75 65 73 20 66 6f 72 20 74 68 ed values for th
9fc0: 65 20 6e 65 78 74 20 63 61 62 69 6e 65 74 2e 0d e next cabinet..
9fd0: 0a 20 2a 20 20 20 20 20 20 20 20 49 66 20 6e 6f . * If no
9fe0: 74 2c 20 46 44 49 20 77 69 6c 6c 20 63 6f 6e 74 t, FDI will cont
9ff0: 69 6e 75 65 20 74 6f 20 63 61 6c 6c 20 74 68 69 inue to call thi
a000: 73 20 66 75 6e 63 74 69 6f 6e 20 75 6e 74 69 6c s function until
a010: 20 74 68 65 20 63 6f 72 72 65 63 74 0d 0a 20 2a the correct.. *
a020: 20 20 20 20 20 20 20 20 63 61 62 69 6e 65 74 20 cabinet
a030: 66 69 6c 65 20 69 73 20 73 70 65 63 69 66 69 65 file is specifie
a040: 64 2c 20 6f 72 20 75 6e 74 69 6c 20 74 68 69 73 d, or until this
a050: 20 66 75 6e 63 74 69 6f 6e 20 72 65 74 75 72 6e function return
a060: 73 20 2d 31 20 74 6f 0d 0a 20 2a 20 20 20 20 20 s -1 to.. *
a070: 20 20 20 61 62 6f 72 74 20 74 68 65 20 46 44 49 abort the FDI
a080: 43 6f 70 79 28 29 20 66 75 6e 63 74 69 6f 6e 2e Copy() function.
a090: 20 20 70 66 64 69 6e 2d 3e 66 64 69 65 20 69 73 pfdin->fdie is
a0a0: 20 73 65 74 20 74 6f 0d 0a 20 2a 20 20 20 20 20 set to.. *
a0b0: 20 20 20 46 44 49 45 52 52 4f 52 5f 57 52 4f 4e FDIERROR_WRON
a0c0: 47 5f 43 41 42 49 4e 45 54 20 74 6f 20 69 6e 64 G_CABINET to ind
a0d0: 69 63 61 74 65 20 74 68 69 73 20 63 61 73 65 2e icate this case.
a0e0: 0d 0a 20 2a 0d 0a 20 2a 20 20 20 20 20 20 20 20 .. *.. *
a0f0: 49 66 20 79 6f 75 20 2a 68 61 76 65 6e 27 74 2a If you *haven't*
a100: 20 65 6e 73 75 72 65 64 20 74 68 61 74 20 74 68 ensured that th
a110: 65 20 63 61 62 69 6e 65 74 20 66 69 6c 65 20 69 e cabinet file i
a120: 73 20 70 72 65 73 65 6e 74 20 61 6e 64 0d 0a 20 s present and..
a130: 2a 20 20 20 20 20 20 20 20 72 65 61 64 61 62 6c * readabl
a140: 65 2c 20 6f 72 20 74 68 65 20 63 61 62 69 6e 65 e, or the cabine
a150: 74 20 66 69 6c 65 20 68 61 73 20 62 65 65 6e 20 t file has been
a160: 64 61 6d 61 67 65 64 2c 20 70 66 64 69 6e 2d 3e damaged, pfdin->
a170: 66 64 69 65 20 77 69 6c 6c 0d 0a 20 2a 20 20 20 fdie will.. *
a180: 20 20 20 20 20 72 65 63 65 69 76 65 20 6f 74 68 receive oth
a190: 65 72 20 61 70 70 72 6f 70 72 69 61 74 65 20 65 er appropriate e
a1a0: 72 72 6f 72 20 63 6f 64 65 73 3a 0d 0a 20 2a 0d rror codes:.. *.
a1b0: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 . *
a1c0: 20 46 44 49 45 52 52 4f 52 5f 43 41 42 49 4e 45 FDIERROR_CABINE
a1d0: 54 5f 4e 4f 54 5f 46 4f 55 4e 44 0d 0a 20 2a 20 T_NOT_FOUND.. *
a1e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 46 44 49 FDI
a1f0: 45 52 52 4f 52 5f 4e 4f 54 5f 41 5f 43 41 42 49 ERROR_NOT_A_CABI
a200: 4e 45 54 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 NET.. *
a210: 20 20 20 20 20 46 44 49 45 52 52 4f 52 5f 55 4e FDIERROR_UN
a220: 4b 4e 4f 57 4e 5f 43 41 42 49 4e 45 54 5f 56 45 KNOWN_CABINET_VE
a230: 52 53 49 4f 4e 0d 0a 20 2a 20 20 20 20 20 20 20 RSION.. *
a240: 20 20 20 20 20 20 20 46 44 49 45 52 52 4f 52 5f FDIERROR_
a250: 43 4f 52 52 55 50 54 5f 43 41 42 49 4e 45 54 0d CORRUPT_CABINET.
a260: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 . *
a270: 20 46 44 49 45 52 52 4f 52 5f 42 41 44 5f 43 4f FDIERROR_BAD_CO
a280: 4d 50 52 5f 54 59 50 45 0d 0a 20 2a 20 20 20 20 MPR_TYPE.. *
a290: 20 20 20 20 20 20 20 20 20 20 46 44 49 45 52 52 FDIERR
a2a0: 4f 52 5f 52 45 53 45 52 56 45 5f 4d 49 53 4d 41 OR_RESERVE_MISMA
a2b0: 54 43 48 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 TCH.. *
a2c0: 20 20 20 20 20 46 44 49 45 52 52 4f 52 5f 57 52 FDIERROR_WR
a2d0: 4f 4e 47 5f 43 41 42 49 4e 45 54 0d 0a 20 2a 0d ONG_CABINET.. *.
a2e0: 0a 20 2a 20 20 20 20 20 20 45 6e 74 72 79 3a 0d . * Entry:.
a2f0: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 . * pfd
a300: 69 6e 2d 3e 70 73 7a 31 20 3d 20 6e 61 6d 65 20 in->psz1 = name
a310: 6f 66 20 6e 65 78 74 20 63 61 62 69 6e 65 74 20 of next cabinet
a320: 77 68 65 72 65 20 63 75 72 72 65 6e 74 20 66 69 where current fi
a330: 6c 65 20 69 73 20 63 6f 6e 74 69 6e 75 65 64 0d le is continued.
a340: 0a 20 2a 20 20 20 20 20 20 20 20 20 20 70 66 64 . * pfd
a350: 69 6e 2d 3e 70 73 7a 32 20 3d 20 6e 61 6d 65 20 in->psz2 = name
a360: 6f 66 20 6e 65 78 74 20 64 69 73 6b 20 77 68 65 of next disk whe
a370: 72 65 20 63 75 72 72 65 6e 74 20 66 69 6c 65 20 re current file
a380: 69 73 20 63 6f 6e 74 69 6e 75 65 64 0d 0a 20 2a is continued.. *
a390: 20 20 20 20 20 20 20 20 20 20 70 66 64 69 6e 2d pfdin-
a3a0: 3e 70 73 7a 33 20 3d 20 63 61 62 69 6e 65 74 20 >psz3 = cabinet
a3b0: 70 61 74 68 20 6e 61 6d 65 3b 20 46 44 49 20 63 path name; FDI c
a3c0: 6f 6e 63 61 74 65 6e 61 74 65 73 20 70 73 7a 33 oncatenates psz3
a3d0: 20 77 69 74 68 20 70 73 7a 31 0d 0a 20 2a 20 20 with psz1.. *
a3e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a3f0: 20 20 20 20 20 20 20 20 74 6f 20 70 72 6f 64 75 to produ
a400: 63 65 20 74 68 65 20 66 75 6c 6c 79 2d 71 75 61 ce the fully-qua
a410: 6c 69 66 69 65 64 20 70 61 74 68 20 66 6f 72 20 lified path for
a420: 74 68 65 20 63 61 62 69 6e 65 74 0d 0a 20 2a 20 the cabinet.. *
a430: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a440: 20 20 20 20 20 20 20 20 20 66 69 6c 65 2e 20 20 file.
a450: 54 68 65 20 32 35 36 2d 62 79 74 65 20 62 75 66 The 256-byte buf
a460: 66 65 72 20 70 6f 69 6e 74 65 64 20 61 74 20 62 fer pointed at b
a470: 79 20 70 73 7a 33 20 6d 61 79 0d 0a 20 2a 20 20 y psz3 may.. *
a480: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a490: 20 20 20 20 20 20 20 20 62 65 20 6d 6f 64 69 66 be modif
a4a0: 69 65 64 2c 20 62 75 74 20 70 73 7a 31 20 6d 61 ied, but psz1 ma
a4b0: 79 20 6e 6f 74 21 0d 0a 20 2a 20 20 20 20 20 20 y not!.. *
a4c0: 20 20 20 20 70 66 64 69 6e 2d 3e 66 64 69 65 20 pfdin->fdie
a4d0: 3d 20 46 44 49 45 52 52 4f 52 5f 57 52 4f 4e 47 = FDIERROR_WRONG
a4e0: 5f 43 41 42 49 4e 45 54 20 69 66 20 74 68 65 20 _CABINET if the
a4f0: 70 72 65 76 69 6f 75 73 20 63 61 6c 6c 20 74 6f previous call to
a500: 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 .. *
a510: 20 20 20 20 20 20 20 20 20 20 20 20 66 64 69 6e fdin
a520: 74 4e 45 58 54 5f 43 41 42 49 4e 45 54 20 73 70 tNEXT_CABINET sp
a530: 65 63 69 66 69 65 64 20 61 20 63 61 62 69 6e 65 ecified a cabine
a540: 74 20 66 69 6c 65 20 74 68 61 74 0d 0a 20 2a 20 t file that.. *
a550: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a560: 20 20 20 20 20 20 20 64 69 64 20 6e 6f 74 20 6d did not m
a570: 61 74 63 68 20 74 68 65 20 73 65 74 49 44 2f 69 atch the setID/i
a580: 43 61 62 69 6e 65 74 20 74 68 61 74 20 77 61 73 Cabinet that was
a590: 20 65 78 70 65 63 74 65 64 2e 0d 0a 20 2a 20 20 expected... *
a5a0: 20 20 20 20 45 78 69 74 2d 53 75 63 63 65 73 73 Exit-Success
a5b0: 3a 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 52 :.. * R
a5c0: 65 74 75 72 6e 20 61 6e 79 74 68 69 6e 67 20 62 eturn anything b
a5d0: 75 74 20 2d 31 0d 0a 20 2a 20 20 20 20 20 20 45 ut -1.. * E
a5e0: 78 69 74 2d 46 61 69 6c 75 72 65 3a 0d 0a 20 2a xit-Failure:.. *
a5f0: 20 20 20 20 20 20 20 20 20 20 52 65 74 75 72 6e Return
a600: 73 20 2d 31 20 3d 3e 20 41 62 6f 72 74 20 46 44 s -1 => Abort FD
a610: 49 43 6f 70 79 28 29 20 63 61 6c 6c 0d 0a 20 2a ICopy() call.. *
a620: 20 20 20 20 20 20 4e 6f 74 65 73 3a 0d 0a 20 2a Notes:.. *
a630: 20 20 20 20 20 20 20 20 20 20 54 68 69 73 20 63 This c
a640: 61 6c 6c 20 69 73 20 61 6c 6d 6f 73 74 20 61 6c all is almost al
a650: 77 61 79 73 20 6d 61 64 65 20 77 68 65 6e 20 61 ways made when a
a660: 20 74 61 72 67 65 74 20 66 69 6c 65 20 69 73 20 target file is
a670: 6f 70 65 6e 20 61 6e 64 0d 0a 20 2a 20 20 20 20 open and.. *
a680: 20 20 20 20 20 20 62 65 69 6e 67 20 77 72 69 74 being writ
a690: 74 65 6e 20 74 6f 2c 20 61 6e 64 20 74 68 65 20 ten to, and the
a6a0: 6e 65 78 74 20 63 61 62 69 6e 65 74 20 69 73 20 next cabinet is
a6b0: 6e 65 65 64 65 64 20 74 6f 20 67 65 74 20 6d 6f needed to get mo
a6c0: 72 65 0d 0a 20 2a 20 20 20 20 20 20 20 20 20 20 re.. *
a6d0: 64 61 74 61 20 66 6f 72 20 74 68 65 20 66 69 6c data for the fil
a6e0: 65 2e 0d 0a 20 2a 2f 0d 0a 74 79 70 65 64 65 66 e... */..typedef
a6f0: 20 65 6e 75 6d 20 7b 0d 0a 20 20 20 20 66 64 69 enum {.. fdi
a700: 6e 74 43 41 42 49 4e 45 54 5f 49 4e 46 4f 2c 20 ntCABINET_INFO,
a710: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
a720: 47 65 6e 65 72 61 6c 20 69 6e 66 6f 72 6d 61 74 General informat
a730: 69 6f 6e 20 61 62 6f 75 74 20 63 61 62 69 6e 65 ion about cabine
a740: 74 0d 0a 20 20 20 20 66 64 69 6e 74 50 41 52 54 t.. fdintPART
a750: 49 41 4c 5f 46 49 4c 45 2c 20 20 20 20 20 20 20 IAL_FILE,
a760: 20 20 20 20 20 20 20 2f 2f 20 46 69 72 73 74 20 // First
a770: 66 69 6c 65 20 69 6e 20 63 61 62 69 6e 65 74 20 file in cabinet
a780: 69 73 20 63 6f 6e 74 69 6e 75 61 74 69 6f 6e 0d is continuation.
a790: 0a 20 20 20 20 66 64 69 6e 74 43 4f 50 59 5f 46 . fdintCOPY_F
a7a0: 49 4c 45 2c 20 20 20 20 20 20 20 20 20 20 20 20 ILE,
a7b0: 20 20 20 20 20 2f 2f 20 46 69 6c 65 20 74 6f 20 // File to
a7c0: 62 65 20 63 6f 70 69 65 64 0d 0a 20 20 20 20 66 be copied.. f
a7d0: 64 69 6e 74 43 4c 4f 53 45 5f 46 49 4c 45 5f 49 dintCLOSE_FILE_I
a7e0: 4e 46 4f 2c 20 20 20 20 20 20 20 20 20 20 20 2f NFO, /
a7f0: 2f 20 63 6c 6f 73 65 20 74 68 65 20 66 69 6c 65 / close the file
a800: 2c 20 73 65 74 20 72 65 6c 65 76 61 6e 74 20 69 , set relevant i
a810: 6e 66 6f 0d 0a 20 20 20 20 66 64 69 6e 74 4e 45 nfo.. fdintNE
a820: 58 54 5f 43 41 42 49 4e 45 54 2c 20 20 20 20 20 XT_CABINET,
a830: 20 20 20 20 20 20 20 20 20 2f 2f 20 46 69 6c 65 // File
a840: 20 63 6f 6e 74 69 6e 75 65 64 20 74 6f 20 6e 65 continued to ne
a850: 78 74 20 63 61 62 69 6e 65 74 0d 0a 20 20 20 20 xt cabinet..
a860: 66 64 69 6e 74 45 4e 55 4d 45 52 41 54 45 2c 20 fdintENUMERATE,
a870: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a880: 2f 2f 20 45 6e 75 6d 65 72 61 74 69 6f 6e 20 73 // Enumeration s
a890: 74 61 74 75 73 0d 0a 7d 20 46 44 49 4e 4f 54 49 tatus..} FDINOTI
a8a0: 46 49 43 41 54 49 4f 4e 54 59 50 45 3b 20 2f 2a FICATIONTYPE; /*
a8b0: 20 66 64 69 6e 74 20 2a 2f 0d 0a 0d 0a 74 79 70 fdint */....typ
a8c0: 65 64 65 66 20 69 6e 74 20 28 46 41 52 20 44 49 edef int (FAR DI
a8d0: 41 4d 4f 4e 44 41 50 49 20 2a 50 46 4e 46 44 49 AMONDAPI *PFNFDI
a8e0: 4e 4f 54 49 46 59 29 28 46 44 49 4e 4f 54 49 46 NOTIFY)(FDINOTIF
a8f0: 49 43 41 54 49 4f 4e 54 59 50 45 20 66 64 69 6e ICATIONTYPE fdin
a900: 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t,..
a910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 50 P
a930: 46 44 49 4e 4f 54 49 46 49 43 41 54 49 4f 4e 20 FDINOTIFICATION
a940: 20 20 20 70 66 64 69 6e 29 3b 20 2f 2a 20 70 66 pfdin); /* pf
a950: 6e 66 64 69 6e 20 2a 2f 0d 0a 0d 0a 23 64 65 66 nfdin */....#def
a960: 69 6e 65 20 46 4e 46 44 49 4e 4f 54 49 46 59 28 ine FNFDINOTIFY(
a970: 66 6e 29 20 69 6e 74 20 46 41 52 20 44 49 41 4d fn) int FAR DIAM
a980: 4f 4e 44 41 50 49 20 66 6e 28 46 44 49 4e 4f 54 ONDAPI fn(FDINOT
a990: 49 46 49 43 41 54 49 4f 4e 54 59 50 45 20 66 64 IFICATIONTYPE fd
a9a0: 69 6e 74 2c 20 5c 0d 0a 20 20 20 20 20 20 20 20 int, \..
a9b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a9c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a9d0: 20 20 20 20 20 20 50 46 44 49 4e 4f 54 49 46 49 PFDINOTIFI
a9e0: 43 41 54 49 4f 4e 20 20 20 20 70 66 64 69 6e 29 CATION pfdin)
a9f0: 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 63 70 75 54 79 ....../*** cpuTy
aa00: 70 65 20 76 61 6c 75 65 73 20 66 6f 72 20 46 44 pe values for FD
aa10: 49 43 72 65 61 74 65 28 29 0d 0a 20 2a 0d 0a 20 ICreate().. *..
aa20: 2a 20 20 28 49 67 6e 6f 72 65 64 20 62 79 20 33 * (Ignored by 3
aa30: 32 2d 62 69 74 20 46 44 49 2e 29 0d 0a 20 2a 2f 2-bit FDI.).. */
aa40: 0d 0a 23 64 65 66 69 6e 65 20 20 20 20 20 63 70 ..#define cp
aa50: 75 55 4e 4b 4e 4f 57 4e 20 20 20 20 20 20 20 20 uUNKNOWN
aa60: 20 28 2d 31 29 20 20 20 20 2f 2a 20 46 44 49 20 (-1) /* FDI
aa70: 64 6f 65 73 20 64 65 74 65 63 74 69 6f 6e 20 2a does detection *
aa80: 2f 0d 0a 23 64 65 66 69 6e 65 20 20 20 20 20 63 /..#define c
aa90: 70 75 38 30 32 38 36 20 20 20 20 20 20 20 20 20 pu80286
aaa0: 20 20 28 30 29 20 20 20 20 20 2f 2a 20 27 32 38 (0) /* '28
aab0: 36 20 6f 70 63 6f 64 65 73 20 6f 6e 6c 79 20 2a 6 opcodes only *
aac0: 2f 0d 0a 23 64 65 66 69 6e 65 20 20 20 20 20 63 /..#define c
aad0: 70 75 38 30 33 38 36 20 20 20 20 20 20 20 20 20 pu80386
aae0: 20 20 28 31 29 20 20 20 20 20 2f 2a 20 27 33 38 (1) /* '38
aaf0: 36 20 6f 70 63 6f 64 65 73 20 75 73 65 64 20 2a 6 opcodes used *
ab00: 2f 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 /....../*** F
ab10: 44 49 43 72 65 61 74 65 20 2d 20 43 72 65 61 74 DICreate - Creat
ab20: 65 20 61 6e 20 46 44 49 20 63 6f 6e 74 65 78 74 e an FDI context
ab30: 0d 0a 20 2a 0d 0a 20 2a 20 20 45 6e 74 72 79 3a .. *.. * Entry:
ab40: 0d 0a 20 2a 20 20 20 20 20 20 70 66 6e 61 6c 6c .. * pfnall
ab50: 6f 63 0d 0a 20 2a 20 20 20 20 20 20 70 66 6e 66 oc.. * pfnf
ab60: 72 65 65 0d 0a 20 2a 20 20 20 20 20 20 70 66 6e ree.. * pfn
ab70: 6f 70 65 6e 0d 0a 20 2a 20 20 20 20 20 20 70 66 open.. * pf
ab80: 6e 72 65 61 64 0d 0a 20 2a 20 20 20 20 20 20 70 nread.. * p
ab90: 66 6e 77 72 69 74 65 0d 0a 20 2a 20 20 20 20 20 fnwrite.. *
aba0: 20 70 66 6e 63 6c 6f 73 65 0d 0a 20 2a 20 20 20 pfnclose.. *
abb0: 20 20 20 70 66 6e 6c 73 65 65 6b 0d 0a 20 2a 20 pfnlseek.. *
abc0: 20 20 20 20 20 63 70 75 54 79 70 65 20 20 2d 20 cpuType -
abd0: 53 65 6c 65 63 74 20 43 50 55 20 74 79 70 65 20 Select CPU type
abe0: 28 61 75 74 6f 2d 64 65 74 65 63 74 2c 20 32 38 (auto-detect, 28
abf0: 36 2c 20 6f 72 20 33 38 36 2b 29 0d 0a 20 2a 20 6, or 386+).. *
ac00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ac10: 4e 4f 54 45 3a 20 46 6f 72 20 74 68 65 20 33 32 NOTE: For the 32
ac20: 2d 62 69 74 20 46 44 49 2e 4c 49 42 2c 20 74 68 -bit FDI.LIB, th
ac30: 69 73 20 70 61 72 61 6d 65 74 65 72 20 69 73 20 is parameter is
ac40: 69 67 6e 6f 72 65 64 21 0d 0a 20 2a 20 20 20 20 ignored!.. *
ac50: 20 20 70 65 72 66 0d 0a 20 2a 0d 0a 20 2a 20 20 perf.. *.. *
ac60: 45 78 69 74 2d 53 75 63 63 65 73 73 3a 0d 0a 20 Exit-Success:..
ac70: 2a 20 20 20 20 20 20 52 65 74 75 72 6e 73 20 6e * Returns n
ac80: 6f 6e 2d 4e 55 4c 4c 20 46 44 49 20 63 6f 6e 74 on-NULL FDI cont
ac90: 65 78 74 20 68 61 6e 64 6c 65 2e 0d 0a 20 2a 0d ext handle... *.
aca0: 0a 20 2a 20 20 45 78 69 74 2d 46 61 69 6c 75 72 . * Exit-Failur
acb0: 65 3a 0d 0a 20 2a 20 20 20 20 20 20 52 65 74 75 e:.. * Retu
acc0: 72 6e 73 20 4e 55 4c 4c 3b 20 70 65 72 66 20 66 rns NULL; perf f
acd0: 69 6c 6c 65 64 20 69 6e 20 77 69 74 68 20 65 72 illed in with er
ace0: 72 6f 72 20 63 6f 64 65 0d 0a 20 2a 0d 0a 20 2a ror code.. *.. *
acf0: 2f 0d 0a 48 46 44 49 20 46 41 52 20 44 49 41 4d /..HFDI FAR DIAM
ad00: 4f 4e 44 41 50 49 20 46 44 49 43 72 65 61 74 65 ONDAPI FDICreate
ad10: 28 50 46 4e 41 4c 4c 4f 43 20 70 66 6e 61 6c 6c (PFNALLOC pfnall
ad20: 6f 63 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 oc,..
ad30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ad40: 20 20 20 50 46 4e 46 52 45 45 20 20 70 66 6e 66 PFNFREE pfnf
ad50: 72 65 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ree,..
ad60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ad70: 20 20 20 20 50 46 4e 4f 50 45 4e 20 20 70 66 6e PFNOPEN pfn
ad80: 6f 70 65 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 open,..
ad90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ada0: 20 20 20 20 20 50 46 4e 52 45 41 44 20 20 70 66 PFNREAD pf
adb0: 6e 72 65 61 64 2c 0d 0a 20 20 20 20 20 20 20 20 nread,..
adc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
add0: 20 20 20 20 20 20 50 46 4e 57 52 49 54 45 20 70 PFNWRITE p
ade0: 66 6e 77 72 69 74 65 2c 0d 0a 20 20 20 20 20 20 fnwrite,..
adf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ae00: 20 20 20 20 20 20 20 20 50 46 4e 43 4c 4f 53 45 PFNCLOSE
ae10: 20 70 66 6e 63 6c 6f 73 65 2c 0d 0a 20 20 20 20 pfnclose,..
ae20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ae30: 20 20 20 20 20 20 20 20 20 20 50 46 4e 53 45 45 PFNSEE
ae40: 4b 20 20 70 66 6e 73 65 65 6b 2c 0d 0a 20 20 20 K pfnseek,..
ae50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ae60: 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 20 int
ae70: 20 20 20 20 63 70 75 54 79 70 65 2c 0d 0a 20 20 cpuType,..
ae80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ae90: 20 20 20 20 20 20 20 20 20 20 20 20 50 45 52 46 PERF
aea0: 20 20 20 20 20 70 65 72 66 29 3b 0d 0a 0d 0a 0d perf);.....
aeb0: 0a 2f 2a 2a 2a 20 20 20 20 46 44 49 49 73 43 61 ./*** FDIIsCa
aec0: 62 69 6e 65 74 20 2d 20 44 65 74 65 72 6d 69 6e binet - Determin
aed0: 65 73 20 69 66 20 66 69 6c 65 20 69 73 20 61 20 es if file is a
aee0: 63 61 62 69 6e 65 74 2c 20 72 65 74 75 72 6e 73 cabinet, returns
aef0: 20 69 6e 66 6f 20 69 66 20 69 74 20 69 73 0d 0a info if it is..
af00: 20 2a 0d 0a 20 2a 20 20 45 6e 74 72 79 3a 0d 0a *.. * Entry:..
af10: 20 2a 20 20 20 20 20 20 68 66 64 69 20 20 20 2d * hfdi -
af20: 20 48 61 6e 64 6c 65 20 74 6f 20 46 44 49 20 63 Handle to FDI c
af30: 6f 6e 74 65 78 74 20 28 63 72 65 61 74 65 64 20 ontext (created
af40: 62 79 20 46 44 49 43 72 65 61 74 65 28 29 29 0d by FDICreate()).
af50: 0a 20 2a 20 20 20 20 20 20 68 66 20 20 20 20 20 . * hf
af60: 2d 20 46 69 6c 65 20 68 61 6e 64 6c 65 20 73 75 - File handle su
af70: 69 74 61 62 6c 65 20 66 6f 72 20 50 46 4e 52 45 itable for PFNRE
af80: 41 44 2f 50 46 4e 53 45 45 4b 2c 20 70 6f 73 69 AD/PFNSEEK, posi
af90: 74 69 6f 6e 65 64 0d 0a 20 2a 20 20 20 20 20 20 tioned.. *
afa0: 20 20 20 20 20 20 20 20 20 61 74 20 6f 66 66 73 at offs
afb0: 65 74 20 30 20 69 6e 20 74 68 65 20 66 69 6c 65 et 0 in the file
afc0: 20 74 6f 20 74 65 73 74 2e 0d 0a 20 2a 20 20 20 to test... *
afd0: 20 20 20 70 66 64 69 63 69 20 2d 20 42 75 66 66 pfdici - Buff
afe0: 65 72 20 74 6f 20 72 65 63 65 69 76 65 20 69 6e er to receive in
aff0: 66 6f 20 61 62 6f 75 74 20 63 61 62 69 6e 65 74 fo about cabinet
b000: 20 69 66 20 69 74 20 69 73 20 6f 6e 65 2e 0d 0a if it is one...
b010: 20 2a 0d 0a 20 2a 20 20 45 78 69 74 2d 53 75 63 *.. * Exit-Suc
b020: 63 65 73 73 3a 0d 0a 20 2a 20 20 20 20 20 20 52 cess:.. * R
b030: 65 74 75 72 6e 73 20 54 52 55 45 3b 20 66 69 6c eturns TRUE; fil
b040: 65 20 69 73 20 61 20 63 61 62 69 6e 65 74 2c 20 e is a cabinet,
b050: 70 66 64 69 63 69 20 66 69 6c 6c 65 64 20 69 6e pfdici filled in
b060: 2e 0d 0a 20 2a 0d 0a 20 2a 20 20 45 78 69 74 2d ... *.. * Exit-
b070: 46 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 Failure:.. *
b080: 20 20 52 65 74 75 72 6e 73 20 46 41 4c 53 45 2c Returns FALSE,
b090: 20 66 69 6c 65 20 69 73 20 6e 6f 74 20 61 20 63 file is not a c
b0a0: 61 62 69 6e 65 74 3b 20 20 49 66 20 61 6e 20 65 abinet; If an e
b0b0: 72 72 6f 72 20 6f 63 63 75 72 72 65 64 2c 0d 0a rror occurred,..
b0c0: 20 2a 20 20 20 20 20 20 20 20 20 20 70 65 72 66 * perf
b0d0: 20 28 70 61 73 73 65 64 20 6f 6e 20 46 44 49 43 (passed on FDIC
b0e0: 72 65 61 74 65 20 63 61 6c 6c 21 29 20 66 69 6c reate call!) fil
b0f0: 6c 65 64 20 69 6e 20 77 69 74 68 20 65 72 72 6f led in with erro
b100: 72 2e 0d 0a 20 2a 2f 0d 0a 42 4f 4f 4c 20 46 41 r... */..BOOL FA
b110: 52 20 44 49 41 4d 4f 4e 44 41 50 49 20 46 44 49 R DIAMONDAPI FDI
b120: 49 73 43 61 62 69 6e 65 74 28 48 46 44 49 20 20 IsCabinet(HFDI
b130: 20 20 20 20 20 20 20 20 20 20 68 66 64 69 2c 0d hfdi,.
b140: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
b150: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b160: 20 20 69 6e 74 20 20 20 20 20 20 20 20 20 20 20 int
b170: 20 20 68 66 2c 0d 0a 20 20 20 20 20 20 20 20 20 hf,..
b180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b190: 20 20 20 20 20 20 20 20 50 46 44 49 43 41 42 49 PFDICABI
b1a0: 4e 45 54 49 4e 46 4f 20 70 66 64 69 63 69 29 3b NETINFO pfdici);
b1b0: 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 46 44 ....../*** FD
b1c0: 49 43 6f 70 79 20 2d 20 65 78 74 72 61 63 74 73 ICopy - extracts
b1d0: 20 66 69 6c 65 73 20 66 72 6f 6d 20 61 20 63 61 files from a ca
b1e0: 62 69 6e 65 74 0d 0a 20 2a 0d 0a 20 2a 20 20 45 binet.. *.. * E
b1f0: 6e 74 72 79 3a 0d 0a 20 2a 20 20 20 20 20 20 68 ntry:.. * h
b200: 66 64 69 20 20 20 20 20 20 20 20 2d 20 68 61 6e fdi - han
b210: 64 6c 65 20 74 6f 20 46 44 49 20 63 6f 6e 74 65 dle to FDI conte
b220: 78 74 20 28 63 72 65 61 74 65 64 20 62 79 20 46 xt (created by F
b230: 44 49 43 72 65 61 74 65 28 29 29 0d 0a 20 2a 20 DICreate()).. *
b240: 20 20 20 20 20 70 73 7a 43 61 62 69 6e 65 74 20 pszCabinet
b250: 20 2d 20 6d 61 69 6e 20 6e 61 6d 65 20 6f 66 20 - main name of
b260: 63 61 62 69 6e 65 74 20 66 69 6c 65 0d 0a 20 2a cabinet file.. *
b270: 20 20 20 20 20 20 70 73 7a 43 61 62 50 61 74 68 pszCabPath
b280: 20 20 2d 20 50 61 74 68 20 74 6f 20 63 61 62 69 - Path to cabi
b290: 6e 65 74 20 66 69 6c 65 28 73 29 0d 0a 20 2a 20 net file(s).. *
b2a0: 20 20 20 20 20 66 6c 61 67 73 20 20 20 20 20 20 flags
b2b0: 20 2d 20 46 6c 61 67 73 20 74 6f 20 6d 6f 64 69 - Flags to modi
b2c0: 66 79 20 62 65 68 61 76 69 6f 72 0d 0a 20 2a 20 fy behavior.. *
b2d0: 20 20 20 20 20 70 66 6e 66 64 69 6e 20 20 20 20 pfnfdin
b2e0: 20 2d 20 4e 6f 74 69 66 69 63 61 74 69 6f 6e 20 - Notification
b2f0: 66 75 6e 63 74 69 6f 6e 0d 0a 20 2a 20 20 20 20 function.. *
b300: 20 20 70 66 6e 66 64 69 64 20 20 20 20 20 2d 20 pfnfdid -
b310: 44 65 63 72 79 70 74 69 6f 6e 20 66 75 6e 63 74 Decryption funct
b320: 69 6f 6e 20 28 70 61 73 73 20 4e 55 4c 4c 20 69 ion (pass NULL i
b330: 66 20 6e 6f 74 20 75 73 65 64 29 0d 0a 20 2a 20 f not used).. *
b340: 20 20 20 20 20 70 76 55 73 65 72 20 20 20 20 20 pvUser
b350: 20 2d 20 55 73 65 72 20 73 70 65 63 69 66 69 65 - User specifie
b360: 64 20 76 61 6c 75 65 20 74 6f 20 70 61 73 73 20 d value to pass
b370: 74 6f 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 20 to notification
b380: 66 75 6e 63 74 69 6f 6e 0d 0a 20 2a 0d 0a 20 2a function.. *.. *
b390: 20 20 45 78 69 74 2d 53 75 63 63 65 73 73 3a 0d Exit-Success:.
b3a0: 0a 20 2a 20 20 20 20 20 20 52 65 74 75 72 6e 73 . * Returns
b3b0: 20 54 52 55 45 3b 0d 0a 20 2a 0d 0a 20 2a 20 20 TRUE;.. *.. *
b3c0: 45 78 69 74 2d 46 61 69 6c 75 72 65 3a 0d 0a 20 Exit-Failure:..
b3d0: 2a 20 20 20 20 20 20 52 65 74 75 72 6e 73 20 46 * Returns F
b3e0: 41 4c 53 45 2c 20 70 65 72 66 20 28 70 61 73 73 ALSE, perf (pass
b3f0: 65 64 20 6f 6e 20 46 44 49 43 72 65 61 74 65 20 ed on FDICreate
b400: 63 61 6c 6c 21 29 20 66 69 6c 6c 65 64 20 69 6e call!) filled in
b410: 20 77 69 74 68 0d 0a 20 2a 20 20 20 20 20 20 20 with.. *
b420: 20 20 20 65 72 72 6f 72 2e 0d 0a 20 2a 0d 0a 20 error... *..
b430: 2a 20 20 4e 6f 74 65 73 3a 0d 0a 20 2a 20 20 28 * Notes:.. * (
b440: 31 29 20 49 66 20 46 44 49 43 6f 70 79 28 29 20 1) If FDICopy()
b450: 66 61 69 6c 73 20 77 68 69 6c 65 20 61 20 74 61 fails while a ta
b460: 72 67 65 74 20 66 69 6c 65 20 69 73 20 62 65 69 rget file is bei
b470: 6e 67 20 77 72 69 74 74 65 6e 20 6f 75 74 2c 20 ng written out,
b480: 74 68 65 6e 0d 0a 20 2a 20 20 20 20 20 20 46 44 then.. * FD
b490: 49 20 77 69 6c 6c 20 75 73 65 20 74 68 65 20 50 I will use the P
b4a0: 46 4e 43 4c 4f 53 45 20 66 75 6e 63 74 69 6f 6e FNCLOSE function
b4b0: 20 74 6f 20 63 6c 6f 73 65 20 74 68 65 20 66 69 to close the fi
b4c0: 6c 65 20 68 61 6e 64 6c 65 20 66 6f 72 20 74 68 le handle for th
b4d0: 61 74 0d 0a 20 2a 20 20 20 20 20 20 74 61 72 67 at.. * targ
b4e0: 65 74 20 66 69 6c 65 20 74 68 61 74 20 77 61 73 et file that was
b4f0: 20 72 65 74 75 72 6e 65 64 20 66 72 6f 6d 20 74 returned from t
b500: 68 65 20 66 64 69 6e 74 43 4f 50 59 5f 46 49 4c he fdintCOPY_FIL
b510: 45 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 2e 0d E notification..
b520: 0a 20 2a 20 20 20 20 20 20 54 68 65 20 63 6c 69 . * The cli
b530: 65 6e 74 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 ent application
b540: 69 73 20 74 68 65 6e 20 66 72 65 65 20 74 6f 20 is then free to
b550: 64 65 6c 65 74 65 20 74 68 65 20 74 61 72 67 65 delete the targe
b560: 74 20 66 69 6c 65 2c 20 73 69 6e 63 65 0d 0a 20 t file, since..
b570: 2a 20 20 20 20 20 20 69 74 20 77 69 6c 6c 20 6e * it will n
b580: 6f 74 20 62 65 20 69 6e 20 61 20 76 61 6c 69 64 ot be in a valid
b590: 20 73 74 61 74 65 20 28 73 69 6e 63 65 20 74 68 state (since th
b5a0: 65 72 65 20 77 61 73 20 61 6e 20 65 72 72 6f 72 ere was an error
b5b0: 20 77 68 69 6c 65 0d 0a 20 2a 20 20 20 20 20 20 while.. *
b5c0: 77 72 69 74 69 6e 67 20 69 74 20 6f 75 74 29 2e writing it out).
b5d0: 0d 0a 20 2a 2f 0d 0a 42 4f 4f 4c 20 46 41 52 20 .. */..BOOL FAR
b5e0: 44 49 41 4d 4f 4e 44 41 50 49 20 46 44 49 43 6f DIAMONDAPI FDICo
b5f0: 70 79 28 48 46 44 49 20 20 20 20 20 20 20 20 20 py(HFDI
b600: 20 68 66 64 69 2c 0d 0a 20 20 20 20 20 20 20 20 hfdi,..
b610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b620: 20 20 20 20 63 68 61 72 20 46 41 52 20 20 20 20 char FAR
b630: 20 2a 70 73 7a 43 61 62 69 6e 65 74 2c 0d 0a 20 *pszCabinet,..
b640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b650: 20 20 20 20 20 20 20 20 20 20 20 63 68 61 72 20 char
b660: 46 41 52 20 20 20 20 20 2a 70 73 7a 43 61 62 50 FAR *pszCabP
b670: 61 74 68 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ath,..
b680: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b690: 20 20 69 6e 74 20 20 20 20 20 20 20 20 20 20 20 int
b6a0: 66 6c 61 67 73 2c 0d 0a 20 20 20 20 20 20 20 20 flags,..
b6b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b6c0: 20 20 20 20 50 46 4e 46 44 49 4e 4f 54 49 46 59 PFNFDINOTIFY
b6d0: 20 20 70 66 6e 66 64 69 6e 2c 0d 0a 20 20 20 20 pfnfdin,..
b6e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b6f0: 20 20 20 20 20 20 20 20 50 46 4e 46 44 49 44 45 PFNFDIDE
b700: 43 52 59 50 54 20 70 66 6e 66 64 69 64 2c 0d 0a CRYPT pfnfdid,..
b710: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b720: 20 20 20 20 20 20 20 20 20 20 20 20 76 6f 69 64 void
b730: 20 46 41 52 20 20 20 20 20 2a 70 76 55 73 65 72 FAR *pvUser
b740: 29 3b 0d 0a 0d 0a 0d 0a 2f 2a 2a 2a 20 20 20 20 );....../***
b750: 46 44 49 44 65 73 74 72 6f 79 20 2d 20 44 65 73 FDIDestroy - Des
b760: 74 72 6f 79 20 61 6e 20 46 44 49 20 63 6f 6e 74 troy an FDI cont
b770: 65 78 74 0d 0a 20 2a 0d 0a 20 2a 20 20 45 6e 74 ext.. *.. * Ent
b780: 72 79 3a 0d 0a 20 2a 20 20 20 20 20 20 68 66 64 ry:.. * hfd
b790: 69 20 2d 20 68 61 6e 64 6c 65 20 74 6f 20 46 44 i - handle to FD
b7a0: 49 20 63 6f 6e 74 65 78 74 20 28 63 72 65 61 74 I context (creat
b7b0: 65 64 20 62 79 20 46 44 49 43 72 65 61 74 65 28 ed by FDICreate(
b7c0: 29 29 0d 0a 20 2a 0d 0a 20 2a 20 20 45 78 69 74 )).. *.. * Exit
b7d0: 2d 53 75 63 63 65 73 73 3a 0d 0a 20 2a 20 20 20 -Success:.. *
b7e0: 20 20 20 52 65 74 75 72 6e 73 20 54 52 55 45 3b Returns TRUE;
b7f0: 0d 0a 20 2a 0d 0a 20 2a 20 20 45 78 69 74 2d 46 .. *.. * Exit-F
b800: 61 69 6c 75 72 65 3a 0d 0a 20 2a 20 20 20 20 20 ailure:.. *
b810: 20 52 65 74 75 72 6e 73 20 46 41 4c 53 45 3b 0d Returns FALSE;.
b820: 0a 20 2a 2f 0d 0a 42 4f 4f 4c 20 46 41 52 20 44 . */..BOOL FAR D
b830: 49 41 4d 4f 4e 44 41 50 49 20 46 44 49 44 65 73 IAMONDAPI FDIDes
b840: 74 72 6f 79 28 48 46 44 49 20 68 66 64 69 29 3b troy(HFDI hfdi);
b850: 0d 0a 0d 0a 0d 0a 2f 2f 2a 2a 20 52 65 76 65 72 ......//** Rever
b860: 74 20 74 6f 20 64 65 66 61 75 6c 74 20 73 74 72 t to default str
b870: 75 63 74 75 72 65 20 70 61 63 6b 69 6e 67 0d 0a ucture packing..
b880: 23 70 72 61 67 6d 61 20 70 61 63 6b 28 29 0d 0a #pragma pack()..
b890: 0d 0a 23 65 6e 64 69 66 20 2f 2f 20 21 49 4e 43 ..#endif // !INC
b8a0: 4c 55 44 45 44 5f 46 44 49 0d 0a 0d 0a 23 69 66 LUDED_FDI....#if
b8b0: 64 65 66 20 20 5f 5f 63 70 6c 75 73 70 6c 75 73 def __cplusplus
b8c0: 0d 0a 7d 0d 0a 23 65 6e 64 69 66 0d 0a ..}..#endif..