annotate unrarlib.c @ 9148:946b14a9e743

type autodetection (from filemask/filelist extension)
author arpi
date Tue, 28 Jan 2003 22:00:57 +0000
parents fb88ccbc5ccc
children 31126ea5cd36
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
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
296 UBYTE *TempMemory; /* temporary unpack-buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
297 char *CommMemory;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
298
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
299
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
300 UBYTE *UnpMemory;
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
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
425 free(UnpMemory); /* free memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
426 free(TempMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
427 free(CommMemory);
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 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
435 free(temp_output_buffer); /* free memory and return NULL */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
436 temp_output_buffer=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
437 *(DWORD*)output=0; /* pointer on errors */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
438 *size=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
439 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
440
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 /* 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
443 /* white spaces within strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
444 str_offs = sprintf(DebugMsg, "Error - couldn't extract ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
445 str_offs += sprintf(DebugMsg + str_offs, ">%s<", filename);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
446 str_offs += sprintf(DebugMsg + str_offs, " and allocated ");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
447 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
448 str_offs += sprintf(DebugMsg + str_offs, " of unused memory!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
449
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
450 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
451 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
452 sprintf(DebugMsg, "Extracted %u Bytes.", (unsigned int)*size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
453 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
454 debug_log(DebugMsg);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
455 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
456 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
457 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
458 *(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
459 /* data */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
460
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
461 return retcode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
462 }
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 int urarlib_list(void *rarfile, ArchiveList_struct *list)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
466 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
467 ArchiveList_struct *tmp_List = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
468 int NoOfFilesInArchive = 0; /* number of files in archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
469
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
470 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
471 if(debug_log_first_start)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
472 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
473 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
474 debug_init(_DEBUG_LOG_FILE); /* on startup */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
475 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
476 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
477
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
478 InitCRC(); /* init some vars */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
479
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
480 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
481 MemRARFile = rarfile; /* assign pointer to RAR file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
482 MemRARFile->offset = 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
483 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
484 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
485 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
486 return NoOfFilesInArchive; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
487 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
488 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
489 /* open and identify archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
490 if ((ArcPtr=fopen(rarfile,READBINARY))!=NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
491 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
492 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
493 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
494 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
495 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
496 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
497 return NoOfFilesInArchive; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
498 }
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 else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
501 debug_log("Error opening file.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
502 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
503 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
504 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
505
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
506 if ((UnpMemory=malloc(UNP_MEMORY))==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
507 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
508 debug_log("Can't allocate memory for decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
509 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
510 }
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 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
513 MemRARFile->offset+=NewMhd.HeadSize-MainHeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
514 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
515 tseek(ArcPtr,NewMhd.HeadSize-MainHeadSize,SEEK_CUR);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
516 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
517 (*(DWORD*)list) = (DWORD)NULL; /* init file list */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
518 /* 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
519 while (TRUE)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
520 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
521 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
522 { /* file within the RAR archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
523 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
524 break; /* error, file not found in */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
525 } /* archive or I/O error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
526 if (BlockHead.HeadType==SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
527 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
528 debug_log("Sorry, sub-headers not supported.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
529 break; /* error => exit */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
530 }
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 if((void*)(*(DWORD*)list) == NULL) /* first entry */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
533 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
534 tmp_List = malloc(sizeof(ArchiveList_struct));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
535 tmp_List->next = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
536
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
537 (*(DWORD*)list) = (DWORD)tmp_List;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
538
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
539 } else /* add entry */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
540 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
541 tmp_List->next = malloc(sizeof(ArchiveList_struct));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
542 tmp_List = (ArchiveList_struct*) tmp_List->next;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
543 tmp_List->next = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
544 }
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 tmp_List->item.Name = malloc(NewLhd.NameSize + 1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
547 strcpy(tmp_List->item.Name, ArcFileName);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
548 tmp_List->item.NameSize = NewLhd.NameSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
549 tmp_List->item.PackSize = NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
550 tmp_List->item.UnpSize = NewLhd.UnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
551 tmp_List->item.HostOS = NewLhd.HostOS;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
552 tmp_List->item.FileCRC = NewLhd.FileCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
553 tmp_List->item.FileTime = NewLhd.FileTime;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
554 tmp_List->item.UnpVer = NewLhd.UnpVer;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
555 tmp_List->item.Method = NewLhd.Method;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
556 tmp_List->item.FileAttr = NewLhd.FileAttr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
557
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
558 NoOfFilesInArchive++; /* count files */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
559
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
560 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
561 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
562 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
563 if (ArcPtr!=NULL) tseek(ArcPtr,NextBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
564 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
565
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 /* free memory, clear password and close archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
569 memset(Password,0,sizeof(Password)); /* clear password */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
570 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
571 if (ArcPtr!=NULL){
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
572 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
573 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
574 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
575 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
576
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
577 free(UnpMemory); /* free memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
578 free(TempMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
579 free(CommMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
580 UnpMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
581 TempMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
582 CommMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
583
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
584 return NoOfFilesInArchive;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
585 }
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 /* urarlib_freelist:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
590 * (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
591 * and Johannes Winkelmann who independently wrote a patch)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
592 * 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
593 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
594 * input: *list pointer to an ArchiveList_struct
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
595 * output: -
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
596 */
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 void urarlib_freelist(ArchiveList_struct *list)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
599 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
600 ArchiveList_struct* tmp = list;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
601
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
602 while ( list ) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
603 tmp = list->next;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
604 free( list->item.Name );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
605 free( list );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
606 list = tmp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
607 }
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 ******* B L O C K I / O *******
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
637 ******* *******
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 #define GetHeaderByte(N) Header[N]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
648
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
649 #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
650
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
651 #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
652 ((UDWORD)Header[N+2]<<16)+\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
653 ((UDWORD)Header[N+3]<<24))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
654
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 int ReadBlock(int BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
657 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
658 struct NewFileHeader SaveFileHead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
659 int Size=0,ReadSubBlock=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
660 static int LastBlock;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
661 memcpy(&SaveFileHead,&NewLhd,sizeof(SaveFileHead));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
662 if (BlockType & READSUBBLOCK)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
663 ReadSubBlock=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
664 BlockType &= 0xff;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
665 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
666 while (1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
667 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
668 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
669 CurBlockPos=MemRARFile->offset; /* get offset of mem-file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
670 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
671 CurBlockPos=ftell(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
672 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
673 Size=ReadHeader(FILE_HEAD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
674 if (Size!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
675 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
676 if (NewLhd.HeadSize<SIZEOF_SHORTBLOCKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
677 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
678 NextBlockPos=CurBlockPos+NewLhd.HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
679 if (NewLhd.Flags & LONG_BLOCK)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
680 NextBlockPos+=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
681 if (NextBlockPos<=CurBlockPos)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
682 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
683 }
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 if (Size > 0 && BlockType!=SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
686 LastBlock=BlockType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
687 if (Size==0 || BlockType==ALL_HEAD || NewLhd.HeadType==BlockType ||
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
688 (NewLhd.HeadType==SUB_HEAD && ReadSubBlock && LastBlock==BlockType))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
689 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
690 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
691 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
692 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
693 tseek(ArcPtr, NextBlockPos, SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
694 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
695 }
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 BlockHead.HeadCRC=NewLhd.HeadCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
699 BlockHead.HeadType=NewLhd.HeadType;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
700 BlockHead.Flags=NewLhd.Flags;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
701 BlockHead.HeadSize=NewLhd.HeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
702 BlockHead.DataSize=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
703
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
704 if (BlockType!=NewLhd.HeadType) BlockType=ALL_HEAD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
705
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
706 if((FILE_HEAD == BlockType) && (Size>0))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
707 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
708 NewLhd.NameSize=Min(NewLhd.NameSize,sizeof(ArcFileName)-1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
709 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
710 tread(MemRARFile, ArcFileName, NewLhd.NameSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
711 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
712 tread(ArcPtr,ArcFileName,NewLhd.NameSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
713 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
714 ArcFileName[NewLhd.NameSize]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
715 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
716 if (NewLhd.HeadCRC!=(UWORD)~CalcCRC32(HeaderCRC,(UBYTE*)&ArcFileName[0],
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
717 NewLhd.NameSize))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
718 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
719 debug_log("file header broken");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
720 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
721 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
722 Size+=NewLhd.NameSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
723 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
724 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
725 memcpy(&NewLhd,&SaveFileHead,sizeof(NewLhd));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
726 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
727 MemRARFile->offset = CurBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
728 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
729 tseek(ArcPtr,CurBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
730 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
731 }
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 return(Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
735 }
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 int ReadHeader(int BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
739 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
740 int Size = 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
741 unsigned char Header[64];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
742 switch(BlockType)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
743 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
744 case MAIN_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
745 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
746 Size=tread(MemRARFile, Header, SIZEOF_NEWMHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
747 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
748 Size=tread(ArcPtr,Header,SIZEOF_NEWMHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
749 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
750 NewMhd.HeadCRC=(unsigned short)GetHeaderWord(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
751 NewMhd.HeadType=GetHeaderByte(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
752 NewMhd.Flags=(unsigned short)GetHeaderWord(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
753 NewMhd.HeadSize=(unsigned short)GetHeaderWord(5);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
754 NewMhd.Reserved=(unsigned short)GetHeaderWord(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
755 NewMhd.Reserved1=GetHeaderDword(9);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
756 HeaderCRC=CalcCRC32(0xFFFFFFFFL,&Header[2],SIZEOF_NEWMHD-2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
757 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
758 case FILE_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
759 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
760 Size=tread(MemRARFile, Header, SIZEOF_NEWLHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
761 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
762 Size=tread(ArcPtr,Header,SIZEOF_NEWLHD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
763 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
764 NewLhd.HeadCRC=(unsigned short)GetHeaderWord(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
765 NewLhd.HeadType=GetHeaderByte(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
766 NewLhd.Flags=(unsigned short)GetHeaderWord(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
767 NewLhd.HeadSize=(unsigned short)GetHeaderWord(5);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
768 NewLhd.PackSize=GetHeaderDword(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
769 NewLhd.UnpSize=GetHeaderDword(11);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
770 NewLhd.HostOS=GetHeaderByte(15);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
771 NewLhd.FileCRC=GetHeaderDword(16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
772 NewLhd.FileTime=GetHeaderDword(20);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
773 NewLhd.UnpVer=GetHeaderByte(24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
774 NewLhd.Method=GetHeaderByte(25);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
775 NewLhd.NameSize=(unsigned short)GetHeaderWord(26);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
776 NewLhd.FileAttr=GetHeaderDword(28);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
777 HeaderCRC=CalcCRC32(0xFFFFFFFFL,&Header[2],SIZEOF_NEWLHD-2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
778 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
779
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
780 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
781 case COMM_HEAD: /* log errors in case of debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
782 debug_log("Comment headers not supported! "\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
783 "Please create archives without comments.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
784 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
785 case PROTECT_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
786 debug_log("Protected headers not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
787 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
788 case ALL_HEAD:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
789 debug_log("ShortBlockHeader not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
790 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
791 default:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
792 debug_log("Unknown//unsupported !");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
793 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
794 default: /* else do nothing */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
795 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
796 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
797 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
798 return(Size);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
799 }
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 ******* 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
830 ******* *******
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 int IsArchive(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
840 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
841 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
842 int str_offs; /* used for debug-strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
843 char DebugMsg[500]; /* used to compose debug msg */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
844 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
845
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
846 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
847 if (tread(MemRARFile, MarkHead.Mark, SIZEOF_MARKHEAD) != SIZEOF_MARKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
848 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
849 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
850 if (tread(ArcPtr,MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
851 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
852 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
853 /* Old archive => error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
854 if (MarkHead.Mark[0]==0x52 && MarkHead.Mark[1]==0x45 &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
855 MarkHead.Mark[2]==0x7e && MarkHead.Mark[3]==0x5e)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
856 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
857 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
858 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
859 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
860 /* original RAR v2.0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
861 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
862 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
863 MarkHead.Mark[4]==0x1a && MarkHead.Mark[5]==0x07 &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
864 MarkHead.Mark[6]==0x00) ||
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
865 /* "UniquE!" - header */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
866 (MarkHead.Mark[0]=='U' && MarkHead.Mark[1]=='n' && /* "UniquE!" */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
867 MarkHead.Mark[2]=='i' && MarkHead.Mark[3]=='q' && /* header */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
868 MarkHead.Mark[4]=='u' && MarkHead.Mark[5]=='E' &&
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
869 MarkHead.Mark[6]=='!'))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
870
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 if (ReadHeader(MAIN_HEAD)!=SIZEOF_NEWMHD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
873 return(FALSE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
874 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
875 {
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 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
878 /* 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
879 /* support white spaces within strings */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
880 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
881 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
882 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
883 str_offs += sprintf(DebugMsg + str_offs, "are NOT supported!)");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
884
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
885 debug_log(DebugMsg);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
886 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
887
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 MainHeadSize=SIZEOF_NEWMHD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
892
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
893 return(TRUE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
894 }
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 BOOL ExtrFile(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
898 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
899 BOOL ReturnCode=TRUE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
900 FileFound=FALSE; /* no file found by default */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
901
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
902 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
903 MemRARFile->offset = 0; /* start reading from offset 0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
904 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
905 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
906 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
907 return FALSE; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
908 }
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 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
911 /* open and identify archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
912 if ((ArcPtr=fopen(ArcName,READBINARY))!=NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
913 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
914 if (!IsArchive())
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
915 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
916 debug_log("Not a RAR file");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
917 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
918 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
919 return FALSE; /* error => exit! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
920 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
921 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
922 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
923 debug_log("Error opening file.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
924 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
925 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
926 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
927
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 if ((UnpMemory=malloc(UNP_MEMORY))==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
930 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
931 debug_log("Can't allocate memory for decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
932 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
933 }
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 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
936 MemRARFile->offset+=NewMhd.HeadSize-MainHeadSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
937 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
938 tseek(ArcPtr,NewMhd.HeadSize-MainHeadSize,SEEK_CUR);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
939 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
940
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
941 /* 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
942 do
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
943 {
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 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
946 { /* file within the RAR archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
947 /*
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 * 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
950 * can not be found in an archive.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
951 *
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
952 * 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
953 *
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 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
956 break; /* error, file not found in */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
957 } /* archive or I/O error */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
958 if (BlockHead.HeadType==SUB_HEAD)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
959 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
960 debug_log("Sorry, sub-headers not supported.");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
961 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
962 break; /* error => exit */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
963 }
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 if(TRUE == (FileFound=(stricomp(ArgName, ArcFileName) == 0)))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
967 /* *** file found! *** */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
968 {
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 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
971 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
972 *temp_output_buffer_offset=0; /* file. The default offset */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
973 /* within the buffer is 0 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
974
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
975 if(temp_output_buffer == NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
976 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
977 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
978 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
979 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
980 }
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 /* 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
986 * 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
987 * (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
988 * one we want.
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
989 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
990 if((NewMhd.Flags & 0x08) || FileFound)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
991 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
992 if (NewLhd.UnpVer<13 || NewLhd.UnpVer>UNP_VER)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
993 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
994 debug_log("unknown compression method");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
995 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
996 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
997 }
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 CurUnpRead=CurUnpWrite=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1000 if ((*Password!=0) && (NewLhd.Flags & LHD_PASSWORD))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1001 Encryption=NewLhd.UnpVer;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1002 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1003 Encryption=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1004 if (Encryption) SetCryptKeys(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1005
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1006 UnpPackedSize=NewLhd.PackSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1007 DestUnpSize=NewLhd.UnpSize;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1008
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1009 if (NewLhd.Method==0x30)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1010 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1011 UnstoreFile();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1012 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1013 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1014 Unpack(UnpMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1015 }
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 #ifdef _DO_CRC32_CHECK /* calculate CRC32 */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1020 if((UBYTE*)temp_output_buffer != NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1021 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1022 if(NewLhd.FileCRC!=~CalcCRC32(0xFFFFFFFFL,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1023 (UBYTE*)temp_output_buffer,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1024 NewLhd.UnpSize))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1025 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1026 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
1027 ReturnCode=FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1028 break; /* error, can't extract file! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1029 }
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 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1032
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 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1036 MemRARFile->offset = NextBlockPos;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1037 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1038 if (ArcPtr!=NULL) tseek(ArcPtr,NextBlockPos,SEEK_SET);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1039 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1040 } 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
1041
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1042 /* free memory, clear password and close archive */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1043 free(UnpMemory);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1044 UnpMemory=NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1045 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1046 if (ArcPtr!=NULL){
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1047 fclose(ArcPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1048 ArcPtr = NULL;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1049 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1050 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1051
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1052 return ReturnCode; /* file extracted successful! */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1053 }
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 ******* 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
1085 ******* *******
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 int tread(void *stream,void *buf,unsigned len)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1095 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1096 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1097
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1098 if(((MemRARFile->offset + len) > MemRARFile->size) || (len == 0))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1099 return 0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1100
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1101 memcpy(buf,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1102 (BYTE*)(((MemoryFile*)stream)->data)+((MemoryFile*)stream)->offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1103 len % ((((MemoryFile*)stream)->size) - 1));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1104
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1105 MemRARFile->offset+=len; /* update read pointer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1106 return len % ((((MemoryFile*)stream)->size) - 1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1107 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1108 return(fread(buf,1,len,(FILE*)stream));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1109 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1110 }
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 #ifndef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1114 int tseek(void *stream,long offset,int fromwhere)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1115 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1116 return(fseek((FILE*)stream,offset,fromwhere));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1117 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1118 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1119
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 char* strupper(char *Str)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1122 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1123 char *ChPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1124 for (ChPtr=Str;*ChPtr;ChPtr++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1125 *ChPtr=(char)toupper(*ChPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1126 return(Str);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1127 }
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 int stricomp(char *Str1,char *Str2)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1131 /* compare strings without regard of '\' and '/' */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1132 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1133 char S1[512],S2[512];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1134 char *chptr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1135
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1136 strncpy(S1,Str1,sizeof(S1));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1137 strncpy(S2,Str2,sizeof(S2));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1138
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1139 while((chptr = strchr(S1, '\\')) != NULL) /* ignore backslash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1140 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1141 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1142 }
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 while((chptr = strchr(S2, '\\')) != NULL) /* ignore backslash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1145 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1146 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1147 }
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 while((chptr = strchr(S1, '/')) != NULL) /* ignore slash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1150 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1151 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1152 }
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 while((chptr = strchr(S2, '/')) != NULL) /* ignore slash */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1155 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1156 *chptr = '_';
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1157 }
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 return(strcmp(strupper(S1),strupper(S2)));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1160 }
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 ******* 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
1193 ******* *******
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 * ** unpack stored RAR files **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1204 * *****************************/
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 BOOL UnstoreFile(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1207 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1208 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
1209 NewLhd.UnpSize))==-1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1210 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1211 debug_log("Read error of stored file!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1212 return FALSE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1213 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1214 return TRUE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1215 }
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 * ** RAR decompression code starts here **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1222 * ****************************************/
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 #define NC 298 /* alphabet = {0,1,2, .,NC - 1} */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1225 #define DC 48
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1226 #define RC 28
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1227 #define BC 19
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1228 #define MC 257
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1229
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1230 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
1231 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
1232 CODE_MMDELTA=9};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1233
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1234 struct AudioVariables
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1235 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1236 int K1,K2,K3,K4,K5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1237 int D1,D2,D3,D4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1238 int LastDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1239 unsigned int Dif[11];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1240 unsigned int ByteCount;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1241 int LastChar;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1242 };
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 #define NC 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1246 #define DC 48
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1247 #define RC 28
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1248 #define BC 19
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1249 #define MC 257
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1250
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 struct AudioVariables AudV[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1253
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1254 #define GetBits() \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1255 BitField = ( ( ( (UDWORD)InBuf[InAddr] << 16 ) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1256 ( (UWORD) InBuf[InAddr+1] << 8 ) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1257 ( InBuf[InAddr+2] ) ) \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1258 >> (8-InBit) ) & 0xffff;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1259
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 #define AddBits(Bits) \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1262 InAddr += ( InBit + (Bits) ) >> 3; \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1263 InBit = ( InBit + (Bits) ) & 7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1264
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1265 static unsigned char *UnpBuf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1266 static unsigned int BitField;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1267 static unsigned int Number;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1268
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1269 unsigned char InBuf[8192]; /* input read buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1270
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1271 unsigned char UnpOldTable[MC*4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1272
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1273 unsigned int InAddr,InBit,ReadTop;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1274
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1275 unsigned int LastDist,LastLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1276 static unsigned int Length,Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1277
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1278 unsigned int OldDist[4],OldDistPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1279
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 struct LitDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1282 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1283 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1284 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1285 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1286 unsigned int DecodeNum[NC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1287 } LD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1288
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1289 struct DistDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1290 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1291 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1292 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1293 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1294 unsigned int DecodeNum[DC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1295 } DD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1296
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1297 struct RepDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1298 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1299 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1300 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1301 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1302 unsigned int DecodeNum[RC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1303 } RD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1304
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1305 struct MultDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1306 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1307 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1308 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1309 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1310 unsigned int DecodeNum[MC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1311 } MD[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1312
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1313 struct BitDecode
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1314 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1315 unsigned int MaxNum;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1316 unsigned int DecodeLen[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1317 unsigned int DecodePos[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1318 unsigned int DecodeNum[BC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1319 } BD;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1320
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1321 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
1322
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1323 int UnpAudioBlock,UnpChannels,CurChannel,ChannelDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1324
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 void Unpack(unsigned char *UnpAddr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1327 /* *** 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
1328 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1329 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
1330 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
1331 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
1332 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
1333 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
1334 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
1335 16384,24576,32768U,49152U,65536,98304,131072,196608,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1336 262144,327680,393216,458752,524288,589824,655360,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1337 720896,786432,851968,917504,983040};
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1338 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
1339 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
1340 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
1341 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
1342 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
1343 unsigned int Bits;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1344
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 UnpBuf=UnpAddr; /* UnpAddr is a pointer to the */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1347 UnpInitData(); /* unpack buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1348 UnpReadBuf(1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1349 if (!(NewLhd.Flags & LHD_SOLID))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1350 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1351 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1352
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1353 while (DestUnpSize>=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1354 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1355 UnpPtr&=MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1356
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1357 if (InAddr>sizeof(InBuf)-30)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1358 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1359 if (((WrPtr-UnpPtr) & MAXWINMASK)<270 && WrPtr!=UnpPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1360 {
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 if (FileFound)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1364 {
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 if (UnpPtr<WrPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1367 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1368 if((*temp_output_buffer_offset + UnpPtr) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1369 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1370 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1371 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1372
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1373 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1374 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1375 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1376 memcpy(temp_output_buffer + *temp_output_buffer_offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1377 &UnpBuf[WrPtr], (0-WrPtr) & MAXWINMASK);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1378 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1379 *temp_output_buffer_offset+= (0-WrPtr) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1380 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1381 memcpy(temp_output_buffer + *temp_output_buffer_offset, UnpBuf,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1382 UnpPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1383 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1384 *temp_output_buffer_offset+=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1385 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1386 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1387 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1388 if((*temp_output_buffer_offset + (UnpPtr-WrPtr)) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1389 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1390 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1391 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1392 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1393 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1394 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1395 memcpy(temp_output_buffer + *temp_output_buffer_offset,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1396 &UnpBuf[WrPtr], UnpPtr-WrPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1397 *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
1398 }
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 WrPtr=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1404 }
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 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1407 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1408 DecodeNumber((struct Decode *)MDPtr[CurChannel]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1409 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1410 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1411 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1412 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1413 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1414 UnpBuf[UnpPtr++]=DecodeAudio(Number);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1415 if (++CurChannel==UnpChannels)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1416 CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1417 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1418 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1419 }
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 DecodeNumber((struct Decode *)&LD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1422 if (Number<256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1423 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1424 UnpBuf[UnpPtr++]=(UBYTE)Number;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1425 DestUnpSize--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1426 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1427 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1428 if (Number>269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1429 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1430 Length=LDecode[Number-=270]+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1431 if ((Bits=LBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1432 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1433 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1434 Length+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1435 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1436 }
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 DecodeNumber((struct Decode *)&DD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1439 Distance=DDecode[Number]+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1440 if ((Bits=DBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1441 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1442 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1443 Distance+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1444 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1445 }
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 if (Distance>=0x40000L)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1448 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1449
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1450 if (Distance>=0x2000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1451 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1452
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1453 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1454 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1455 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1456 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1457 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1458 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1459 }
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 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1462 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1463 if (Number==269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1464 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1465 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1466 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1467 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1468 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1469 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1470 Length=LastLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1471 Distance=LastDist;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1472 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1473 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1474 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1475 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1476 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1477 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1478 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1479 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1480 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1481 if (Number<261)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1482 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1483 Distance=OldDist[(OldDistPtr-(Number-256)) & 3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1484 DecodeNumber((struct Decode *)&RD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1485 Length=LDecode[Number]+2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1486 if ((Bits=LBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1487 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1488 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1489 Length+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1490 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1491 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1492 if (Distance>=0x40000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1493 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1494 if (Distance>=0x2000)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1495 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1496 if (Distance>=0x101)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1497 Length++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1498 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1499 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1500 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1501 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1502 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1503 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1504 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1505 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1506 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1507 if (Number<270)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1508 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1509 Distance=SDDecode[Number-=261]+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1510 if ((Bits=SDBits[Number])>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1511 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1512 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1513 Distance+=BitField>>(16-Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1514 AddBits(Bits);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1515 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1516 Length=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1517 LastDist=OldDist[OldDistPtr++ & 3]=Distance;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1518 DestUnpSize-=(LastLength=Length);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1519 while (Length--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1520 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1521 UnpBuf[UnpPtr]=UnpBuf[(UnpPtr-Distance) & MAXWINMASK];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1522 UnpPtr=(UnpPtr+1) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1523 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1524 continue;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1525 }
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 ReadLastTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1528
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1529 if (FileFound) /* flush buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1530 {
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 if (UnpPtr<WrPtr)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1533 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1534 if((*temp_output_buffer_offset + UnpPtr) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1535 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1536 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1537 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1538 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1539 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1540 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1541 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
1542 (0-WrPtr) & MAXWINMASK);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1543 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1544 *temp_output_buffer_offset+= (0-WrPtr) & MAXWINMASK;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1545 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1546 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
1547 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1548 *temp_output_buffer_offset+=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1549 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1550 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1551 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1552 if((*temp_output_buffer_offset + (UnpPtr-WrPtr)) > NewLhd.UnpSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1553 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1554 debug_log("Fatal! Buffer overrun during decompression!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1555 DestUnpSize=-1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1556 } else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1557 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1558 /* copy extracted data to output buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1559 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
1560 UnpPtr-WrPtr);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1561 /* update offset within buffer */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1562 *temp_output_buffer_offset+=UnpPtr-WrPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1563 }
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 WrPtr=UnpPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1568 }
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 unsigned int UnpRead(unsigned char *Addr,unsigned int Count)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1572 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1573 int RetCode=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1574 unsigned int I,ReadSize,TotalRead=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1575 unsigned char *ReadAddr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1576 ReadAddr=Addr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1577 while (Count > 0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1578 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1579 ReadSize=(unsigned int)((Count>(unsigned long)UnpPackedSize) ?
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1580 UnpPackedSize : Count);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1581 #ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1582 if(MemRARFile->data == NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1583 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1584 RetCode=tread(MemRARFile, ReadAddr, ReadSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1585 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1586 if (ArcPtr==NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1587 return(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1588 RetCode=tread(ArcPtr,ReadAddr,ReadSize);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1589 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1590 CurUnpRead+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1591 ReadAddr+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1592 TotalRead+=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1593 Count-=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1594 UnpPackedSize-=RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1595 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1596 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1597 if (RetCode!= -1)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1598 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1599 RetCode=TotalRead;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1600 if (Encryption)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1601 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1602 if (Encryption<20)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1603 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1604 debug_log("Old Crypt() not supported!");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1605 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1606 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1607 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1608 for (I=0;I<(unsigned int)RetCode;I+=16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1609 DecryptBlock(&Addr[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1610 }
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 return(RetCode);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1614 }
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 void UnpReadBuf(int FirstBuf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1618 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1619 int RetCode;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1620 if (FirstBuf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1621 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1622 ReadTop=UnpRead(InBuf,sizeof(InBuf));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1623 InAddr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1624 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1625 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1626 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1627 memcpy(InBuf,&InBuf[sizeof(InBuf)-32],32);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1628 InAddr&=0x1f;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1629 RetCode=UnpRead(&InBuf[32],sizeof(InBuf)-32);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1630 if (RetCode>0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1631 ReadTop=RetCode+32;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1632 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1633 ReadTop=InAddr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1634 }
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 void ReadTables(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1639 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1640 UBYTE BitLength[BC];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1641 unsigned char Table[MC*4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1642 int TableSize,N,I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1643 if (InAddr>sizeof(InBuf)-25)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1644 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1645 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1646 UnpAudioBlock=(BitField & 0x8000);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1647
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1648 if (!(BitField & 0x4000))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1649 memset(UnpOldTable,0,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1650 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1651
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 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1654 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1655 UnpChannels=((BitField>>12) & 3)+1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1656 if (CurChannel>=UnpChannels)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1657 CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1658 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1659 TableSize=MC*UnpChannels;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1660 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1661 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1662 TableSize=NC+DC+RC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1663
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 for (I=0;I<BC;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1666 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1667 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1668 BitLength[I]=(UBYTE)(BitField >> 12);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1669 AddBits(4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1670 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1671 MakeDecodeTables(BitLength,(struct Decode *)&BD,BC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1672 I=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1673 while (I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1674 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1675 if (InAddr>sizeof(InBuf)-5)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1676 UnpReadBuf(0);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1677 DecodeNumber((struct Decode *)&BD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1678 if (Number<16)
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1679 {
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1680 Table[I]=(Number+UnpOldTable[I]) & 0xf;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1681 I++;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7446
diff changeset
1682 }
7446
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1683 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1684 if (Number==16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1685 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1686 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1687 N=(BitField >> 14)+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1688 AddBits(2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1689 while (N-- > 0 && I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1690 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1691 Table[I]=Table[I-1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1692 I++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1693 }
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 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1696 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1697 if (Number==17)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1698 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1699 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1700 N=(BitField >> 13)+3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1701 AddBits(3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1702 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1703 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1704 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1705 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1706 N=(BitField >> 9)+11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1707 AddBits(7);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1708 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1709 while (N-- > 0 && I<TableSize)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1710 Table[I++]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1711 }
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 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1714 for (I=0;I<UnpChannels;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1715 MakeDecodeTables(&Table[I*MC],(struct Decode *)MDPtr[I],MC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1716 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1717 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1718 MakeDecodeTables(&Table[0],(struct Decode *)&LD,NC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1719 MakeDecodeTables(&Table[NC],(struct Decode *)&DD,DC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1720 MakeDecodeTables(&Table[NC+DC],(struct Decode *)&RD,RC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1721 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1722 memcpy(UnpOldTable,Table,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1723 }
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 static void ReadLastTables(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1727 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1728 if (ReadTop>=InAddr+5)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1729 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1730 if (UnpAudioBlock)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1731 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1732 DecodeNumber((struct Decode *)MDPtr[CurChannel]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1733 if (Number==256)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1734 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1735 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1736 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1737 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1738 DecodeNumber((struct Decode *)&LD);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1739 if (Number==269)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1740 ReadTables();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1741 }
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 static void MakeDecodeTables(unsigned char *LenTab,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1747 struct Decode *Dec,
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1748 int Size)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1749 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1750 int LenCount[16],TmpPos[16],I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1751 long M,N;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1752 memset(LenCount,0,sizeof(LenCount));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1753 for (I=0;I<Size;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1754 LenCount[LenTab[I] & 0xF]++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1755
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1756 LenCount[0]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1757 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
1758 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1759 N=2*(N+LenCount[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1760 M=N<<(15-I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1761 if (M>0xFFFF)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1762 M=0xFFFF;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1763 Dec->DecodeLen[I]=(unsigned int)M;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1764 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
1765 }
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 for (I=0;I<Size;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1768 if (LenTab[I]!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1769 Dec->DecodeNum[TmpPos[LenTab[I] & 0xF]++]=I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1770 Dec->MaxNum=Size;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1771 }
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 static void DecodeNumber(struct Decode *Deco)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1775 /* *** 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
1776 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1777 unsigned int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1778 register unsigned int N;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1779 GetBits();
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1780
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1781 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1782
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1783 #ifdef _WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1784 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1785
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1786 xor eax, eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1787 mov eax, BitField // N=BitField & 0xFFFE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1788 and eax, 0xFFFFFFFE
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1789 mov [N], eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1790 mov edx, [Deco] // EAX=N, EDX=Deco
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1791
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1792 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
1793 jae else_G
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1794
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1795 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
1796 jae else_F
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1797
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 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
1800 jae else_C
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1801
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1802 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
1803 jae else_1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1804 mov I, 1 // I=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1805 jmp next_1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1806 else_1: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1807 mov I, 2 // I=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1808 next_1:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1809
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1810 jmp next_C
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1811 else_C: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1812
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1813 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
1814 jae else_2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1815 mov I, 3 // I=3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1816 jmp next_2
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1817 else_2: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1818 mov I, 4 // I=4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1819 next_2:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1820
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1821 next_C: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1822
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1823 jmp next_F
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1824 else_F:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1825
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 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
1828 jae else_E
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1829
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1830 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
1831 jae else_3
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1832 mov I, 5 // I=5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1833 jmp next_3
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1834 else_3: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1835 mov I, 6 // I=6;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1836 next_3:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1837
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1838 jmp next_E
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1839 else_E: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1840
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1841 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
1842 jae else_4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1843 mov I, 7 // I=7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1844 jmp next_4
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1845 else_4: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1846 mov I, 8 // I=8;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1847 next_4:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1848
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1849 next_E:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1850
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1851 next_F:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1852
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1853 jmp next_G
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1854 else_G:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1855
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1856 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
1857 jae else_D
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1858
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1859 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
1860 jae else_B
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1861
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1862 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
1863 jae else_5
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1864 mov I, 9 // I=9;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1865 jmp next_5
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1866 else_5: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1867 mov I, 10 // I=10;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1868 next_5:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1869
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1870 jmp next_B
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1871 else_B: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1872
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1873 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
1874 jae else_6
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1875 mov I, 11 // I=11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1876 jmp next_6
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1877 else_6: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1878 mov I, 12 // I=12;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1879 next_6:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1880
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1881 next_B:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1882
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 jmp next_D
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1885 else_D: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1886
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1887 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
1888 jae else_A
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1889
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1890 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
1891 jae else_7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1892 mov I, 13 // I=13;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1893 jmp next_7
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1894 else_7: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1895 mov I, 14 // I=14;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1896 next_7:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1897
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1898 jmp next_A
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1899 else_A: // else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1900 mov I, 15 // I=15;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1901 next_A:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1902
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1903 next_D:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1904 next_G:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1905 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1906 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1907 __asm__ __volatile__ (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1908 "andl $0xFFFFFFFE, %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1909 " movl %%eax, %1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1910 " cmpl 8*4(%%edx), %%eax /* 5379 */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1911 " jae else_G"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1912 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1913 " cmpl 4*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1914 " jae else_F"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1915 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1916 " cmpl 2*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1917 " jae else_C"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1918 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1919 " cmpl 1*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1920 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1921 " jae else_1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1922 " movl $1, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1923 " jmp next_1"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1924 " else_1: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1925 " movl $2, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1926 " next_1:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1927 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1928 " jmp next_C"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1929 " else_C: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1930 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1931 " cmpl 3*4(%%edx), %%eax "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1932 " jae else_2"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1933 " movl $3, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1934 " jmp next_2"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1935 " else_2: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1936 " movl $4, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1937 " next_2:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1938 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1939 " next_C: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1940 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1941 " jmp next_F"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1942 " else_F:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1943 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1944 " cmpl 6*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1945 " jae else_E"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1946 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1947 " cmpl 5*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1948 " jae else_3"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1949 " movl $5, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1950 " jmp next_3"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1951 " else_3: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1952 " movl $6, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1953 " next_3:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1954 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1955 " jmp next_E"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1956 " else_E: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1957 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1958 " cmpl 7*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1959 " jae else_4"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1960 " movl $7, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1961 " jmp next_4"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1962 " else_4: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1963 " movl $8, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1964 " next_4:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1965 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1966 " next_E:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1967 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1968 " next_F:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1969 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1970 " jmp next_G"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1971 " else_G:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1972 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1973 " cmpl 12*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1974 " jae else_D"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1975 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1976 " cmpl 10*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1977 " jae else_B"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1978 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1979 " cmpl 9*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1980 " jae else_5"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1981 " movl $9, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1982 " jmp next_5"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1983 " else_5: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1984 " movl $10, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1985 " next_5:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1986 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1987 " jmp next_B"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1988 " else_B: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1989 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1990 " cmpl 11*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1991 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1992 " jae else_6"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1993 " movl $11, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1994 " jmp next_6"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1995 " else_6: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1996 " movl $12, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1997 " next_6:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1998 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
1999 " next_B:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2000 " "
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 " jmp next_D"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2003 " else_D: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2004 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2005 " cmpl 14*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2006 " jae else_A"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2007 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2008 " cmpl 13*4(%%edx), %%eax"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2009 " jae else_7"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2010 " movl $13, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2011 " jmp next_7"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2012 " else_7: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2013 " movl $14, %0"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2014 " next_7:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2015 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2016 " jmp next_A"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2017 " else_A: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2018 " movl $15, %0 "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2019 " next_A:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2020 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2021 " next_D: "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2022 " next_G:"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2023 : "=g" (I), "=r"(N)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2024 : "eax" ((long)BitField), "edx"((long)Deco->DecodeLen)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2025 : "memory"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2026 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2027 #endif /* #ifdef _WIN_32 ... #elif defined _X86_ASM_ */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2028
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2029 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2030 N=BitField & 0xFFFE;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2031 if (N<Deco->DecodeLen[8]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2032 if (N<Deco->DecodeLen[4]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2033 if (N<Deco->DecodeLen[2]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2034 if (N<Deco->DecodeLen[1])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2035 I=1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2036 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2037 I=2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2038 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2039 if (N<Deco->DecodeLen[3])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2040 I=3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2041 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2042 I=4;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2043 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2044 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2045 if (N<Deco->DecodeLen[6]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2046 if (N<Deco->DecodeLen[5])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2047 I=5;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2048 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2049 I=6;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2050 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2051 if (N<Deco->DecodeLen[7])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2052 I=7;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2053 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2054 I=8;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2055 }
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 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2058 if (N<Deco->DecodeLen[12]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2059 if (N<Deco->DecodeLen[10]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2060 if (N<Deco->DecodeLen[9])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2061 I=9;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2062 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2063 I=10;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2064 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2065 if (N<Deco->DecodeLen[11])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2066 I=11;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2067 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2068 I=12;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2069 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2070 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2071 if (N<Deco->DecodeLen[14]) {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2072 if (N<Deco->DecodeLen[13])
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2073 I=13;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2074 else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2075 I=14;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2076
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2077 } else {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2078 I=15;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2079 }
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 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2084
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2085 AddBits(I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2086 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
2087 N=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2088 Number=Deco->DecodeNum[N];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2089 }
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 void UnpInitData()
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2093 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2094 InAddr=InBit=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2095 if (!(NewLhd.Flags & LHD_SOLID))
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2096 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2097 ChannelDelta=CurChannel=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2098
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2099 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2100
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2101 #ifdef _WIN_32 /* Win32 with VisualC */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2102
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2103 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2104 push edi
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2105 push eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2106 push ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2107
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2108 cld /* increment EDI and ESI */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2109 mov al, 0x00
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2110 mov ecx, SIZE AudV
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2111 mov edi, Offset AudV
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2112 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2113
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2114 mov ecx, SIZE OldDist
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2115 mov edi, Offset OldDist
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2116 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2117
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2118 mov ecx, SIZE UnpOldTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2119 mov edi, Offset UnpOldTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2120 rep stosb /* clear memory */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2121
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2122 pop ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2123 pop eax
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2124 pop edi
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2125
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 mov [OldDistPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2128 mov [LastDist], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2129 mov [LastLength], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2130 mov [UnpPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2131 mov [WrPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2132 mov [OldDistPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2133 mov [LastLength], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2134 mov [LastDist], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2135 mov [UnpPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2136 mov [WrPtr], 0
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2137
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 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2140
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 #else /* unix/linux on i386 cpus */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2143 __asm__ __volatile (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2144 " cld /* increment EDI and ESI */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2145 " movb $0x00, %%al"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2146 " movl %0, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2147 " movl %1, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2148 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2149 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2150 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2151 " movl %2, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2152 " mov %3, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2153 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2154 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2155 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2156 " movl %4, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2157 " movl %5, %%edi"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2158 " rep "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2159 " stosb /* clear memory */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2160 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2161 " movl $0, (OldDistPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2162 " movl $0, (LastDist)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2163 " movl $0, (LastLength)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2164 " movl $0, (UnpPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2165 " movl $0, (WrPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2166 " movl $0, (OldDistPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2167 " movl $0, (LastLength)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2168 " movl $0, (LastDist)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2169 " movl $0, (UnpPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2170 " movl $0, (WrPtr)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2171 :
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2172 : "m" ((long)sizeof(AudV)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2173 "m" ((long)AudV),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2174 "m" ((long)sizeof(OldDist)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2175 "m" ((long)OldDist),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2176 "m" ((long)sizeof(UnpOldTable)),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2177 "m" ((long)UnpOldTable)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2178 : "memory", "edi", "eax", "ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2179 );
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2180 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2181 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2182
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2183 #else /* unix/linux on non-i386 cpu */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2184 memset(AudV,0,sizeof(AudV));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2185 memset(OldDist,0,sizeof(OldDist));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2186 OldDistPtr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2187 LastDist=LastLength=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2188 memset(UnpBuf,0,MAXWINSIZE);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2189 memset(UnpOldTable,0,sizeof(UnpOldTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2190 UnpPtr=WrPtr=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2191 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2192
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 UBYTE DecodeAudio(int Delta)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2198 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2199 struct AudioVariables *V;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2200 unsigned int Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2201 unsigned int NumMinDif,MinDif;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2202 int PCh,I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2203
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2204 V=&AudV[CurChannel];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2205 V->ByteCount++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2206 V->D4=V->D3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2207 V->D3=V->D2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2208 V->D2=V->LastDelta-V->D1;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2209 V->D1=V->LastDelta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2210 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
2211 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
2212 PCh=(PCh>>3) & 0xFF;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2213
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2214 Ch=PCh-Delta;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2215
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2216 I=((signed char)Delta)<<3;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2217
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2218 V->Dif[0]+=abs(I);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2219 V->Dif[1]+=abs(I-V->D1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2220 V->Dif[2]+=abs(I+V->D1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2221 V->Dif[3]+=abs(I-V->D2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2222 V->Dif[4]+=abs(I+V->D2);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2223 V->Dif[5]+=abs(I-V->D3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2224 V->Dif[6]+=abs(I+V->D3);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2225 V->Dif[7]+=abs(I-V->D4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2226 V->Dif[8]+=abs(I+V->D4);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2227 V->Dif[9]+=abs(I-ChannelDelta);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2228 V->Dif[10]+=abs(I+ChannelDelta);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2229
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2230 ChannelDelta=V->LastDelta=(signed char)(Ch-V->LastChar);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2231 V->LastChar=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2232
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2233 if ((V->ByteCount & 0x1F)==0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2234 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2235 MinDif=V->Dif[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2236 NumMinDif=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2237 V->Dif[0]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2238 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
2239 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2240 if (V->Dif[I]<MinDif)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2241 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2242 MinDif=V->Dif[I];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2243 NumMinDif=I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2244 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2245 V->Dif[I]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2246 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2247 switch(NumMinDif)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2248 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2249 case 1:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2250 if (V->K1>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2251 V->K1--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2252 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2253 case 2:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2254 if (V->K1<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2255 V->K1++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2256 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2257 case 3:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2258 if (V->K2>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2259 V->K2--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2260 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2261 case 4:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2262 if (V->K2<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2263 V->K2++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2264 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2265 case 5:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2266 if (V->K3>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2267 V->K3--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2268 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2269 case 6:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2270 if (V->K3<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2271 V->K3++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2272 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2273 case 7:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2274 if (V->K4>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2275 V->K4--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2276 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2277 case 8:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2278 if (V->K4<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2279 V->K4++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2280 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2281 case 9:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2282 if (V->K5>=-16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2283 V->K5--;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2284 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2285 case 10:
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2286 if (V->K5<16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2287 V->K5++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2288 break;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2289 }
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 return((UBYTE)Ch);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2292 }
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 * ** CRCCrypt Code - decryption engine starts here **
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2302 * ***************************************************/
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 #define NROUNDS 32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2306
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2307 #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
2308 #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
2309
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2310 #define substLong(t) ( (UDWORD)SubstTable[(int)t&255] | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2311 ((UDWORD)SubstTable[(int)(t>> 8)&255]<< 8) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2312 ((UDWORD)SubstTable[(int)(t>>16)&255]<<16) | \
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2313 ((UDWORD)SubstTable[(int)(t>>24)&255]<<24) )
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2314
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 UDWORD CRCTab[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2317
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2318 UBYTE SubstTable[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2319 UBYTE InitSubstTable[256]={
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2320 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
2321 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
2322 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
2323 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
2324 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
2325 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
2326 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
2327 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
2328 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
2329 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
2330 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
2331 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
2332 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
2333 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
2334 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
2335 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
2336 };
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 UDWORD Key[4];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2339
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 void EncryptBlock(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2342 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2343 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2344
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2345 UDWORD A,B,C,D,T,TA,TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2346 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2347 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
2348 ((UDWORD)Buf[3]<<24))^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2349 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
2350 ((UDWORD)Buf[7]<<24))^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2351 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
2352 ((UDWORD)Buf[11]<<24))^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2353 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
2354 ((UDWORD)Buf[15]<<24))^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2355 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2356 UDWORD *BufPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2357 BufPtr=(UDWORD *)Buf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2358 A=BufPtr[0]^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2359 B=BufPtr[1]^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2360 C=BufPtr[2]^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2361 D=BufPtr[3]^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2362 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2363 for(I=0;I<NROUNDS;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2364 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2365 T=((C+rol(D,11))^Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2366 TA=A^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2367 T=((D^rol(C,17))+Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2368 TB=B^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2369 A=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2370 B=D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2371 C=TA;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2372 D=TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2373 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2374 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2375 C^=Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2376 Buf[0]=(UBYTE)C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2377 Buf[1]=(UBYTE)(C>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2378 Buf[2]=(UBYTE)(C>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2379 Buf[3]=(UBYTE)(C>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2380 D^=Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2381 Buf[4]=(UBYTE)D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2382 Buf[5]=(UBYTE)(D>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2383 Buf[6]=(UBYTE)(D>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2384 Buf[7]=(UBYTE)(D>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2385 A^=Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2386 Buf[8]=(UBYTE)A;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2387 Buf[9]=(UBYTE)(A>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2388 Buf[10]=(UBYTE)(A>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2389 Buf[11]=(UBYTE)(A>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2390 B^=Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2391 Buf[12]=(UBYTE)B;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2392 Buf[13]=(UBYTE)(B>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2393 Buf[14]=(UBYTE)(B>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2394 Buf[15]=(UBYTE)(B>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2395 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2396 BufPtr[0]=C^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2397 BufPtr[1]=D^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2398 BufPtr[2]=A^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2399 BufPtr[3]=B^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2400 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2401 UpdKeys(Buf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2402 }
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 void DecryptBlock(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2406 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2407 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2408 UBYTE InBuf[16];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2409 UDWORD A,B,C,D,T,TA,TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2410 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2411 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
2412 ((UDWORD)Buf[3]<<24))^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2413 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
2414 ((UDWORD)Buf[7]<<24))^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2415 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
2416 ((UDWORD)Buf[11]<<24))^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2417 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
2418 ((UDWORD)Buf[15]<<24))^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2419 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2420 UDWORD *BufPtr;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2421 BufPtr=(UDWORD *)Buf;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2422 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
2423 B=BufPtr[1]^Key[1]; /* optimized in assembler */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2424 C=BufPtr[2]^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2425 D=BufPtr[3]^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2426 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2427 memcpy(InBuf,Buf,sizeof(InBuf));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2428 for(I=NROUNDS-1;I>=0;I--)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2429 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2430 T=((C+rol(D,11))^Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2431 TA=A^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2432 T=((D^rol(C,17))+Key[I&3]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2433 TB=B^substLong(T);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2434 A=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2435 B=D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2436 C=TA;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2437 D=TB;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2438 }
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2439 #ifdef NON_INTEL_BYTE_ORDER
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2440 C^=Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2441 Buf[0]=(UBYTE)C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2442 Buf[1]=(UBYTE)(C>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2443 Buf[2]=(UBYTE)(C>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2444 Buf[3]=(UBYTE)(C>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2445 D^=Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2446 Buf[4]=(UBYTE)D;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2447 Buf[5]=(UBYTE)(D>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2448 Buf[6]=(UBYTE)(D>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2449 Buf[7]=(UBYTE)(D>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2450 A^=Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2451 Buf[8]=(UBYTE)A;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2452 Buf[9]=(UBYTE)(A>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2453 Buf[10]=(UBYTE)(A>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2454 Buf[11]=(UBYTE)(A>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2455 B^=Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2456 Buf[12]=(UBYTE)B;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2457 Buf[13]=(UBYTE)(B>>8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2458 Buf[14]=(UBYTE)(B>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2459 Buf[15]=(UBYTE)(B>>24);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2460 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2461 BufPtr[0]=C^Key[0];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2462 BufPtr[1]=D^Key[1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2463 BufPtr[2]=A^Key[2];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2464 BufPtr[3]=B^Key[3];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2465 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2466 UpdKeys(InBuf);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2467 }
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 void UpdKeys(UBYTE *Buf)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2471 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2472 int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2473 for (I=0;I<16;I+=4)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2474 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2475 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
2476 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
2477 Key[2]^=CRCTab[Buf[I+2]];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2478 Key[3]^=CRCTab[Buf[I+3]];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2479 }
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 void SetCryptKeys(char *Password)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2483 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2484 unsigned int I,J,K,PswLength;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2485 unsigned char N1,N2;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2486 unsigned char Psw[256];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2487
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2488 #if !defined _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2489 UBYTE Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2490 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2491
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2492 SetOldKeys(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2493
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2494 Key[0]=0xD3A3B879L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2495 Key[1]=0x3F6D12F7L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2496 Key[2]=0x7515A235L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2497 Key[3]=0xA4E7F123L;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2498 memset(Psw,0,sizeof(Psw));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2499 strcpy((char *)Psw,Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2500 PswLength=strlen(Password);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2501 memcpy(SubstTable,InitSubstTable,sizeof(SubstTable));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2502
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2503 for (J=0;J<256;J++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2504 for (I=0;I<PswLength;I+=2)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2505 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2506 N2=(unsigned char)CRCTab[(Psw[I+1]+J)&0xFF];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2507 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
2508 (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
2509 N1++, K++) /* because the system crashed with */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2510 { /* encrypted RARs */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2511 #ifdef _USE_ASM
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2512
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2513 #ifdef _WIN_32
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2514 __asm {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2515
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2516 mov ebx, Offset SubstTable
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2517 mov edx, ebx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2518
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2519 xor ecx, ecx // read SubstTable[N1]...
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2520 mov cl, N1
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2521 add ebx, ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2522 mov al, byte ptr[ebx]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2523
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2524 mov cl, N1 // read SubstTable[(N1+I+K)&0xFF]...
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2525 add ecx, I
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2526 add ecx, K
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2527 and ecx, 0xFF
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2528 add edx, ecx
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2529 mov ah, byte ptr[edx]
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2530
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2531 mov byte ptr[ebx], ah // and write back
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2532 mov byte ptr[edx], al
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2533
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 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2536 __asm__ __volatile__ (
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2537 " xorl %%ecx, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2538 " movl %2, %%ecx /* ecx = N1 */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2539 " mov %%ebx, %%edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2540 " addl %%ecx, %%ebx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2541 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2542 " addl %0, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2543 " addl %1, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2544 " andl $0x000000FF, %%ecx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2545 " addl %%ecx, %%edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2546 " "
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2547 " movb (%%ebx), %%al"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2548 " movb (%%edx), %%ah"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2549 ""
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2550 " movb %%ah, (%%ebx) /* and write back */"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2551 " movb %%al, (%%edx)"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2552 : : "g" ((long)I),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2553 "g" ((long)K),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2554 "g" ((long)N1),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2555 "ebx"((long)SubstTable)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2556 : "ecx", "edx"
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2557
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 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2560
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2561 #else
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2562 /* Swap(&SubstTable[N1],&SubstTable[(N1+I+K)&0xFF]); */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2563 Ch=SubstTable[N1];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2564 SubstTable[N1]=SubstTable[(N1+I+K)&0xFF];
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2565 SubstTable[(N1+I+K)&0xFF]=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2566 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2567 }
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 for (I=0;I<PswLength;I+=16)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2570 EncryptBlock(&Psw[I]);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2571 }
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 void SetOldKeys(char *Password)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2575 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2576 UDWORD PswCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2577 UBYTE Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2578 PswCRC=CalcCRC32(0xFFFFFFFFL,(UBYTE*)Password,strlen(Password));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2579 OldKey[0]=(UWORD)PswCRC;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2580 OldKey[1]=(UWORD)(PswCRC>>16);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2581 OldKey[2]=OldKey[3]=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2582 PN1=PN2=PN3=0;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2583 while ((Ch=*Password)!=0)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2584 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2585 PN1+=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2586 PN2^=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2587 PN3+=Ch;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2588 PN3=(UBYTE)rol(PN3,1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2589 OldKey[2]^=((UWORD)(Ch^CRCTab[Ch]));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2590 OldKey[3]+=((UWORD)(Ch+(CRCTab[Ch]>>16)));
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2591 Password++;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2592 }
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 void InitCRC(void)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2596 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2597 int I, J;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2598 UDWORD C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2599 for (I=0;I<256;I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2600 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2601 for (C=I,J=0;J<8;J++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2602 C=(C & 1) ? (C>>1)^0xEDB88320L : (C>>1);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2603 CRCTab[I]=C;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2604 }
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 UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2609 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2610 unsigned int I;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2611 for (I=0; I<Size; I++)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2612 StartCRC = CRCTab[(UBYTE)StartCRC ^ Addr[I]] ^ (StartCRC >> 8);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2613 return(StartCRC);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2614 }
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 ******* 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
2654 ******* *******
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 #ifdef _DEBUG_LOG
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2662
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 /* -- global stuff -------------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2665 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
2666 DWORD debug_start_time; /* starttime of debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2667 BOOL debug_started = FALSE; /* debug_log writes only if */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2668 /* this is TRUE */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2669 /* ------------------------------------------------------------------------ */
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 /* -- global functions ---------------------------------------------------- */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2673 void debug_init_proc(char *file_name)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2674 /* Create/Rewrite a log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2675 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2676 FILE *fp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2677 char date[] = __DATE__;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2678 char time[] = __TIME__;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2679
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2680 debug_start_time = GetTickCount(); /* get start time */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2681 strcpy(log_file_name, file_name); /* save file name */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2682
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2683 if((fp = fopen(log_file_name, CREATETEXT)) != NULL)
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2684 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2685 debug_started = TRUE; /* enable debug */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2686 fprintf(fp, "Debug log of UniquE's RARFileLib\n"\
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2687 "~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~\n");
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2688 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
2689 fclose(fp);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2690 }
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 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
2695 /* add a line to the log file */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2696 {
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2697 FILE *fp;
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2698
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2699 if(debug_started == FALSE) return; /* exit if not initialized */
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2700
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2701 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
2702
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 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
2705 (unsigned int)(GetTickCount() - debug_start_time),
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2706 sourceline, sourcefile, text);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2707 fclose(fp);
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2708 }
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 #endif
ad00ad5f25a9 Automatic unrar of vobsub. Does not work with rar v3
kmkaplan
parents:
diff changeset
2713 /* **************************************************************************
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 /* end of file urarlib.c */