annotate unrarlib.c @ 10085:f3bc060a1731

ffsvq3 note, according to anonymous the stsd atom must be passed in extradata ...
author michael
date Sat, 10 May 2003 00:19:19 +0000
parents 31126ea5cd36
children 228a767a51fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1 /* ***************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
3 ** This file is part of the UniquE RAR File Library.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
4 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
5 ** Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
6 ** UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw@tks6.net)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
7 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
8 ** The contents of this file are subject to the UniquE RAR File Library
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
9 ** License (the "unrarlib-license.txt"). You may not use this file except
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
10 ** in compliance with the License. You may obtain a copy of the License
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
11 ** at http://www.unrarlib.org/license.html.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
12 ** Software distributed under the License is distributed on an "AS IS"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
13 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied warranty.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
14 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
15 ** Alternatively, the contents of this file may be used under the terms
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
16 ** of the GNU General Public License Version 2 or later (the "GPL"), in
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
17 ** which case the provisions of the GPL are applicable instead of those
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
18 ** above. If you wish to allow use of your version of this file only
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
19 ** under the terms of the GPL and not to allow others to use your version
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
20 ** of this file under the terms of the UniquE RAR File Library License,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
21 ** indicate your decision by deleting the provisions above and replace
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
22 ** them with the notice and other provisions required by the GPL. If you
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
23 ** do not delete the provisions above, a recipient may use your version
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
24 ** of this file under the terms of the GPL or the UniquE RAR File Library
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
25 ** License.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
26 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
27 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
28
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
29 /* ***************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
30 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
31 ** UniquE RAR File Library
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
32 ** The free file lib for the demoscene
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
33 ** multi-OS version (Win32, Linux and SunOS)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
34 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
35 *****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
36 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
37 ** ==> Please configure the program in "unrarlib.h". <==
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
38 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
39 ** RAR decompression code:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
40 ** (C) Eugene Roshal
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
41 ** Modifications to a FileLib:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
42 ** (C) 2000-2002 Christian Scheurer aka. UniquE/Vantage (cs@unrarlib.org)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
43 ** Linux port:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
44 ** (C) 2000-2002 Johannes Winkelmann (jw@tks6.net)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
45 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
46 ** The UniquE RAR File Library gives you the ability to access RAR archives
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
47 ** (any compression method supported in RAR v2.0 including Multimedia
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
48 ** Compression and encryption) directly from your program with ease an by
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
49 ** adding only 12kB (6kB UPX-compressed) additional code to your program.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
50 ** Both solid and normal (recommended for fast random access to the files!)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
51 ** archives are supported. This FileLib is made for the Demo scene, so it's
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
52 ** designed for easy use within your demos and intros.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
53 ** Please read "licence.txt" to learn more about how you may use URARFileLib
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
54 ** in your productions.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
55 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
56 *****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
57 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
58 ** ==> see the "CHANGES" file to see what's new
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
59 **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
60 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
61
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
62 /* -- include files ------------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
63 #include "unrarlib.h" /* include global configuration */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
64 /* ------------------------------------------------------------------------ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
65
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
66
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
67
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
68 /* -- global stuff -------------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
69 #ifdef _WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
70
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
71 #include <windows.h> /* WIN32 definitions */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
72 #include <stdio.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
73 #include <string.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
74
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
75
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
76 #define ENABLE_ACCESS
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
77
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
78 #define HOST_OS WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
79
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
80 #define FM_NORMAL 0x00
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
81 #define FM_RDONLY 0x01
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
82 #define FM_HIDDEN 0x02
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
83 #define FM_SYSTEM 0x04
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
84 #define FM_LABEL 0x08
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
85 #define FM_DIREC 0x10
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
86 #define FM_ARCH 0x20
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
87
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
88 #define PATHDIVIDER "\\"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
89 #define CPATHDIVIDER '\\'
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
90 #define MASKALL "*.*"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
91
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
92 #define READBINARY "rb"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
93 #define READTEXT "rt"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
94 #define UPDATEBINARY "r+b"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
95 #define CREATEBINARY "w+b"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
96 #define CREATETEXT "w"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
97 #define APPENDTEXT "at"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
98
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
99 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
100
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
101 #ifdef _UNIX
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
102
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
103 #include <stdio.h> /* LINUX/UNIX definitions */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
104 #include <stdlib.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
105 #include <ctype.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
106 #include <string.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
107
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
108 #define ENABLE_ACCESS
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
109
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
110 #define HOST_OS UNIX
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
111
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
112 #define FM_LABEL 0x0000
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
113 #define FM_DIREC 0x4000
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
114
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
115 #define PATHDIVIDER "/"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
116 #define CPATHDIVIDER '/'
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
117 #define MASKALL "*.*"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
118
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
119 #define READBINARY "r"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
120 #define READTEXT "r"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
121 #define UPDATEBINARY "r+"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
122 #define CREATEBINARY "w+"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
123 #define CREATETEXT "w"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
124 #define APPENDTEXT "a"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
125
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
126
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
127 /* emulation of the windows API and data types */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
128 /* 20-08-2000 Johannes Winkelmann, jw@tks6.net */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
129
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
130 typedef long DWORD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
131 typedef short BOOL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
132 #define TRUE 1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
133 #define FALSE 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
134
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
135
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
136 #ifdef _DEBUG_LOG /* define macros for debugging */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
137 #include <unistd.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
138 #include <sys/time.h>
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
139
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
140 DWORD GetTickCount()
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
141 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
142 struct timeval tv;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
143 gettimeofday( &tv, 0 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
144 return (tv.tv_usec / 1000);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
145 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
146 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
147
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
148 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
149
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
150
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
151
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
152
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
153
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
154 #ifdef _DEBUG_LOG /* define macros for debugging */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
155
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
156 BOOL debug_log_first_start = TRUE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
157
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
158 #define debug_log(a); debug_log_proc(a, __FILE__, __LINE__);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
159 #define debug_init(a); debug_init_proc(a);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
160
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
161 void debug_log_proc(char *text, char *sourcefile, int sourceline);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
162 void debug_init_proc(char *file_name);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
163
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
164 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
165 #define debug_log(a); /* no debug this time */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
166 #define debug_init(a); /* no debug this time */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
167 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
168
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
169
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
170
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
171
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
172
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
173 #define MAXWINSIZE 0x100000
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
174 #define MAXWINMASK (MAXWINSIZE-1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
175 #define UNP_MEMORY MAXWINSIZE
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
176 #define Min(x,y) (((x)<(y)) ? (x):(y))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
177 #define Max(x,y) (((x)>(y)) ? (x):(y))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
178 #define NM 260
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
179
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
180 #define SIZEOF_MARKHEAD 7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
181 #define SIZEOF_OLDMHD 7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
182 #define SIZEOF_NEWMHD 13
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
183 #define SIZEOF_OLDLHD 21
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
184 #define SIZEOF_NEWLHD 32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
185 #define SIZEOF_SHORTBLOCKHEAD 7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
186 #define SIZEOF_LONGBLOCKHEAD 11
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
187 #define SIZEOF_COMMHEAD 13
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
188 #define SIZEOF_PROTECTHEAD 26
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
189
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
190
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
191 #define PACK_VER 20 /* version of decompression code*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
192 #define UNP_VER 20
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
193 #define PROTECT_VER 20
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
194
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
195
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
196 enum { M_DENYREAD,M_DENYWRITE,M_DENYNONE,M_DENYALL };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
197 enum { FILE_EMPTY,FILE_ADD,FILE_UPDATE,FILE_COPYOLD,FILE_COPYBLOCK };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
198 enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
199 OPEN_ERROR,USER_ERROR,MEMORY_ERROR,USER_BREAK=255,IMM_ABORT=0x8000 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
200 enum { EN_LOCK=1,EN_VOL=2 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
201 enum { SD_MEMORY=1,SD_FILES=2 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
202 enum { NAMES_DONTCHANGE };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
203 enum { LOG_ARC=1,LOG_FILE=2 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
204 enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
205 enum { OLD_UNPACK,NEW_UNPACK };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
206
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
207
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
208 #define MHD_COMMENT 2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
209 #define MHD_LOCK 4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
210 #define MHD_PACK_COMMENT 16
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
211 #define MHD_AV 32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
212 #define MHD_PROTECT 64
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
213
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
214 #define LHD_SPLIT_BEFORE 1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
215 #define LHD_SPLIT_AFTER 2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
216 #define LHD_PASSWORD 4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
217 #define LHD_COMMENT 8
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
218 #define LHD_SOLID 16
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
219
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
220 #define LHD_WINDOWMASK 0x00e0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
221 #define LHD_WINDOW64 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
222 #define LHD_WINDOW128 32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
223 #define LHD_WINDOW256 64
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
224 #define LHD_WINDOW512 96
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
225 #define LHD_WINDOW1024 128
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
226 #define LHD_DIRECTORY 0x00e0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
227
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
228 #define LONG_BLOCK 0x8000
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
229 #define READSUBBLOCK 0x8000
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
230
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
231 enum { ALL_HEAD=0,MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
232 COMM_HEAD=0x75,AV_HEAD=0x76,SUB_HEAD=0x77,PROTECT_HEAD=0x78};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
233 enum { EA_HEAD=0x100 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
234 enum { MS_DOS=0,OS2=1,WIN_32=2,UNIX=3 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
235
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
236
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
237 struct MarkHeader
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
238 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
239 UBYTE Mark[7];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
240 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
241
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
242
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
243 struct NewMainArchiveHeader
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
244 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
245 UWORD HeadCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
246 UBYTE HeadType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
247 UWORD Flags;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
248 UWORD HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
249 UWORD Reserved;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
250 UDWORD Reserved1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
251 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
252
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
253
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
254 struct NewFileHeader
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
255 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
256 UWORD HeadCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
257 UBYTE HeadType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
258 UWORD Flags;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
259 UWORD HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
260 UDWORD PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
261 UDWORD UnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
262 UBYTE HostOS;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
263 UDWORD FileCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
264 UDWORD FileTime;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
265 UBYTE UnpVer;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
266 UBYTE Method;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
267 UWORD NameSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
268 UDWORD FileAttr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
269 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
270
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
271
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
272 struct BlockHeader
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
273 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
274 UWORD HeadCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
275 UBYTE HeadType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
276 UWORD Flags;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
277 UWORD HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
278 UDWORD DataSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
279 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
280
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
281
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
282 struct Decode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
283 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
284 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
285 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
286 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
287 unsigned int DecodeNum[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
288 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
289
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
290
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
291 struct MarkHeader MarkHead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
292 struct NewMainArchiveHeader NewMhd;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
293 struct NewFileHeader NewLhd;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
294 struct BlockHeader BlockHead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
295
9584
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
296 UBYTE *TempMemory = NULL; /* temporary unpack-buffer */
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
297 char *CommMemory = NULL;
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
298
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
299
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
300 UBYTE *UnpMemory = NULL;
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
301 char ArgName[NM]; /* current file in rar archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
302 char ArcFileName[NM]; /* file to decompress */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
303
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
304 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION /* mem-to-mem decompression */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
305 MemoryFile *MemRARFile; /* pointer to RAR file in memory*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
306 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
307 char ArcName[255]; /* RAR archive name */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
308 FILE *ArcPtr; /* input RAR file handler */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
309 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
310 char Password[255]; /* password to decrypt files */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
311
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
312 unsigned char *temp_output_buffer; /* extract files to this pointer*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
313 unsigned long *temp_output_buffer_offset; /* size of temp. extract buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
314
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
315 BOOL FileFound; /* TRUE=use current extracted */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
316 /* data FALSE=throw data away, */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
317 /* wrong file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
318 int MainHeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
319 long CurBlockPos,NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
320
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
321 unsigned long CurUnpRead, CurUnpWrite;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
322 long UnpPackedSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
323 long DestUnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
324
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
325 UDWORD HeaderCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
326 int Encryption;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
327
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
328 unsigned int UnpWrSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
329 unsigned char *UnpWrAddr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
330 unsigned int UnpPtr,WrPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
331
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
332 unsigned char PN1,PN2,PN3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
333 unsigned short OldKey[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
334
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
335
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
336
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
337 /* function header definitions */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
338 int ReadHeader(int BlockType);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
339 BOOL ExtrFile(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
340 BOOL ListFile(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
341 int tread(void *stream,void *buf,unsigned len);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
342 int tseek(void *stream,long offset,int fromwhere);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
343 BOOL UnstoreFile(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
344 int IsArchive(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
345 int ReadBlock(int BlockType);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
346 unsigned int UnpRead(unsigned char *Addr,unsigned int Count);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
347 void UnpInitData(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
348 void Unpack(unsigned char *UnpAddr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
349 UBYTE DecodeAudio(int Delta);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
350 static void DecodeNumber(struct Decode *Dec);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
351 void UpdKeys(UBYTE *Buf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
352 void SetCryptKeys(char *Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
353 void SetOldKeys(char *Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
354 void DecryptBlock(unsigned char *Buf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
355 void InitCRC(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
356 UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
357 void UnpReadBuf(int FirstBuf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
358 void ReadTables(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
359 static void ReadLastTables(void);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
360 static void MakeDecodeTables(unsigned char *LenTab,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
361 struct Decode *Dec,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
362 int Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
363 int stricomp(char *Str1,char *Str2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
364 /* ------------------------------------------------------------------------ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
365
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
366
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
367 /* -- global functions ---------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
368
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
369 int urarlib_get(void *output,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
370 unsigned long *size,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
371 char *filename,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
372 void *rarfile,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
373 char *libpassword)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
374 /* Get a file from a RAR file to the "output" buffer. The UniquE RAR FileLib
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
375 * does everything from allocating memory, decrypting and unpacking the file
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
376 * from the archive. TRUE is returned if the file could be successfully
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
377 * extracted, else a FALSE indicates a failure.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
378 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
379 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
380 BOOL retcode = FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
381
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
382 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
383 int str_offs; /* used for debug-strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
384 char DebugMsg[500]; /* used to compose debug msg */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
385
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
386 if(debug_log_first_start)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
387 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
388 debug_log_first_start=FALSE; /* only create a new log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
389 debug_init(_DEBUG_LOG_FILE); /* on startup */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
390 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
391
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
392 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
393
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
394 InitCRC(); /* init some vars */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
395
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
396 strcpy(ArgName, filename); /* set file(s) to extract */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
397 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
398 MemRARFile = rarfile; /* set pointer to mem-RAR file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
399 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
400 strcpy(ArcName, rarfile); /* set RAR file name */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
401 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
402 if(libpassword != NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
403 strcpy(Password, libpassword); /* init password */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
404
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
405 temp_output_buffer = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
406 temp_output_buffer_offset=size; /* set size of the temp buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
407
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
408 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
409 sprintf(DebugMsg, "Extracting >%s< from >%s< (password is >%s<)...",
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
410 filename, (char*)rarfile, libpassword);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
411 debug_log(DebugMsg);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
412 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
413
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
414 retcode = ExtrFile(); /* unpack file now! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
415
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
416 memset(Password,0,sizeof(Password)); /* clear password */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
417
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
418 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
419 if (ArcPtr!=NULL){
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
420 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
421 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
422 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
423 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
424
9584
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
425 if(UnpMemory) free(UnpMemory); /* free memory */
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
426 if(TempMemory) free(TempMemory);
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
427 if(CommMemory) free(CommMemory);
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
428 UnpMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
429 TempMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
430 CommMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
431
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
432
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
433 if(retcode == FALSE)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
434 {
9584
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
435 if(temp_output_buffer) /* free memory and return NULL */
31126ea5cd36 Some free(NULL) found with njamd
albeu
parents: 8451
diff changeset
436 free(temp_output_buffer);
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
437 temp_output_buffer=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
438 *(DWORD*)output=0; /* pointer on errors */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
439 *size=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
440 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
441
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
442
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
443 /* sorry for this ugly code, but older SunOS gcc compilers don't support */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
444 /* white spaces within strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
445 str_offs = sprintf(DebugMsg, "Error - couldn't extract ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
446 str_offs += sprintf(DebugMsg + str_offs, ">%s<", filename);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
447 str_offs += sprintf(DebugMsg + str_offs, " and allocated ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
448 str_offs += sprintf(DebugMsg + str_offs, "%u Bytes", (unsigned int)*size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
449 str_offs += sprintf(DebugMsg + str_offs, " of unused memory!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
450
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
451 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
452 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
453 sprintf(DebugMsg, "Extracted %u Bytes.", (unsigned int)*size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
454 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
455 debug_log(DebugMsg);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
456 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
457 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
458 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
459 *(DWORD*)output=(DWORD)temp_output_buffer;/* return pointer for unpacked*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
460 /* data */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
461
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
462 return retcode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
463 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
464
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
465
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
466 int urarlib_list(void *rarfile, ArchiveList_struct *list)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
467 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
468 ArchiveList_struct *tmp_List = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
469 int NoOfFilesInArchive = 0; /* number of files in archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
470
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
471 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
472 if(debug_log_first_start)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
473 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
474 debug_log_first_start=FALSE; /* only create a new log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
475 debug_init(_DEBUG_LOG_FILE); /* on startup */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
476 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
477 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
478
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
479 InitCRC(); /* init some vars */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
480
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
481 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
482 MemRARFile = rarfile; /* assign pointer to RAR file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
483 MemRARFile->offset = 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
484 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
485 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
486 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
487 return NoOfFilesInArchive; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
488 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
489 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
490 /* open and identify archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
491 if ((ArcPtr=fopen(rarfile,READBINARY))!=NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
492 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
493 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
494 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
495 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
496 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
497 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
498 return NoOfFilesInArchive; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
499 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
500 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
501 else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
502 debug_log("Error opening file.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
503 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
504 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
505 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
506
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
507 if ((UnpMemory=malloc(UNP_MEMORY))==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
508 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
509 debug_log("Can't allocate memory for decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
510 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
511 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
512
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
513 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
514 MemRARFile->offset+=NewMhd.HeadSize-MainHeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
515 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
516 tseek(ArcPtr,NewMhd.HeadSize-MainHeadSize,SEEK_CUR);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
517 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
518 (*(DWORD*)list) = (DWORD)NULL; /* init file list */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
519 /* do while file is not extracted and there's no error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
520 while (TRUE)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
521 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
522 if (ReadBlock(FILE_HEAD | READSUBBLOCK) <= 0) /* read name of the next */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
523 { /* file within the RAR archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
524 debug_log("Couldn't read next filename from archive (I/O error).");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
525 break; /* error, file not found in */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
526 } /* archive or I/O error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
527 if (BlockHead.HeadType==SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
528 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
529 debug_log("Sorry, sub-headers not supported.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
530 break; /* error => exit */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
531 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
532
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
533 if((void*)(*(DWORD*)list) == NULL) /* first entry */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
534 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
535 tmp_List = malloc(sizeof(ArchiveList_struct));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
536 tmp_List->next = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
537
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
538 (*(DWORD*)list) = (DWORD)tmp_List;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
539
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
540 } else /* add entry */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
541 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
542 tmp_List->next = malloc(sizeof(ArchiveList_struct));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
543 tmp_List = (ArchiveList_struct*) tmp_List->next;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
544 tmp_List->next = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
545 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
546
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
547 tmp_List->item.Name = malloc(NewLhd.NameSize + 1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
548 strcpy(tmp_List->item.Name, ArcFileName);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
549 tmp_List->item.NameSize = NewLhd.NameSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
550 tmp_List->item.PackSize = NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
551 tmp_List->item.UnpSize = NewLhd.UnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
552 tmp_List->item.HostOS = NewLhd.HostOS;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
553 tmp_List->item.FileCRC = NewLhd.FileCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
554 tmp_List->item.FileTime = NewLhd.FileTime;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
555 tmp_List->item.UnpVer = NewLhd.UnpVer;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
556 tmp_List->item.Method = NewLhd.Method;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
557 tmp_List->item.FileAttr = NewLhd.FileAttr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
558
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
559 NoOfFilesInArchive++; /* count files */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
560
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
561 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
562 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
563 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
564 if (ArcPtr!=NULL) tseek(ArcPtr,NextBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
565 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
566
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
567 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
568
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
569 /* free memory, clear password and close archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
570 memset(Password,0,sizeof(Password)); /* clear password */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
571 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
572 if (ArcPtr!=NULL){
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
573 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
574 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
575 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
576 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
577
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
578 free(UnpMemory); /* free memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
579 free(TempMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
580 free(CommMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
581 UnpMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
582 TempMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
583 CommMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
584
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
585 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
586 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
587
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
588
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
589
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
590 /* urarlib_freelist:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
591 * (after the suggestion and code of Duy Nguyen, Sean O'Blarney
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
592 * and Johannes Winkelmann who independently wrote a patch)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
593 * free the memory of a ArchiveList_struct created by urarlib_list.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
594 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
595 * input: *list pointer to an ArchiveList_struct
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
596 * output: -
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
597 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
598
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
599 void urarlib_freelist(ArchiveList_struct *list)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
600 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
601 ArchiveList_struct* tmp = list;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
602
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
603 while ( list ) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
604 tmp = list->next;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
605 free( list->item.Name );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
606 free( list );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
607 list = tmp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
608 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
609 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
610
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
611
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
612 /* ------------------------------------------------------------------------ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
613
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
614
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
615
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
616
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
617
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
618
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
619
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
620
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
621
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
622
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
623
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
624
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
625
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
626
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
627
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
628
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
629
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
630 /****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
631 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
632 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
633 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
634 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
635 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
636 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
637 ******* B L O C K I / O *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
638 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
639 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
640 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
641 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
642 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
643 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
644 ****************************************************************************/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
645
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
646
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
647
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
648 #define GetHeaderByte(N) Header[N]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
649
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
650 #define GetHeaderWord(N) (Header[N]+((UWORD)Header[N+1]<<8))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
651
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
652 #define GetHeaderDword(N) (Header[N]+((UWORD)Header[N+1]<<8)+\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
653 ((UDWORD)Header[N+2]<<16)+\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
654 ((UDWORD)Header[N+3]<<24))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
655
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
656
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
657 int ReadBlock(int BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
658 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
659 struct NewFileHeader SaveFileHead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
660 int Size=0,ReadSubBlock=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
661 static int LastBlock;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
662 memcpy(&SaveFileHead,&NewLhd,sizeof(SaveFileHead));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
663 if (BlockType & READSUBBLOCK)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
664 ReadSubBlock=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
665 BlockType &= 0xff;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
666 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
667 while (1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
668 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
669 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
670 CurBlockPos=MemRARFile->offset; /* get offset of mem-file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
671 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
672 CurBlockPos=ftell(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
673 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
674 Size=ReadHeader(FILE_HEAD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
675 if (Size!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
676 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
677 if (NewLhd.HeadSize<SIZEOF_SHORTBLOCKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
678 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
679 NextBlockPos=CurBlockPos+NewLhd.HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
680 if (NewLhd.Flags & LONG_BLOCK)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
681 NextBlockPos+=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
682 if (NextBlockPos<=CurBlockPos)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
683 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
684 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
685
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
686 if (Size > 0 && BlockType!=SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
687 LastBlock=BlockType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
688 if (Size==0 || BlockType==ALL_HEAD || NewLhd.HeadType==BlockType ||
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
689 (NewLhd.HeadType==SUB_HEAD && ReadSubBlock && LastBlock==BlockType))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
690 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
691 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
692 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
693 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
694 tseek(ArcPtr, NextBlockPos, SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
695 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
696 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
697 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
698
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
699 BlockHead.HeadCRC=NewLhd.HeadCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
700 BlockHead.HeadType=NewLhd.HeadType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
701 BlockHead.Flags=NewLhd.Flags;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
702 BlockHead.HeadSize=NewLhd.HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
703 BlockHead.DataSize=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
704
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
705 if (BlockType!=NewLhd.HeadType) BlockType=ALL_HEAD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
706
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
707 if((FILE_HEAD == BlockType) && (Size>0))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
708 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
709 NewLhd.NameSize=Min(NewLhd.NameSize,sizeof(ArcFileName)-1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
710 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
711 tread(MemRARFile, ArcFileName, NewLhd.NameSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
712 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
713 tread(ArcPtr,ArcFileName,NewLhd.NameSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
714 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
715 ArcFileName[NewLhd.NameSize]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
716 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
717 if (NewLhd.HeadCRC!=(UWORD)~CalcCRC32(HeaderCRC,(UBYTE*)&ArcFileName[0],
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
718 NewLhd.NameSize))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
719 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
720 debug_log("file header broken");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
721 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
722 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
723 Size+=NewLhd.NameSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
724 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
725 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
726 memcpy(&NewLhd,&SaveFileHead,sizeof(NewLhd));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
727 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
728 MemRARFile->offset = CurBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
729 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
730 tseek(ArcPtr,CurBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
731 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
732 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
733
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
734
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
735 return(Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
736 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
737
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
738
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
739 int ReadHeader(int BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
740 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
741 int Size = 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
742 unsigned char Header[64];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
743 switch(BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
744 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
745 case MAIN_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
746 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
747 Size=tread(MemRARFile, Header, SIZEOF_NEWMHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
748 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
749 Size=tread(ArcPtr,Header,SIZEOF_NEWMHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
750 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
751 NewMhd.HeadCRC=(unsigned short)GetHeaderWord(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
752 NewMhd.HeadType=GetHeaderByte(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
753 NewMhd.Flags=(unsigned short)GetHeaderWord(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
754 NewMhd.HeadSize=(unsigned short)GetHeaderWord(5);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
755 NewMhd.Reserved=(unsigned short)GetHeaderWord(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
756 NewMhd.Reserved1=GetHeaderDword(9);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
757 HeaderCRC=CalcCRC32(0xFFFFFFFFL,&Header[2],SIZEOF_NEWMHD-2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
758 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
759 case FILE_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
760 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
761 Size=tread(MemRARFile, Header, SIZEOF_NEWLHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
762 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
763 Size=tread(ArcPtr,Header,SIZEOF_NEWLHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
764 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
765 NewLhd.HeadCRC=(unsigned short)GetHeaderWord(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
766 NewLhd.HeadType=GetHeaderByte(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
767 NewLhd.Flags=(unsigned short)GetHeaderWord(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
768 NewLhd.HeadSize=(unsigned short)GetHeaderWord(5);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
769 NewLhd.PackSize=GetHeaderDword(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
770 NewLhd.UnpSize=GetHeaderDword(11);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
771 NewLhd.HostOS=GetHeaderByte(15);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
772 NewLhd.FileCRC=GetHeaderDword(16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
773 NewLhd.FileTime=GetHeaderDword(20);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
774 NewLhd.UnpVer=GetHeaderByte(24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
775 NewLhd.Method=GetHeaderByte(25);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
776 NewLhd.NameSize=(unsigned short)GetHeaderWord(26);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
777 NewLhd.FileAttr=GetHeaderDword(28);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
778 HeaderCRC=CalcCRC32(0xFFFFFFFFL,&Header[2],SIZEOF_NEWLHD-2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
779 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
780
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
781 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
782 case COMM_HEAD: /* log errors in case of debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
783 debug_log("Comment headers not supported! "\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
784 "Please create archives without comments.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
785 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
786 case PROTECT_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
787 debug_log("Protected headers not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
788 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
789 case ALL_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
790 debug_log("ShortBlockHeader not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
791 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
792 default:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
793 debug_log("Unknown//unsupported !");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
794 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
795 default: /* else do nothing */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
796 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
797 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
798 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
799 return(Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
800 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
801
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
802 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
803 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
804 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
805 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
806
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
807
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
808
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
809
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
810
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
811
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
812
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
813
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
814
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
815
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
816
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
817
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
818
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
819
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
820
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
821
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
822
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
823 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
824 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
825 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
826 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
827 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
828 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
829 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
830 ******* E X T R A C T L O O P *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
831 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
832 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
833 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
834 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
835 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
836 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
837 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
838
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
839
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
840 int IsArchive(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
841 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
842 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
843 int str_offs; /* used for debug-strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
844 char DebugMsg[500]; /* used to compose debug msg */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
845 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
846
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
847 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
848 if (tread(MemRARFile, MarkHead.Mark, SIZEOF_MARKHEAD) != SIZEOF_MARKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
849 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
850 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
851 if (tread(ArcPtr,MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
852 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
853 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
854 /* Old archive => error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
855 if (MarkHead.Mark[0]==0x52 && MarkHead.Mark[1]==0x45 &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
856 MarkHead.Mark[2]==0x7e && MarkHead.Mark[3]==0x5e)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
857 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
858 debug_log("Attention: format as OLD detected! Can't handel archive!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
859 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
860 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
861 /* original RAR v2.0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
862 if ((MarkHead.Mark[0]==0x52 && MarkHead.Mark[1]==0x61 && /* original */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
863 MarkHead.Mark[2]==0x72 && MarkHead.Mark[3]==0x21 && /* RAR header*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
864 MarkHead.Mark[4]==0x1a && MarkHead.Mark[5]==0x07 &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
865 MarkHead.Mark[6]==0x00) ||
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
866 /* "UniquE!" - header */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
867 (MarkHead.Mark[0]=='U' && MarkHead.Mark[1]=='n' && /* "UniquE!" */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
868 MarkHead.Mark[2]=='i' && MarkHead.Mark[3]=='q' && /* header */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
869 MarkHead.Mark[4]=='u' && MarkHead.Mark[5]=='E' &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
870 MarkHead.Mark[6]=='!'))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
871
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
872 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
873 if (ReadHeader(MAIN_HEAD)!=SIZEOF_NEWMHD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
874 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
875 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
876 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
877
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
878 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
879 /* sorry for this ugly code, but older SunOS gcc compilers don't */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
880 /* support white spaces within strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
881 str_offs = sprintf(DebugMsg, "unknown archive type (only plain RAR ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
882 str_offs += sprintf(DebugMsg + str_offs, "supported (normal and solid ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
883 str_offs += sprintf(DebugMsg + str_offs, "archives), SFX and Volumes ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
884 str_offs += sprintf(DebugMsg + str_offs, "are NOT supported!)");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
885
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
886 debug_log(DebugMsg);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
887 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
888
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
889 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
890
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
891
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
892 MainHeadSize=SIZEOF_NEWMHD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
893
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
894 return(TRUE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
895 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
896
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
897
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
898 BOOL ExtrFile(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
899 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
900 BOOL ReturnCode=TRUE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
901 FileFound=FALSE; /* no file found by default */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
902
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
903 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
904 MemRARFile->offset = 0; /* start reading from offset 0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
905 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
906 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
907 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
908 return FALSE; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
909 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
910
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
911 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
912 /* open and identify archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
913 if ((ArcPtr=fopen(ArcName,READBINARY))!=NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
914 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
915 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
916 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
917 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
918 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
919 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
920 return FALSE; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
921 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
922 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
923 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
924 debug_log("Error opening file.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
925 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
926 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
927 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
928
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
929
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
930 if ((UnpMemory=malloc(UNP_MEMORY))==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
931 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
932 debug_log("Can't allocate memory for decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
933 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
934 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
935
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
936 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
937 MemRARFile->offset+=NewMhd.HeadSize-MainHeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
938 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
939 tseek(ArcPtr,NewMhd.HeadSize-MainHeadSize,SEEK_CUR);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
940 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
941
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
942 /* do while file is not extracted and there's no error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
943 do
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
944 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
945
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
946 if (ReadBlock(FILE_HEAD | READSUBBLOCK) <= 0) /* read name of the next */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
947 { /* file within the RAR archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
948 /*
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
949 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
950 * 21.11.2000 UnQ There's a problem with some linux distros when a file
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
951 * can not be found in an archive.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
952 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
953 * debug_log("Couldn't read next filename from archive (I/O error).");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
954 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
955 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
956 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
957 break; /* error, file not found in */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
958 } /* archive or I/O error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
959 if (BlockHead.HeadType==SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
960 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
961 debug_log("Sorry, sub-headers not supported.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
962 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
963 break; /* error => exit */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
964 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
965
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
966
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
967 if(TRUE == (FileFound=(stricomp(ArgName, ArcFileName) == 0)))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
968 /* *** file found! *** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
969 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
970 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
971 temp_output_buffer=malloc(NewLhd.UnpSize);/* allocate memory for the*/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
972 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
973 *temp_output_buffer_offset=0; /* file. The default offset */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
974 /* within the buffer is 0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
975
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
976 if(temp_output_buffer == NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
977 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
978 debug_log("can't allocate memory for the file decompression");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
979 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
980 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
981 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
982
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
983
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
984 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
985
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
986 /* in case of a solid archive, we need to decompress any single file till
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
987 * we have found the one we are looking for. In case of normal archives
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
988 * (recommended!!), we skip the files until we are sure that it is the
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
989 * one we want.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
990 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
991 if((NewMhd.Flags & 0x08) || FileFound)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
992 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
993 if (NewLhd.UnpVer<13 || NewLhd.UnpVer>UNP_VER)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
994 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
995 debug_log("unknown compression method");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
996 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
997 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
998 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
999
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1000 CurUnpRead=CurUnpWrite=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1001 if ((*Password!=0) && (NewLhd.Flags & LHD_PASSWORD))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1002 Encryption=NewLhd.UnpVer;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1003 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1004 Encryption=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1005 if (Encryption) SetCryptKeys(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1006
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1007 UnpPackedSize=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1008 DestUnpSize=NewLhd.UnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1009
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1010 if (NewLhd.Method==0x30)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1011 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1012 UnstoreFile();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1013 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1014 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1015 Unpack(UnpMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1016 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1017
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1018
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1019
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1020 #ifdef _DO_CRC32_CHECK /* calculate CRC32 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1021 if((UBYTE*)temp_output_buffer != NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1022 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1023 if(NewLhd.FileCRC!=~CalcCRC32(0xFFFFFFFFL,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1024 (UBYTE*)temp_output_buffer,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1025 NewLhd.UnpSize))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1026 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1027 debug_log("CRC32 error - file couldn't be decompressed correctly!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1028 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1029 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1030 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1031 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1032 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1033
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1034 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1035
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1036 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1037 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1038 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1039 if (ArcPtr!=NULL) tseek(ArcPtr,NextBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1040 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1041 } while(stricomp(ArgName, ArcFileName) != 0);/* exit if file is extracted */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1042
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1043 /* free memory, clear password and close archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1044 free(UnpMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1045 UnpMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1046 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1047 if (ArcPtr!=NULL){
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1048 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1049 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1050 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1051 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1052
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1053 return ReturnCode; /* file extracted successful! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1054 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1055
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1056 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1057 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1058 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1059 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1060
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1061
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1062
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1063
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1064
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1065
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1066
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1067
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1068
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1069
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1070
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1071
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1072
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1073
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1074
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1075
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1076
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1077
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1078 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1079 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1080 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1081 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1082 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1083 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1084 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1085 ******* G L O B A L F U N C T I O N S *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1086 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1087 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1088 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1089 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1090 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1091 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1092 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1093
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1094
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1095 int tread(void *stream,void *buf,unsigned len)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1096 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1097 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1098
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1099 if(((MemRARFile->offset + len) > MemRARFile->size) || (len == 0))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1100 return 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1101
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1102 memcpy(buf,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1103 (BYTE*)(((MemoryFile*)stream)->data)+((MemoryFile*)stream)->offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1104 len % ((((MemoryFile*)stream)->size) - 1));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1105
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1106 MemRARFile->offset+=len; /* update read pointer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1107 return len % ((((MemoryFile*)stream)->size) - 1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1108 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1109 return(fread(buf,1,len,(FILE*)stream));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1110 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1111 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1112
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1113
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1114 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1115 int tseek(void *stream,long offset,int fromwhere)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1116 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1117 return(fseek((FILE*)stream,offset,fromwhere));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1118 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1119 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1120
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1121
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1122 char* strupper(char *Str)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1123 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1124 char *ChPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1125 for (ChPtr=Str;*ChPtr;ChPtr++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1126 *ChPtr=(char)toupper(*ChPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1127 return(Str);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1128 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1129
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1130
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1131 int stricomp(char *Str1,char *Str2)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1132 /* compare strings without regard of '\' and '/' */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1133 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1134 char S1[512],S2[512];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1135 char *chptr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1136
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1137 strncpy(S1,Str1,sizeof(S1));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1138 strncpy(S2,Str2,sizeof(S2));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1139
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1140 while((chptr = strchr(S1, '\\')) != NULL) /* ignore backslash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1141 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1142 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1143 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1144
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1145 while((chptr = strchr(S2, '\\')) != NULL) /* ignore backslash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1146 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1147 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1148 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1149
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1150 while((chptr = strchr(S1, '/')) != NULL) /* ignore slash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1151 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1152 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1153 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1154
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1155 while((chptr = strchr(S2, '/')) != NULL) /* ignore slash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1156 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1157 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1158 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1159
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1160 return(strcmp(strupper(S1),strupper(S2)));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1161 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1162
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1163
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1164 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1165 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1166 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1167 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1168
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1169
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1170
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1171
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1172
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1173
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1174
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1175
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1176
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1177
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1178
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1179
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1180
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1181
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1182
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1183
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1184
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1185
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1186 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1187 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1188 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1189 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1190 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1191 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1192 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1193 ******* U N P A C K C O D E *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1194 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1195 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1196 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1197 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1198 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1199 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1200 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1201
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1202
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1203 /* *****************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1204 * ** unpack stored RAR files **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1205 * *****************************/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1206
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1207 BOOL UnstoreFile(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1208 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1209 if ((long)(*temp_output_buffer_offset=UnpRead(temp_output_buffer,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1210 NewLhd.UnpSize))==-1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1211 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1212 debug_log("Read error of stored file!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1213 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1214 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1215 return TRUE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1216 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1217
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1218
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1219
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1220
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1221 /* ****************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1222 * ** RAR decompression code starts here **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1223 * ****************************************/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1224
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1225 #define NC 298 /* alphabet = {0,1,2, .,NC - 1} */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1226 #define DC 48
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1227 #define RC 28
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1228 #define BC 19
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1229 #define MC 257
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1230
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1231 enum {CODE_HUFFMAN=0,CODE_LZ=1,CODE_LZ2=2,CODE_REPEATLZ=3,CODE_CACHELZ=4,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1232 CODE_STARTFILE=5,CODE_ENDFILE=6,CODE_STARTMM=8,CODE_ENDMM=7,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1233 CODE_MMDELTA=9};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1234
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1235 struct AudioVariables
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1236 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1237 int K1,K2,K3,K4,K5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1238 int D1,D2,D3,D4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1239 int LastDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1240 unsigned int Dif[11];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1241 unsigned int ByteCount;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1242 int LastChar;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1243 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1244
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1245
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1246 #define NC 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1247 #define DC 48
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1248 #define RC 28
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1249 #define BC 19
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1250 #define MC 257
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1251
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1252
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1253 struct AudioVariables AudV[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1254
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1255 #define GetBits() \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1256 BitField = ( ( ( (UDWORD)InBuf[InAddr] << 16 ) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1257 ( (UWORD) InBuf[InAddr+1] << 8 ) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1258 ( InBuf[InAddr+2] ) ) \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1259 >> (8-InBit) ) & 0xffff;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1260
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1261
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1262 #define AddBits(Bits) \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1263 InAddr += ( InBit + (Bits) ) >> 3; \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1264 InBit = ( InBit + (Bits) ) & 7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1265
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1266 static unsigned char *UnpBuf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1267 static unsigned int BitField;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1268 static unsigned int Number;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1269
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1270 unsigned char InBuf[8192]; /* input read buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1271
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1272 unsigned char UnpOldTable[MC*4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1273
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1274 unsigned int InAddr,InBit,ReadTop;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1275
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1276 unsigned int LastDist,LastLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1277 static unsigned int Length,Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1278
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1279 unsigned int OldDist[4],OldDistPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1280
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1281
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1282 struct LitDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1283 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1284 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1285 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1286 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1287 unsigned int DecodeNum[NC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1288 } LD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1289
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1290 struct DistDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1291 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1292 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1293 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1294 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1295 unsigned int DecodeNum[DC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1296 } DD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1297
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1298 struct RepDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1299 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1300 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1301 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1302 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1303 unsigned int DecodeNum[RC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1304 } RD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1305
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1306 struct MultDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1307 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1308 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1309 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1310 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1311 unsigned int DecodeNum[MC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1312 } MD[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1313
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1314 struct BitDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1315 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1316 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1317 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1318 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1319 unsigned int DecodeNum[BC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1320 } BD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1321
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1322 static struct MultDecode *MDPtr[4]={&MD[0],&MD[1],&MD[2],&MD[3]};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1323
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1324 int UnpAudioBlock,UnpChannels,CurChannel,ChannelDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1325
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1326
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1327 void Unpack(unsigned char *UnpAddr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1328 /* *** 38.3% of all CPU time is spent within this function!!! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1329 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1330 static unsigned char LDecode[]={0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1331 40,48,56,64,80,96,112,128,160,192,224};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1332 static unsigned char LBits[]= {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1333 3,3,3,4,4,4,4,5,5,5,5};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1334 static int DDecode[]={0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1335 512,768,1024,1536,2048,3072,4096,6144,8192,12288,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1336 16384,24576,32768U,49152U,65536,98304,131072,196608,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1337 262144,327680,393216,458752,524288,589824,655360,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1338 720896,786432,851968,917504,983040};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1339 static unsigned char DBits[]= {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1340 9,10,10,11,11,12,12,13,13,14,14,15,15,16,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1341 16,16,16,16,16,16,16,16,16,16,16,16,16};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1342 static unsigned char SDDecode[]={0,4,8,16,32,64,128,192};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1343 static unsigned char SDBits[]={2,2,3, 4, 5, 6, 6, 6};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1344 unsigned int Bits;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1345
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1346
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1347 UnpBuf=UnpAddr; /* UnpAddr is a pointer to the */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1348 UnpInitData(); /* unpack buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1349 UnpReadBuf(1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1350 if (!(NewLhd.Flags & LHD_SOLID))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1351 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1352 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1353
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1354 while (DestUnpSize>=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1355 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1356 UnpPtr&=MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1357
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1358 if (InAddr>sizeof(InBuf)-30)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1359 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1360 if (((WrPtr-UnpPtr) & MAXWINMASK)<270 && WrPtr!=UnpPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1361 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1362
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1363
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1364 if (FileFound)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1365 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1366
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1367 if (UnpPtr<WrPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1368 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1369 if((*temp_output_buffer_offset + UnpPtr) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1370 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1371 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1372 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1373
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1374 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1375 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1376 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1377 memcpy(temp_output_buffer + *temp_output_buffer_offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1378 &UnpBuf[WrPtr], (0-WrPtr) & MAXWINMASK);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1379 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1380 *temp_output_buffer_offset+= (0-WrPtr) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1381 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1382 memcpy(temp_output_buffer + *temp_output_buffer_offset, UnpBuf,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1383 UnpPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1384 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1385 *temp_output_buffer_offset+=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1386 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1387 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1388 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1389 if((*temp_output_buffer_offset + (UnpPtr-WrPtr)) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1390 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1391 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1392 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1393 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1394 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1395 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1396 memcpy(temp_output_buffer + *temp_output_buffer_offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1397 &UnpBuf[WrPtr], UnpPtr-WrPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1398 *temp_output_buffer_offset+=UnpPtr-WrPtr; /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1399 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1400
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1401 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1402 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1403
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1404 WrPtr=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1405 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1406
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1407 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1408 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1409 DecodeNumber((struct Decode *)MDPtr[CurChannel]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1410 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1411 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1412 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1413 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1414 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1415 UnpBuf[UnpPtr++]=DecodeAudio(Number);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1416 if (++CurChannel==UnpChannels)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1417 CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1418 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1419 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1420 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1421
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1422 DecodeNumber((struct Decode *)&LD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1423 if (Number<256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1424 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1425 UnpBuf[UnpPtr++]=(UBYTE)Number;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1426 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1427 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1428 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1429 if (Number>269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1430 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1431 Length=LDecode[Number-=270]+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1432 if ((Bits=LBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1433 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1434 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1435 Length+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1436 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1437 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1438
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1439 DecodeNumber((struct Decode *)&DD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1440 Distance=DDecode[Number]+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1441 if ((Bits=DBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1442 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1443 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1444 Distance+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1445 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1446 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1447
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1448 if (Distance>=0x40000L)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1449 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1450
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1451 if (Distance>=0x2000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1452 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1453
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1454 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1455 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1456 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1457 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1458 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1459 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1460 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1461
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1462 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1463 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1464 if (Number==269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1465 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1466 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1467 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1468 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1469 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1470 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1471 Length=LastLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1472 Distance=LastDist;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1473 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1474 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1475 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1476 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1477 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1478 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1479 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1480 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1481 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1482 if (Number<261)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1483 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1484 Distance=OldDist[(OldDistPtr-(Number-256)) & 3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1485 DecodeNumber((struct Decode *)&RD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1486 Length=LDecode[Number]+2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1487 if ((Bits=LBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1488 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1489 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1490 Length+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1491 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1492 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1493 if (Distance>=0x40000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1494 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1495 if (Distance>=0x2000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1496 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1497 if (Distance>=0x101)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1498 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1499 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1500 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1501 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1502 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1503 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1504 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1505 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1506 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1507 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1508 if (Number<270)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1509 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1510 Distance=SDDecode[Number-=261]+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1511 if ((Bits=SDBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1512 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1513 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1514 Distance+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1515 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1516 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1517 Length=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1518 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1519 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1520 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1521 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1522 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1523 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1524 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1525 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1526 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1527 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1528 ReadLastTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1529
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1530 if (FileFound) /* flush buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1531 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1532
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1533 if (UnpPtr<WrPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1534 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1535 if((*temp_output_buffer_offset + UnpPtr) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1536 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1537 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1538 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1539 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1540 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1541 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1542 memcpy(temp_output_buffer + *temp_output_buffer_offset, &UnpBuf[WrPtr],
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1543 (0-WrPtr) & MAXWINMASK);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1544 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1545 *temp_output_buffer_offset+= (0-WrPtr) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1546 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1547 memcpy(temp_output_buffer + *temp_output_buffer_offset, UnpBuf, UnpPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1548 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1549 *temp_output_buffer_offset+=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1550 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1551 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1552 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1553 if((*temp_output_buffer_offset + (UnpPtr-WrPtr)) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1554 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1555 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1556 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1557 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1558 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1559 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1560 memcpy(temp_output_buffer + *temp_output_buffer_offset, &UnpBuf[WrPtr],
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1561 UnpPtr-WrPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1562 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1563 *temp_output_buffer_offset+=UnpPtr-WrPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1564 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1565 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1566 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1567
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1568 WrPtr=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1569 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1570
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1571
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1572 unsigned int UnpRead(unsigned char *Addr,unsigned int Count)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1573 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1574 int RetCode=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1575 unsigned int I,ReadSize,TotalRead=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1576 unsigned char *ReadAddr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1577 ReadAddr=Addr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1578 while (Count > 0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1579 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1580 ReadSize=(unsigned int)((Count>(unsigned long)UnpPackedSize) ?
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1581 UnpPackedSize : Count);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1582 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1583 if(MemRARFile->data == NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1584 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1585 RetCode=tread(MemRARFile, ReadAddr, ReadSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1586 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1587 if (ArcPtr==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1588 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1589 RetCode=tread(ArcPtr,ReadAddr,ReadSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1590 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1591 CurUnpRead+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1592 ReadAddr+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1593 TotalRead+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1594 Count-=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1595 UnpPackedSize-=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1596 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1597 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1598 if (RetCode!= -1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1599 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1600 RetCode=TotalRead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1601 if (Encryption)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1602 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1603 if (Encryption<20)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1604 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1605 debug_log("Old Crypt() not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1606 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1607 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1608 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1609 for (I=0;I<(unsigned int)RetCode;I+=16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1610 DecryptBlock(&Addr[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1611 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1612 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1613 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1614 return(RetCode);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1615 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1616
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1617
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1618 void UnpReadBuf(int FirstBuf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1619 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1620 int RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1621 if (FirstBuf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1622 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1623 ReadTop=UnpRead(InBuf,sizeof(InBuf));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1624 InAddr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1625 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1626 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1627 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1628 memcpy(InBuf,&InBuf[sizeof(InBuf)-32],32);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1629 InAddr&=0x1f;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1630 RetCode=UnpRead(&InBuf[32],sizeof(InBuf)-32);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1631 if (RetCode>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1632 ReadTop=RetCode+32;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1633 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1634 ReadTop=InAddr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1635 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1636 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1637
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1638
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1639 void ReadTables(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1640 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1641 UBYTE BitLength[BC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1642 unsigned char Table[MC*4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1643 int TableSize,N,I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1644 if (InAddr>sizeof(InBuf)-25)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1645 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1646 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1647 UnpAudioBlock=(BitField & 0x8000);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1648
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1649 if (!(BitField & 0x4000))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1650 memset(UnpOldTable,0,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1651 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1652
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1653
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1654 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1655 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1656 UnpChannels=((BitField>>12) & 3)+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1657 if (CurChannel>=UnpChannels)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1658 CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1659 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1660 TableSize=MC*UnpChannels;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1661 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1662 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1663 TableSize=NC+DC+RC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1664
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1665
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1666 for (I=0;I<BC;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1667 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1668 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1669 BitLength[I]=(UBYTE)(BitField >> 12);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1670 AddBits(4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1671 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1672 MakeDecodeTables(BitLength,(struct Decode *)&BD,BC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1673 I=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1674 while (I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1675 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1676 if (InAddr>sizeof(InBuf)-5)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1677 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1678 DecodeNumber((struct Decode *)&BD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1679 if (Number<16)
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1680 {
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1681 Table[I]=(Number+UnpOldTable[I]) & 0xf;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1682 I++;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1683 }
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1684 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1685 if (Number==16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1686 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1687 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1688 N=(BitField >> 14)+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1689 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1690 while (N-- > 0 && I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1691 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1692 Table[I]=Table[I-1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1693 I++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1694 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1695 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1696 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1697 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1698 if (Number==17)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1699 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1700 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1701 N=(BitField >> 13)+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1702 AddBits(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1703 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1704 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1705 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1706 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1707 N=(BitField >> 9)+11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1708 AddBits(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1709 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1710 while (N-- > 0 && I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1711 Table[I++]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1712 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1713 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1714 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1715 for (I=0;I<UnpChannels;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1716 MakeDecodeTables(&Table[I*MC],(struct Decode *)MDPtr[I],MC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1717 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1718 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1719 MakeDecodeTables(&Table[0],(struct Decode *)&LD,NC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1720 MakeDecodeTables(&Table[NC],(struct Decode *)&DD,DC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1721 MakeDecodeTables(&Table[NC+DC],(struct Decode *)&RD,RC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1722 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1723 memcpy(UnpOldTable,Table,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1724 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1725
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1726
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1727 static void ReadLastTables(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1728 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1729 if (ReadTop>=InAddr+5)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1730 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1731 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1732 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1733 DecodeNumber((struct Decode *)MDPtr[CurChannel]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1734 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1735 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1736 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1737 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1738 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1739 DecodeNumber((struct Decode *)&LD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1740 if (Number==269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1741 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1742 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1743 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1744 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1745
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1746
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1747 static void MakeDecodeTables(unsigned char *LenTab,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1748 struct Decode *Dec,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1749 int Size)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1750 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1751 int LenCount[16],TmpPos[16],I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1752 long M,N;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1753 memset(LenCount,0,sizeof(LenCount));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1754 for (I=0;I<Size;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1755 LenCount[LenTab[I] & 0xF]++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1756
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1757 LenCount[0]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1758 for (TmpPos[0]=Dec->DecodePos[0]=Dec->DecodeLen[0]=0,N=0,I=1;I<16;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1759 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1760 N=2*(N+LenCount[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1761 M=N<<(15-I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1762 if (M>0xFFFF)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1763 M=0xFFFF;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1764 Dec->DecodeLen[I]=(unsigned int)M;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1765 TmpPos[I]=Dec->DecodePos[I]=Dec->DecodePos[I-1]+LenCount[I-1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1766 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1767
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1768 for (I=0;I<Size;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1769 if (LenTab[I]!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1770 Dec->DecodeNum[TmpPos[LenTab[I] & 0xF]++]=I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1771 Dec->MaxNum=Size;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1772 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1773
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1774
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1775 static void DecodeNumber(struct Decode *Deco)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1776 /* *** 52.6% of all CPU time is spent within this function!!! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1777 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1778 unsigned int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1779 register unsigned int N;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1780 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1781
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1782 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1783
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1784 #ifdef _WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1785 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1786
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1787 xor eax, eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1788 mov eax, BitField // N=BitField & 0xFFFE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1789 and eax, 0xFFFFFFFE
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1790 mov [N], eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1791 mov edx, [Deco] // EAX=N, EDX=Deco
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1792
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1793 cmp eax, dword ptr[edx + 8*4 + 4]// if (N<Dec->DecodeLen[8])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1794 jae else_G
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1795
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1796 cmp eax, dword ptr[edx + 4*4 + 4]// if (N<Dec->DecodeLen[4])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1797 jae else_F
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1798
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1799
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1800 cmp eax, dword ptr[edx + 2*4 + 4]// if (N<Dec->DecodeLen[2])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1801 jae else_C
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1802
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1803 cmp eax, dword ptr[edx + 1*4 + 4]// if (N<Dec->DecodeLen[1])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1804 jae else_1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1805 mov I, 1 // I=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1806 jmp next_1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1807 else_1: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1808 mov I, 2 // I=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1809 next_1:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1810
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1811 jmp next_C
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1812 else_C: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1813
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1814 cmp eax, dword ptr[edx + 3*4 + 4]// if (N<Dec->DecodeLen[3])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1815 jae else_2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1816 mov I, 3 // I=3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1817 jmp next_2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1818 else_2: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1819 mov I, 4 // I=4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1820 next_2:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1821
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1822 next_C: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1823
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1824 jmp next_F
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1825 else_F:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1826
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1827
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1828 cmp eax, dword ptr[edx + 6*4 + 4]// if (N<Dec->DecodeLen[6])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1829 jae else_E
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1830
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1831 cmp eax, dword ptr[edx + 5*4 + 4]// if (N<Dec->DecodeLen[5])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1832 jae else_3
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1833 mov I, 5 // I=5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1834 jmp next_3
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1835 else_3: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1836 mov I, 6 // I=6;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1837 next_3:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1838
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1839 jmp next_E
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1840 else_E: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1841
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1842 cmp eax, dword ptr[edx + 7*4 + 4]// if (N<Dec->DecodeLen[7])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1843 jae else_4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1844 mov I, 7 // I=7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1845 jmp next_4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1846 else_4: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1847 mov I, 8 // I=8;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1848 next_4:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1849
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1850 next_E:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1851
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1852 next_F:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1853
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1854 jmp next_G
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1855 else_G:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1856
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1857 cmp eax, dword ptr[edx + 12*4 + 4] // if (N<Dec->DecodeLen[12])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1858 jae else_D
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1859
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1860 cmp eax, dword ptr[edx + 10*4 + 4]// if (N<Dec->DecodeLen[10])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1861 jae else_B
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1862
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1863 cmp eax, dword ptr[edx + 9*4 + 4]// if (N<Dec->DecodeLen[9])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1864 jae else_5
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1865 mov I, 9 // I=9;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1866 jmp next_5
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1867 else_5: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1868 mov I, 10 // I=10;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1869 next_5:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1870
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1871 jmp next_B
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1872 else_B: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1873
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1874 cmp eax, dword ptr[edx + 11*4 + 4]// if (N<Dec->DecodeLen[11])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1875 jae else_6
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1876 mov I, 11 // I=11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1877 jmp next_6
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1878 else_6: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1879 mov I, 12 // I=12;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1880 next_6:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1881
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1882 next_B:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1883
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1884
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1885 jmp next_D
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1886 else_D: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1887
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1888 cmp eax, dword ptr[edx + 14*4 + 4]// if (N<Dec->DecodeLen[14])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1889 jae else_A
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1890
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1891 cmp eax, dword ptr[edx + 13*4 + 4]// if (N<Dec->DecodeLen[13])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1892 jae else_7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1893 mov I, 13 // I=13;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1894 jmp next_7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1895 else_7: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1896 mov I, 14 // I=14;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1897 next_7:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1898
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1899 jmp next_A
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1900 else_A: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1901 mov I, 15 // I=15;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1902 next_A:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1903
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1904 next_D:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1905 next_G:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1906 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1907 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1908 __asm__ __volatile__ (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1909 "andl $0xFFFFFFFE, %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1910 " movl %%eax, %1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1911 " cmpl 8*4(%%edx), %%eax /* 5379 */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1912 " jae else_G"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1913 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1914 " cmpl 4*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1915 " jae else_F"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1916 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1917 " cmpl 2*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1918 " jae else_C"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1919 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1920 " cmpl 1*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1921 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1922 " jae else_1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1923 " movl $1, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1924 " jmp next_1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1925 " else_1: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1926 " movl $2, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1927 " next_1:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1928 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1929 " jmp next_C"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1930 " else_C: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1931 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1932 " cmpl 3*4(%%edx), %%eax "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1933 " jae else_2"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1934 " movl $3, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1935 " jmp next_2"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1936 " else_2: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1937 " movl $4, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1938 " next_2:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1939 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1940 " next_C: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1941 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1942 " jmp next_F"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1943 " else_F:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1944 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1945 " cmpl 6*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1946 " jae else_E"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1947 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1948 " cmpl 5*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1949 " jae else_3"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1950 " movl $5, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1951 " jmp next_3"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1952 " else_3: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1953 " movl $6, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1954 " next_3:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1955 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1956 " jmp next_E"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1957 " else_E: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1958 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1959 " cmpl 7*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1960 " jae else_4"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1961 " movl $7, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1962 " jmp next_4"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1963 " else_4: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1964 " movl $8, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1965 " next_4:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1966 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1967 " next_E:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1968 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1969 " next_F:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1970 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1971 " jmp next_G"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1972 " else_G:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1973 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1974 " cmpl 12*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1975 " jae else_D"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1976 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1977 " cmpl 10*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1978 " jae else_B"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1979 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1980 " cmpl 9*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1981 " jae else_5"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1982 " movl $9, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1983 " jmp next_5"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1984 " else_5: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1985 " movl $10, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1986 " next_5:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1987 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1988 " jmp next_B"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1989 " else_B: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1990 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1991 " cmpl 11*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1992 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1993 " jae else_6"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1994 " movl $11, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1995 " jmp next_6"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1996 " else_6: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1997 " movl $12, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1998 " next_6:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1999 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2000 " next_B:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2001 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2002 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2003 " jmp next_D"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2004 " else_D: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2005 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2006 " cmpl 14*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2007 " jae else_A"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2008 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2009 " cmpl 13*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2010 " jae else_7"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2011 " movl $13, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2012 " jmp next_7"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2013 " else_7: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2014 " movl $14, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2015 " next_7:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2016 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2017 " jmp next_A"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2018 " else_A: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2019 " movl $15, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2020 " next_A:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2021 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2022 " next_D: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2023 " next_G:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2024 : "=g" (I), "=r"(N)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2025 : "eax" ((long)BitField), "edx"((long)Deco->DecodeLen)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2026 : "memory"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2027 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2028 #endif /* #ifdef _WIN_32 ... #elif defined _X86_ASM_ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2029
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2030 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2031 N=BitField & 0xFFFE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2032 if (N<Deco->DecodeLen[8]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2033 if (N<Deco->DecodeLen[4]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2034 if (N<Deco->DecodeLen[2]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2035 if (N<Deco->DecodeLen[1])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2036 I=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2037 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2038 I=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2039 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2040 if (N<Deco->DecodeLen[3])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2041 I=3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2042 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2043 I=4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2044 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2045 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2046 if (N<Deco->DecodeLen[6]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2047 if (N<Deco->DecodeLen[5])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2048 I=5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2049 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2050 I=6;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2051 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2052 if (N<Deco->DecodeLen[7])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2053 I=7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2054 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2055 I=8;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2056 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2057 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2058 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2059 if (N<Deco->DecodeLen[12]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2060 if (N<Deco->DecodeLen[10]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2061 if (N<Deco->DecodeLen[9])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2062 I=9;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2063 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2064 I=10;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2065 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2066 if (N<Deco->DecodeLen[11])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2067 I=11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2068 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2069 I=12;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2070 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2071 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2072 if (N<Deco->DecodeLen[14]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2073 if (N<Deco->DecodeLen[13])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2074 I=13;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2075 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2076 I=14;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2077
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2078 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2079 I=15;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2080 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2081 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2082
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2083 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2084 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2085
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2086 AddBits(I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2087 if ((N=Deco->DecodePos[I]+((N-Deco->DecodeLen[I-1])>>(16-I)))>=Deco->MaxNum)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2088 N=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2089 Number=Deco->DecodeNum[N];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2090 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2091
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2092
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2093 void UnpInitData()
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2094 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2095 InAddr=InBit=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2096 if (!(NewLhd.Flags & LHD_SOLID))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2097 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2098 ChannelDelta=CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2099
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2100 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2101
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2102 #ifdef _WIN_32 /* Win32 with VisualC */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2103
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2104 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2105 push edi
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2106 push eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2107 push ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2108
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2109 cld /* increment EDI and ESI */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2110 mov al, 0x00
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2111 mov ecx, SIZE AudV
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2112 mov edi, Offset AudV
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2113 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2114
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2115 mov ecx, SIZE OldDist
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2116 mov edi, Offset OldDist
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2117 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2118
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2119 mov ecx, SIZE UnpOldTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2120 mov edi, Offset UnpOldTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2121 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2122
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2123 pop ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2124 pop eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2125 pop edi
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2126
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2127
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2128 mov [OldDistPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2129 mov [LastDist], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2130 mov [LastLength], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2131 mov [UnpPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2132 mov [WrPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2133 mov [OldDistPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2134 mov [LastLength], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2135 mov [LastDist], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2136 mov [UnpPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2137 mov [WrPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2138
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2139 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2140 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2141
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2142
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2143 #else /* unix/linux on i386 cpus */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2144 __asm__ __volatile (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2145 " cld /* increment EDI and ESI */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2146 " movb $0x00, %%al"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2147 " movl %0, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2148 " movl %1, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2149 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2150 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2151 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2152 " movl %2, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2153 " mov %3, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2154 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2155 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2156 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2157 " movl %4, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2158 " movl %5, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2159 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2160 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2161 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2162 " movl $0, (OldDistPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2163 " movl $0, (LastDist)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2164 " movl $0, (LastLength)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2165 " movl $0, (UnpPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2166 " movl $0, (WrPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2167 " movl $0, (OldDistPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2168 " movl $0, (LastLength)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2169 " movl $0, (LastDist)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2170 " movl $0, (UnpPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2171 " movl $0, (WrPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2172 :
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2173 : "m" ((long)sizeof(AudV)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2174 "m" ((long)AudV),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2175 "m" ((long)sizeof(OldDist)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2176 "m" ((long)OldDist),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2177 "m" ((long)sizeof(UnpOldTable)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2178 "m" ((long)UnpOldTable)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2179 : "memory", "edi", "eax", "ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2180 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2181 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2182 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2183
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2184 #else /* unix/linux on non-i386 cpu */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2185 memset(AudV,0,sizeof(AudV));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2186 memset(OldDist,0,sizeof(OldDist));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2187 OldDistPtr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2188 LastDist=LastLength=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2189 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2190 memset(UnpOldTable,0,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2191 UnpPtr=WrPtr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2192 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2193
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2194 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2195 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2196
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2197
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2198 UBYTE DecodeAudio(int Delta)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2199 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2200 struct AudioVariables *V;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2201 unsigned int Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2202 unsigned int NumMinDif,MinDif;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2203 int PCh,I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2204
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2205 V=&AudV[CurChannel];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2206 V->ByteCount++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2207 V->D4=V->D3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2208 V->D3=V->D2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2209 V->D2=V->LastDelta-V->D1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2210 V->D1=V->LastDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2211 PCh=8*V->LastChar+V->K1*V->D1+V->K2*V->D2+
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2212 V->K3*V->D3+V->K4*V->D4+V->K5*ChannelDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2213 PCh=(PCh>>3) & 0xFF;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2214
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2215 Ch=PCh-Delta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2216
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2217 I=((signed char)Delta)<<3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2218
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2219 V->Dif[0]+=abs(I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2220 V->Dif[1]+=abs(I-V->D1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2221 V->Dif[2]+=abs(I+V->D1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2222 V->Dif[3]+=abs(I-V->D2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2223 V->Dif[4]+=abs(I+V->D2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2224 V->Dif[5]+=abs(I-V->D3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2225 V->Dif[6]+=abs(I+V->D3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2226 V->Dif[7]+=abs(I-V->D4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2227 V->Dif[8]+=abs(I+V->D4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2228 V->Dif[9]+=abs(I-ChannelDelta);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2229 V->Dif[10]+=abs(I+ChannelDelta);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2230
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2231 ChannelDelta=V->LastDelta=(signed char)(Ch-V->LastChar);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2232 V->LastChar=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2233
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2234 if ((V->ByteCount & 0x1F)==0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2235 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2236 MinDif=V->Dif[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2237 NumMinDif=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2238 V->Dif[0]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2239 for (I=1;(unsigned int)I<sizeof(V->Dif)/sizeof(V->Dif[0]);I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2240 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2241 if (V->Dif[I]<MinDif)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2242 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2243 MinDif=V->Dif[I];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2244 NumMinDif=I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2245 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2246 V->Dif[I]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2247 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2248 switch(NumMinDif)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2249 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2250 case 1:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2251 if (V->K1>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2252 V->K1--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2253 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2254 case 2:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2255 if (V->K1<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2256 V->K1++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2257 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2258 case 3:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2259 if (V->K2>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2260 V->K2--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2261 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2262 case 4:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2263 if (V->K2<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2264 V->K2++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2265 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2266 case 5:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2267 if (V->K3>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2268 V->K3--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2269 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2270 case 6:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2271 if (V->K3<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2272 V->K3++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2273 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2274 case 7:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2275 if (V->K4>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2276 V->K4--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2277 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2278 case 8:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2279 if (V->K4<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2280 V->K4++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2281 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2282 case 9:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2283 if (V->K5>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2284 V->K5--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2285 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2286 case 10:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2287 if (V->K5<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2288 V->K5++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2289 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2290 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2291 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2292 return((UBYTE)Ch);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2293 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2294
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2295
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2296
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2297
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2298
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2299
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2300
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2301 /* ***************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2302 * ** CRCCrypt Code - decryption engine starts here **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2303 * ***************************************************/
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2304
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2305
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2306 #define NROUNDS 32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2307
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2308 #define rol(x,n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n))))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2309 #define ror(x,n) (((x)>>(n)) | ((x)<<(8*sizeof(x)-(n))))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2310
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2311 #define substLong(t) ( (UDWORD)SubstTable[(int)t&255] | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2312 ((UDWORD)SubstTable[(int)(t>> 8)&255]<< 8) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2313 ((UDWORD)SubstTable[(int)(t>>16)&255]<<16) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2314 ((UDWORD)SubstTable[(int)(t>>24)&255]<<24) )
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2315
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2316
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2317 UDWORD CRCTab[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2318
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2319 UBYTE SubstTable[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2320 UBYTE InitSubstTable[256]={
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2321 215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221, 2, 42,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2322 232, 1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2323 255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86, 6,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2324 71, 24,171,196,101,113,218,123, 93, 91,163,178,202, 67, 44,235,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2325 107,250, 75,234, 49,167,125,211, 83,114,157,144, 32,193,143, 36,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2326 158,124,247,187, 89,214,141, 47,121,228, 61,130,213,194,174,251,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2327 97,110, 54,229,115, 57,152, 94,105,243,212, 55,209,245, 63, 11,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2328 164,200, 31,156, 81,176,227, 21, 76, 99,139,188,127, 17,248, 51,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2329 207,120,189,210, 8,226, 41, 72,183,203,135,165,166, 60, 98, 7,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2330 122, 38,155,170, 69,172,252,238, 39,134, 59,128,236, 27,240, 80,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2331 131, 3, 85,206,145, 79,154,142,159,220,201,133, 74, 64, 20,129,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2332 224,185,138,103,173,182, 43, 34,254, 82,198,151,231,180, 58, 10,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2333 118, 26,102, 12, 50,132, 22,191,136,111,162,179, 45, 4,148,108,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2334 161, 56, 78,126,242,222, 15,175,146, 23, 33,241,181,190, 77,225,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2335 0, 46,169,186, 68, 95,237, 65, 53,208,253,168, 9, 18,100, 52,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2336 116,184,160, 96,109, 37, 30,106,140,104,150, 5,204,117,112, 84
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2337 };
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2338
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2339 UDWORD Key[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2340
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2341
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2342 void EncryptBlock(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2343 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2344 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2345
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2346 UDWORD A,B,C,D,T,TA,TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2347 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2348 A=((UDWORD)Buf[0]|((UDWORD)Buf[1]<<8)|((UDWORD)Buf[2]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2349 ((UDWORD)Buf[3]<<24))^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2350 B=((UDWORD)Buf[4]|((UDWORD)Buf[5]<<8)|((UDWORD)Buf[6]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2351 ((UDWORD)Buf[7]<<24))^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2352 C=((UDWORD)Buf[8]|((UDWORD)Buf[9]<<8)|((UDWORD)Buf[10]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2353 ((UDWORD)Buf[11]<<24))^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2354 D=((UDWORD)Buf[12]|((UDWORD)Buf[13]<<8)|((UDWORD)Buf[14]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2355 ((UDWORD)Buf[15]<<24))^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2356 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2357 UDWORD *BufPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2358 BufPtr=(UDWORD *)Buf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2359 A=BufPtr[0]^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2360 B=BufPtr[1]^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2361 C=BufPtr[2]^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2362 D=BufPtr[3]^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2363 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2364 for(I=0;I<NROUNDS;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2365 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2366 T=((C+rol(D,11))^Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2367 TA=A^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2368 T=((D^rol(C,17))+Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2369 TB=B^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2370 A=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2371 B=D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2372 C=TA;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2373 D=TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2374 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2375 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2376 C^=Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2377 Buf[0]=(UBYTE)C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2378 Buf[1]=(UBYTE)(C>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2379 Buf[2]=(UBYTE)(C>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2380 Buf[3]=(UBYTE)(C>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2381 D^=Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2382 Buf[4]=(UBYTE)D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2383 Buf[5]=(UBYTE)(D>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2384 Buf[6]=(UBYTE)(D>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2385 Buf[7]=(UBYTE)(D>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2386 A^=Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2387 Buf[8]=(UBYTE)A;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2388 Buf[9]=(UBYTE)(A>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2389 Buf[10]=(UBYTE)(A>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2390 Buf[11]=(UBYTE)(A>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2391 B^=Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2392 Buf[12]=(UBYTE)B;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2393 Buf[13]=(UBYTE)(B>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2394 Buf[14]=(UBYTE)(B>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2395 Buf[15]=(UBYTE)(B>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2396 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2397 BufPtr[0]=C^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2398 BufPtr[1]=D^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2399 BufPtr[2]=A^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2400 BufPtr[3]=B^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2401 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2402 UpdKeys(Buf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2403 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2404
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2405
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2406 void DecryptBlock(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2407 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2408 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2409 UBYTE InBuf[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2410 UDWORD A,B,C,D,T,TA,TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2411 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2412 A=((UDWORD)Buf[0]|((UDWORD)Buf[1]<<8)|((UDWORD)Buf[2]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2413 ((UDWORD)Buf[3]<<24))^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2414 B=((UDWORD)Buf[4]|((UDWORD)Buf[5]<<8)|((UDWORD)Buf[6]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2415 ((UDWORD)Buf[7]<<24))^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2416 C=((UDWORD)Buf[8]|((UDWORD)Buf[9]<<8)|((UDWORD)Buf[10]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2417 ((UDWORD)Buf[11]<<24))^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2418 D=((UDWORD)Buf[12]|((UDWORD)Buf[13]<<8)|((UDWORD)Buf[14]<<16)|
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2419 ((UDWORD)Buf[15]<<24))^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2420 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2421 UDWORD *BufPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2422 BufPtr=(UDWORD *)Buf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2423 A=BufPtr[0]^Key[0]; /* xxx may be this can be */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2424 B=BufPtr[1]^Key[1]; /* optimized in assembler */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2425 C=BufPtr[2]^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2426 D=BufPtr[3]^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2427 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2428 memcpy(InBuf,Buf,sizeof(InBuf));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2429 for(I=NROUNDS-1;I>=0;I--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2430 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2431 T=((C+rol(D,11))^Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2432 TA=A^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2433 T=((D^rol(C,17))+Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2434 TB=B^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2435 A=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2436 B=D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2437 C=TA;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2438 D=TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2439 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2440 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2441 C^=Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2442 Buf[0]=(UBYTE)C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2443 Buf[1]=(UBYTE)(C>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2444 Buf[2]=(UBYTE)(C>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2445 Buf[3]=(UBYTE)(C>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2446 D^=Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2447 Buf[4]=(UBYTE)D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2448 Buf[5]=(UBYTE)(D>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2449 Buf[6]=(UBYTE)(D>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2450 Buf[7]=(UBYTE)(D>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2451 A^=Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2452 Buf[8]=(UBYTE)A;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2453 Buf[9]=(UBYTE)(A>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2454 Buf[10]=(UBYTE)(A>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2455 Buf[11]=(UBYTE)(A>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2456 B^=Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2457 Buf[12]=(UBYTE)B;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2458 Buf[13]=(UBYTE)(B>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2459 Buf[14]=(UBYTE)(B>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2460 Buf[15]=(UBYTE)(B>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2461 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2462 BufPtr[0]=C^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2463 BufPtr[1]=D^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2464 BufPtr[2]=A^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2465 BufPtr[3]=B^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2466 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2467 UpdKeys(InBuf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2468 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2469
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2470
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2471 void UpdKeys(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2472 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2473 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2474 for (I=0;I<16;I+=4)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2475 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2476 Key[0]^=CRCTab[Buf[I]]; /* xxx may be I'll rewrite this */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2477 Key[1]^=CRCTab[Buf[I+1]]; /* in asm for speedup */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2478 Key[2]^=CRCTab[Buf[I+2]];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2479 Key[3]^=CRCTab[Buf[I+3]];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2480 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2481 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2482
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2483 void SetCryptKeys(char *Password)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2484 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2485 unsigned int I,J,K,PswLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2486 unsigned char N1,N2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2487 unsigned char Psw[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2488
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2489 #if !defined _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2490 UBYTE Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2491 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2492
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2493 SetOldKeys(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2494
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2495 Key[0]=0xD3A3B879L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2496 Key[1]=0x3F6D12F7L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2497 Key[2]=0x7515A235L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2498 Key[3]=0xA4E7F123L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2499 memset(Psw,0,sizeof(Psw));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2500 strcpy((char *)Psw,Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2501 PswLength=strlen(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2502 memcpy(SubstTable,InitSubstTable,sizeof(SubstTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2503
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2504 for (J=0;J<256;J++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2505 for (I=0;I<PswLength;I+=2)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2506 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2507 N2=(unsigned char)CRCTab[(Psw[I+1]+J)&0xFF];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2508 for (K=1, N1=(unsigned char)CRCTab[(Psw[I]-J)&0xFF];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2509 (N1!=N2) && (N1 < 256); /* I had to add "&& (N1 < 256)", */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2510 N1++, K++) /* because the system crashed with */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2511 { /* encrypted RARs */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2512 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2513
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2514 #ifdef _WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2515 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2516
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2517 mov ebx, Offset SubstTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2518 mov edx, ebx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2519
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2520 xor ecx, ecx // read SubstTable[N1]...
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2521 mov cl, N1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2522 add ebx, ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2523 mov al, byte ptr[ebx]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2524
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2525 mov cl, N1 // read SubstTable[(N1+I+K)&0xFF]...
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2526 add ecx, I
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2527 add ecx, K
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2528 and ecx, 0xFF
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2529 add edx, ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2530 mov ah, byte ptr[edx]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2531
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2532 mov byte ptr[ebx], ah // and write back
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2533 mov byte ptr[edx], al
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2534
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2535 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2536 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2537 __asm__ __volatile__ (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2538 " xorl %%ecx, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2539 " movl %2, %%ecx /* ecx = N1 */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2540 " mov %%ebx, %%edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2541 " addl %%ecx, %%ebx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2542 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2543 " addl %0, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2544 " addl %1, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2545 " andl $0x000000FF, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2546 " addl %%ecx, %%edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2547 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2548 " movb (%%ebx), %%al"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2549 " movb (%%edx), %%ah"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2550 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2551 " movb %%ah, (%%ebx) /* and write back */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2552 " movb %%al, (%%edx)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2553 : : "g" ((long)I),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2554 "g" ((long)K),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2555 "g" ((long)N1),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2556 "ebx"((long)SubstTable)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2557 : "ecx", "edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2558
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2559 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2560 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2561
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2562 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2563 /* Swap(&SubstTable[N1],&SubstTable[(N1+I+K)&0xFF]); */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2564 Ch=SubstTable[N1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2565 SubstTable[N1]=SubstTable[(N1+I+K)&0xFF];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2566 SubstTable[(N1+I+K)&0xFF]=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2567 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2568 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2569 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2570 for (I=0;I<PswLength;I+=16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2571 EncryptBlock(&Psw[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2572 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2573
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2574
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2575 void SetOldKeys(char *Password)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2576 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2577 UDWORD PswCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2578 UBYTE Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2579 PswCRC=CalcCRC32(0xFFFFFFFFL,(UBYTE*)Password,strlen(Password));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2580 OldKey[0]=(UWORD)PswCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2581 OldKey[1]=(UWORD)(PswCRC>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2582 OldKey[2]=OldKey[3]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2583 PN1=PN2=PN3=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2584 while ((Ch=*Password)!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2585 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2586 PN1+=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2587 PN2^=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2588 PN3+=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2589 PN3=(UBYTE)rol(PN3,1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2590 OldKey[2]^=((UWORD)(Ch^CRCTab[Ch]));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2591 OldKey[3]+=((UWORD)(Ch+(CRCTab[Ch]>>16)));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2592 Password++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2593 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2594 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2595
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2596 void InitCRC(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2597 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2598 int I, J;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2599 UDWORD C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2600 for (I=0;I<256;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2601 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2602 for (C=I,J=0;J<8;J++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2603 C=(C & 1) ? (C>>1)^0xEDB88320L : (C>>1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2604 CRCTab[I]=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2605 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2606 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2607
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2608
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2609 UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2610 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2611 unsigned int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2612 for (I=0; I<Size; I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2613 StartCRC = CRCTab[(UBYTE)StartCRC ^ Addr[I]] ^ (StartCRC >> 8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2614 return(StartCRC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2615 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2616
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2617
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2618 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2619 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2620 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2621 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2622
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2623
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2624
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2625
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2626
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2627
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2628
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2629
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2630
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2631
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2632
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2633
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2634
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2635
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2636
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2637
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2638
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2639
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2640
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2641
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2642
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2643
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2644
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2645
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2646
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2647 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2648 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2649 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2650 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2651 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2652 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2653 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2654 ******* D E B U G F U N C T I O N S *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2655 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2656 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2657 ******* *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2658 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2659 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2660 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2661 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2662 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2663
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2664
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2665 /* -- global stuff -------------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2666 char log_file_name[256]; /* file name for the log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2667 DWORD debug_start_time; /* starttime of debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2668 BOOL debug_started = FALSE; /* debug_log writes only if */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2669 /* this is TRUE */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2670 /* ------------------------------------------------------------------------ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2671
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2672
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2673 /* -- global functions ---------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2674 void debug_init_proc(char *file_name)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2675 /* Create/Rewrite a log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2676 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2677 FILE *fp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2678 char date[] = __DATE__;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2679 char time[] = __TIME__;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2680
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2681 debug_start_time = GetTickCount(); /* get start time */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2682 strcpy(log_file_name, file_name); /* save file name */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2683
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2684 if((fp = fopen(log_file_name, CREATETEXT)) != NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2685 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2686 debug_started = TRUE; /* enable debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2687 fprintf(fp, "Debug log of UniquE's RARFileLib\n"\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2688 "~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~\n");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2689 fprintf(fp, "(executable compiled on %s at %s)\n\n", date, time);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2690 fclose(fp);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2691 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2692 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2693
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2694
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2695 void debug_log_proc(char *text, char *sourcefile, int sourceline)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2696 /* add a line to the log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2697 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2698 FILE *fp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2699
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2700 if(debug_started == FALSE) return; /* exit if not initialized */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2701
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2702 if((fp = fopen(log_file_name, APPENDTEXT)) != NULL) /* append to logfile */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2703
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2704 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2705 fprintf(fp, " %8u ms (line %u in %s):\n - %s\n",
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2706 (unsigned int)(GetTickCount() - debug_start_time),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2707 sourceline, sourcefile, text);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2708 fclose(fp);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2709 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2710 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2711
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2712 /* ------------------------------------------------------------------------ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2713 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2714 /* **************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2715 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2716 ****************************************************************************
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2717 ************************************************************************** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2718
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2719
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2720 /* end of file urarlib.c */