libmspack

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Macros
mspack.h
Go to the documentation of this file.
1 /* libmspack -- a library for working with Microsoft compression formats.
2 * (C) 2003-2013 Stuart Caie <kyzer@4u.net>
3 *
4 * libmspack is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License (LGPL) version 2.1
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
158 #ifndef LIB_MSPACK_H
159 #define LIB_MSPACK_H 1
160
161 #ifdef __cplusplus
162 extern "C" {
163 #endif
164
165 #include <sys/types.h>
166 #include <stdlib.h>
167
191 #define MSPACK_SYS_SELFTEST(result) do { \
192 (result) = mspack_sys_selftest_internal(sizeof(off_t)); \
193 } while (0)
194
196 extern int mspack_sys_selftest_internal(int);
197
229 extern int mspack_version(int entity);
230
232 #define MSPACK_VER_LIBRARY (0)
233
234 #define MSPACK_VER_SYSTEM (1)
235
236 #define MSPACK_VER_MSCABD (2)
237
238 #define MSPACK_VER_MSCABC (3)
239
240 #define MSPACK_VER_MSCHMD (4)
241
242 #define MSPACK_VER_MSCHMC (5)
243
244 #define MSPACK_VER_MSLITD (6)
245
246 #define MSPACK_VER_MSLITC (7)
247
248 #define MSPACK_VER_MSHLPD (8)
249
250 #define MSPACK_VER_MSHLPC (9)
251
252 #define MSPACK_VER_MSSZDDD (10)
253
254 #define MSPACK_VER_MSSZDDC (11)
255
256 #define MSPACK_VER_MSKWAJD (12)
257
258 #define MSPACK_VER_MSKWAJC (13)
259
260 #define MSPACK_VER_MSOABD (14)
261
262 #define MSPACK_VER_MSOABC (15)
263
264 /* --- file I/O abstraction ------------------------------------------------ */
265
285 struct mspack_system {
310 struct mspack_file * (*open)(struct mspack_system *self,
311 const char *filename,
312 int mode);
313
321 void (*close)(struct mspack_file *file);
322
334 int (*read)(struct mspack_file *file,
335 void *buffer,
336 int bytes);
337
351 int (*write)(struct mspack_file *file,
352 void *buffer,
353 int bytes);
354
378 int (*seek)(struct mspack_file *file,
379 off_t offset,
380 int mode);
381
389 off_t (*tell)(struct mspack_file *file);
390
405 void (*message)(struct mspack_file *file,
406 const char *format,
407 ...);
408
419 void * (*alloc)(struct mspack_system *self,
420 size_t bytes);
421
428 void (*free)(void *ptr);
429
442 void (*copy)(void *src,
443 void *dest,
444 size_t bytes);
445
452 void *null_ptr;
453 };
454
456 #define MSPACK_SYS_OPEN_READ (0)
457
458 #define MSPACK_SYS_OPEN_WRITE (1)
459
460 #define MSPACK_SYS_OPEN_UPDATE (2)
461
462 #define MSPACK_SYS_OPEN_APPEND (3)
463
465 #define MSPACK_SYS_SEEK_START (0)
466
467 #define MSPACK_SYS_SEEK_CUR (1)
468
469 #define MSPACK_SYS_SEEK_END (2)
470
476 struct mspack_file {
477 int dummy;
478 };
479
480 /* --- error codes --------------------------------------------------------- */
481
483 #define MSPACK_ERR_OK (0)
484
485 #define MSPACK_ERR_ARGS (1)
486
487 #define MSPACK_ERR_OPEN (2)
488
489 #define MSPACK_ERR_READ (3)
490
491 #define MSPACK_ERR_WRITE (4)
492
493 #define MSPACK_ERR_SEEK (5)
494
495 #define MSPACK_ERR_NOMEMORY (6)
496
497 #define MSPACK_ERR_SIGNATURE (7)
498
499 #define MSPACK_ERR_DATAFORMAT (8)
500
501 #define MSPACK_ERR_CHECKSUM (9)
502
503 #define MSPACK_ERR_CRUNCH (10)
504
505 #define MSPACK_ERR_DECRUNCH (11)
506
507 /* --- functions available in library -------------------------------------- */
508
513 extern struct mscab_compressor *
514 mspack_create_cab_compressor(struct mspack_system *sys);
515
520 extern struct mscab_decompressor *
521 mspack_create_cab_decompressor(struct mspack_system *sys);
522
526 extern void mspack_destroy_cab_compressor(struct mscab_compressor *self);
527
531 extern void mspack_destroy_cab_decompressor(struct mscab_decompressor *self);
532
533
538 extern struct mschm_compressor *
539 mspack_create_chm_compressor(struct mspack_system *sys);
540
545 extern struct mschm_decompressor *
546 mspack_create_chm_decompressor(struct mspack_system *sys);
547
551 extern void mspack_destroy_chm_compressor(struct mschm_compressor *self);
552
556 extern void mspack_destroy_chm_decompressor(struct mschm_decompressor *self);
557
558
563 extern struct mslit_compressor *
564 mspack_create_lit_compressor(struct mspack_system *sys);
565
570 extern struct mslit_decompressor *
571 mspack_create_lit_decompressor(struct mspack_system *sys);
572
576 extern void mspack_destroy_lit_compressor(struct mslit_compressor *self);
577
581 extern void mspack_destroy_lit_decompressor(struct mslit_decompressor *self);
582
583
588 extern struct mshlp_compressor *
589 mspack_create_hlp_compressor(struct mspack_system *sys);
590
595 extern struct mshlp_decompressor *
596 mspack_create_hlp_decompressor(struct mspack_system *sys);
597
601 extern void mspack_destroy_hlp_compressor(struct mshlp_compressor *self);
602
606 extern void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *self);
607
608
613 extern struct msszdd_compressor *
614 mspack_create_szdd_compressor(struct mspack_system *sys);
615
620 extern struct msszdd_decompressor *
621 mspack_create_szdd_decompressor(struct mspack_system *sys);
622
626 extern void mspack_destroy_szdd_compressor(struct msszdd_compressor *self);
627
631 extern void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *self);
632
633
638 extern struct mskwaj_compressor *
639 mspack_create_kwaj_compressor(struct mspack_system *sys);
640
645 extern struct mskwaj_decompressor *
646 mspack_create_kwaj_decompressor(struct mspack_system *sys);
647
651 extern void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self);
652
656 extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self);
657
658
663 extern struct msoab_compressor *
664 mspack_create_oab_compressor(struct mspack_system *sys);
665
670 extern struct msoab_decompressor *
671 mspack_create_oab_decompressor(struct mspack_system *sys);
672
676 extern void mspack_destroy_oab_compressor(struct msoab_compressor *self);
677
681 extern void mspack_destroy_oab_decompressor(struct msoab_decompressor *self);
682
683
684 /* --- support for .CAB (MS Cabinet) file format --------------------------- */
685
697 struct mscabd_cabinet {
703 struct mscabd_cabinet *next;
704
710 const char *filename;
711
713 off_t base_offset;
714
716 unsigned int length;
717
719 struct mscabd_cabinet *prevcab;
720
722 struct mscabd_cabinet *nextcab;
723
725 char *prevname;
726
728 char *nextname;
729
733 char *previnfo;
734
738 char *nextinfo;
739
741 struct mscabd_file *files;
742
744 struct mscabd_folder *folders;
745
750 unsigned short set_id;
751
757 unsigned short set_index;
758
769 unsigned short header_resv;
770
782 int flags;
783 };
784
786 #define MSCAB_HDR_RESV_OFFSET (0x28)
787
789 #define MSCAB_HDR_PREVCAB (0x01)
790
791 #define MSCAB_HDR_NEXTCAB (0x02)
792
793 #define MSCAB_HDR_RESV (0x04)
794
804 struct mscabd_folder {
809 struct mscabd_folder *next;
810
820 int comp_type;
821
827 unsigned int num_blocks;
828 };
829
837 #define MSCABD_COMP_METHOD(comp_type) ((comp_type) & 0x0F)
838
845 #define MSCABD_COMP_LEVEL(comp_type) (((comp_type) >> 8) & 0x1F)
846
848 #define MSCAB_COMP_NONE (0)
849
850 #define MSCAB_COMP_MSZIP (1)
851
852 #define MSCAB_COMP_QUANTUM (2)
853
854 #define MSCAB_COMP_LZX (3)
855
861 struct mscabd_file {
866 struct mscabd_file *next;
867
876 char *filename;
877
879 unsigned int length;
880
893 int attribs;
894
896 char time_h;
898 char time_m;
900 char time_s;
901
903 char date_d;
905 char date_m;
907 int date_y;
908
910 struct mscabd_folder *folder;
911
913 unsigned int offset;
914 };
915
917 #define MSCAB_ATTRIB_RDONLY (0x01)
918
919 #define MSCAB_ATTRIB_HIDDEN (0x02)
920
921 #define MSCAB_ATTRIB_SYSTEM (0x04)
922
923 #define MSCAB_ATTRIB_ARCH (0x20)
924
925 #define MSCAB_ATTRIB_EXEC (0x40)
926
927 #define MSCAB_ATTRIB_UTF_NAME (0x80)
928
930 #define MSCABD_PARAM_SEARCHBUF (0)
931
932 #define MSCABD_PARAM_FIXMSZIP (1)
933
934 #define MSCABD_PARAM_DECOMPBUF (2)
935
937 struct mscab_compressor {
938 int dummy;
939 };
940
948 struct mscab_decompressor {
969 struct mscabd_cabinet * (*open) (struct mscab_decompressor *self,
970 const char *filename);
971
1001 void (*close)(struct mscab_decompressor *self,
1002 struct mscabd_cabinet *cab);
1003
1038 struct mscabd_cabinet * (*search) (struct mscab_decompressor *self,
1039 const char *filename);
1040
1081 int (*append) (struct mscab_decompressor *self,
1082 struct mscabd_cabinet *cab,
1083 struct mscabd_cabinet *nextcab);
1084
1103 int (*prepend) (struct mscab_decompressor *self,
1104 struct mscabd_cabinet *cab,
1105 struct mscabd_cabinet *prevcab);
1106
1129 int (*extract)(struct mscab_decompressor *self,
1130 struct mscabd_file *file,
1131 const char *filename);
1132
1155 int (*set_param)(struct mscab_decompressor *self,
1156 int param,
1157 int value);
1158
1170 int (*last_error)(struct mscab_decompressor *self);
1171 };
1172
1173 /* --- support for .CHM (HTMLHelp) file format ----------------------------- */
1174
1183 struct mschmc_file {
1185 int section;
1186
1189 const char *filename;
1190
1193 char *chm_filename;
1194
1198 off_t length;
1199 };
1200
1209 struct mschmd_section {
1211 struct mschmd_header *chm;
1212
1218 unsigned int id;
1219 };
1220
1226 struct mschmd_sec_uncompressed {
1228 struct mschmd_section base;
1229
1231 off_t offset;
1232 };
1233
1239 struct mschmd_sec_mscompressed {
1241 struct mschmd_section base;
1242
1244 struct mschmd_file *content;
1245
1247 struct mschmd_file *control;
1248
1250 struct mschmd_file *rtable;
1251
1255 struct mschmd_file *spaninfo;
1256 };
1257
1263 struct mschmd_header {
1265 unsigned int version;
1266
1274 unsigned int timestamp;
1275
1280 unsigned int language;
1281
1286 const char *filename;
1287
1289 off_t length;
1290
1292 struct mschmd_file *files;
1293
1300 struct mschmd_file *sysfiles;
1301
1303 struct mschmd_sec_uncompressed sec0;
1304
1306 struct mschmd_sec_mscompressed sec1;
1307
1309 off_t dir_offset;
1310
1312 unsigned int num_chunks;
1313
1315 unsigned int chunk_size;
1316
1318 unsigned int density;
1319
1328 unsigned int depth;
1329
1335 unsigned int index_root;
1336
1341 unsigned int first_pmgl;
1342
1347 unsigned int last_pmgl;
1348
1353 unsigned char **chunk_cache;
1354 };
1355
1361 struct mschmd_file {
1366 struct mschmd_file *next;
1367
1372 struct mschmd_section *section;
1373
1375 off_t offset;
1376
1378 off_t length;
1379
1381 char *filename;
1382 };
1383
1385 #define MSCHMC_ENDLIST (0)
1386
1387 #define MSCHMC_UNCOMP (1)
1388
1389 #define MSCHMC_MSCOMP (2)
1390
1392 #define MSCHMC_PARAM_TIMESTAMP (0)
1393
1394 #define MSCHMC_PARAM_LANGUAGE (1)
1395
1396 #define MSCHMC_PARAM_LZXWINDOW (2)
1397
1398 #define MSCHMC_PARAM_DENSITY (3)
1399
1400 #define MSCHMC_PARAM_INDEX (4)
1401
1409 struct mschm_compressor {
1441 int (*generate)(struct mschm_compressor *self,
1442 struct mschmc_file file_list[],
1443 const char *output_file);
1444
1498 int (*use_temporary_file)(struct mschm_compressor *self,
1499 int use_temp_file,
1500 const char *temp_file);
1546 int (*set_param)(struct mschm_compressor *self,
1547 int param,
1548 unsigned int value);
1549
1558 int (*last_error)(struct mschm_compressor *self);
1559 };
1560
1568 struct mschm_decompressor {
1589 struct mschmd_header *(*open)(struct mschm_decompressor *self,
1590 const char *filename);
1591
1609 void (*close)(struct mschm_decompressor *self,
1610 struct mschmd_header *chm);
1611
1630 int (*extract)(struct mschm_decompressor *self,
1631 struct mschmd_file *file,
1632 const char *filename);
1633
1645 int (*last_error)(struct mschm_decompressor *self);
1646
1669 struct mschmd_header *(*fast_open)(struct mschm_decompressor *self,
1670 const char *filename);
1671
1710 int (*fast_find)(struct mschm_decompressor *self,
1711 struct mschmd_header *chm,
1712 const char *filename,
1713 struct mschmd_file *f_ptr,
1714 int f_size);
1715 };
1716
1717 /* --- support for .LIT (EBook) file format -------------------------------- */
1718
1720 struct mslit_compressor {
1721 int dummy;
1722 };
1723
1725 struct mslit_decompressor {
1726 int dummy;
1727 };
1728
1729
1730 /* --- support for .HLP (MS Help) file format ------------------------------ */
1731
1733 struct mshlp_compressor {
1734 int dummy;
1735 };
1736
1738 struct mshlp_decompressor {
1739 int dummy;
1740 };
1741
1742
1743 /* --- support for SZDD file format ---------------------------------------- */
1744
1746 #define MSSZDDC_PARAM_MISSINGCHAR (0)
1747
1749 #define MSSZDD_FMT_NORMAL (0)
1750
1752 #define MSSZDD_FMT_QBASIC (1)
1753
1759 struct msszddd_header {
1761 int format;
1762
1764 off_t length;
1765
1773 char missing_char;
1774 };
1775
1783 struct msszdd_compressor {
1819 int (*compress)(struct msszdd_compressor *self,
1820 const char *input,
1821 const char *output,
1822 off_t length);
1823
1845 int (*set_param)(struct msszdd_compressor *self,
1846 int param,
1847 unsigned int value);
1848
1857 int (*last_error)(struct mschm_decompressor *self);
1858 };
1859
1867 struct msszdd_decompressor {
1887 struct msszddd_header *(*open)(struct msszdd_decompressor *self,
1888 const char *filename);
1889
1903 void (*close)(struct msszdd_decompressor *self,
1904 struct msszddd_header *szdd);
1905
1919 int (*extract)(struct msszdd_decompressor *self,
1920 struct msszddd_header *szdd,
1921 const char *filename);
1922
1940 int (*decompress)(struct msszdd_decompressor *self,
1941 const char *input,
1942 const char *output);
1943
1955 int (*last_error)(struct msszdd_decompressor *self);
1956 };
1957
1958 /* --- support for KWAJ file format ---------------------------------------- */
1959
1961 #define MSKWAJC_PARAM_COMP_TYPE (0)
1962
1966 #define MSKWAJC_PARAM_INCLUDE_LENGTH (1)
1967
1969 #define MSKWAJ_COMP_NONE (0)
1970
1971 #define MSKWAJ_COMP_XOR (1)
1972
1973 #define MSKWAJ_COMP_SZDD (2)
1974
1975 #define MSKWAJ_COMP_LZH (3)
1976
1977 #define MSKWAJ_COMP_MSZIP (4)
1978
1980 #define MSKWAJ_HDR_HASLENGTH (0x01)
1981
1983 #define MSKWAJ_HDR_HASUNKNOWN1 (0x02)
1984
1986 #define MSKWAJ_HDR_HASUNKNOWN2 (0x04)
1987
1989 #define MSKWAJ_HDR_HASFILENAME (0x08)
1990
1992 #define MSKWAJ_HDR_HASFILEEXT (0x10)
1993
1995 #define MSKWAJ_HDR_HASEXTRATEXT (0x20)
1996
2002 struct mskwajd_header {
2006 unsigned short comp_type;
2007
2009 off_t data_offset;
2010
2012 int headers;
2013
2015 off_t length;
2016
2018 char *filename;
2019
2023 char *extra;
2024
2026 unsigned short extra_length;
2027 };
2028
2036 struct mskwaj_compressor {
2055 int (*compress)(struct mskwaj_compressor *self,
2056 const char *input,
2057 const char *output,
2058 off_t length);
2059
2083 int (*set_param)(struct mskwaj_compressor *self,
2084 int param,
2085 unsigned int value);
2086
2087
2105 int (*set_filename)(struct mskwaj_compressor *self,
2106 const char *filename);
2107
2125 int (*set_extra_data)(struct mskwaj_compressor *self,
2126 void *data,
2127 size_t bytes);
2128
2137 int (*last_error)(struct mschm_decompressor *self);
2138 };
2139
2147 struct mskwaj_decompressor {
2167 struct mskwajd_header *(*open)(struct mskwaj_decompressor *self,
2168 const char *filename);
2169
2182 void (*close)(struct mskwaj_decompressor *self,
2183 struct mskwajd_header *kwaj);
2184
2198 int (*extract)(struct mskwaj_decompressor *self,
2199 struct mskwajd_header *kwaj,
2200 const char *filename);
2201
2219 int (*decompress)(struct mskwaj_decompressor *self,
2220 const char *input,
2221 const char *output);
2222
2234 int (*last_error)(struct mskwaj_decompressor *self);
2235 };
2236
2237 /* --- support for .LZX (Offline Address Book) file format ----------------- */
2238
2246 struct msoab_compressor {
2261 int (*compress) (struct msoab_compressor *self,
2262 const char *input,
2263 const char *output);
2264
2285 int (*compress_incremental) (struct msoab_compressor *self,
2286 const char *input,
2287 const char *base,
2288 const char *output);
2289 };
2290
2298 struct msoab_decompressor {
2314 int (*decompress) (struct msoab_decompressor *self,
2315 const char *input,
2316 const char *output);
2317
2343 int (*decompress_incremental) (struct msoab_decompressor *self,
2344 const char *input,
2345 const char *base,
2346 const char *output);
2347 };
2348
2349 #ifdef __cplusplus
2350 }
2351 #endif
2352
2353 #endif
msszdd_decompressor
A decompressor for SZDD compressed files.
Definition: mspack.h:1867
mscabd_file::offset
unsigned int offset
The uncompressed offset of this file in its folder.
Definition: mspack.h:913
msoab_compressor::compress_incremental
int(* compress_incremental)(struct msoab_compressor *self, const char *input, const char *base, const char *output)
Generate a compressed incremental OAB patch file.
Definition: mspack.h:2285
mspack_create_oab_decompressor
struct msoab_decompressor * mspack_create_oab_decompressor(struct mspack_system *sys)
Creates a new OAB decompressor.
mskwaj_compressor
A compressor for the KWAJ file format.
Definition: mspack.h:2036
mspack_create_szdd_compressor
struct msszdd_compressor * mspack_create_szdd_compressor(struct mspack_system *sys)
Creates a new SZDD compressor.
msszdd_decompressor::decompress
int(* decompress)(struct msszdd_decompressor *self, const char *input, const char *output)
Decompresses an SZDD file to an output file in one step.
Definition: mspack.h:1940
mspack_destroy_lit_compressor
void mspack_destroy_lit_compressor(struct mslit_compressor *self)
Destroys an existing LIT compressor.
mschm_decompressor::last_error
int(* last_error)(struct mschm_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:1645
mspack_system::seek
int(* seek)(struct mspack_file *file, off_t offset, int mode)
Seeks to a specific file offset within an open file.
Definition: mspack.h:378
mscab_decompressor::extract
int(* extract)(struct mscab_decompressor *self, struct mscabd_file *file, const char *filename)
Extracts a file from a cabinet or cabinet set.
Definition: mspack.h:1129
mspack_create_cab_compressor
struct mscab_compressor * mspack_create_cab_compressor(struct mspack_system *sys)
Creates a new CAB compressor.
mscabd_file::filename
char * filename
The filename of the file.
Definition: mspack.h:876
mskwaj_decompressor::close
void(* close)(struct mskwaj_decompressor *self, struct mskwajd_header *kwaj)
Closes a previously opened KWAJ file.
Definition: mspack.h:2182
mspack_create_chm_decompressor
struct mschm_decompressor * mspack_create_chm_decompressor(struct mspack_system *sys)
Creates a new CHM decompressor.
mspack_system::close
void(* close)(struct mspack_file *file)
Closes a previously opened file.
Definition: mspack.h:321
mschmd_file::offset
off_t offset
The offset within the section data that this file is located at.
Definition: mspack.h:1375
mspack_destroy_hlp_compressor
void mspack_destroy_hlp_compressor(struct mshlp_compressor *self)
Destroys an existing hlp compressor.
msszddd_header::missing_char
char missing_char
The last character in the filename, traditionally replaced with an underscore to show the file is com...
Definition: mspack.h:1773
mschmd_header::language
unsigned int language
The default Language and Country ID (LCID) of the user who ran the HTMLHelp Compiler.
Definition: mspack.h:1280
mschmc_file
A structure which represents a file to be placed in a CHM helpfile.
Definition: mspack.h:1183
mspack_file::dummy
int dummy
Definition: mspack.h:477
msoab_compressor::compress
int(* compress)(struct msoab_compressor *self, const char *input, const char *output)
Compress a full OAB file.
Definition: mspack.h:2261
mspack_create_szdd_decompressor
struct msszdd_decompressor * mspack_create_szdd_decompressor(struct mspack_system *sys)
Creates a new SZDD decompressor.
mskwaj_compressor::compress
int(* compress)(struct mskwaj_compressor *self, const char *input, const char *output, off_t length)
Reads an input file and creates a compressed output file in the KWAJ compressed file format...
Definition: mspack.h:2055
msoab_decompressor::decompress_incremental
int(* decompress_incremental)(struct msoab_decompressor *self, const char *input, const char *base, const char *output)
Decompresses an Offline Address Book with an incremental patch file.
Definition: mspack.h:2343
mscabd_cabinet::set_id
unsigned short set_id
The set ID of the cabinet.
Definition: mspack.h:750
mschmd_sec_mscompressed
A structure which represents the LZX compressed section of a CHM helpfile.
Definition: mspack.h:1239
mschm_compressor::last_error
int(* last_error)(struct mschm_compressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:1558
mscabd_file::date_d
char date_d
File's last modified date, day field.
Definition: mspack.h:903
mspack_create_hlp_compressor
struct mshlp_compressor * mspack_create_hlp_compressor(struct mspack_system *sys)
Creates a new HLP compressor.
mscabd_folder::comp_type
int comp_type
The compression format used by this folder.
Definition: mspack.h:820
mspack_create_kwaj_decompressor
struct mskwaj_decompressor * mspack_create_kwaj_decompressor(struct mspack_system *sys)
Creates a new KWAJ decompressor.
mschm_decompressor::close
void(* close)(struct mschm_decompressor *self, struct mschmd_header *chm)
Closes a previously opened CHM helpfile.
Definition: mspack.h:1609
mspack_destroy_szdd_compressor
void mspack_destroy_szdd_compressor(struct msszdd_compressor *self)
Destroys an existing SZDD compressor.
mspack_system::message
void(* message)(struct mspack_file *file, const char *format,...)
Used to send messages from the library to the user.
Definition: mspack.h:405
mscabd_cabinet::nextinfo
char * nextinfo
The name of the disk containing the next cabinet in a cabinet set, or NULL.
Definition: mspack.h:738
mspack_destroy_hlp_decompressor
void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *self)
Destroys an existing hlp decompressor.
mscab_decompressor::prepend
int(* prepend)(struct mscab_decompressor *self, struct mscabd_cabinet *cab, struct mscabd_cabinet *prevcab)
Prepends one mscabd_cabinet to another, forming or extending a cabinet set.
Definition: mspack.h:1103
mschm_decompressor::fast_find
int(* fast_find)(struct mschm_decompressor *self, struct mschmd_header *chm, const char *filename, struct mschmd_file *f_ptr, int f_size)
Finds file details quickly.
Definition: mspack.h:1710
mscabd_file::folder
struct mscabd_folder * folder
A pointer to the folder that contains this file.
Definition: mspack.h:910
mspack_system::free
void(* free)(void *ptr)
Frees memory.
Definition: mspack.h:428
mschmd_sec_uncompressed::base
struct mschmd_section base
Generic section data.
Definition: mspack.h:1228
msszdd_compressor::last_error
int(* last_error)(struct mschm_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:1857
mscab_decompressor::append
int(* append)(struct mscab_decompressor *self, struct mscabd_cabinet *cab, struct mscabd_cabinet *nextcab)
Appends one mscabd_cabinet to another, forming or extending a cabinet set.
Definition: mspack.h:1081
mschm_decompressor
A decompressor for .CHM (Microsoft HTMLHelp) files.
Definition: mspack.h:1568
msszdd_compressor::compress
int(* compress)(struct msszdd_compressor *self, const char *input, const char *output, off_t length)
Reads an input file and creates a compressed output file in the SZDD compressed file format...
Definition: mspack.h:1819
mspack_system
A structure which abstracts file I/O and memory management.
Definition: mspack.h:285
mschmd_section
A structure which represents a section of a CHM helpfile.
Definition: mspack.h:1209
mshlp_decompressor
TODO.
Definition: mspack.h:1738
mspack_sys_selftest_internal
int mspack_sys_selftest_internal(int)
Part of the MSPACK_SYS_SELFTEST() macro, must not be used directly.
mscab_decompressor::last_error
int(* last_error)(struct mscab_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:1170
mschmd_section::chm
struct mschmd_header * chm
A pointer to the CHM helpfile that contains this section.
Definition: mspack.h:1211
mschmd_file::filename
char * filename
The filename of this file – a null terminated string in UTF-8.
Definition: mspack.h:1381
mslit_decompressor
TODO.
Definition: mspack.h:1725
msoab_compressor
A compressor for the Offline Address Book (OAB) format.
Definition: mspack.h:2246
mscabd_cabinet::next
struct mscabd_cabinet * next
The next cabinet in a chained list, if this cabinet was opened with mscab_decompressor::search().
Definition: mspack.h:703
mscabd_cabinet::prevname
char * prevname
The filename of the previous cabinet in a cabinet set, or NULL.
Definition: mspack.h:725
msszddd_header::format
int format
The file format; either MSSZDD_FMT_NORMAL or MSSZDD_FMT_QBASIC.
Definition: mspack.h:1761
mscabd_folder
A structure which represents a single folder in a cabinet or cabinet set.
Definition: mspack.h:804
mscabd_folder::num_blocks
unsigned int num_blocks
The total number of data blocks used by this folder.
Definition: mspack.h:827
mschmd_header::index_root
unsigned int index_root
The number of the root PMGI chunk.
Definition: mspack.h:1335
msoab_decompressor
A decompressor for .LZX (Offline Address Book) files.
Definition: mspack.h:2298
mscabd_file::attribs
int attribs
File attributes.
Definition: mspack.h:893
mscab_compressor
TODO.
Definition: mspack.h:937
mskwajd_header
A structure which represents an KWAJ compressed file.
Definition: mspack.h:2002
mspack_create_lit_compressor
struct mslit_compressor * mspack_create_lit_compressor(struct mspack_system *sys)
Creates a new LIT compressor.
mschm_decompressor::extract
int(* extract)(struct mschm_decompressor *self, struct mschmd_file *file, const char *filename)
Extracts a file from a CHM helpfile.
Definition: mspack.h:1630
mschmd_sec_mscompressed::rtable
struct mschmd_file * rtable
A pointer to the file which contains the LZX reset table.
Definition: mspack.h:1250
mscabd_cabinet::prevcab
struct mscabd_cabinet * prevcab
The previous cabinet in a cabinet set, or NULL.
Definition: mspack.h:719
mschmd_sec_mscompressed::spaninfo
struct mschmd_file * spaninfo
A pointer to the file which contains the LZX span information.
Definition: mspack.h:1255
mspack_destroy_lit_decompressor
void mspack_destroy_lit_decompressor(struct mslit_decompressor *self)
Destroys an existing LIT decompressor.
mscabd_cabinet::files
struct mscabd_file * files
A list of all files in the cabinet or cabinet set.
Definition: mspack.h:741
mschmd_sec_mscompressed::content
struct mschmd_file * content
A pointer to the meta-file which represents all LZX compressed data.
Definition: mspack.h:1244
mschmd_header::sec0
struct mschmd_sec_uncompressed sec0
The section 0 (uncompressed) data in this CHM helpfile.
Definition: mspack.h:1303
mschmd_header::sysfiles
struct mschmd_file * sysfiles
A list of all system files in the CHM helpfile.
Definition: mspack.h:1300
mschm_compressor::use_temporary_file
int(* use_temporary_file)(struct mschm_compressor *self, int use_temp_file, const char *temp_file)
Specifies whether a temporary file is used during CHM generation.
Definition: mspack.h:1498
mspack_destroy_szdd_decompressor
void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *self)
Destroys an existing SZDD decompressor.
mschm_compressor::generate
int(* generate)(struct mschm_compressor *self, struct mschmc_file file_list[], const char *output_file)
Generates a CHM help file.
Definition: mspack.h:1441
mschmd_sec_uncompressed::offset
off_t offset
The file offset of where this section begins in the CHM helpfile.
Definition: mspack.h:1231
mspack_create_chm_compressor
struct mschm_compressor * mspack_create_chm_compressor(struct mspack_system *sys)
Creates a new CHM compressor.
mspack_system::null_ptr
void * null_ptr
A null pointer to mark the end of mspack_system.
Definition: mspack.h:452
msszdd_decompressor::close
void(* close)(struct msszdd_decompressor *self, struct msszddd_header *szdd)
Closes a previously opened SZDD file.
Definition: mspack.h:1903
mspack_file
A structure which represents an open file handle.
Definition: mspack.h:476
mschmd_header::length
off_t length
The length of the CHM helpfile, in bytes.
Definition: mspack.h:1289
mscabd_cabinet::previnfo
char * previnfo
The name of the disk containing the previous cabinet in a cabinet set, or NULL.
Definition: mspack.h:733
mschmd_header::files
struct mschmd_file * files
A list of all non-system files in the CHM helpfile.
Definition: mspack.h:1292
mskwajd_header::length
off_t length
The amount of uncompressed data in the file, or 0 if not present.
Definition: mspack.h:2015
mshlp_compressor::dummy
int dummy
Definition: mspack.h:1734
mscabd_file::time_h
char time_h
File's last modified time, hour field.
Definition: mspack.h:896
mspack_version
int mspack_version(int entity)
Enquire about the binary compatibility version of a specific interface in the library.
mscabd_file
A structure which represents a single file in a cabinet or cabinet set.
Definition: mspack.h:861
mscab_decompressor::close
void(* close)(struct mscab_decompressor *self, struct mscabd_cabinet *cab)
Closes a previously opened cabinet or cabinet set.
Definition: mspack.h:1001
mscabd_folder::next
struct mscabd_folder * next
A pointer to the next folder in this cabinet or cabinet set, or NULL if this is the final folder...
Definition: mspack.h:809
mskwaj_decompressor::decompress
int(* decompress)(struct mskwaj_decompressor *self, const char *input, const char *output)
Decompresses an KWAJ file to an output file in one step.
Definition: mspack.h:2219
mschmd_header::first_pmgl
unsigned int first_pmgl
The number of the first PMGL chunk.
Definition: mspack.h:1341
mschmd_file
A structure which represents a file stored in a CHM helpfile.
Definition: mspack.h:1361
mscabd_file::date_m
char date_m
File's last modified date, month field.
Definition: mspack.h:905
msszdd_decompressor::extract
int(* extract)(struct msszdd_decompressor *self, struct msszddd_header *szdd, const char *filename)
Extracts the compressed data from a SZDD file.
Definition: mspack.h:1919
mschmd_header::num_chunks
unsigned int num_chunks
The number of PMGL/PMGI directory chunks in this CHM helpfile.
Definition: mspack.h:1312
mschmd_header::chunk_size
unsigned int chunk_size
The size of each PMGL/PMGI chunk, in bytes.
Definition: mspack.h:1315
mscab_decompressor
A decompressor for .CAB (Microsoft Cabinet) files.
Definition: mspack.h:948
mschmd_header::last_pmgl
unsigned int last_pmgl
The number of the last PMGL chunk.
Definition: mspack.h:1347
mschmd_header::version
unsigned int version
The version of the CHM file format used in this file.
Definition: mspack.h:1265
mschmd_header::sec1
struct mschmd_sec_mscompressed sec1
The section 1 (MSCompressed) data in this CHM helpfile.
Definition: mspack.h:1306
mscabd_cabinet::nextname
char * nextname
The filename of the next cabinet in a cabinet set, or NULL.
Definition: mspack.h:728
mspack_system::write
int(* write)(struct mspack_file *file, void *buffer, int bytes)
Writes a given number of bytes to an open file.
Definition: mspack.h:351
mspack_destroy_cab_compressor
void mspack_destroy_cab_compressor(struct mscab_compressor *self)
Destroys an existing CAB compressor.
mschmd_file::section
struct mschmd_section * section
A pointer to the section that this file is located in.
Definition: mspack.h:1372
mscabd_file::time_s
char time_s
File's last modified time, second field.
Definition: mspack.h:900
mschmd_header
A structure which represents a CHM helpfile.
Definition: mspack.h:1263
mscabd_cabinet::nextcab
struct mscabd_cabinet * nextcab
The next cabinet in a cabinet set, or NULL.
Definition: mspack.h:722
mskwaj_compressor::last_error
int(* last_error)(struct mschm_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:2137
mschmd_file::length
off_t length
The length of this file, in bytes.
Definition: mspack.h:1378
mspack_system::tell
off_t(* tell)(struct mspack_file *file)
Returns the current file position (in bytes) of the given file.
Definition: mspack.h:389
mscabd_cabinet
A structure which represents a single cabinet file.
Definition: mspack.h:697
mscabd_cabinet::set_index
unsigned short set_index
The index number of the cabinet within the set.
Definition: mspack.h:757
mschmc_file::section
int section
One of MSCHMC_ENDLIST, MSCHMC_UNCOMP or MSCHMC_MSCOMP.
Definition: mspack.h:1185
mskwajd_header::extra
char * extra
extra uncompressed data (usually text) in the header.
Definition: mspack.h:2023
mschmd_header::dir_offset
off_t dir_offset
The file offset of the first PMGL/PMGI directory chunk.
Definition: mspack.h:1309
mskwajd_header::filename
char * filename
output filename, or NULL if not present
Definition: mspack.h:2018
mspack_destroy_kwaj_decompressor
void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self)
Destroys an existing KWAJ decompressor.
mskwaj_compressor::set_filename
int(* set_filename)(struct mskwaj_compressor *self, const char *filename)
Sets the original filename of the file before compression, which will be stored in the header of the ...
Definition: mspack.h:2105
msszdd_compressor
A compressor for the SZDD file format.
Definition: mspack.h:1783
mschmd_header::chunk_cache
unsigned char ** chunk_cache
A cache of loaded chunks, filled in by mschm_decoder::fast_find().
Definition: mspack.h:1353
mspack_create_cab_decompressor
struct mscab_decompressor * mspack_create_cab_decompressor(struct mspack_system *sys)
Creates a new CAB decompressor.
mscabd_cabinet::filename
const char * filename
The filename of the cabinet.
Definition: mspack.h:710
msszdd_decompressor::last_error
int(* last_error)(struct msszdd_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:1955
mshlp_compressor
TODO.
Definition: mspack.h:1733
mslit_compressor
TODO.
Definition: mspack.h:1720
msszddd_header::length
off_t length
The amount of data in the SZDD file once uncompressed.
Definition: mspack.h:1764
mshlp_decompressor::dummy
int dummy
Definition: mspack.h:1739
mschmd_file::next
struct mschmd_file * next
A pointer to the next file in the list, or NULL if this is the final file.
Definition: mspack.h:1366
msszdd_compressor::set_param
int(* set_param)(struct msszdd_compressor *self, int param, unsigned int value)
Sets an SZDD compression engine parameter.
Definition: mspack.h:1845
mscab_decompressor::set_param
int(* set_param)(struct mscab_decompressor *self, int param, int value)
Sets a CAB decompression engine parameter.
Definition: mspack.h:1155
mslit_compressor::dummy
int dummy
Definition: mspack.h:1721
mschmd_header::filename
const char * filename
The filename of the CHM helpfile.
Definition: mspack.h:1286
mskwaj_decompressor::extract
int(* extract)(struct mskwaj_decompressor *self, struct mskwajd_header *kwaj, const char *filename)
Extracts the compressed data from a KWAJ file.
Definition: mspack.h:2198
mspack_create_lit_decompressor
struct mslit_decompressor * mspack_create_lit_decompressor(struct mspack_system *sys)
Creates a new LIT decompressor.
mscabd_file::date_y
int date_y
File's last modified date, year field.
Definition: mspack.h:907
mskwajd_header::comp_type
unsigned short comp_type
The compression type; should be one of MSKWAJ_COMP_NONE, MSKWAJ_COMP_XOR, MSKWAJ_COMP_SZDD or MSKWAJ_...
Definition: mspack.h:2006
mscabd_cabinet::flags
int flags
Header flags.
Definition: mspack.h:782
mscabd_file::time_m
char time_m
File's last modified time, minute field.
Definition: mspack.h:898
mschm_compressor::set_param
int(* set_param)(struct mschm_compressor *self, int param, unsigned int value)
Sets a CHM compression engine parameter.
Definition: mspack.h:1546
mschmc_file::length
off_t length
The length of the file, in bytes.
Definition: mspack.h:1198
mscab_compressor::dummy
int dummy
Definition: mspack.h:938
mslit_decompressor::dummy
int dummy
Definition: mspack.h:1726
mschmd_section::id
unsigned int id
The section ID.
Definition: mspack.h:1218
mskwajd_header::extra_length
unsigned short extra_length
length of extra uncompressed data in the header
Definition: mspack.h:2026
mskwaj_compressor::set_param
int(* set_param)(struct mskwaj_compressor *self, int param, unsigned int value)
Sets an KWAJ compression engine parameter.
Definition: mspack.h:2083
mschmd_header::depth
unsigned int depth
The depth of the index tree.
Definition: mspack.h:1328
mskwaj_decompressor::last_error
int(* last_error)(struct mskwaj_decompressor *self)
Returns the error code set by the most recently called method.
Definition: mspack.h:2234
msoab_decompressor::decompress
int(* decompress)(struct msoab_decompressor *self, const char *input, const char *output)
Decompresses a full Offline Address Book file.
Definition: mspack.h:2314
msszddd_header
A structure which represents an SZDD compressed file.
Definition: mspack.h:1759
mschmd_sec_mscompressed::control
struct mschmd_file * control
A pointer to the file which contains the LZX control data.
Definition: mspack.h:1247
mspack_destroy_chm_decompressor
void mspack_destroy_chm_decompressor(struct mschm_decompressor *self)
Destroys an existing CHM decompressor.
mscabd_cabinet::folders
struct mscabd_folder * folders
A list of all folders in the cabinet or cabinet set.
Definition: mspack.h:744
mskwajd_header::data_offset
off_t data_offset
The offset in the file where the compressed data stream begins.
Definition: mspack.h:2009
mskwaj_decompressor
A decompressor for KWAJ compressed files.
Definition: mspack.h:2147
mschmc_file::chm_filename
char * chm_filename
The full path and filename of the file within the CHM helpfile, a UTF-1 encoded null-terminated strin...
Definition: mspack.h:1193
mspack_destroy_cab_decompressor
void mspack_destroy_cab_decompressor(struct mscab_decompressor *self)
Destroys an existing CAB decompressor.
mspack_destroy_oab_compressor
void mspack_destroy_oab_compressor(struct msoab_compressor *self)
Destroys an existing OAB compressor.
mschmd_sec_uncompressed
A structure which represents the uncompressed section of a CHM helpfile.
Definition: mspack.h:1226
mscabd_cabinet::base_offset
off_t base_offset
The file offset of cabinet within the physical file it resides in.
Definition: mspack.h:713
mschmd_sec_mscompressed::base
struct mschmd_section base
Generic section data.
Definition: mspack.h:1241
mscabd_cabinet::header_resv
unsigned short header_resv
The number of bytes reserved in the header area of the cabinet.
Definition: mspack.h:769
mspack_system::copy
void(* copy)(void *src, void *dest, size_t bytes)
Copies from one region of memory to another.
Definition: mspack.h:442
mspack_create_hlp_decompressor
struct mshlp_decompressor * mspack_create_hlp_decompressor(struct mspack_system *sys)
Creates a new HLP decompressor.
mspack_create_kwaj_compressor
struct mskwaj_compressor * mspack_create_kwaj_compressor(struct mspack_system *sys)
Creates a new KWAJ compressor.
mspack_destroy_kwaj_compressor
void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self)
Destroys an existing KWAJ compressor.
mscabd_file::length
unsigned int length
The uncompressed length of the file, in bytes.
Definition: mspack.h:879
mschmd_header::timestamp
unsigned int timestamp
The "timestamp" of the CHM helpfile.
Definition: mspack.h:1274
mscabd_file::next
struct mscabd_file * next
The next file in the cabinet or cabinet set, or NULL if this is the final file.
Definition: mspack.h:866
mscabd_cabinet::length
unsigned int length
The length of the cabinet file in bytes.
Definition: mspack.h:716
mskwaj_compressor::set_extra_data
int(* set_extra_data)(struct mskwaj_compressor *self, void *data, size_t bytes)
Sets arbitrary data that will be stored in the header of the output file, uncompressed.
Definition: mspack.h:2125
mspack_system::read
int(* read)(struct mspack_file *file, void *buffer, int bytes)
Reads a given number of bytes from an open file.
Definition: mspack.h:334
mschm_compressor
A compressor for .CHM (Microsoft HTMLHelp) files.
Definition: mspack.h:1409
mschmc_file::filename
const char * filename
The filename of the source file that will be added to the CHM.
Definition: mspack.h:1189
mskwajd_header::headers
int headers
Flags indicating which optional headers were included.
Definition: mspack.h:2012
mspack_create_oab_compressor
struct msoab_compressor * mspack_create_oab_compressor(struct mspack_system *sys)
Creates a new OAB compressor.
mspack_destroy_oab_decompressor
void mspack_destroy_oab_decompressor(struct msoab_decompressor *self)
Destroys an existing OAB decompressor.
mspack_destroy_chm_compressor
void mspack_destroy_chm_compressor(struct mschm_compressor *self)
Destroys an existing CHM compressor.
mschmd_header::density
unsigned int density
The "density" of the quick-reference section in PMGL/PMGI chunks.
Definition: mspack.h:1318