summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/mspack/mspack.h
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/mspack/mspack.h')
-rw-r--r--rbutil/rbutilqt/mspack/mspack.h316
1 files changed, 249 insertions, 67 deletions
diff --git a/rbutil/rbutilqt/mspack/mspack.h b/rbutil/rbutilqt/mspack/mspack.h
index 7f6bdf1465..3e99624463 100644
--- a/rbutil/rbutilqt/mspack/mspack.h
+++ b/rbutil/rbutilqt/mspack/mspack.h
@@ -1,5 +1,5 @@
1/* libmspack -- a library for working with Microsoft compression formats. 1/* libmspack -- a library for working with Microsoft compression formats.
2 * (C) 2003-2011 Stuart Caie <kyzer@4u.net> 2 * (C) 2003-2019 Stuart Caie <kyzer@cabextract.org.uk>
3 * 3 *
4 * libmspack is free software; you can redistribute it and/or modify it under 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 5 * the terms of the GNU Lesser General Public License (LGPL) version 2.1
@@ -30,6 +30,7 @@
30 * - .CAB (MS Cabinet) files, which use deflate, LZX or Quantum compression 30 * - .CAB (MS Cabinet) files, which use deflate, LZX or Quantum compression
31 * - .CHM (HTML Help) files, which use LZX compression 31 * - .CHM (HTML Help) files, which use LZX compression
32 * - .LIT (MS EBook) files, which use LZX compression and DES encryption 32 * - .LIT (MS EBook) files, which use LZX compression and DES encryption
33 * - .LZX (Exchange Offline Addressbook) files, which use LZX compression
33 * 34 *
34 * To determine the capabilities of the library, and the binary 35 * To determine the capabilities of the library, and the binary
35 * compatibility version of any particular compressor or decompressor, use 36 * compatibility version of any particular compressor or decompressor, use
@@ -60,6 +61,7 @@
60 * - mspack_create_hlp_compressor() creates a mshlp_compressor 61 * - mspack_create_hlp_compressor() creates a mshlp_compressor
61 * - mspack_create_szdd_compressor() creates a msszdd_compressor 62 * - mspack_create_szdd_compressor() creates a msszdd_compressor
62 * - mspack_create_kwaj_compressor() creates a mskwaj_compressor 63 * - mspack_create_kwaj_compressor() creates a mskwaj_compressor
64 * - mspack_create_oab_compressor() creates a msoab_compressor
63 * 65 *
64 * For decompression: 66 * For decompression:
65 * - mspack_create_cab_decompressor() creates a mscab_decompressor 67 * - mspack_create_cab_decompressor() creates a mscab_decompressor
@@ -68,6 +70,7 @@
68 * - mspack_create_hlp_decompressor() creates a mshlp_decompressor 70 * - mspack_create_hlp_decompressor() creates a mshlp_decompressor
69 * - mspack_create_szdd_decompressor() creates a msszdd_decompressor 71 * - mspack_create_szdd_decompressor() creates a msszdd_decompressor
70 * - mspack_create_kwaj_decompressor() creates a mskwaj_decompressor 72 * - mspack_create_kwaj_decompressor() creates a mskwaj_decompressor
73 * - mspack_create_oab_decompressor() creates a msoab_decompressor
71 * 74 *
72 * Once finished working with a format, each kind of 75 * Once finished working with a format, each kind of
73 * compressor/decompressor has its own specific destructor: 76 * compressor/decompressor has its own specific destructor:
@@ -83,6 +86,8 @@
83 * - mspack_destroy_szdd_decompressor() 86 * - mspack_destroy_szdd_decompressor()
84 * - mspack_destroy_kwaj_compressor() 87 * - mspack_destroy_kwaj_compressor()
85 * - mspack_destroy_kwaj_decompressor() 88 * - mspack_destroy_kwaj_decompressor()
89 * - mspack_destroy_oab_compressor()
90 * - mspack_destroy_oab_decompressor()
86 * 91 *
87 * Destroying a compressor or decompressor does not destroy any objects, 92 * Destroying a compressor or decompressor does not destroy any objects,
88 * structures or handles that have been created using that compressor or 93 * structures or handles that have been created using that compressor or
@@ -208,6 +213,8 @@ extern int mspack_sys_selftest_internal(int);
208 * - #MSPACK_VER_MSSZDDC: the msszdd_compressor interface 213 * - #MSPACK_VER_MSSZDDC: the msszdd_compressor interface
209 * - #MSPACK_VER_MSKWAJD: the mskwaj_decompressor interface 214 * - #MSPACK_VER_MSKWAJD: the mskwaj_decompressor interface
210 * - #MSPACK_VER_MSKWAJC: the mskwaj_compressor interface 215 * - #MSPACK_VER_MSKWAJC: the mskwaj_compressor interface
216 * - #MSPACK_VER_MSOABD: the msoab_decompressor interface
217 * - #MSPACK_VER_MSOABC: the msoab_compressor interface
211 * 218 *
212 * The result of the function should be interpreted as follows: 219 * The result of the function should be interpreted as follows:
213 * - -1: this interface is completely unknown to the library 220 * - -1: this interface is completely unknown to the library
@@ -249,6 +256,10 @@ extern int mspack_version(int entity);
249#define MSPACK_VER_MSKWAJD (12) 256#define MSPACK_VER_MSKWAJD (12)
250/** Pass to mspack_version() to get the mskwaj_compressor version */ 257/** Pass to mspack_version() to get the mskwaj_compressor version */
251#define MSPACK_VER_MSKWAJC (13) 258#define MSPACK_VER_MSKWAJC (13)
259/** Pass to mspack_version() to get the msoab_decompressor version */
260#define MSPACK_VER_MSOABD (14)
261/** Pass to mspack_version() to get the msoab_compressor version */
262#define MSPACK_VER_MSOABC (15)
252 263
253/* --- file I/O abstraction ------------------------------------------------ */ 264/* --- file I/O abstraction ------------------------------------------------ */
254 265
@@ -297,8 +308,8 @@ struct mspack_system {
297 * @see close(), read(), write(), seek(), tell(), message() 308 * @see close(), read(), write(), seek(), tell(), message()
298 */ 309 */
299 struct mspack_file * (*open)(struct mspack_system *self, 310 struct mspack_file * (*open)(struct mspack_system *self,
300 const char *filename, 311 const char *filename,
301 int mode); 312 int mode);
302 313
303 /** 314 /**
304 * Closes a previously opened file. If any memory was allocated for this 315 * Closes a previously opened file. If any memory was allocated for this
@@ -317,12 +328,14 @@ struct mspack_system {
317 * @param bytes the number of bytes to read from the file. 328 * @param bytes the number of bytes to read from the file.
318 * @return the number of bytes successfully read (this can be less than 329 * @return the number of bytes successfully read (this can be less than
319 * the number requested), zero to mark the end of file, or less 330 * the number requested), zero to mark the end of file, or less
320 * than zero to indicate an error. 331 * than zero to indicate an error. The library does not "retry"
332 * reads and assumes short reads are due to EOF, so you should
333 * avoid returning short reads because of transient errors.
321 * @see open(), write() 334 * @see open(), write()
322 */ 335 */
323 int (*read)(struct mspack_file *file, 336 int (*read)(struct mspack_file *file,
324 void *buffer, 337 void *buffer,
325 int bytes); 338 int bytes);
326 339
327 /** 340 /**
328 * Writes a given number of bytes to an open file. 341 * Writes a given number of bytes to an open file.
@@ -338,8 +351,8 @@ struct mspack_system {
338 * @see open(), read() 351 * @see open(), read()
339 */ 352 */
340 int (*write)(struct mspack_file *file, 353 int (*write)(struct mspack_file *file,
341 void *buffer, 354 void *buffer,
342 int bytes); 355 int bytes);
343 356
344 /** 357 /**
345 * Seeks to a specific file offset within an open file. 358 * Seeks to a specific file offset within an open file.
@@ -365,8 +378,8 @@ struct mspack_system {
365 * @see open(), tell() 378 * @see open(), tell()
366 */ 379 */
367 int (*seek)(struct mspack_file *file, 380 int (*seek)(struct mspack_file *file,
368 off_t offset, 381 off_t offset,
369 int mode); 382 int mode);
370 383
371 /** 384 /**
372 * Returns the current file position (in bytes) of the given file. 385 * Returns the current file position (in bytes) of the given file.
@@ -392,8 +405,8 @@ struct mspack_system {
392 * @see open() 405 * @see open()
393 */ 406 */
394 void (*message)(struct mspack_file *file, 407 void (*message)(struct mspack_file *file,
395 const char *format, 408 const char *format,
396 ...); 409 ...);
397 410
398 /** 411 /**
399 * Allocates memory. 412 * Allocates memory.
@@ -406,12 +419,12 @@ struct mspack_system {
406 * @see free() 419 * @see free()
407 */ 420 */
408 void * (*alloc)(struct mspack_system *self, 421 void * (*alloc)(struct mspack_system *self,
409 size_t bytes); 422 size_t bytes);
410 423
411 /** 424 /**
412 * Frees memory. 425 * Frees memory.
413 * 426 *
414 * @param ptr the memory to be freed. 427 * @param ptr the memory to be freed. NULL is accepted and ignored.
415 * @see alloc() 428 * @see alloc()
416 */ 429 */
417 void (*free)(void *ptr); 430 void (*free)(void *ptr);
@@ -429,8 +442,8 @@ struct mspack_system {
429 * @param bytes the size of the memory region, in bytes 442 * @param bytes the size of the memory region, in bytes
430 */ 443 */
431 void (*copy)(void *src, 444 void (*copy)(void *src,
432 void *dest, 445 void *dest,
433 size_t bytes); 446 size_t bytes);
434 447
435 /** 448 /**
436 * A null pointer to mark the end of mspack_system. It must equal NULL. 449 * A null pointer to mark the end of mspack_system. It must equal NULL.
@@ -645,6 +658,31 @@ extern void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self);
645extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self); 658extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self);
646 659
647 660
661/** Creates a new OAB compressor.
662 * @param sys a custom mspack_system structure, or NULL to use the default
663 * @return a #msoab_compressor or NULL
664 */
665extern struct msoab_compressor *
666 mspack_create_oab_compressor(struct mspack_system *sys);
667
668/** Creates a new OAB decompressor.
669 * @param sys a custom mspack_system structure, or NULL to use the default
670 * @return a #msoab_decompressor or NULL
671 */
672extern struct msoab_decompressor *
673 mspack_create_oab_decompressor(struct mspack_system *sys);
674
675/** Destroys an existing OAB compressor.
676 * @param self the #msoab_compressor to destroy
677 */
678extern void mspack_destroy_oab_compressor(struct msoab_compressor *self);
679
680/** Destroys an existing OAB decompressor.
681 * @param self the #msoab_decompressor to destroy
682 */
683extern void mspack_destroy_oab_decompressor(struct msoab_decompressor *self);
684
685
648/* --- support for .CAB (MS Cabinet) file format --------------------------- */ 686/* --- support for .CAB (MS Cabinet) file format --------------------------- */
649 687
650/** 688/**
@@ -896,6 +934,13 @@ struct mscabd_file {
896#define MSCABD_PARAM_FIXMSZIP (1) 934#define MSCABD_PARAM_FIXMSZIP (1)
897/** mscab_decompressor::set_param() parameter: size of decompression buffer */ 935/** mscab_decompressor::set_param() parameter: size of decompression buffer */
898#define MSCABD_PARAM_DECOMPBUF (2) 936#define MSCABD_PARAM_DECOMPBUF (2)
937/** mscab_decompressor::set_param() parameter: salvage data from bad cabinets?
938 * If enabled, open() will skip file with bad folder indices or filenames
939 * rather than reject the whole cabinet, and extract() will limit rather than
940 * reject files with invalid offsets and lengths, and bad data block checksums
941 * will be ignored. Available only in CAB decoder version 2 and above.
942 */
943#define MSCABD_PARAM_SALVAGE (3)
899 944
900/** TODO */ 945/** TODO */
901struct mscab_compressor { 946struct mscab_compressor {
@@ -931,7 +976,7 @@ struct mscab_decompressor {
931 * @see close(), search(), last_error() 976 * @see close(), search(), last_error()
932 */ 977 */
933 struct mscabd_cabinet * (*open) (struct mscab_decompressor *self, 978 struct mscabd_cabinet * (*open) (struct mscab_decompressor *self,
934 const char *filename); 979 const char *filename);
935 980
936 /** 981 /**
937 * Closes a previously opened cabinet or cabinet set. 982 * Closes a previously opened cabinet or cabinet set.
@@ -963,7 +1008,7 @@ struct mscab_decompressor {
963 * @see open(), search(), append(), prepend() 1008 * @see open(), search(), append(), prepend()
964 */ 1009 */
965 void (*close)(struct mscab_decompressor *self, 1010 void (*close)(struct mscab_decompressor *self,
966 struct mscabd_cabinet *cab); 1011 struct mscabd_cabinet *cab);
967 1012
968 /** 1013 /**
969 * Searches a regular file for embedded cabinets. 1014 * Searches a regular file for embedded cabinets.
@@ -1000,7 +1045,7 @@ struct mscab_decompressor {
1000 * @see close(), open(), last_error() 1045 * @see close(), open(), last_error()
1001 */ 1046 */
1002 struct mscabd_cabinet * (*search) (struct mscab_decompressor *self, 1047 struct mscabd_cabinet * (*search) (struct mscab_decompressor *self,
1003 const char *filename); 1048 const char *filename);
1004 1049
1005 /** 1050 /**
1006 * Appends one mscabd_cabinet to another, forming or extending a cabinet 1051 * Appends one mscabd_cabinet to another, forming or extending a cabinet
@@ -1043,8 +1088,8 @@ struct mscab_decompressor {
1043 * @see prepend(), open(), close() 1088 * @see prepend(), open(), close()
1044 */ 1089 */
1045 int (*append) (struct mscab_decompressor *self, 1090 int (*append) (struct mscab_decompressor *self,
1046 struct mscabd_cabinet *cab, 1091 struct mscabd_cabinet *cab,
1047 struct mscabd_cabinet *nextcab); 1092 struct mscabd_cabinet *nextcab);
1048 1093
1049 /** 1094 /**
1050 * Prepends one mscabd_cabinet to another, forming or extending a 1095 * Prepends one mscabd_cabinet to another, forming or extending a
@@ -1065,8 +1110,8 @@ struct mscab_decompressor {
1065 * @see append(), open(), close() 1110 * @see append(), open(), close()
1066 */ 1111 */
1067 int (*prepend) (struct mscab_decompressor *self, 1112 int (*prepend) (struct mscab_decompressor *self,
1068 struct mscabd_cabinet *cab, 1113 struct mscabd_cabinet *cab,
1069 struct mscabd_cabinet *prevcab); 1114 struct mscabd_cabinet *prevcab);
1070 1115
1071 /** 1116 /**
1072 * Extracts a file from a cabinet or cabinet set. 1117 * Extracts a file from a cabinet or cabinet set.
@@ -1091,8 +1136,8 @@ struct mscab_decompressor {
1091 * @return an error code, or MSPACK_ERR_OK if successful 1136 * @return an error code, or MSPACK_ERR_OK if successful
1092 */ 1137 */
1093 int (*extract)(struct mscab_decompressor *self, 1138 int (*extract)(struct mscab_decompressor *self,
1094 struct mscabd_file *file, 1139 struct mscabd_file *file,
1095 const char *filename); 1140 const char *filename);
1096 1141
1097 /** 1142 /**
1098 * Sets a CAB decompression engine parameter. 1143 * Sets a CAB decompression engine parameter.
@@ -1117,8 +1162,8 @@ struct mscab_decompressor {
1117 * @see search(), extract() 1162 * @see search(), extract()
1118 */ 1163 */
1119 int (*set_param)(struct mscab_decompressor *self, 1164 int (*set_param)(struct mscab_decompressor *self,
1120 int param, 1165 int param,
1121 int value); 1166 int value);
1122 1167
1123 /** 1168 /**
1124 * Returns the error code set by the most recently called method. 1169 * Returns the error code set by the most recently called method.
@@ -1403,8 +1448,8 @@ struct mschm_compressor {
1403 * @see use_temporary_file() set_param() 1448 * @see use_temporary_file() set_param()
1404 */ 1449 */
1405 int (*generate)(struct mschm_compressor *self, 1450 int (*generate)(struct mschm_compressor *self,
1406 struct mschmc_file file_list[], 1451 struct mschmc_file file_list[],
1407 const char *output_file); 1452 const char *output_file);
1408 1453
1409 /** 1454 /**
1410 * Specifies whether a temporary file is used during CHM generation. 1455 * Specifies whether a temporary file is used during CHM generation.
@@ -1460,8 +1505,8 @@ struct mschm_compressor {
1460 * @see generate() 1505 * @see generate()
1461 */ 1506 */
1462 int (*use_temporary_file)(struct mschm_compressor *self, 1507 int (*use_temporary_file)(struct mschm_compressor *self,
1463 int use_temp_file, 1508 int use_temp_file,
1464 const char *temp_file); 1509 const char *temp_file);
1465 /** 1510 /**
1466 * Sets a CHM compression engine parameter. 1511 * Sets a CHM compression engine parameter.
1467 * 1512 *
@@ -1508,8 +1553,8 @@ struct mschm_compressor {
1508 * @see generate() 1553 * @see generate()
1509 */ 1554 */
1510 int (*set_param)(struct mschm_compressor *self, 1555 int (*set_param)(struct mschm_compressor *self,
1511 int param, 1556 int param,
1512 unsigned int value); 1557 int value);
1513 1558
1514 /** 1559 /**
1515 * Returns the error code set by the most recently called method. 1560 * Returns the error code set by the most recently called method.
@@ -1551,7 +1596,7 @@ struct mschm_decompressor {
1551 * @see close() 1596 * @see close()
1552 */ 1597 */
1553 struct mschmd_header *(*open)(struct mschm_decompressor *self, 1598 struct mschmd_header *(*open)(struct mschm_decompressor *self,
1554 const char *filename); 1599 const char *filename);
1555 1600
1556 /** 1601 /**
1557 * Closes a previously opened CHM helpfile. 1602 * Closes a previously opened CHM helpfile.
@@ -1571,7 +1616,7 @@ struct mschm_decompressor {
1571 * @see open(), fast_open() 1616 * @see open(), fast_open()
1572 */ 1617 */
1573 void (*close)(struct mschm_decompressor *self, 1618 void (*close)(struct mschm_decompressor *self,
1574 struct mschmd_header *chm); 1619 struct mschmd_header *chm);
1575 1620
1576 /** 1621 /**
1577 * Extracts a file from a CHM helpfile. 1622 * Extracts a file from a CHM helpfile.
@@ -1592,8 +1637,8 @@ struct mschm_decompressor {
1592 * @return an error code, or MSPACK_ERR_OK if successful 1637 * @return an error code, or MSPACK_ERR_OK if successful
1593 */ 1638 */
1594 int (*extract)(struct mschm_decompressor *self, 1639 int (*extract)(struct mschm_decompressor *self,
1595 struct mschmd_file *file, 1640 struct mschmd_file *file,
1596 const char *filename); 1641 const char *filename);
1597 1642
1598 /** 1643 /**
1599 * Returns the error code set by the most recently called method. 1644 * Returns the error code set by the most recently called method.
@@ -1631,7 +1676,7 @@ struct mschm_decompressor {
1631 * @see open(), close(), fast_find(), extract() 1676 * @see open(), close(), fast_find(), extract()
1632 */ 1677 */
1633 struct mschmd_header *(*fast_open)(struct mschm_decompressor *self, 1678 struct mschmd_header *(*fast_open)(struct mschm_decompressor *self,
1634 const char *filename); 1679 const char *filename);
1635 1680
1636 /** 1681 /**
1637 * Finds file details quickly. 1682 * Finds file details quickly.
@@ -1672,10 +1717,10 @@ struct mschm_decompressor {
1672 * @see open(), close(), fast_find(), extract() 1717 * @see open(), close(), fast_find(), extract()
1673 */ 1718 */
1674 int (*fast_find)(struct mschm_decompressor *self, 1719 int (*fast_find)(struct mschm_decompressor *self,
1675 struct mschmd_header *chm, 1720 struct mschmd_header *chm,
1676 const char *filename, 1721 const char *filename,
1677 struct mschmd_file *f_ptr, 1722 struct mschmd_file *f_ptr,
1678 int f_size); 1723 int f_size);
1679}; 1724};
1680 1725
1681/* --- support for .LIT (EBook) file format -------------------------------- */ 1726/* --- support for .LIT (EBook) file format -------------------------------- */
@@ -1781,9 +1826,9 @@ struct msszdd_compressor {
1781 * @see set_param() 1826 * @see set_param()
1782 */ 1827 */
1783 int (*compress)(struct msszdd_compressor *self, 1828 int (*compress)(struct msszdd_compressor *self,
1784 const char *input, 1829 const char *input,
1785 const char *output, 1830 const char *output,
1786 off_t length); 1831 off_t length);
1787 1832
1788 /** 1833 /**
1789 * Sets an SZDD compression engine parameter. 1834 * Sets an SZDD compression engine parameter.
@@ -1807,8 +1852,8 @@ struct msszdd_compressor {
1807 * @see compress() 1852 * @see compress()
1808 */ 1853 */
1809 int (*set_param)(struct msszdd_compressor *self, 1854 int (*set_param)(struct msszdd_compressor *self,
1810 int param, 1855 int param,
1811 unsigned int value); 1856 int value);
1812 1857
1813 /** 1858 /**
1814 * Returns the error code set by the most recently called method. 1859 * Returns the error code set by the most recently called method.
@@ -1849,7 +1894,7 @@ struct msszdd_decompressor {
1849 * @see close() 1894 * @see close()
1850 */ 1895 */
1851 struct msszddd_header *(*open)(struct msszdd_decompressor *self, 1896 struct msszddd_header *(*open)(struct msszdd_decompressor *self,
1852 const char *filename); 1897 const char *filename);
1853 1898
1854 /** 1899 /**
1855 * Closes a previously opened SZDD file. 1900 * Closes a previously opened SZDD file.
@@ -1865,7 +1910,7 @@ struct msszdd_decompressor {
1865 * @see open() 1910 * @see open()
1866 */ 1911 */
1867 void (*close)(struct msszdd_decompressor *self, 1912 void (*close)(struct msszdd_decompressor *self,
1868 struct msszddd_header *szdd); 1913 struct msszddd_header *szdd);
1869 1914
1870 /** 1915 /**
1871 * Extracts the compressed data from a SZDD file. 1916 * Extracts the compressed data from a SZDD file.
@@ -1881,8 +1926,8 @@ struct msszdd_decompressor {
1881 * @return an error code, or MSPACK_ERR_OK if successful 1926 * @return an error code, or MSPACK_ERR_OK if successful
1882 */ 1927 */
1883 int (*extract)(struct msszdd_decompressor *self, 1928 int (*extract)(struct msszdd_decompressor *self,
1884 struct msszddd_header *szdd, 1929 struct msszddd_header *szdd,
1885 const char *filename); 1930 const char *filename);
1886 1931
1887 /** 1932 /**
1888 * Decompresses an SZDD file to an output file in one step. 1933 * Decompresses an SZDD file to an output file in one step.
@@ -1902,8 +1947,8 @@ struct msszdd_decompressor {
1902 * @return an error code, or MSPACK_ERR_OK if successful 1947 * @return an error code, or MSPACK_ERR_OK if successful
1903 */ 1948 */
1904 int (*decompress)(struct msszdd_decompressor *self, 1949 int (*decompress)(struct msszdd_decompressor *self,
1905 const char *input, 1950 const char *input,
1906 const char *output); 1951 const char *output);
1907 1952
1908 /** 1953 /**
1909 * Returns the error code set by the most recently called method. 1954 * Returns the error code set by the most recently called method.
@@ -1937,6 +1982,8 @@ struct msszdd_decompressor {
1937#define MSKWAJ_COMP_SZDD (2) 1982#define MSKWAJ_COMP_SZDD (2)
1938/** KWAJ compression type: LZ+Huffman compression */ 1983/** KWAJ compression type: LZ+Huffman compression */
1939#define MSKWAJ_COMP_LZH (3) 1984#define MSKWAJ_COMP_LZH (3)
1985/** KWAJ compression type: MSZIP */
1986#define MSKWAJ_COMP_MSZIP (4)
1940 1987
1941/** KWAJ optional header flag: decompressed file length is included */ 1988/** KWAJ optional header flag: decompressed file length is included */
1942#define MSKWAJ_HDR_HASLENGTH (0x01) 1989#define MSKWAJ_HDR_HASLENGTH (0x01)
@@ -2015,9 +2062,9 @@ struct mskwaj_compressor {
2015 * @see set_param() 2062 * @see set_param()
2016 */ 2063 */
2017 int (*compress)(struct mskwaj_compressor *self, 2064 int (*compress)(struct mskwaj_compressor *self,
2018 const char *input, 2065 const char *input,
2019 const char *output, 2066 const char *output,
2020 off_t length); 2067 off_t length);
2021 2068
2022 /** 2069 /**
2023 * Sets an KWAJ compression engine parameter. 2070 * Sets an KWAJ compression engine parameter.
@@ -2043,8 +2090,8 @@ struct mskwaj_compressor {
2043 * @see generate() 2090 * @see generate()
2044 */ 2091 */
2045 int (*set_param)(struct mskwaj_compressor *self, 2092 int (*set_param)(struct mskwaj_compressor *self,
2046 int param, 2093 int param,
2047 unsigned int value); 2094 int value);
2048 2095
2049 2096
2050 /** 2097 /**
@@ -2065,7 +2112,7 @@ struct mskwaj_compressor {
2065 * filename is too long 2112 * filename is too long
2066 */ 2113 */
2067 int (*set_filename)(struct mskwaj_compressor *self, 2114 int (*set_filename)(struct mskwaj_compressor *self,
2068 const char *filename); 2115 const char *filename);
2069 2116
2070 /** 2117 /**
2071 * Sets arbitrary data that will be stored in the header of the 2118 * Sets arbitrary data that will be stored in the header of the
@@ -2085,8 +2132,8 @@ struct mskwaj_compressor {
2085 * is too long 2132 * is too long
2086 */ 2133 */
2087 int (*set_extra_data)(struct mskwaj_compressor *self, 2134 int (*set_extra_data)(struct mskwaj_compressor *self,
2088 void *data, 2135 void *data,
2089 size_t bytes); 2136 size_t bytes);
2090 2137
2091 /** 2138 /**
2092 * Returns the error code set by the most recently called method. 2139 * Returns the error code set by the most recently called method.
@@ -2127,7 +2174,7 @@ struct mskwaj_decompressor {
2127 * @see close() 2174 * @see close()
2128 */ 2175 */
2129 struct mskwajd_header *(*open)(struct mskwaj_decompressor *self, 2176 struct mskwajd_header *(*open)(struct mskwaj_decompressor *self,
2130 const char *filename); 2177 const char *filename);
2131 2178
2132 /** 2179 /**
2133 * Closes a previously opened KWAJ file. 2180 * Closes a previously opened KWAJ file.
@@ -2142,7 +2189,7 @@ struct mskwaj_decompressor {
2142 * @see open() 2189 * @see open()
2143 */ 2190 */
2144 void (*close)(struct mskwaj_decompressor *self, 2191 void (*close)(struct mskwaj_decompressor *self,
2145 struct mskwajd_header *kwaj); 2192 struct mskwajd_header *kwaj);
2146 2193
2147 /** 2194 /**
2148 * Extracts the compressed data from a KWAJ file. 2195 * Extracts the compressed data from a KWAJ file.
@@ -2158,8 +2205,8 @@ struct mskwaj_decompressor {
2158 * @return an error code, or MSPACK_ERR_OK if successful 2205 * @return an error code, or MSPACK_ERR_OK if successful
2159 */ 2206 */
2160 int (*extract)(struct mskwaj_decompressor *self, 2207 int (*extract)(struct mskwaj_decompressor *self,
2161 struct mskwajd_header *kwaj, 2208 struct mskwajd_header *kwaj,
2162 const char *filename); 2209 const char *filename);
2163 2210
2164 /** 2211 /**
2165 * Decompresses an KWAJ file to an output file in one step. 2212 * Decompresses an KWAJ file to an output file in one step.
@@ -2179,8 +2226,8 @@ struct mskwaj_decompressor {
2179 * @return an error code, or MSPACK_ERR_OK if successful 2226 * @return an error code, or MSPACK_ERR_OK if successful
2180 */ 2227 */
2181 int (*decompress)(struct mskwaj_decompressor *self, 2228 int (*decompress)(struct mskwaj_decompressor *self,
2182 const char *input, 2229 const char *input,
2183 const char *output); 2230 const char *output);
2184 2231
2185 /** 2232 /**
2186 * Returns the error code set by the most recently called method. 2233 * Returns the error code set by the most recently called method.
@@ -2196,6 +2243,141 @@ struct mskwaj_decompressor {
2196 int (*last_error)(struct mskwaj_decompressor *self); 2243 int (*last_error)(struct mskwaj_decompressor *self);
2197}; 2244};
2198 2245
2246/* --- support for .LZX (Offline Address Book) file format ----------------- */
2247
2248/**
2249 * A compressor for the Offline Address Book (OAB) format.
2250 *
2251 * All fields are READ ONLY.
2252 *
2253 * @see mspack_create_oab_compressor(), mspack_destroy_oab_compressor()
2254 */
2255struct msoab_compressor {
2256 /**
2257 * Compress a full OAB file.
2258 *
2259 * The input file will be read and the compressed contents written to the
2260 * output file.
2261 *
2262 * @param self a self-referential pointer to the msoab_decompressor
2263 * instance being called
2264 * @param input the filename of the input file. This is passed
2265 * directly to mspack_system::open().
2266 * @param output the filename of the output file. This is passed
2267 * directly to mspack_system::open().
2268 * @return an error code, or MSPACK_ERR_OK if successful
2269 */
2270 int (*compress) (struct msoab_compressor *self,
2271 const char *input,
2272 const char *output);
2273
2274 /**
2275 * Generate a compressed incremental OAB patch file.
2276 *
2277 * The two uncompressed files "input" and "base" will be read, and an
2278 * incremental patch to generate "input" from "base" will be written to
2279 * the output file.
2280 *
2281 * @param self a self-referential pointer to the msoab_compressor
2282 * instance being called
2283 * @param input the filename of the input file containing the new
2284 * version of its contents. This is passed directly
2285 * to mspack_system::open().
2286 * @param base the filename of the original base file containing
2287 * the old version of its contents, against which the
2288 * incremental patch shall generated. This is passed
2289 * directly to mspack_system::open().
2290 * @param output the filename of the output file. This is passed
2291 * directly to mspack_system::open().
2292 * @return an error code, or MSPACK_ERR_OK if successful
2293 */
2294 int (*compress_incremental) (struct msoab_compressor *self,
2295 const char *input,
2296 const char *base,
2297 const char *output);
2298};
2299
2300/**
2301 * A decompressor for .LZX (Offline Address Book) files
2302 *
2303 * All fields are READ ONLY.
2304 *
2305 * @see mspack_create_oab_decompressor(), mspack_destroy_oab_decompressor()
2306 */
2307struct msoab_decompressor {
2308 /**
2309 * Decompresses a full Offline Address Book file.
2310 *
2311 * If the input file is a valid compressed Offline Address Book file,
2312 * it will be read and the decompressed contents will be written to
2313 * the output file.
2314 *
2315 * @param self a self-referential pointer to the msoab_decompressor
2316 * instance being called
2317 * @param input the filename of the input file. This is passed
2318 * directly to mspack_system::open().
2319 * @param output the filename of the output file. This is passed
2320 * directly to mspack_system::open().
2321 * @return an error code, or MSPACK_ERR_OK if successful
2322 */
2323 int (*decompress) (struct msoab_decompressor *self,
2324 const char *input,
2325 const char *output);
2326
2327 /**
2328 * Decompresses an Offline Address Book with an incremental patch file.
2329 *
2330 * This requires both a full UNCOMPRESSED Offline Address Book file to
2331 * act as the "base", and a compressed incremental patch file as input.
2332 * If the input file is valid, it will be decompressed with reference to
2333 * the base file, and the decompressed contents will be written to the
2334 * output file.
2335 *
2336 * There is no way to tell what the right base file is for the given
2337 * incremental patch, but if you get it wrong, this will usually result
2338 * in incorrect data being decompressed, which will then fail a checksum
2339 * test.
2340 *
2341 * @param self a self-referential pointer to the msoab_decompressor
2342 * instance being called
2343 * @param input the filename of the input file. This is passed
2344 * directly to mspack_system::open().
2345 * @param base the filename of the base file to which the
2346 * incremental patch shall be applied. This is passed
2347 * directly to mspack_system::open().
2348 * @param output the filename of the output file. This is passed
2349 * directly to mspack_system::open().
2350 * @return an error code, or MSPACK_ERR_OK if successful
2351 */
2352 int (*decompress_incremental) (struct msoab_decompressor *self,
2353 const char *input,
2354 const char *base,
2355 const char *output);
2356
2357 /**
2358 * Sets an OAB decompression engine parameter. Available only in OAB
2359 * decompressor version 2 and above.
2360 *
2361 * - #MSOABD_PARAM_DECOMPBUF: How many bytes should be used as an input
2362 * buffer by decompressors? The minimum value is 16. The default value
2363 * is 4096.
2364 *
2365 * @param self a self-referential pointer to the msoab_decompressor
2366 * instance being called
2367 * @param param the parameter to set
2368 * @param value the value to set the parameter to
2369 * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there
2370 * is a problem with either parameter or value.
2371 */
2372 int (*set_param)(struct msoab_decompressor *self,
2373 int param,
2374 int value);
2375
2376};
2377
2378/** msoab_decompressor::set_param() parameter: size of decompression buffer */
2379#define MSOABD_PARAM_DECOMPBUF (0)
2380
2199#ifdef __cplusplus 2381#ifdef __cplusplus
2200} 2382}
2201#endif 2383#endif