ReactOS 0.4.15-dev-8079-g5db69da
lzexpand.c File Reference
#include "config.h"
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "lzexpand.h"
#include "wine/unicode.h"
#include "wine/debug.h"
Include dependency graph for lzexpand.c:

Go to the source code of this file.

Classes

struct  lzfileheader
 
struct  lzstate
 

Macros

#define GETLEN   2048
 
#define LZ_MAGIC_LEN   8
 
#define LZ_HEADER_LEN   14
 
#define LZ_TABLE_SIZE   0x1000
 
#define MAX_LZSTATES   16
 
#define LZ_MIN_HANDLE   0x400
 
#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)
 
#define GET(lzs, b)   _lzget(lzs,&b)
 
#define GET_FLUSH(lzs)   lzs->getcur=lzs->getlen;
 
#define DECOMPRESS_ONE_BYTE
 
#define BUFLEN   1000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (file)
 
static int _lzget (struct lzstate *lzs, BYTE *b)
 
static INT read_header (HFILE fd, struct lzfileheader *head)
 
INT WINAPI LZStart (void)
 
HFILE WINAPI LZInit (HFILE hfSrc)
 
void WINAPI LZDone (void)
 
INT WINAPI GetExpandedNameA (LPSTR in, LPSTR out)
 
INT WINAPI GetExpandedNameW (LPWSTR in, LPWSTR out)
 
INT WINAPI LZRead (HFILE fd, LPSTR vbuf, INT toread)
 
LONG WINAPI LZSeek (HFILE fd, LONG off, INT type)
 
LONG WINAPI LZCopy (HFILE src, HFILE dest)
 
static LPSTR LZEXPAND_MangleName (LPCSTR fn)
 
HFILE WINAPI LZOpenFileA (LPSTR fn, LPOFSTRUCT ofs, WORD mode)
 
HFILE WINAPI LZOpenFileW (LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
 
void WINAPI LZClose (HFILE fd)
 

Variables

static const BYTE LZMagic [LZ_MAGIC_LEN] ={'S','Z','D','D',0x88,0xf0,0x27,0x33}
 
static struct lzstatelzstates [MAX_LZSTATES]
 

Macro Definition Documentation

◆ BUFLEN

#define BUFLEN   1000

◆ DECOMPRESS_ONE_BYTE

#define DECOMPRESS_ONE_BYTE

◆ GET

#define GET (   lzs,
  b 
)    _lzget(lzs,&b)

Definition at line 123 of file lzexpand.c.

◆ GET_FLUSH

#define GET_FLUSH (   lzs)    lzs->getcur=lzs->getlen;

Definition at line 124 of file lzexpand.c.

◆ GET_LZ_STATE

#define GET_LZ_STATE (   h)    (IS_LZ_HANDLE(h) ? lzstates[(h)-LZ_MIN_HANDLE] : NULL)

Definition at line 120 of file lzexpand.c.

◆ GETLEN

#define GETLEN   2048

Definition at line 77 of file lzexpand.c.

◆ IS_LZ_HANDLE

#define IS_LZ_HANDLE (   h)    (((h) >= LZ_MIN_HANDLE) && ((h) < LZ_MIN_HANDLE+MAX_LZSTATES))

Definition at line 119 of file lzexpand.c.

◆ LZ_HEADER_LEN

#define LZ_HEADER_LEN   14

Definition at line 80 of file lzexpand.c.

◆ LZ_MAGIC_LEN

#define LZ_MAGIC_LEN   8

Definition at line 79 of file lzexpand.c.

◆ LZ_MIN_HANDLE

#define LZ_MIN_HANDLE   0x400

Definition at line 118 of file lzexpand.c.

◆ LZ_TABLE_SIZE

#define LZ_TABLE_SIZE   0x1000

Definition at line 91 of file lzexpand.c.

◆ MAX_LZSTATES

#define MAX_LZSTATES   16

Definition at line 115 of file lzexpand.c.

Function Documentation

◆ _lzget()

static int _lzget ( struct lzstate lzs,
BYTE b 
)
static

