libmspack
mspack.h
Go to the documentation of this file.
1 /* libmspack -- a library for working with Microsoft compression formats.
2  * (C) 2003-2016 Stuart Caie <kyzer@cabextract.org.uk>
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 
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 *
515 
520 extern struct mscab_decompressor *
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 *
540 
545 extern struct mschm_decompressor *
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 *
565 
570 extern struct mslit_decompressor *
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 *
590 
595 extern struct mshlp_decompressor *
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 *
615 
620 extern struct msszdd_decompressor *
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 *
640 
645 extern struct mskwaj_decompressor *
647 
651