1 #ifndef ___LIBARC_LIBARC_H_ 2 #define ___LIBARC_LIBARC_H_ 3 /* 4 Copyright (C) 2000 Masanao Izumo <mo@goice.co.jp> 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21 /* Archive library */ 22 23 #include "libarc/url.h" 24 #include "libarc/mblock.h" 25 26 #define ARC_LIB_VERSION "2.0.2" 27 #define ARC_DEFLATE_LEVEL 6 /* 1:Compress faster .. 9:Compress better */ 28 #define ARC_ENTRY_HASHSIZE 63 29 30 31 32 /* 33 * Interfaces 34 */ 35 36 extern char **expand_archive_names(int *nfiles_in_out, char **files); 37 /* Regist all archive files in `files_in_out', and expand the archive */ 38 39 void arc_list_free(char **files); 40 /* Free memories which are allocated by expand_archive_names() */ 41 42 extern URL url_arc_open(char *name); 43 /* Open input stream from archive. `name' format must be "filename#entry". 44 */ 45 46 extern void free_archive_files(void); 47 /* Call once at the last */ 48 49 /* utilities */ 50 extern int skip_gzip_header(URL url); 51 extern int parse_gzip_header_bytes(char *gz, long maxparse, int *hdrsiz); 52 extern int get_archive_type(char *archive_name); 53 extern void *arc_compress(void *buff, long bufsiz, 54 int compress_level, long *compressed_size); 55 extern void *arc_decompress(void *buff, long bufsiz, long *decompressed_size); 56 extern int arc_case_wildmat(char *text, char *p); 57 extern int arc_wildmat(char *text, char *p); 58 extern void (* arc_error_handler)(char *error_message); 59 60 61 /* 62 * Internal library usage only 63 */ 64 typedef struct _ArchiveEntryNode 65 { 66 struct _ArchiveEntryNode *next; /* next entry */ 67 char *name; /* Name of this entry */ 68 69 int comptype; /* Compression/Encoding type */ 70 long compsize; /* Compressed size */ 71 long origsize; /* Uncompressed size */ 72 long start; /* Offset start point */ 73 void *cache; /* Cached data */ 74 } ArchiveEntryNode; 75 76 typedef struct _ArchiveHandler { 77 int isfile; 78 URL url; /* Input stream */ 79 int counter;/* counter to extract the entry*/ 80 long pos; 81 } ArchiveHandler; 82 83 extern ArchiveHandler arc_handler; 84 extern ArchiveEntryNode *arc_parse_entry(URL url, int archive_type); 85 extern ArchiveEntryNode *new_entry_node(char *name, int len); 86 extern ArchiveEntryNode *next_tar_entry(void); 87 extern ArchiveEntryNode *next_zip_entry(void); 88 extern ArchiveEntryNode *next_lzh_entry(void); 89 extern ArchiveEntryNode *next_mime_entry(void); 90 extern void free_entry_node(ArchiveEntryNode *entry); 91 92 /* Compression/Encoding type */ 93 enum 94 { 95 ARCHIVEC_STORED, /* No compression */ 96 ARCHIVEC_PATHNAME, /* Pathname (Contents exists there) */ 97 ARCHIVEC_COMPRESSED, /* Compressed */ 98 ARCHIVEC_PACKED, /* Packed */ 99 ARCHIVEC_DEFLATED, /* Deflate */ 100 ARCHIVEC_SHRUNKED, /* Shrunked */ 101 ARCHIVEC_REDUCED1, /* Reduced with compression factor 1 */ 102 ARCHIVEC_REDUCED2, /* Reduced with compression factor 2 */ 103 ARCHIVEC_REDUCED3, /* Reduced with compression factor 3 */ 104 ARCHIVEC_REDUCED4, /* Reduced with compression factor 4 */ 105 ARCHIVEC_IMPLODED, /* Implode base-tag */ 106 ARCHIVEC_IMPLODED_LIT8, /* 8K sliding window (coded) */ 107 ARCHIVEC_IMPLODED_LIT4, /* 4K sliding window (coded) */ 108 ARCHIVEC_IMPLODED_NOLIT8, /* 8K sliding window (uncoded) */ 109 ARCHIVEC_IMPLODED_NOLIT4, /* 4K sliding window (uncoded) */ 110 ARCHIVEC_LZHED, /* LZH base-tag */ 111 ARCHIVEC_LZHED_LH0, /* -lh0- (ARCHIVE_STORED) */ 112 ARCHIVEC_LZHED_LH1, /* -lh1- */ 113 ARCHIVEC_LZHED_LH2, /* -lh2- */ 114 ARCHIVEC_LZHED_LH3, /* -lh3- */ 115 ARCHIVEC_LZHED_LH4, /* -lh4- */ 116 ARCHIVEC_LZHED_LH5, /* -lh5- */ 117 ARCHIVEC_LZHED_LZS, /* -lzs- */ 118 ARCHIVEC_LZHED_LZ5, /* -lz5- */ 119 ARCHIVEC_LZHED_LZ4, /* -lz4- (ARCHIVE_STORED) */ 120 ARCHIVEC_LZHED_LHD, /* -lhd- (Directory, No compression data) */ 121 ARCHIVEC_LZHED_LH6, /* -lh6- */ 122 ARCHIVEC_LZHED_LH7, /* -lh7- */ 123 124 /* Encode for MIME */ 125 ARCHIVEC_UU, /* uu encoded */ 126 ARCHIVEC_B64, /* base64 encoded */ 127 ARCHIVEC_QS, /* quoted string encoded */ 128 ARCHIVEC_HQX /* HQX encoded */ 129 }; 130 131 /* archive_type */ 132 enum 133 { 134 ARCHIVE_TAR, 135 ARCHIVE_TGZ, 136 ARCHIVE_ZIP, 137 ARCHIVE_LZH, 138 ARCHIVE_DIR, 139 ARCHIVE_MIME, 140 ARCHIVE_NEWSGROUP 141 }; 142 143 #endif /* ___LIBARC_H_ */ 144