Definition at line 127 of file lzexpand.c.

127 {
128 if (lzs->getcur<lzs->getlen) {
129 *b = lzs->get[lzs->getcur++];
130 return 1;
131 } else {
132 int ret = _lread(lzs->realfd,lzs->get,GETLEN);
133 if (ret==HFILE_ERROR)
134 return HFILE_ERROR;
135 if (ret==0)
136 return 0;
137 lzs->getlen = ret;
138 lzs->getcur = 1;
139 *b = *(lzs->get);
140 return 1;
141 }
142}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define _lread(a, b, c)
Definition: kernel32.h:171
#define GETLEN
Definition: lzexpand.c:77
BYTE * get
Definition: lzexpand.c:110
DWORD getcur
Definition: lzexpand.c:111
HFILE realfd
Definition: lzexpand.c:94
DWORD getlen
Definition: lzexpand.c:112
int ret
#define HFILE_ERROR
Definition: winbase.h:111

◆ GetExpandedNameA()

INT WINAPI GetExpandedNameA ( LPSTR  in,
LPSTR  out 
)

Definition at line 257 of file lzexpand.c.

258{
259 struct lzfileheader head;
260 HFILE fd;
261 OFSTRUCT ofs;
262 INT fnislowercased,ret,len;
263 LPSTR s,t;
264
265 TRACE("(%s)\n",in);
266 fd=OpenFile(in,&ofs,OF_READ);
267 if (fd==HFILE_ERROR)
269 strcpy(out,in);
271 if (ret<=0) {
272 /* not a LZ compressed file, so the expanded name is the same
273 * as the input name */
274 _lclose(fd);
275 return 1;
276 }
277
278
279 /* look for directory prefix and skip it. */
280 s=out;
281 while (NULL!=(t=strpbrk(s,"/\\:")))
282 s=t+1;
283
284 /* now mangle the basename */
285 if (!*s) {
286 /* FIXME: hmm. shouldn't happen? */
287 WARN("Specified a directory or what? (%s)\n",in);
288 _lclose(fd);
289 return 1;
290 }
291 /* see if we should use lowercase or uppercase on the last char */
292 fnislowercased=1;
293 t=s+strlen(s)-1;
294 while (t>=out) {
295 if (!isalpha(*t)) {
296 t--;
297 continue;
298 }
299 fnislowercased=islower(*t);
300 break;
301 }
302 if (isalpha(head.lastchar)) {
303 if (fnislowercased)
304 head.lastchar=tolower(head.lastchar);
305 else
306 head.lastchar=toupper(head.lastchar);
307 }
308
309 /* now look where to replace the last character */
310 if (NULL!=(t=strchr(s,'.'))) {
311 if (t[1]=='\0') {
312 t[0]='\0';
313 } else {
314 len=strlen(t)-1;
315 if (t[len]=='_')
316 t[len]=head.lastchar;
317 }
318 } /* else no modification necessary */
319 _lclose(fd);
320 return 1;
321}
signed short INT16
#define islower(c)
Definition: acclib.h:72
#define isalpha(c)
Definition: acclib.h:74
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int toupper(int c)
Definition: utclib.c:881
int tolower(int c)
Definition: utclib.c:902
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * strchr(const char *String, int ch)
Definition: utclib.c:501
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define WARN(fmt,...)
Definition: debug.h:115
#define NULL
Definition: types.h:112
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLuint in
Definition: glext.h:9616
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
static INT read_header(HFILE fd, struct lzfileheader *head)
Definition: lzexpand.c:149
#define LZERROR_BADINHANDLE
Definition: lzexpand.h:7
static FILE * out
Definition: regtests2xml.c:44
static int fd
Definition: io.c:51
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58
#define OF_READ
Definition: winbase.h:116
int HFILE
Definition: windef.h:298
char * LPSTR
Definition: xmlstorage.h:182

Referenced by GetExpandedNameW(), and main().

◆ GetExpandedNameW()

INT WINAPI GetExpandedNameW ( LPWSTR  in,
LPWSTR  out 
)

