7446
|
1 /* ***************************************************************************
|
|
2 **
|
|
3 ** This file is part of the UniquE RAR File Library.
|
|
4 **
|
|
5 ** Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch)
|
|
6 ** UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw@tks6.net)
|
|
7 **
|
|
8 ** The contents of this file are subject to the UniquE RAR File Library
|
|
9 ** License (the "unrarlib-license.txt"). You may not use this file except
|
|
10 ** in compliance with the License. You may obtain a copy of the License
|
|
11 ** at http://www.unrarlib.org/license.html.
|
|
12 ** Software distributed under the License is distributed on an "AS IS"
|
|
13 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied warranty.
|
|
14 **
|
|
15 ** Alternatively, the contents of this file may be used under the terms
|
|
16 ** of the GNU General Public License Version 2 or later (the "GPL"), in
|
|
17 ** which case the provisions of the GPL are applicable instead of those
|
|
18 ** above. If you wish to allow use of your version of this file only
|
|
19 ** under the terms of the GPL and not to allow others to use your version
|
|
20 ** of this file under the terms of the UniquE RAR File Library License,
|
|
21 ** indicate your decision by deleting the provisions above and replace
|
|
22 ** them with the notice and other provisions required by the GPL. If you
|
|
23 ** do not delete the provisions above, a recipient may use your version
|
|
24 ** of this file under the terms of the GPL or the UniquE RAR File Library
|
|
25 ** License.
|
|
26 **
|
|
27 ************************************************************************** */
|
|
28
|
|
29 /* include file for the "UniquE RAR File Library" */
|
|
30 /* (C) 2000-2002 by Christian Scheurer aka. UniquE */
|
|
31 /* multi-OS version (Win32, Linux and SUN) */
|
|
32
|
|
33 #ifndef __URARLIB_H
|
|
34 #define __URARLIB_H
|
|
35
|
|
36 #ifdef __cplusplus
|
|
37 extern "C"
|
|
38 {
|
|
39 #endif
|
|
40
|
|
41
|
|
42 /* ************************************************************************ */
|
|
43 /* ************************************************************************ */
|
|
44 /* ** ** */
|
|
45 /* ** CONFIGURATION of the UniquE RAR FileLib ** */
|
|
46 /* ** ==> you may change the setting for the lib HERE! ** */
|
|
47 /* ** ** */
|
|
48 /* ************************************************************************ */
|
|
49 /* ************************************************************************ */
|
|
50
|
|
51
|
|
52 #define _DEBUG_LOG /* generate debug messages */
|
|
53
|
|
54 #define _DO_CRC32_CHECK /* perform cyclical redundancy */
|
|
55 /* check (CRC32) - disable this */
|
|
56 /* for a little speed-up */
|
|
57 /*#define _USE_ASM*/ /*
|
|
58 * enable assembly extensions
|
|
59 * x86 cpus.
|
|
60 */
|
|
61
|
|
62 /*#define _USE_MEMORY_TO_MEMORY_DECOMPRESSION*/ /* read file from memory or a */
|
|
63 /* resource instead of reading */
|
|
64 /* from a file. NOTE: you wont't*/
|
|
65 /* be able to decompress from */
|
|
66 /* file if you enable this */
|
|
67 /* option! */
|
|
68
|
|
69
|
|
70 #ifdef WIN32 /* autodetect Win32 and Linux */
|
|
71 #define _WIN_32 /* Win32 with VisualC */
|
|
72 #define _DEBUG_LOG_FILE "C:\\temp\\debug_unrar.txt" /* log file path */
|
|
73 #else
|
|
74 #define _UNIX /* Linux or Unix with GCC */
|
|
75 #define _DEBUG_LOG_FILE "/tmp/debug_unrar.txt" /* log file path */
|
|
76 /*#define NON_INTEL_BYTE_ORDER*/ /* GCC on motorola systems */
|
|
77
|
|
78 #endif
|
|
79
|
|
80 /* ------------------------------------------------------------------------ */
|
|
81
|
|
82
|
|
83
|
|
84 /* -- global type definitions --------------------------------------------- */
|
|
85
|
|
86 #ifdef NON_INTEL_BYTE_ORDER
|
|
87 #ifdef _USE_ASM
|
|
88 #warning Disabling assembly because NON_INTEL_BYTE_ORDER is set
|
|
89 #undef _USE_ASM
|
|
90 #endif
|
|
91 #endif
|
|
92
|
|
93 #ifdef _WIN_32
|
|
94 typedef unsigned char UBYTE; /* WIN32 definitions */
|
|
95 typedef unsigned short UWORD;
|
|
96 typedef unsigned long UDWORD;
|
|
97 #endif
|
|
98
|
|
99 #ifdef _UNIX /* LINUX/UNIX definitions */
|
|
100 typedef unsigned char UBYTE;
|
|
101 typedef unsigned short UWORD;
|
|
102 typedef unsigned long UDWORD;
|
|
103 #endif
|
|
104
|
|
105
|
|
106 /* This structure is used for listing archive content */
|
|
107 struct RAR20_archive_entry /* These infos about files are */
|
|
108 { /* stored in RAR v2.0 archives */
|
|
109 char *Name;
|
|
110 UWORD NameSize;
|
|
111 UDWORD PackSize;
|
|
112 UDWORD UnpSize;
|
|
113 UBYTE HostOS; /* MSDOS=0,OS2=1,WIN32=2,UNIX=3 */
|
|
114 UDWORD FileCRC;
|
|
115 UDWORD FileTime;
|
|
116 UBYTE UnpVer;
|
|
117 UBYTE Method;
|
|
118 UDWORD FileAttr;
|
|
119 };
|
|
120
|
|
121 typedef struct archivelist /* used to list archives */
|
|
122 {
|
|
123 struct RAR20_archive_entry item;
|
|
124 struct archivelist *next;
|
|
125 } ArchiveList_struct;
|
|
126
|
|
127
|
|
128 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
|
|
129 typedef struct memory_file /* used to decompress files in */
|
|
130 { /* memory */
|
|
131 void *data; /* pointer to the file data */
|
|
132 unsigned long size; /* total size of the file data */
|
|
133 unsigned long offset; /* offset within "memory-file" */
|
|
134 } MemoryFile;
|
|
135 #endif
|
|
136
|
|
137 /* -- global functions ---------------------------------------------------- */
|
|
138
|
|
139 /* urarlib_get:
|
|
140 * decompresses and decrypt data from a RAR file to a buffer in system memory.
|
|
141 *
|
|
142 * input: *output pointer to an empty char*. This pointer will show
|
|
143 * to the extracted data
|
|
144 * *size shows where to write the size of the decompressed
|
|
145 * file
|
|
146 * (**NOTE: URARLib _does_ memory allocation etc.!**)
|
|
147 * *filename pointer to string containing the file to decompress
|
|
148 * *rarfile pointer to a string with the full name and path of
|
|
149 * the RAR file or pointer to a RAR file in memory if
|
|
150 * memory-to-memory decompression is active.
|
|
151 * *libpassword pointer to a string with the password used to
|
|
152 * en-/decrypt the RAR
|
|
153 * output: int returns TRUE on success or FALSE on error
|
|
154 * (FALSE=0, TRUE=1)
|
|
155 */
|
|
156
|
|
157 extern int urarlib_get(void *output,
|
|
158 unsigned long *size,
|
|
159 char *filename,
|
|
160 void *rarfile,
|
|
161 char *libpassword);
|
|
162
|
|
163
|
|
164
|
|
165 /* urarlib_list:
|
|
166 * list the content of a RAR archive.
|
|
167 *
|
|
168 * input: *rarfile pointer to a string with the full name and path of
|
|
169 * the RAR file or pointer to a RAR file in memory if
|
|
170 * memory-to-memory decompression is active.
|
|
171 * *list pointer to an ArchiveList_struct that can be
|
|
172 * filled with details about the archive
|
|
173 * to the extracted data
|
|
174 * output: int number of files/directories within archive
|
|
175 */
|
|
176
|
|
177 extern int urarlib_list(void *rarfile, ArchiveList_struct *list);
|
|
178
|
|
179
|
|
180 /* urarlib_freelist:
|
|
181 * (after the suggestion and code of Duy Nguyen, Sean O'Blarney
|
|
182 * and Johannes Winkelmann who independently wrote a patch)
|
|
183 * free the memory of a ArchiveList_struct created by urarlib_list.
|
|
184 *
|
|
185 * input: *list pointer to an ArchiveList_struct
|
|
186 * output: -
|
|
187 */
|
|
188
|
|
189 extern void urarlib_freelist(ArchiveList_struct *list);
|
|
190
|
|
191 /* ------------------------------------------------------------------------ */
|
|
192
|
|
193
|
|
194
|
|
195 #ifdef __cplusplus
|
|
196 };
|
|
197 #endif
|
|
198
|
|
199 #endif
|
|
200
|