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 ** Modified for use with MPlayer, detailed changelog at
9 ** http://svn.mplayerhq.hu/mplayer/trunk/
12 ** The contents of this file are subject to the UniquE RAR File Library
13 ** License (the "unrarlib-license.txt"). You may not use this file except
14 ** in compliance with the License. You may obtain a copy of the License
15 ** at http://www.unrarlib.org/license.html.
16 ** Software distributed under the License is distributed on an "AS IS"
17 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied warranty.
19 ** Alternatively, the contents of this file may be used under the terms
20 ** of the GNU General Public License Version 2 or later (the "GPL"), in
21 ** which case the provisions of the GPL are applicable instead of those
22 ** above. If you wish to allow use of your version of this file only
23 ** under the terms of the GPL and not to allow others to use your version
24 ** of this file under the terms of the UniquE RAR File Library License,
25 ** indicate your decision by deleting the provisions above and replace
26 ** them with the notice and other provisions required by the GPL. If you
27 ** do not delete the provisions above, a recipient may use your version
28 ** of this file under the terms of the GPL or the UniquE RAR File Library
31 ************************************************************************** */
33 /* include file for the "UniquE RAR File Library" */
34 /* (C) 2000-2002 by Christian Scheurer aka. UniquE */
35 /* multi-OS version (Win32, Linux and SUN) */
46 /* ************************************************************************ */
47 /* ************************************************************************ */
49 /* ** CONFIGURATION of the UniquE RAR FileLib ** */
50 /* ** ==> you may change the setting for the lib HERE! ** */
52 /* ************************************************************************ */
53 /* ************************************************************************ */
56 /*#define _DEBUG_LOG*/ /* generate debug messages */
58 #define _DO_CRC32_CHECK /* perform cyclical redundancy */
59 /* check (CRC32) - disable this */
60 /* for a little speed-up */
61 /*#define _USE_ASM*/ /*
62 * enable assembly extensions
66 /*#define _USE_MEMORY_TO_MEMORY_DECOMPRESSION*/ /* read file from memory or a */
67 /* resource instead of reading */
68 /* from a file. NOTE: you won't */
69 /* be able to decompress from */
70 /* file if you enable this */
74 #ifdef WIN32 /* autodetect Win32 and Linux */
75 #define _WIN_32 /* Win32 with VisualC */
76 #define _DEBUG_LOG_FILE "C:\\temp\\debug_unrar.txt" /* log file path */
78 #define _UNIX /* Linux or Unix with GCC */
79 #define _DEBUG_LOG_FILE "/tmp/debug_unrar.txt" /* log file path */
80 /*#define NON_INTEL_BYTE_ORDER*/ /* GCC on motorola systems */
84 /* ------------------------------------------------------------------------ */
88 /* -- global type definitions --------------------------------------------- */
90 #ifdef NON_INTEL_BYTE_ORDER
92 #warning Disabling assembly because NON_INTEL_BYTE_ORDER is set
98 typedef unsigned char UBYTE
; /* WIN32 definitions */
99 typedef unsigned short UWORD
;
100 typedef unsigned long UDWORD
;
103 #ifdef _UNIX /* LINUX/UNIX definitions */
104 typedef unsigned char UBYTE
;
105 typedef unsigned short UWORD
;
106 typedef unsigned long UDWORD
;
110 /* This structure is used for listing archive content */
111 struct RAR20_archive_entry
/* These infos about files are */
112 { /* stored in RAR v2.0 archives */
117 UBYTE HostOS
; /* MSDOS=0,OS2=1,WIN32=2,UNIX=3 */
125 typedef struct archivelist
/* used to list archives */
127 struct RAR20_archive_entry item
;
128 struct archivelist
*next
;
129 } ArchiveList_struct
;
132 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
133 typedef struct memory_file
/* used to decompress files in */
135 void *data
; /* pointer to the file data */
136 unsigned long size
; /* total size of the file data */
137 unsigned long offset
; /* offset within "memory-file" */
141 /* -- global functions ---------------------------------------------------- */
144 * decompresses and decrypt data from a RAR file to a buffer in system memory.
146 * input: *output pointer to an empty char*. This pointer will show
147 * to the extracted data
148 * *size shows where to write the size of the decompressed
150 * (**NOTE: URARLib _does_ memory allocation etc.!**)
151 * *filename pointer to string containing the file to decompress
152 * *rarfile pointer to a string with the full name and path of
153 * the RAR file or pointer to a RAR file in memory if
154 * memory-to-memory decompression is active.
155 * *libpassword pointer to a string with the password used to
156 * en-/decrypt the RAR
157 * output: int returns TRUE on success or FALSE on error
161 extern int urarlib_get(void *output
,
170 * list the content of a RAR archive.
172 * input: *rarfile pointer to a string with the full name and path of
173 * the RAR file or pointer to a RAR file in memory if
174 * memory-to-memory decompression is active.
175 * *list pointer to an ArchiveList_struct that can be
176 * filled with details about the archive
177 * to the extracted data
178 * output: int number of files/directories within archive
181 extern int urarlib_list(void *rarfile
, ArchiveList_struct
*list
);
185 * (after the suggestion and code of Duy Nguyen, Sean O'Blarney
186 * and Johannes Winkelmann who independently wrote a patch)
187 * free the memory of a ArchiveList_struct created by urarlib_list.
189 * input: *list pointer to an ArchiveList_struct
193 extern void urarlib_freelist(ArchiveList_struct
*list
);
195 /* ------------------------------------------------------------------------ */