Definition at line 327 of file lzexpand.c.

328{
329 INT ret;
330 DWORD len = WideCharToMultiByte( CP_ACP, 0, in, -1, NULL, 0, NULL, NULL );
331 char *xin = HeapAlloc( GetProcessHeap(), 0, len );
332 char *xout = HeapAlloc( GetProcessHeap(), 0, len+3 );
333 WideCharToMultiByte( CP_ACP, 0, in, -1, xin, len, NULL, NULL );
334 if ((ret = GetExpandedNameA( xin, xout )) > 0)
335 MultiByteToWideChar( CP_ACP, 0, xout, -1, out, strlenW(in)+4 );
336 HeapFree( GetProcessHeap(), 0, xin );
337 HeapFree( GetProcessHeap(), 0, xout );
338 return ret;
339}
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WINAPI GetExpandedNameA(LPSTR in, LPSTR out)
Definition: lzexpand.c:257
#define strlenW(s)
Definition: unicode.h:34

◆ LZClose()

◆ LZCopy()

LONG WINAPI LZCopy ( HFILE  src,
HFILE  dest 
)

Definition at line 467 of file lzexpand.c.

473{
474 int usedlzinit = 0, ret, wret;
475 LONG len;
476 HFILE oldsrc = src, srcfd;
478 struct lzstate *lzs;
479#define BUFLEN 1000
480 CHAR buf[BUFLEN];
481 /* we need that weird typedef, for i can't seem to get function pointer
482 * casts right. (Or they probably just do not like WINAPI in general)
483 */
484 typedef UINT (WINAPI *_readfun)(HFILE,LPVOID,UINT);
485
486 _readfun xread;
487
488 TRACE("(%d,%d)\n",src,dest);
489 if (!IS_LZ_HANDLE(src)) {
490 src = LZInit(src);
491 if ((INT)src <= 0) return 0;
492 if (src != oldsrc) usedlzinit=1;
493 }
494
495 /* not compressed? just copy */
496 if (!IS_LZ_HANDLE(src))
497#ifdef __REACTOS__
498 xread=(_readfun)_hread; // ROSHACK
499#else
500 xread=_lread;
501#endif
502 else
503 xread=(_readfun)LZRead;
504 len=0;
505 while (1) {
506 ret=xread(src,buf,BUFLEN);
507 if (ret<=0) {
508 if (ret==0)
509 break;
510 if (ret==-1)
511 return LZERROR_READ;
512 return ret;
513 }
514 len += ret;
515 wret = _lwrite(dest,buf,ret);
516 if (wret!=ret)
517 return LZERROR_WRITE;
518 }
519
520 /* Maintain the timestamp of source file to destination file */
521 srcfd = (!(lzs = GET_LZ_STATE(src))) ? src : lzs->realfd;
524
525 /* close handle */
#define LongToHandle(h)
Definition: basetsd.h:82
BOOL WINAPI SetFileTime(IN HANDLE hFile, CONST FILETIME *lpCreationTime OPTIONAL, CONST FILETIME *lpLastAccessTime OPTIONAL, CONST FILETIME *lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:948
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
GLenum src
Definition: glext.h:6340
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
long WINAPI _hread(HFILE hFile, LPVOID lpBuffer, long lBytes)
Definition: lfile.c:20
INT WINAPI LZRead(HFILE fd, LPSTR vbuf, INT toread)
Definition: lzexpand.c:345
HFILE WINAPI LZInit(HFILE hfSrc)
Definition: lzexpand.c:197
#define BUFLEN
#define IS_LZ_HANDLE(h)
Definition: lzexpand.c:119
#define LZERROR_WRITE
Definition: lzexpand.h:10
#define LZERROR_READ
Definition: lzexpand.h:9
static char * dest
Definition: rtl.c:135
unsigned int UINT
Definition: ndis.h:50
#define LPVOID
Definition: nt_native.h:45
long LONG
Definition: pedump.c:60
UINT WINAPI _lwrite(_In_ HFILE hFile, _In_reads_bytes_(uBytes) LPCCH lpBuffer, _In_ UINT uBytes)
#define WINAPI
Definition: msvc.h:6
char CHAR
Definition: xmlstorage.h:175

Referenced by decompress_file_lz(), do_file_copyW(), Imm32CopyImeFile(), main(), test_LZCopy(), and VerInstallFileA().

◆ LZDone()

void WINAPI LZDone ( void  )

Definition at line 240 of file lzexpand.c.

241{
242 TRACE("(void)\n");
243}

◆ LZEXPAND_MangleName()

static LPSTR LZEXPAND_MangleName ( LPCSTR  fn)
static

Definition at line 528 of file lzexpand.c.

534{
535 char *p;
536 char *mfn = HeapAlloc( GetProcessHeap(), 0, strlen(fn) + 3 ); /* "._" and \0 */
537 if(mfn == NULL) return NULL;
538 strcpy( mfn, fn );
539 if (!(p = strrchr( mfn, '\\' ))) p = mfn;
540 if ((p = strchr( p, '.' )))
541 {
542 p++;
543 if (strlen(p) < 3) strcat( p, "_" ); /* append '_' */
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Referenced by LZOpenFileA().

◆ LZInit()

HFILE WINAPI LZInit ( HFILE  hfSrc)

Definition at line 197 of file lzexpand.c.

198{
199
200 struct lzfileheader head;
201 struct lzstate *lzs;
202 int i, ret;
203
204 TRACE("(%d)\n",hfSrc);
205 ret=read_header(hfSrc,&head);
206 if (ret<=0) {
207 _llseek(hfSrc,0,SEEK_SET);
208 return ret?ret:hfSrc;
209 }
210 for (i = 0; i < MAX_LZSTATES; i++) if (!lzstates[i]) break;
211 if (i == MAX_LZSTATES) return LZERROR_GLOBALLOC;
212 lzstates[i] = lzs = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lzs) );
213 if(lzs == NULL) return LZERROR_GLOBALLOC;
214
215 lzs->realfd = hfSrc;
216 lzs->lastchar = head.lastchar;
217 lzs->reallength = head.reallength;
218
219 lzs->get = HeapAlloc( GetProcessHeap(), 0, GETLEN );
220 lzs->getlen = 0;
221 lzs->getcur = 0;
222
223 if(lzs->get == NULL) {
224 HeapFree(GetProcessHeap(), 0, lzs);
225 lzstates[i] = NULL;
226 return LZERROR_GLOBALLOC;
227 }
228
229 /* Yes, preinitialize with spaces */
230 memset(lzs->table,' ',LZ_TABLE_SIZE);
231 /* Yes, start 16 byte from the END of the table */
232 lzs->curtabent = 0xff0;
233 return LZ_MIN_HANDLE + i;
234}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SEEK_SET
Definition: jmemansi.c:26
LONG WINAPI _llseek(HFILE hFile, LONG lOffset, int iOrigin)
Definition: lfile.c:149
#define LZ_MIN_HANDLE
Definition: lzexpand.c:118
#define MAX_LZSTATES
Definition: lzexpand.c:115
#define LZ_TABLE_SIZE
Definition: lzexpand.c:91
static struct lzstate * lzstates[MAX_LZSTATES]
Definition: lzexpand.c:116
#define LZERROR_GLOBALLOC
Definition: lzexpand.h:11
#define memset(x, y, z)
Definition: compat.h:39
BYTE table[LZ_TABLE_SIZE]
Definition: lzexpand.c:101
CHAR lastchar
Definition: lzexpand.c:95
DWORD reallength
Definition: lzexpand.c:97
UINT curtabent
Definition: lzexpand.c:102

Referenced by LZCopy(), and LZOpenFileA().

◆ LZOpenFileA()

HFILE WINAPI LZOpenFileA ( LPSTR  fn,
LPOFSTRUCT  ofs,
WORD  mode 
)

Definition at line 551 of file lzexpand.c.

557{
558 HFILE fd,cfd;
559 BYTE ofs_cBytes = ofs->cBytes;
560
561 TRACE("(%s,%p,%d)\n",fn,ofs,mode);
562 /* 0x70 represents all OF_SHARE_* flags, ignore them for the check */
563 fd=OpenFile(fn,ofs,mode);
564 if (fd==HFILE_ERROR)
565 {
567 fd = OpenFile(mfn,ofs,mode);
568 HeapFree( GetProcessHeap(), 0, mfn );
569 }
570 if (fd==HFILE_ERROR)
571 ofs->cBytes = ofs_cBytes;
572 if ((mode&~0x70)!=OF_READ)
573 return fd;
574 if (fd==HFILE_ERROR)
GLenum mode
Definition: glext.h:6217
static LPSTR LZEXPAND_MangleName(LPCSTR fn)
Definition: lzexpand.c:528
BYTE cBytes
Definition: winbase.h:1289
unsigned char BYTE
Definition: xxhash.c:193

Referenced by create_file(), delete_file(), LZOpenFileW(), main(), test_LZCopy(), test_LZOpenFileA(), test_LZOpenFileA_existing_compressed(), test_LZOpenFileA_nonexisting_compressed(), test_LZRead(), and VerInstallFileA().

◆ LZOpenFileW()

◆ LZRead()

INT WINAPI LZRead ( HFILE  fd,
LPSTR  vbuf,
INT  toread 
)

Definition at line 345 of file lzexpand.c.

346{
347 int howmuch;
348 BYTE b,*buf;
349 struct lzstate *lzs;
350
351 buf=(LPBYTE)vbuf;
352 TRACE("(%d,%p,%d)\n",fd,buf,toread);
353 howmuch=toread;
354 if (!(lzs = GET_LZ_STATE(fd))) return _lread(fd,buf,toread);
355
356/* The decompressor itself is in a define, cause we need it twice
357 * in this function. (the decompressed byte will be in b)
358 */
359#define DECOMPRESS_ONE_BYTE \
360 if (lzs->stringlen) { \
361 b = lzs->table[lzs->stringpos]; \
362 lzs->stringpos = (lzs->stringpos+1)&0xFFF; \
363 lzs->stringlen--; \
364 } else { \
365 if (!(lzs->bytetype&0x100)) { \
366 if (1!=GET(lzs,b)) \
367 return toread-howmuch; \
368 lzs->bytetype = b|0xFF00; \
369 } \
370 if (lzs->bytetype & 1) { \
371 if (1!=GET(lzs,b)) \
372 return toread-howmuch; \
373 } else { \
374 BYTE b1,b2; \
375 \
376 if (1!=GET(lzs,b1)) \
377 return toread-howmuch; \
378 if (1!=GET(lzs,b2)) \
379 return toread-howmuch; \
380 /* Format: \
381 * b1 b2 \
382 * AB CD \
383 * where CAB is the stringoffset in the table\
384 * and D+3 is the len of the string \
385 */ \
386 lzs->stringpos = b1|((b2&0xf0)<<4); \
387 lzs->stringlen = (b2&0xf)+2; \
388 /* 3, but we use a byte already below ... */\
389 b = lzs->table[lzs->stringpos];\
390 lzs->stringpos = (lzs->stringpos+1)&0xFFF;\
391 } \
392 lzs->bytetype>>=1; \
393 } \
394 /* store b in table */ \
395 lzs->table[lzs->curtabent++]= b; \
396 lzs->curtabent &= 0xFFF; \
397 lzs->realcurrent++;
398
399 /* if someone has seeked, we have to bring the decompressor
400 * to that position
401 */
402 if (lzs->realcurrent!=lzs->realwanted) {
403 /* if the wanted position is before the current position
404 * I see no easy way to unroll ... We have to restart at
405 * the beginning. *sigh*
406 */
407 if (lzs->realcurrent>lzs->realwanted) {
408 /* flush decompressor state */
410 GET_FLUSH(lzs);
411 lzs->realcurrent= 0;
412 lzs->bytetype = 0;
413 lzs->stringlen = 0;
414 memset(lzs->table,' ',LZ_TABLE_SIZE);
415 lzs->curtabent = 0xFF0;
416 }
417 while (lzs->realcurrent<lzs->realwanted) {
419 }
420 }
421
422 while (howmuch) {
424 lzs->realwanted++;
425 *buf++ = b;
#define b
Definition: ke_i.h:79
#define DECOMPRESS_ONE_BYTE
#define LZ_HEADER_LEN
Definition: lzexpand.c:80
#define GET_FLUSH(lzs)
Definition: lzexpand.c:124
BYTE stringlen
Definition: lzexpand.c:104
DWORD realcurrent
Definition: lzexpand.c:98
WORD bytetype
Definition: lzexpand.c:108
DWORD realwanted
Definition: lzexpand.c:99
Definition: internal.h:110
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by find_ne_resource(), find_pe_resource(), GetFileVersionInfoExW(), LZCopy(), read_xx_header(), test_LZRead(), and TLB_NEFile_Open().

◆ LZSeek()

LONG WINAPI LZSeek ( HFILE  fd,
LONG  off,
INT  type 
)

Definition at line 431 of file lzexpand.c.

437{
438 struct lzstate *lzs;
439 LONG newwanted;
440
441 TRACE("(%d,%d,%d)\n",fd,off,type);
442 /* not compressed? just use normal _llseek() */
443 if (!(lzs = GET_LZ_STATE(fd))) return _llseek(fd,off,type);
444 newwanted = lzs->realwanted;
445 switch (type) {
446 case 1: /* SEEK_CUR */
447 newwanted += off;
448 break;
449 case 2: /* SEEK_END */
450 newwanted = lzs->reallength-off;
451 break;
452 default:/* SEEK_SET */
453 newwanted = off;
454 break;
455 }
456 if (newwanted>lzs->reallength)
457 return LZERROR_BADVALUE;
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define LZERROR_BADVALUE
Definition: lzexpand.h:13

Referenced by find_ne_resource(), find_pe_resource(), get_file_sizes_lz(), GetFileVersionInfoExW(), read_xx_header(), and TLB_NEFile_Open().

◆ LZStart()

INT WINAPI LZStart ( void  )

Definition at line 179 of file lzexpand.c.

180{
181 TRACE("(void)\n");
182 return 1;
183}

◆ read_header()

static INT read_header ( HFILE  fd,
struct lzfileheader head 
)
static

Definition at line 149 of file lzexpand.c.

150{
152
153 if (_llseek(fd,0,SEEK_SET)==-1)
154 return LZERROR_BADINHANDLE;
155
156 /* We can't directly read the lzfileheader struct due to
157 * structure element alignment
158 */
160 return 0;
161 memcpy(head->magic,buf,LZ_MAGIC_LEN);
162 memcpy(&(head->compressiontype),buf+LZ_MAGIC_LEN,1);
163 memcpy(&(head->lastchar),buf+LZ_MAGIC_LEN+1,1);
164
165 /* FIXME: consider endianness on non-intel architectures */
166 memcpy(&(head->reallength),buf+LZ_MAGIC_LEN+2,4);
167
168 if (memcmp(head->magic,LZMagic,LZ_MAGIC_LEN))
169 return 0;
170 if (head->compressiontype!='A')
171 return LZERROR_UNKNOWNALG;
172 return 1;
173}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static const BYTE LZMagic[LZ_MAGIC_LEN]
Definition: lzexpand.c:89
#define LZ_MAGIC_LEN
Definition: lzexpand.c:79
#define LZERROR_UNKNOWNALG
Definition: lzexpand.h:14
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by GetExpandedNameA(), and LZInit().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( file  )

Variable Documentation

◆ LZMagic

const BYTE LZMagic[LZ_MAGIC_LEN] ={'S','Z','D','D',0x88,0xf0,0x27,0x33}
static

Definition at line 89 of file lzexpand.c.

Referenced by read_header().

◆ lzstates

struct lzstate* lzstates[MAX_LZSTATES]
static

Definition at line 116 of file lzexpand.c.

Referenced by LZClose(), and LZInit().