random changes and bugfixes
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1547 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Executable
+94
@@ -0,0 +1,94 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
LZ packer/unpacker
|
||||||
|
|
||||||
|
Code is mostly from lzhuf.c found at
|
||||||
|
http://www.cs.umu.se/~isak/Snippets
|
||||||
|
|
||||||
|
***********Original Comment***********************************************
|
||||||
|
lzhuf.c
|
||||||
|
written by Haruyasu Yoshizaki 1988/11/20
|
||||||
|
some minor changes 1989/04/06
|
||||||
|
comments translated by Haruhiko Okumura 1989/04/07
|
||||||
|
getbit and getbyte modified 1990/03/23 by Paul Edwards
|
||||||
|
so that they would work on machines where integers are
|
||||||
|
not necessarily 16 bits (although ANSI guarantees a
|
||||||
|
minimum of 16). This program has compiled and run with
|
||||||
|
no errors under Turbo C 2.0, Power C, and SAS/C 4.5
|
||||||
|
(running on an IBM mainframe under MVS/XA 2.2). Could
|
||||||
|
people please use YYYY/MM/DD date format so that everyone
|
||||||
|
in the world can know what format the date is in?
|
||||||
|
external storage of filesize changed 1990/04/18 by Paul Edwards to
|
||||||
|
Intel's "little endian" rather than a machine-dependant style so
|
||||||
|
that files produced on one machine with lzhuf can be decoded on
|
||||||
|
any other. "little endian" style was chosen since lzhuf
|
||||||
|
originated on PC's, and therefore they should dictate the
|
||||||
|
standard.
|
||||||
|
initialization of something predicting spaces changed 1990/04/22 by
|
||||||
|
Paul Edwards so that when the compressed file is taken somewhere
|
||||||
|
else, it will decode properly, without changing ascii spaces to
|
||||||
|
ebcdic spaces. This was done by changing the ' ' (space literal)
|
||||||
|
to 0x20 (which is the far most likely character to occur, if you
|
||||||
|
don't know what environment it will be running on.
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
//#include <sys/types.h>
|
||||||
|
//#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
//#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
//#include <errno.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#if defined(WIN32) && defined(_MSC_VER)
|
||||||
|
# define inline __inline
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
# define inline __inline__
|
||||||
|
#endif
|
||||||
|
#include "lzhuf.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char* s;
|
||||||
|
lzhuf_session_t sess;
|
||||||
|
FILE* infile;
|
||||||
|
FILE* outfile;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (argc != 4)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"'lz e file1 file2' encodes file1 into file2.\n"
|
||||||
|
"'lz d file2 file1' decodes file2 into file1.\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((s = argv[1], s[1] || strchr("DEde", s[0]) == NULL)
|
||||||
|
|| (s = argv[2], (infile = fopen(s, "rb")) == NULL)
|
||||||
|
|| (s = argv[3], (outfile = fopen(s, "wb")) == NULL))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "??? %s\n", s);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
lzhuf_startSession(&sess, LZHUF_STDIO);
|
||||||
|
sess.infile = infile;
|
||||||
|
sess.outfile = outfile;
|
||||||
|
|
||||||
|
if (toupper(*argv[1]) == 'E')
|
||||||
|
ret = lzhuf_encode(&sess);
|
||||||
|
else
|
||||||
|
ret = lzhuf_decode(&sess);
|
||||||
|
|
||||||
|
lzhuf_endSession(&sess);
|
||||||
|
|
||||||
|
if (ret != 0)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
fclose(infile);
|
||||||
|
fclose(outfile);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -670,9 +670,16 @@ int lzhuf_decode(lzhuf_session_t* sess) /* recover */
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lzhuf_startSession(lzhuf_session_t* sess)
|
void lzhuf_startSession(lzhuf_session_t* sess, int bStdIO)
|
||||||
{
|
{
|
||||||
memset(sess, 0, sizeof(*sess));
|
memset(sess, 0, sizeof(*sess));
|
||||||
|
if (bStdIO)
|
||||||
|
{
|
||||||
|
sess->read = fread;
|
||||||
|
sess->write = fwrite;
|
||||||
|
sess->seek = fseek;
|
||||||
|
sess->tell = ftell;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lzhuf_endSession(lzhuf_session_t* sess)
|
void lzhuf_endSession(lzhuf_session_t* sess)
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ typedef struct
|
|||||||
|
|
||||||
} lzhuf_session_t;
|
} lzhuf_session_t;
|
||||||
|
|
||||||
void lzhuf_startSession(lzhuf_session_t *);
|
#define LZHUF_STDIO 1
|
||||||
|
|
||||||
|
void lzhuf_startSession(lzhuf_session_t *, int bStdIO);
|
||||||
void lzhuf_endSession(lzhuf_session_t *);
|
void lzhuf_endSession(lzhuf_session_t *);
|
||||||
int lzhuf_encode(lzhuf_session_t *); /* compression */
|
int lzhuf_encode(lzhuf_session_t *); /* compression */
|
||||||
int lzhuf_decode(lzhuf_session_t *); /* recover */
|
int lzhuf_decode(lzhuf_session_t *); /* recover */
|
||||||
|
|||||||
@@ -569,14 +569,13 @@ void generateAni(const index_header_t *h, const char *prefix, int plut, FILE *ou
|
|||||||
{
|
{
|
||||||
frame_info_t* info = h->frames + i;
|
frame_info_t* info = h->frames + i;
|
||||||
frame_desc_t* desc = info->desc;
|
frame_desc_t* desc = info->desc;
|
||||||
int actplut;
|
int actplut = plut;
|
||||||
|
|
||||||
if ((h->flags & GFX_HAS_IMAGES) && (h->flags & GFX_HAS_MASKS))
|
if ((h->flags & GFX_HAS_IMAGES) && (h->flags & GFX_HAS_MASKS))
|
||||||
{
|
{
|
||||||
char tempbuf[sizeof("frame -2147483648")];
|
char tempbuf[sizeof("frame -2147483648")];
|
||||||
sprintf(tempbuf, "frame %d", i);
|
sprintf(tempbuf, "frame %d", i);
|
||||||
transparentPixel = findTransparentColour(tempbuf, info);
|
transparentPixel = findTransparentColour(tempbuf, info);
|
||||||
actplut = plut;
|
|
||||||
}
|
}
|
||||||
else if (h->flags & GFX_HAS_MASKS)
|
else if (h->flags & GFX_HAS_MASKS)
|
||||||
{
|
{
|
||||||
@@ -1096,7 +1095,7 @@ int decompressData(uint8_t* src, uint32_t srclen, uint8_t* dst, uint32_t dstlen)
|
|||||||
decomp_handle_t writeh = {dst, dstlen, 0};
|
decomp_handle_t writeh = {dst, dstlen, 0};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lzhuf_startSession(&sess);
|
lzhuf_startSession(&sess, 0);
|
||||||
sess.infile = &readh;
|
sess.infile = &readh;
|
||||||
sess.outfile = &writeh;
|
sess.outfile = &writeh;
|
||||||
sess.read = decRead;
|
sess.read = decRead;
|
||||||
|
|||||||
Reference in New Issue
Block a user