00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00118 #ifndef LIB_MSPACK_H
00119 #define LIB_MSPACK_H 1
00120
00121 #ifdef __cplusplus
00122 extern "C" {
00123 #endif
00124
00125 #include <sys/types.h>
00126 #include <unistd.h>
00127
00151 #define MSPACK_SYS_SELFTEST(result) do { \
00152 (result) = mspack_sys_selftest_internal(sizeof(off_t)); \
00153 } while (0)
00154
00156 extern int mspack_sys_selftest_internal(int);
00157
00187 extern int mspack_version(int interface);
00188
00190 #define MSPACK_VER_LIBRARY (0)
00191
00192 #define MSPACK_VER_SYSTEM (1)
00193
00194 #define MSPACK_VER_MSCABD (2)
00195
00196 #define MSPACK_VER_MSCABC (3)
00197
00198 #define MSPACK_VER_MSCHMD (4)
00199
00200 #define MSPACK_VER_MSCHMC (5)
00201
00202 #define MSPACK_VER_MSLITD (6)
00203
00204 #define MSPACK_VER_MSLITC (7)
00205
00206 #define MSPACK_VER_MSHLPD (8)
00207
00208 #define MSPACK_VER_MSHLPC (9)
00209
00210 #define MSPACK_VER_MSSZDDD (10)
00211
00212 #define MSPACK_VER_MSSZDDC (11)
00213
00214 #define MSPACK_VER_MSKWAJD (12)
00215
00216 #define MSPACK_VER_MSKWAJC (13)
00217
00218
00219
00239 struct mspack_system {
00263 struct mspack_file * (*open)(struct mspack_system *this,
00264 char *filename,
00265 int mode);
00266
00274 void (*close)(struct mspack_file *file);
00275
00287 int (*read)(struct mspack_file *file,
00288 void *buffer,
00289 int bytes);
00290
00304 int (*write)(struct mspack_file *file,
00305 void *buffer,
00306 int bytes);
00307
00331 int (*seek)(struct mspack_file *file,
00332 off_t offset,
00333 int mode);
00334
00342 off_t (*tell)(struct mspack_file *file);
00343
00358 void (*message)(struct mspack_file *file,
00359 char *format,
00360 ...);
00361
00372 void * (*alloc)(struct mspack_system *this,
00373 size_t bytes);
00374
00381 void (*free)(void *ptr);
00382
00395 void (*copy)(void *src,
00396 void *dest,
00397 size_t bytes);
00398
00405 void *null_ptr;
00406 };
00407
00409 #define MSPACK_SYS_OPEN_READ (0)
00410
00411 #define MSPACK_SYS_OPEN_WRITE (1)
00412
00413 #define MSPACK_SYS_OPEN_UPDATE (2)
00414
00415 #define MSPACK_SYS_OPEN_APPEND (3)
00416
00418 #define MSPACK_SYS_SEEK_START (0)
00419
00420 #define MSPACK_SYS_SEEK_CUR (1)
00421
00422 #define MSPACK_SYS_SEEK_END (2)
00423
00429 struct mspack_file {
00430 int dummy;
00431 };
00432
00433
00434
00436 #define MSPACK_ERR_OK (0)
00437
00438 #define MSPACK_ERR_ARGS (1)
00439
00440 #define MSPACK_ERR_OPEN (2)
00441
00442 #define MSPACK_ERR_READ (3)
00443
00444 #define MSPACK_ERR_WRITE (4)
00445
00446 #define MSPACK_ERR_SEEK (5)
00447
00448 #define MSPACK_ERR_NOMEMORY (6)
00449
00450 #define MSPACK_ERR_SIGNATURE (7)
00451
00452 #define MSPACK_ERR_DATAFORMAT (8)
00453
00454 #define MSPACK_ERR_CHECKSUM (9)
00455
00456 #define MSPACK_ERR_CRUNCH (10)
00457
00458 #define MSPACK_ERR_DECRUNCH (11)
00459
00460
00461
00466 extern struct mscab_compressor *
00467 mspack_create_cab_compressor(struct mspack_system *sys);
00468
00473 extern struct mscab_decompressor *
00474 mspack_create_cab_decompressor(struct mspack_system *sys);
00475
00479 extern void mspack_destroy_cab_compressor(struct mscab_compressor *this);
00480
00484 extern void mspack_destroy_cab_decompressor(struct mscab_decompressor *this);
00485
00486
00491 extern struct mschm_compressor *
00492 mspack_create_chm_compressor(struct mspack_system *sys);
00493
00498 extern struct mschm_decompressor *
00499 mspack_create_chm_decompressor(struct mspack_system *sys);
00500
00504 extern void mspack_destroy_chm_compressor(struct mschm_compressor *this);
00505
00509 extern void mspack_destroy_chm_decompressor(struct mschm_decompressor *this);
00510
00511
00516 extern struct mslit_compressor *
00517 mspack_create_lit_compressor(struct mspack_system *sys);
00518
00523 extern struct mslit_decompressor *
00524 mspack_create_lit_decompressor(struct mspack_system *sys);
00525
00529 extern void mspack_destroy_lit_compressor(struct mslit_compressor *this);
00530
00534 extern void mspack_destroy_lit_decompressor(struct mslit_decompressor *this);
00535
00536
00541 extern struct mshlp_compressor *
00542 mspack_create_hlp_compressor(struct mspack_system *sys);
00543
00548 extern struct mshlp_decompressor *
00549 mspack_create_hlp_decompressor(struct mspack_system *sys);
00550
00554 extern void mspack_destroy_hlp_compressor(struct mshlp_compressor *this);
00555
00559 extern void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *this);
00560
00561
00566 extern struct msszdd_compressor *
00567 mspack_create_szdd_compressor(struct mspack_system *sys);
00568
00573 extern struct msszdd_decompressor *
00574 mspack_create_szdd_decompressor(struct mspack_system *sys);
00575
00579 extern void mspack_destroy_szdd_compressor(struct msszdd_compressor *this);
00580
00584 extern void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *this);
00585
00586
00591 extern struct mskwaj_compressor *
00592 mspack_create_kwaj_compressor(struct mspack_system *sys);
00593
00598 extern struct mskwaj_decompressor *
00599 mspack_create_kwaj_decompressor(struct mspack_system *sys);
00600
00604 extern void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *this);
00605
00609 extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *this);
00610
00611
00612
00613
00625 struct mscabd_cabinet {
00631 struct mscabd_cabinet *next;
00632
00638 char *filename;
00639
00641 off_t base_offset;
00642
00644 unsigned int length;
00645
00647 struct mscabd_cabinet *prevcab;
00648
00650 struct mscabd_cabinet *nextcab;
00651
00653 char *prevname;
00654
00656 char *nextname;
00657
00661 char *previnfo;
00662
00666 char *nextinfo;
00667
00669 struct mscabd_file *files;
00670
00672 struct mscabd_folder *folders;
00673
00678 unsigned short set_id;
00679
00685 unsigned short set_index;
00686
00697 unsigned short header_resv;
00698
00710 int flags;
00711 };
00712
00714 #define MSCAB_HDR_RESV_OFFSET (0x28)
00715
00717 #define MSCAB_HDR_PREVCAB (0x01)
00718
00719 #define MSCAB_HDR_NEXTCAB (0x02)
00720
00721 #define MSCAB_HDR_RESV (0x04)
00722
00732 struct mscabd_folder {
00737 struct mscabd_folder *next;
00738
00748 int comp_type;
00749
00755 unsigned int num_blocks;
00756 };
00757
00765 #define MSCABD_COMP_METHOD(comp_type) ((comp_type) & 0x0F)
00766
00773 #define MSCABD_COMP_LEVEL(comp_type) (((comp_type) >> 8) & 0x1F)
00774
00776 #define MSCAB_COMP_NONE (0)
00777
00778 #define MSCAB_COMP_MSZIP (1)
00779
00780 #define MSCAB_COMP_QUANTUM (2)
00781
00782 #define MSCAB_COMP_LZX (3)
00783
00789 struct mscabd_file {
00794 struct mscabd_file *next;
00795
00804 char *filename;
00805
00807 unsigned int length;
00808
00821 int attribs;
00822
00824 char time_h;
00826 char time_m;
00828 char time_s;
00829
00831 char date_d;
00833 char date_m;
00835 int date_y;
00836
00838 struct mscabd_folder *folder;
00839
00841 unsigned int offset;
00842 };
00843
00845 #define MSCAB_ATTRIB_RDONLY (0x01)
00846
00847 #define MSCAB_ATTRIB_HIDDEN (0x02)
00848
00849 #define MSCAB_ATTRIB_SYSTEM (0x04)
00850
00851 #define MSCAB_ATTRIB_ARCH (0x20)
00852
00853 #define MSCAB_ATTRIB_EXEC (0x40)
00854
00855 #define MSCAB_ATTRIB_UTF_NAME (0x80)
00856
00858 #define MSCABD_PARAM_SEARCHBUF (0)
00859
00860 #define MSCABD_PARAM_FIXMSZIP (1)
00861
00862 #define MSCABD_PARAM_DECOMPBUF (2)
00863
00865 struct mscab_compressor {
00866 int dummy;
00867 };
00868
00876 struct mscab_decompressor {
00897 struct mscabd_cabinet * (*open) (struct mscab_decompressor *this,
00898 char *filename);
00899
00929 void (*close)(struct mscab_decompressor *this,
00930 struct mscabd_cabinet *cab);
00931
00966 struct mscabd_cabinet * (*search) (struct mscab_decompressor *this,
00967 char *filename);
00968
01009 int (*append) (struct mscab_decompressor *this,
01010 struct mscabd_cabinet *cab,
01011 struct mscabd_cabinet *nextcab);
01012
01031 int (*prepend) (struct mscab_decompressor *this,
01032 struct mscabd_cabinet *cab,
01033 struct mscabd_cabinet *prevcab);
01034
01057 int (*extract)(struct mscab_decompressor *this,
01058 struct mscabd_file *file,
01059 char *filename);
01060
01083 int (*set_param)(struct mscab_decompressor *this,
01084 int param,
01085 int value);
01086
01098 int (*last_error)(struct mscab_decompressor *);
01099 };
01100
01101
01102
01111 struct mschmd_section {
01113 struct mschmd_header *chm;
01114
01120 unsigned int id;
01121 };
01122
01128 struct mschmd_sec_uncompressed {
01130 struct mschmd_section base;
01131
01133 off_t offset;
01134 };
01135
01141 struct mschmd_sec_mscompressed {
01143 struct mschmd_section base;
01144
01146 struct mschmd_file *content;
01147
01149 struct mschmd_file *control;
01150
01152 struct mschmd_file *rtable;
01153 };
01154
01160 struct mschmd_header {
01162 unsigned int version;
01163
01171 unsigned int timestamp;
01172
01173
01178 unsigned int language;
01179
01184 char *filename;
01185
01187 off_t length;
01188
01190 struct mschmd_file *files;
01191
01198 struct mschmd_file *sysfiles;
01199
01201 struct mschmd_sec_uncompressed sec0;
01202
01204 struct mschmd_sec_mscompressed sec1;
01205
01207 off_t dir_offset;
01208
01210 unsigned int num_chunks;
01211
01213 unsigned int chunk_size;
01214
01216 unsigned int density;
01217
01226 unsigned int depth;
01227
01233 unsigned int index_root;
01234 };
01235
01241 struct mschmd_file {
01246 struct mschmd_file *next;
01247
01252 struct mschmd_section *section;
01253
01255 off_t offset;
01256
01258 off_t length;
01259
01261 char *filename;
01262 };
01263
01265 struct mschm_compressor {
01266 int dummy;
01267 };
01268
01276 struct mschm_decompressor {
01297 struct mschmd_header *(*open)(struct mschm_decompressor *this,
01298 char *filename);
01299
01317 void (*close)(struct mschm_decompressor *this,
01318 struct mschmd_header *chm);
01319
01338 int (*extract)(struct mschm_decompressor *this,
01339 struct mschmd_file *file,
01340 char *filename);
01341
01353 int (*last_error)(struct mschm_decompressor *this);
01354
01377 struct mschmd_header *(*fast_open)(struct mschm_decompressor *this,
01378 char *filename);
01379
01418 int (*fast_find)(struct mschm_decompressor *this,
01419 struct mschmd_header *chm,
01420 char *filename,
01421 struct mschmd_file *f_ptr,
01422 int f_size);
01423 };
01424
01425
01426
01428 struct mslit_compressor {
01429 int dummy;
01430 };
01431
01433 struct mslit_decompressor {
01434 int dummy;
01435 };
01436
01437
01438
01439
01441 struct mshlp_compressor {
01442 int dummy;
01443 };
01444
01446 struct mshlp_decompressor {
01447 int dummy;
01448 };
01449
01450
01451
01452
01454 struct msszdd_compressor {
01455 int dummy;
01456 };
01457
01459 struct msszdd_decompressor {
01460 int dummy;
01461 };
01462
01463
01464
01466 struct mskwaj_compressor {
01467 int dummy;
01468 };
01469
01471 struct mskwaj_decompressor {
01472 int dummy;
01473 };
01474
01475 #ifdef __cplusplus
01476 };
01477 #endif
01478
01479 #endif