Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
15fd7a02
Commit
15fd7a02
authored
Nov 17, 2006
by
James Hawkins
Committed by
Alexandre Julliard
Nov 20, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Replace magic numbers with descriptive defines.
parent
a07dceb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
lzexpand.c
dlls/kernel32/lzexpand.c
+23
-17
No files found.
dlls/kernel32/lzexpand.c
View file @
15fd7a02
...
@@ -58,14 +58,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
...
@@ -58,14 +58,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
*/
*/
#define GETLEN 2048
#define GETLEN 2048
#define LZ_MAGIC_LEN 8
#define LZ_HEADER_LEN 14
/* Format of first 14 byte of LZ compressed file */
/* Format of first 14 byte of LZ compressed file */
struct
lzfileheader
{
struct
lzfileheader
{
BYTE
magic
[
8
];
BYTE
magic
[
LZ_MAGIC_LEN
];
BYTE
compressiontype
;
BYTE
compressiontype
;
CHAR
lastchar
;
CHAR
lastchar
;
DWORD
reallength
;
DWORD
reallength
;
};
};
static
BYTE
LZMagic
[
8
]
=
{
'S'
,
'Z'
,
'D'
,
'D'
,
0x88
,
0xf0
,
0x27
,
0x33
};
static
BYTE
LZMagic
[
LZ_MAGIC_LEN
]
=
{
'S'
,
'Z'
,
'D'
,
'D'
,
0x88
,
0xf0
,
0x27
,
0x33
};
#define LZ_TABLE_SIZE 0x1000
struct
lzstate
{
struct
lzstate
{
HFILE
realfd
;
/* the real filedescriptor */
HFILE
realfd
;
/* the real filedescriptor */
...
@@ -75,7 +80,7 @@ struct lzstate {
...
@@ -75,7 +80,7 @@ struct lzstate {
DWORD
realcurrent
;
/* the position the decompressor currently is */
DWORD
realcurrent
;
/* the position the decompressor currently is */
DWORD
realwanted
;
/* the position the user wants to read from */
DWORD
realwanted
;
/* the position the user wants to read from */
BYTE
table
[
0x1000
];
/* the rotating LZ table */
BYTE
table
[
LZ_TABLE_SIZE
];
/* the rotating LZ table */
UINT
curtabent
;
/* CURrent TABle ENTry */
UINT
curtabent
;
/* CURrent TABle ENTry */
BYTE
stringlen
;
/* length and position of current string */
BYTE
stringlen
;
/* length and position of current string */
...
@@ -92,8 +97,9 @@ struct lzstate {
...
@@ -92,8 +97,9 @@ struct lzstate {
#define MAX_LZSTATES 16
#define MAX_LZSTATES 16
static
struct
lzstate
*
lzstates
[
MAX_LZSTATES
];
static
struct
lzstate
*
lzstates
[
MAX_LZSTATES
];
#define IS_LZ_HANDLE(h) (((h) >= 0x400) && ((h) < 0x400+MAX_LZSTATES))
#define LZ_MIN_HANDLE 0x400
#define GET_LZ_STATE(h) (IS_LZ_HANDLE(h) ? lzstates[(h)-0x400] : NULL)
#define IS_LZ_HANDLE(h) (((h) >= LZ_MIN_HANDLE) && ((h) < LZ_MIN_HANDLE+MAX_LZSTATES))
#define GET_LZ_STATE(h) (IS_LZ_HANDLE(h) ? lzstates[(h)-LZ_MIN_HANDLE] : NULL)
/* reads one compressed byte, including buffering */
/* reads one compressed byte, including buffering */
#define GET(lzs,b) _lzget(lzs,&b)
#define GET(lzs,b) _lzget(lzs,&b)
...
@@ -124,7 +130,7 @@ _lzget(struct lzstate *lzs,BYTE *b) {
...
@@ -124,7 +130,7 @@ _lzget(struct lzstate *lzs,BYTE *b) {
*/
*/
static
INT
read_header
(
HFILE
fd
,
struct
lzfileheader
*
head
)
static
INT
read_header
(
HFILE
fd
,
struct
lzfileheader
*
head
)
{
{
BYTE
buf
[
14
];
BYTE
buf
[
LZ_HEADER_LEN
];
if
(
_llseek
(
fd
,
0
,
SEEK_SET
)
==-
1
)
if
(
_llseek
(
fd
,
0
,
SEEK_SET
)
==-
1
)
return
LZERROR_BADINHANDLE
;
return
LZERROR_BADINHANDLE
;
...
@@ -132,16 +138,16 @@ static INT read_header(HFILE fd,struct lzfileheader *head)
...
@@ -132,16 +138,16 @@ static INT read_header(HFILE fd,struct lzfileheader *head)
/* We can't directly read the lzfileheader struct due to
/* We can't directly read the lzfileheader struct due to
* structure element alignment
* structure element alignment
*/
*/
if
(
_lread
(
fd
,
buf
,
14
)
<
14
)
if
(
_lread
(
fd
,
buf
,
LZ_HEADER_LEN
)
<
LZ_HEADER_LEN
)
return
0
;
return
0
;
memcpy
(
head
->
magic
,
buf
,
8
);
memcpy
(
head
->
magic
,
buf
,
LZ_MAGIC_LEN
);
memcpy
(
&
(
head
->
compressiontype
),
buf
+
8
,
1
);
memcpy
(
&
(
head
->
compressiontype
),
buf
+
LZ_MAGIC_LEN
,
1
);
memcpy
(
&
(
head
->
lastchar
),
buf
+
9
,
1
);
memcpy
(
&
(
head
->
lastchar
),
buf
+
LZ_MAGIC_LEN
+
1
,
1
);
/* FIXME: consider endianess on non-intel architectures */
/* FIXME: consider endianess on non-intel architectures */
memcpy
(
&
(
head
->
reallength
),
buf
+
10
,
4
);
memcpy
(
&
(
head
->
reallength
),
buf
+
LZ_MAGIC_LEN
+
2
,
4
);
if
(
memcmp
(
head
->
magic
,
LZMagic
,
8
))
if
(
memcmp
(
head
->
magic
,
LZMagic
,
LZ_MAGIC_LEN
))
return
0
;
return
0
;
if
(
head
->
compressiontype
!=
'A'
)
if
(
head
->
compressiontype
!=
'A'
)
return
LZERROR_UNKNOWNALG
;
return
LZERROR_UNKNOWNALG
;
...
@@ -205,10 +211,10 @@ HFILE WINAPI LZInit( HFILE hfSrc )
...
@@ -205,10 +211,10 @@ HFILE WINAPI LZInit( HFILE hfSrc )
}
}
/* Yes, preinitialize with spaces */
/* Yes, preinitialize with spaces */
memset
(
lzs
->
table
,
' '
,
0x1000
);
memset
(
lzs
->
table
,
' '
,
LZ_TABLE_SIZE
);
/* Yes, start 16 byte from the END of the table */
/* Yes, start 16 byte from the END of the table */
lzs
->
curtabent
=
0xff0
;
lzs
->
curtabent
=
0xff0
;
return
0x400
+
i
;
return
LZ_MIN_HANDLE
+
i
;
}
}
...
@@ -384,12 +390,12 @@ INT WINAPI LZRead( HFILE fd, LPSTR vbuf, INT toread )
...
@@ -384,12 +390,12 @@ INT WINAPI LZRead( HFILE fd, LPSTR vbuf, INT toread )
*/
*/
if
(
lzs
->
realcurrent
>
lzs
->
realwanted
)
{
if
(
lzs
->
realcurrent
>
lzs
->
realwanted
)
{
/* flush decompressor state */
/* flush decompressor state */
_llseek
(
lzs
->
realfd
,
14
,
SEEK_SET
);
_llseek
(
lzs
->
realfd
,
LZ_HEADER_LEN
,
SEEK_SET
);
GET_FLUSH
(
lzs
);
GET_FLUSH
(
lzs
);
lzs
->
realcurrent
=
0
;
lzs
->
realcurrent
=
0
;
lzs
->
bytetype
=
0
;
lzs
->
bytetype
=
0
;
lzs
->
stringlen
=
0
;
lzs
->
stringlen
=
0
;
memset
(
lzs
->
table
,
' '
,
0x1000
);
memset
(
lzs
->
table
,
' '
,
LZ_TABLE_SIZE
);
lzs
->
curtabent
=
0xFF0
;
lzs
->
curtabent
=
0xFF0
;
}
}
while
(
lzs
->
realcurrent
<
lzs
->
realwanted
)
{
while
(
lzs
->
realcurrent
<
lzs
->
realwanted
)
{
...
@@ -578,7 +584,7 @@ void WINAPI LZClose( HFILE fd )
...
@@ -578,7 +584,7 @@ void WINAPI LZClose( HFILE fd )
{
{
HeapFree
(
GetProcessHeap
(),
0
,
lzs
->
get
);
HeapFree
(
GetProcessHeap
(),
0
,
lzs
->
get
);
CloseHandle
((
HANDLE
)
lzs
->
realfd
);
CloseHandle
((
HANDLE
)
lzs
->
realfd
);
lzstates
[
fd
-
0x400
]
=
NULL
;
lzstates
[
fd
-
LZ_MIN_HANDLE
]
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
lzs
);
HeapFree
(
GetProcessHeap
(),
0
,
lzs
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment