1 /* ***************************************************************************
3 ** This file is part of the UniquE RAR File Library.
5 ** Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch)
6 ** UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw@tks6.net)
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.
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
27 ************************************************************************** */
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) */
42 /* ************************************************************************ */
43 /* ************************************************************************ */
45 /* ** CONFIGURATION of the UniquE RAR FileLib ** */
46 /* ** ==> you may change the setting for the lib HERE! ** */
48 /* ************************************************************************ */
49 /* ************************************************************************ */
52 /*#define _DEBUG_LOG*/ /* generate debug messages */
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
62 /*#define _USE_MEMORY_TO_MEMORY_DECOMPRESSION*/ /* read file from memory or a */
63 /* resource instead of reading */
64 /* from a file. NOTE: you won't */
65 /* be able to decompress from */
66 /* file if you enable this */
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 */
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 */
80 /* ------------------------------------------------------------------------ */
84 /* -- global type definitions --------------------------------------------- */
86 #ifdef NON_INTEL_BYTE_ORDER
88 #warning Disabling assembly because NON_INTEL_BYTE_ORDER is set
94 typedef unsigned char UBYTE
; /* WIN32 definitions */
95 typedef unsigned short UWORD
;
96 typedef unsigned long UDWORD
;
99 #ifdef _UNIX /* LINUX/UNIX definitions */
100 typedef unsigned char UBYTE
;
101 typedef unsigned short UWORD
;
102 typedef unsigned long UDWORD
;
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 */
113 UBYTE HostOS
; /* MSDOS=0,OS2=1,WIN32=2,UNIX=3 */
121 typedef struct archivelist
/* used to list archives */
123 struct RAR20_archive_entry item
;
124 struct archivelist
*next
;
125 } ArchiveList_struct
;
128 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
129 typedef struct memory_file
/* used to decompress files in */
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" */
137 /* -- global functions ---------------------------------------------------- */
140 * decompresses and decrypt data from a RAR file to a buffer in system memory.
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
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
157 extern int urarlib_get(void *output
,
166 * list the content of a RAR archive.
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
177 extern int urarlib_list(void *rarfile
, ArchiveList_struct
*list
);
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.
185 * input: *list pointer to an ArchiveList_struct
189 extern void urarlib_freelist(ArchiveList_struct
*list
);
191 /* ------------------------------------------------------------------------ */