mirror of
https://github.com/ZDoom/zdbsp.git
synced 2024-11-12 23:44:09 +00:00
Added a Makefile for building ZDBSP with GCC and SSE configurations for VC.
SVN r156 (trunk)
This commit is contained in:
parent
1a979de350
commit
938f25e39b
31 changed files with 7761 additions and 6380 deletions
61
Makefile
Normal file
61
Makefile
Normal file
|
@ -0,0 +1,61 @@
|
|||
CFLAGS = -O3 -Wall -fomit-frame-pointer -Izlib -pipe -ffast-math -MMD \
|
||||
-mtune=i686
|
||||
LDFLAGS =
|
||||
RM = rm -f FILE
|
||||
ZLIBDIR = zlib/
|
||||
|
||||
ifeq (Windows_NT,$(OS))
|
||||
EXE = zdbsp.exe
|
||||
LDFLAGS += -luser32 -lgdi32
|
||||
ifneq (msys,$(OSTYPE))
|
||||
RM = del /q /f FILE 2>nul
|
||||
ZLIBDIR = "zlib\"
|
||||
endif
|
||||
else
|
||||
EXE = zdbsp
|
||||
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNO_MAP_VIEWER=1
|
||||
endif
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
OBJS = main.o getopt.o getopt1.o blockmapbuilder.o processor.o view.o wad.o \
|
||||
nodebuild.o nodebuild_events.o nodebuild_extract.o nodebuild_gl.o \
|
||||
nodebuild_utility.o \
|
||||
zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/trees.o \
|
||||
zlib/zutil.o
|
||||
|
||||
all: $(EXE)
|
||||
|
||||
profile:
|
||||
$(MAKE) clean
|
||||
$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LDFLAGS="$(LDFLAGS) -lgcov"
|
||||
@echo "Process a few maps, then rebuild with make profile-use"
|
||||
|
||||
profile-use:
|
||||
$(MAKE) clean
|
||||
$(MAKE) all CXXFLAGS="$(CXXFLAGS) -fprofile-use"
|
||||
|
||||
$(EXE): $(OBJS)
|
||||
$(CCDV) $(CXX) -o $(EXE) $(OBJS) $(LDFLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(subst FILE,$(EXE),$(RM))
|
||||
$(subst FILE,*.o,$(RM))
|
||||
$(subst FILE,*.d,$(RM))
|
||||
$(subst FILE,$(ZLIBDIR)*.o,$(RM))
|
||||
$(subst FILE,$(ZLIBDIR)*.d,$(RM))
|
||||
|
||||
cleanprof:
|
||||
$(subst FILE,*.gc*,$(RM))
|
||||
$(subst FILE,$(ZLIBDIR)*.gc*,$(RM))
|
||||
|
||||
cleanall: clean cleanprof
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(OBJS:%.o=%.d)
|
||||
endif
|
|
@ -355,7 +355,7 @@ void FBlockmapBuilder::CreateUnpackedBlockmap (TArray<WORD> *blocks, int bmapwid
|
|||
BlockMap[4+i] = WORD(BlockMap.Size());
|
||||
BlockMap.Push (zero);
|
||||
block = &blocks[i];
|
||||
for (size_t j = 0; j < block->Size(); ++j)
|
||||
for (unsigned int j = 0; j < block->Size(); ++j)
|
||||
{
|
||||
BlockMap.Push ((*block)[j]);
|
||||
}
|
||||
|
|
6
getopt.c
6
getopt.c
|
@ -699,16 +699,22 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||
else
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
{
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
}
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
|
||||
|
|
4
main.cpp
4
main.cpp
|
@ -169,7 +169,7 @@ int main (int argc, char **argv)
|
|||
|
||||
if (out == NULL)
|
||||
{
|
||||
throw exception("Could not create temporary file name.");
|
||||
throw std::runtime_error("Could not create temporary file name.");
|
||||
}
|
||||
|
||||
strcpy (out, OutName);
|
||||
|
@ -247,7 +247,7 @@ int main (int argc, char **argv)
|
|||
|
||||
END_COUNTER(t1a, t1b, t1c, "\nTotal time: %g seconds.\n")
|
||||
}
|
||||
catch (exception msg)
|
||||
catch (std::exception msg)
|
||||
{
|
||||
printf ("%s\n", msg.what());
|
||||
return 20;
|
||||
|
|
|
@ -170,7 +170,7 @@ DWORD FNodeBuilder::CreateSubsector (DWORD set, fixed_t bbox[4])
|
|||
|
||||
void FNodeBuilder::CreateSubsectorsForReal ()
|
||||
{
|
||||
size_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < SubsectorSets.Size(); ++i)
|
||||
{
|
||||
|
@ -193,14 +193,14 @@ void FNodeBuilder::CreateSubsectorsForReal ()
|
|||
|
||||
// Convert seg pointers into indices
|
||||
D(printf ("Output subsector %d:\n", Subsectors.Size()));
|
||||
for (size_t i = sub.firstline; i < SegList.Size(); ++i)
|
||||
for (unsigned int i = sub.firstline; i < SegList.Size(); ++i)
|
||||
{
|
||||
D(printf (" Seg %5d (%5d,%5d)-(%5d,%5d)\n", SegList[i].SegPtr - &Segs[0],
|
||||
Vertices[SegList[i].SegPtr->v1].x>>16,
|
||||
Vertices[SegList[i].SegPtr->v1].y>>16,
|
||||
Vertices[SegList[i].SegPtr->v2].x>>16,
|
||||
Vertices[SegList[i].SegPtr->v2].y>>16));
|
||||
SegList[i].SegNum = SegList[i].SegPtr - &Segs[0];
|
||||
SegList[i].SegNum = DWORD(SegList[i].SegPtr - &Segs[0]);
|
||||
}
|
||||
Subsectors.Push (sub);
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit)
|
|||
int sidev1, sidev2;
|
||||
int side;
|
||||
bool splitter = false;
|
||||
size_t max, m2, p, q;
|
||||
unsigned int max, m2, p, q;
|
||||
double frac;
|
||||
|
||||
Touched.Clear ();
|
||||
|
@ -824,14 +824,14 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou
|
|||
default: // seg needs to be split
|
||||
double frac;
|
||||
FPrivVert newvert;
|
||||
size_t vertnum;
|
||||
unsigned int vertnum;
|
||||
int seg2;
|
||||
size_t i;
|
||||
unsigned int i;
|
||||
|
||||
//Printf ("%lu is cut\n", set);
|
||||
if (seg->loopnum)
|
||||
{
|
||||
Printf (" Split seg %lu (%ld,%ld)-(%ld,%ld) of sector %d on line %d\n",
|
||||
Printf (" Split seg %lu (%d,%d)-(%d,%d) of sector %d on line %d\n",
|
||||
set,
|
||||
Vertices[seg->v1].x>>16, Vertices[seg->v1].y>>16,
|
||||
Vertices[seg->v2].x>>16, Vertices[seg->v2].y>>16,
|
||||
|
@ -1115,7 +1115,7 @@ void FNodeBuilder::PrintSet (int l, DWORD set)
|
|||
Printf ("set %d:\n", l);
|
||||
for (; set != DWORD_MAX; set = Segs[set].next)
|
||||
{
|
||||
Printf ("\t%lu(%d):%d(%ld,%ld)-%d(%ld,%ld)\n", set, Segs[set].frontsector,
|
||||
Printf ("\t%lu(%d):%d(%d,%d)-%d(%d,%d)\n", set, Segs[set].frontsector,
|
||||
Segs[set].v1,
|
||||
Vertices[Segs[set].v1].x>>16, Vertices[Segs[set].v1].y>>16,
|
||||
Segs[set].v2,
|
||||
|
|
|
@ -420,7 +420,7 @@ void FEventTree::PrintTree (const FEvent *event) const
|
|||
{
|
||||
PrintTree (event->Left);
|
||||
}
|
||||
printf (" Color %s, distance %g, vertex %d, seg %d\n", event->Color ? "BLACK" : " RED ",
|
||||
printf (" Color %s, distance %g, vertex %d, seg %lu\n", event->Color ? "BLACK" : " RED ",
|
||||
sqrt(event->Distance/4294967296.0), event->Info.Vertex, event->Info.FrontSeg);
|
||||
if (event->Right != &Nil)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ void FNodeBuilder::FixSplitSharers ()
|
|||
{
|
||||
D(printf("events:\n"));
|
||||
D(Events.PrintTree());
|
||||
for (size_t i = 0; i < SplitSharers.Size(); ++i)
|
||||
for (unsigned int i = 0; i < SplitSharers.Size(); ++i)
|
||||
{
|
||||
DWORD seg = SplitSharers[i].Seg;
|
||||
int v2 = Segs[seg].v2;
|
||||
|
|
|
@ -69,16 +69,16 @@ void FNodeBuilder::FindUsedVertices (WideVertex *oldverts, int max)
|
|||
map[v2] = SelectVertexExact (newvert);
|
||||
}
|
||||
|
||||
Level.Lines[i].v1 = map[v1];
|
||||
Level.Lines[i].v2 = map[v2];
|
||||
Level.Lines[i].v1 = (WORD)map[v1];
|
||||
Level.Lines[i].v2 = (WORD)map[v2];
|
||||
}
|
||||
InitialVertices = Vertices.Size ();
|
||||
Level.NumOrgVerts = InitialVertices;
|
||||
Level.NumOrgVerts = (int)InitialVertices;
|
||||
}
|
||||
|
||||
int FNodeBuilder::SelectVertexExact (FPrivVert &vertex)
|
||||
{
|
||||
for (size_t i = 0; i < Vertices.Size(); ++i)
|
||||
for (unsigned int i = 0; i < Vertices.Size(); ++i)
|
||||
{
|
||||
if (Vertices[i].x == vertex.x && Vertices[i].y == vertex.y)
|
||||
{
|
||||
|
@ -103,6 +103,7 @@ void FNodeBuilder::MakeSegsFromSides ()
|
|||
|
||||
for (i = 0; i < Level.NumLines; ++i)
|
||||
{
|
||||
share1 = NULL;
|
||||
if (Level.Lines[i].sidenum[0] != NO_INDEX)
|
||||
{
|
||||
WORD backside;
|
||||
|
@ -302,7 +303,7 @@ void FNodeBuilder::FindPolyContainers (TArray<FPolyStart> &spots, TArray<FPolySt
|
|||
{
|
||||
int loop = 1;
|
||||
|
||||
for (size_t i = 0; i < spots.Size(); ++i)
|
||||
for (unsigned int i = 0; i < spots.Size(); ++i)
|
||||
{
|
||||
FPolyStart *spot = &spots[i];
|
||||
fixed_t bbox[4];
|
||||
|
@ -310,8 +311,7 @@ void FNodeBuilder::FindPolyContainers (TArray<FPolyStart> &spots, TArray<FPolySt
|
|||
if (GetPolyExtents (spot->polynum, bbox))
|
||||
{
|
||||
FPolyStart *anchor;
|
||||
|
||||
size_t j;
|
||||
unsigned int j;
|
||||
|
||||
for (j = 0; j < anchors.Size(); ++j)
|
||||
{
|
||||
|
@ -340,7 +340,7 @@ void FNodeBuilder::FindPolyContainers (TArray<FPolyStart> &spots, TArray<FPolySt
|
|||
|
||||
P(Printf ("start %d,%d -- center %d, %d\n", spot->x>>16, spot->y>>16, center.x>>16, center.y>>16));
|
||||
|
||||
for (size_t j = 0; j < Segs.Size(); ++j)
|
||||
for (unsigned int j = 0; j < Segs.Size(); ++j)
|
||||
{
|
||||
FPrivSeg *seg = &Segs[j];
|
||||
FPrivVert *v1 = &Vertices[seg->v1];
|
||||
|
@ -428,7 +428,7 @@ int FNodeBuilder::MarkLoop (DWORD firstseg, int loopnum)
|
|||
}
|
||||
|
||||
seg = bestseg;
|
||||
} while (seg != DWORD_MAX && Segs[seg].loopnum == 0);
|
||||
} while (seg != (int)DWORD_MAX && Segs[seg].loopnum == 0);
|
||||
|
||||
return loopnum + 1;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ int FNodeBuilder::MarkLoop (DWORD firstseg, int loopnum)
|
|||
|
||||
bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4])
|
||||
{
|
||||
size_t i;
|
||||
unsigned int i;
|
||||
|
||||
bbox[BOXLEFT] = bbox[BOXBOTTOM] = FIXED_MAX;
|
||||
bbox[BOXRIGHT] = bbox[BOXTOP] = FIXED_MIN;
|
||||
|
@ -455,7 +455,7 @@ bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4])
|
|||
if (i < Segs.Size())
|
||||
{
|
||||
vertex_t start;
|
||||
size_t vert;
|
||||
unsigned int vert;
|
||||
|
||||
vert = Segs[i].v1;
|
||||
|
||||
|
|
|
@ -464,7 +464,7 @@ void FProcessor::Write (FWadWriter &out)
|
|||
builder = new FNodeBuilder (Level, PolyStarts, PolyAnchors, Wad.LumpName (Lump), BuildGLNodes);
|
||||
if (builder == NULL)
|
||||
{
|
||||
throw exception(" Not enough memory to build nodes!");
|
||||
throw std::runtime_error(" Not enough memory to build nodes!");
|
||||
}
|
||||
|
||||
delete[] Level.Vertices;
|
||||
|
@ -500,7 +500,7 @@ void FProcessor::Write (FWadWriter &out)
|
|||
builder = new FNodeBuilder (Level, PolyStarts, PolyAnchors, Wad.LumpName (Lump), false);
|
||||
if (builder == NULL)
|
||||
{
|
||||
throw exception(" Not enough memory to build regular nodes!");
|
||||
throw std::runtime_error(" Not enough memory to build regular nodes!");
|
||||
}
|
||||
delete[] Level.Vertices;
|
||||
builder->GetVertices (Level.Vertices, Level.NumVertices);
|
||||
|
@ -575,6 +575,7 @@ void FProcessor::Write (FWadWriter &out)
|
|||
|
||||
if (ShowMap)
|
||||
{
|
||||
#ifndef NO_MAP_VIEWER
|
||||
if(BuildNodes||BuildGLNodes)
|
||||
{
|
||||
ShowView (&Level);
|
||||
|
@ -583,6 +584,9 @@ void FProcessor::Write (FWadWriter &out)
|
|||
{
|
||||
puts(" ERROR: You can't view the nodes (-v) if you don't build them! (-N).");
|
||||
}
|
||||
#else
|
||||
puts (" This version of ZDBSP was not compiled with the map viewer enabled.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Level.GLNodes != NULL )
|
||||
|
@ -944,7 +948,7 @@ void FProcessor::WriteBlockmap (FWadWriter &out)
|
|||
{
|
||||
blocks[i] = SHORT(blocks[i]);
|
||||
}
|
||||
out.WriteLump ("BLOCKMAP", blocks, sizeof(*blocks)*count);
|
||||
out.WriteLump ("BLOCKMAP", blocks, int(sizeof(*blocks)*count));
|
||||
|
||||
#ifdef BLOCK_TEST
|
||||
FILE *f = fopen ("blockmap.lm2", "wb");
|
||||
|
@ -1178,7 +1182,7 @@ ZLibOut::ZLibOut (FWadWriter &out)
|
|||
|
||||
if (err != Z_OK)
|
||||
{
|
||||
throw exception("Could not initialize deflate buffer.");
|
||||
throw std::runtime_error("Could not initialize deflate buffer.");
|
||||
}
|
||||
|
||||
Stream.next_out = Buffer;
|
||||
|
@ -1206,7 +1210,7 @@ ZLibOut::~ZLibOut ()
|
|||
deflateEnd (&Stream);
|
||||
if (err != Z_STREAM_END)
|
||||
{
|
||||
throw exception("Error deflating data.");
|
||||
throw std::runtime_error("Error deflating data.");
|
||||
}
|
||||
Out.AddToLump (Buffer, BUFFER_SIZE - Stream.avail_out);
|
||||
}
|
||||
|
@ -1230,7 +1234,7 @@ void ZLibOut::Write (BYTE *data, int len)
|
|||
}
|
||||
if (err != Z_OK)
|
||||
{
|
||||
throw exception("Error deflating data.");
|
||||
throw std::runtime_error("Error deflating data.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
view.cpp
13
view.cpp
|
@ -17,6 +17,8 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
#ifndef NO_MAP_VIEWER
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#include <windows.h>
|
||||
|
@ -256,12 +258,10 @@ static void DrawSubsectorGL (HDC dc, int ssec, HPEN miniPen, HPEN badPen)
|
|||
MoveToEx (dc, GLVERTX(Level->GLSegs[seg].v1), GLVERTY(Level->GLSegs[seg].v1), NULL);
|
||||
for (DWORD i = 0; i < Level->GLSubsectors[ssec].numlines; ++i)
|
||||
{
|
||||
bool mini = false;
|
||||
HPEN oldPen;
|
||||
HPEN oldPen = NULL;
|
||||
seg = Level->GLSubsectors[ssec].firstline + i;
|
||||
if (Level->GLSegs[seg].linedef == NO_INDEX)
|
||||
{
|
||||
mini = true;
|
||||
if (Level->GLSegs[seg].partner == NO_INDEX)
|
||||
{
|
||||
oldPen = (HPEN)SelectObject (dc, badPen);
|
||||
|
@ -281,7 +281,7 @@ static void DrawSubsectorGL (HDC dc, int ssec, HPEN miniPen, HPEN badPen)
|
|||
//MoveToEx (dc, GLVERTX(Level->GLSegs[seg].v2), GLVERTY(Level->GLSegs[seg].v2), NULL);
|
||||
LineTo (dc, GLVERTX(Level->GLSegs[seg].v1), GLVERTY(Level->GLSegs[seg].v1));
|
||||
}
|
||||
if (mini)
|
||||
if (oldPen != NULL)
|
||||
{
|
||||
SelectObject (dc, oldPen);
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ static void SetDesiredSubsector (int x, int y)
|
|||
static void SetDesiredNode (int x, int y)
|
||||
{
|
||||
int node, parent;
|
||||
size_t depth = 0;
|
||||
unsigned int depth = 0;
|
||||
|
||||
// Traverse the tree until we find a node that is not on the
|
||||
// path to the previous desired node.
|
||||
|
@ -649,6 +649,7 @@ static void DrawLevelReject (HDC dc)
|
|||
case CANT_SEE: SelectObject (dc, cantSee); break;
|
||||
case CAN_SEE: SelectObject (dc, canSee); break;
|
||||
case SEE_FROM: SelectObject (dc, seeFrom); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
MoveToEx (dc, VERTX(Level->Lines[i].v1), VERTY(Level->Lines[i].v1), NULL);
|
||||
|
@ -1047,3 +1048,5 @@ void ResetViews ()
|
|||
DesiredSubsector = 0;
|
||||
DesiredSector = 0;
|
||||
}
|
||||
|
||||
#endif /* !NO_MAP_VIEWER */
|
||||
|
|
12
wad.cpp
12
wad.cpp
|
@ -66,7 +66,7 @@ FWadReader::FWadReader (const char *filename)
|
|||
File = fopen (filename, "rb");
|
||||
if (File == NULL)
|
||||
{
|
||||
throw exception("Could not open input file");
|
||||
throw std::runtime_error("Could not open input file");
|
||||
}
|
||||
|
||||
SafeRead (&Header, sizeof(Header));
|
||||
|
@ -77,7 +77,7 @@ FWadReader::FWadReader (const char *filename)
|
|||
{
|
||||
fclose (File);
|
||||
File = NULL;
|
||||
throw exception("Input file is not a wad");
|
||||
throw std::runtime_error("Input file is not a wad");
|
||||
}
|
||||
|
||||
Header.NumLumps = LONG(Header.NumLumps);
|
||||
|
@ -85,7 +85,7 @@ FWadReader::FWadReader (const char *filename)
|
|||
|
||||
if (fseek (File, Header.Directory, SEEK_SET))
|
||||
{
|
||||
throw exception("Could not read wad directory");
|
||||
throw std::runtime_error("Could not read wad directory");
|
||||
}
|
||||
|
||||
Lumps = new WadLump[Header.NumLumps];
|
||||
|
@ -301,7 +301,7 @@ void FWadReader::SafeRead (void *buffer, size_t size)
|
|||
{
|
||||
if (fread (buffer, 1, size, File) != size)
|
||||
{
|
||||
throw exception("Failed to read");
|
||||
throw std::runtime_error("Failed to read");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ FWadWriter::FWadWriter (const char *filename, bool iwad)
|
|||
File = fopen (filename, "wb");
|
||||
if (File == NULL)
|
||||
{
|
||||
throw exception("Could not open output file");
|
||||
throw std::runtime_error("Could not open output file");
|
||||
}
|
||||
|
||||
WadHeader head;
|
||||
|
@ -416,7 +416,7 @@ void FWadWriter::SafeWrite (const void *buffer, size_t size)
|
|||
{
|
||||
fclose (File);
|
||||
File = NULL;
|
||||
throw exception(
|
||||
throw std::runtime_error(
|
||||
"Failed to write. Check that this directory is writable and\n"
|
||||
"that you have enough free disk space.");
|
||||
}
|
||||
|
|
2
wad.h
2
wad.h
|
@ -68,7 +68,7 @@ void ReadLump (FWadReader &wad, int index, T *&data, int &size)
|
|||
}
|
||||
if (fseek (wad.File, wad.Lumps[index].FilePos, SEEK_SET))
|
||||
{
|
||||
throw exception("Failed to seek");
|
||||
throw std::runtime_error("Failed to seek");
|
||||
}
|
||||
size = wad.Lumps[index].Size / sizeof(T);
|
||||
data = new T[size];
|
||||
|
|
6
zdbsp.h
6
zdbsp.h
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
#define ZDBSP_VERSION "1.7"
|
||||
|
||||
|
@ -126,6 +127,11 @@ inline fixed_t DMulScale30 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|||
return (fixed_t)((double(a)*double(b)+double(c)*double(d))/double(1<<30));
|
||||
}
|
||||
|
||||
inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
||||
{
|
||||
return (fixed_t)((double(a)*double(b)+double(c)*double(d))/4294967296.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define SHORT(x) (x)
|
||||
|
|
|
@ -7,12 +7,15 @@ Global
|
|||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
Release (SSE2) = Release (SSE2)
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Debug.ActiveCfg = Debug|Win32
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Debug.Build.0 = Debug|Win32
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release.ActiveCfg = Release|Win32
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release.Build.0 = Release|Win32
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release (SSE2).ActiveCfg = Release (SSE2)|Win32
|
||||
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release (SSE2).Build.0 = Release (SSE2)|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
|
|
100
zdbsp.vcproj
100
zdbsp.vcproj
|
@ -3,6 +3,7 @@
|
|||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="zdbsp"
|
||||
RootNamespace="zdbsp"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
|
@ -34,7 +35,7 @@
|
|||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
EnableEnhancedInstructionSet="2"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/zdbsp.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
|
@ -49,8 +50,9 @@
|
|||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
OutputFile=".\Release/zdbsp.exe"
|
||||
LinkIncremental="1"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories=""$(VSInstallDir)vc7\lib""
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Release/zdbsp.pdb"
|
||||
SubSystem="1"
|
||||
|
@ -112,6 +114,7 @@
|
|||
OutputFile=".\Debug/zdbsp.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories=""$(VSInstallDir)vc7\lib""
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/zdbsp.pdb"
|
||||
SubSystem="1"/>
|
||||
|
@ -139,6 +142,75 @@
|
|||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release (SSE2)|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="0"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="zlib"
|
||||
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
EnableEnhancedInstructionSet="2"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/zdbsp.pch"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
OutputFile=".\Release/zdbsp.exe"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories=""$(VSInstallDir)vc7\lib""
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Release/zdbsp.pdb"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
OptimizeForWindows98="0"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/zdbsp.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
|
@ -199,6 +271,12 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release (SSE2)|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\rejectbuilder.h">
|
||||
|
@ -214,6 +292,12 @@
|
|||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release (SSE2)|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\vis.cpp">
|
||||
|
@ -229,6 +313,12 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release (SSE2)|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\visflow.cpp">
|
||||
|
@ -244,6 +334,12 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release (SSE2)|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
|
|
23
zdbsp_vs2005.sln
Normal file
23
zdbsp_vs2005.sln
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdbsp_vs2005", "zdbsp_vs2005.vcproj", "{E628034A-AE64-43B5-8CF4-668D07041C35}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release (SSE2)|Win32 = Release (SSE2)|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|Win32.ActiveCfg = Release, SSE2|Win32
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|Win32.Build.0 = Release, SSE2|Win32
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
573
zdbsp_vs2005.vcproj
Normal file
573
zdbsp_vs2005.vcproj
Normal file
|
@ -0,0 +1,573 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="zdbsp_vs2005"
|
||||
ProjectGUID="{E628034A-AE64-43B5-8CF4-668D07041C35}"
|
||||
RootNamespace="zdbsp_vs2005"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)_vs2005"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="zlib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\zdbsp.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)_vs2005"
|
||||
IntermediateDirectory="$(ConfigurationName)_vs2005"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="zlib"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
FloatingPointModel="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\zdbsp.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release, SSE2|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="zlib"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="2"
|
||||
FloatingPointModel="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\zdbsp.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\blockmapbuilder.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt1.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild_events.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild_extract.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild_gl.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild_utility.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\processor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\view.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wad.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\blockmapbuilder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\doomdata.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nodebuild.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\processor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\tarray.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\templates.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wad.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\workdata.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zdbsp.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\resource.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Reject(ed)"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Unused\rejectbuilder.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release, SSE2|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\rejectbuilder.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release, SSE2|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\vis.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release, SSE2|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Unused\visflow.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release, SSE2|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="zlib"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\zlib\adler32.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\compress.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\crc32.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\crc32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\deflate.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\deflate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\trees.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
DisableSpecificWarnings="4267"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
DisableSpecificWarnings="4267"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release, SSE2|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
DisableSpecificWarnings="4267"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\trees.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\zconf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\zlib.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\zutil.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\zlib\zutil.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\zdbsp.html"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
111
zlib/adler32.c
111
zlib/adler32.c
|
@ -1,5 +1,5 @@
|
|||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -12,12 +12,13 @@
|
|||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
|
||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* use NO_DIVIDE if your processor does not do division in hardware */
|
||||
#ifdef NO_DIVIDE
|
||||
# define MOD(a) \
|
||||
do { \
|
||||
|
@ -39,8 +40,17 @@
|
|||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
# define MOD4(a) \
|
||||
do { \
|
||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOD(a) a %= BASE
|
||||
# define MOD4(a) a %= BASE
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
@ -49,26 +59,91 @@ uLong ZEXPORT adler32(adler, buf, len)
|
|||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long s1 = adler & 0xffff;
|
||||
unsigned long s2 = (adler >> 16) & 0xffff;
|
||||
int k;
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
if (buf == Z_NULL) return 1L;
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
while (len > 0) {
|
||||
k = len < NMAX ? (int)len : NMAX;
|
||||
len -= k;
|
||||
while (k >= 16) {
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == Z_NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16) {
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
MOD4(sum2); /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
do {
|
||||
DO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
k -= 16;
|
||||
}
|
||||
if (k != 0) do {
|
||||
s1 += *buf++;
|
||||
s2 += s1;
|
||||
} while (--k);
|
||||
MOD(s1);
|
||||
MOD(s2);
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
return (s2 << 16) | s1;
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off_t len2;
|
||||
{
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
rem = (unsigned)(len2 % BASE);
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
MOD(sum2);
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 > BASE) sum1 -= BASE;
|
||||
if (sum1 > BASE) sum1 -= BASE;
|
||||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
|
||||
if (sum2 > BASE) sum2 -= BASE;
|
||||
return sum1 | (sum2 << 16);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* compress.c -- compress a memory buffer
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
|
132
zlib/crc32.c
132
zlib/crc32.c
|
@ -1,16 +1,24 @@
|
|||
/* crc32.c -- compute the CRC-32 of a data stream
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* Copyright (C) 1995-2005 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
||||
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
|
||||
* tables for updating the shift register in one step with three exclusive-ors
|
||||
* instead of four steps with four exclusive-ors. This results about a factor
|
||||
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
|
||||
* instead of four steps with four exclusive-ors. This results in about a
|
||||
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/*
|
||||
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
|
||||
protection on the static variables used to control the first-use generation
|
||||
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
|
||||
first call get_crc_table() to initialize the tables before allowing more than
|
||||
one thread to use crc32().
|
||||
*/
|
||||
|
||||
#ifdef MAKECRCH
|
||||
# include <stdio.h>
|
||||
# ifndef DYNAMIC_CRC_TABLE
|
||||
|
@ -56,15 +64,19 @@
|
|||
# define TBLS 1
|
||||
#endif /* BYFOUR */
|
||||
|
||||
/* Local functions for crc concatenation */
|
||||
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
||||
unsigned long vec));
|
||||
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
||||
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
|
||||
local int crc_table_empty = 1;
|
||||
local volatile int crc_table_empty = 1;
|
||||
local unsigned long FAR crc_table[TBLS][256];
|
||||
local void make_crc_table OF((void));
|
||||
#ifdef MAKECRCH
|
||||
local void write_table OF((FILE *, const unsigned long FAR *));
|
||||
#endif /* MAKECRCH */
|
||||
|
||||
/*
|
||||
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
|
||||
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
|
||||
|
@ -97,8 +109,15 @@ local void make_crc_table()
|
|||
int n, k;
|
||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
||||
/* terms of polynomial defining this crc (except x^32): */
|
||||
static volatile int first = 1; /* flag to limit concurrent making */
|
||||
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||
|
||||
/* See if another task is already doing this (not thread-safe, but better
|
||||
than nothing -- significantly reduces duration of vulnerability in
|
||||
case the advice about DYNAMIC_CRC_TABLE is ignored) */
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||
poly = 0UL;
|
||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||
|
@ -113,8 +132,8 @@ local void make_crc_table()
|
|||
}
|
||||
|
||||
#ifdef BYFOUR
|
||||
/* generate crc for each value followed by one, two, and three zeros, and
|
||||
then the byte reversal of those as well as the first table */
|
||||
/* generate crc for each value followed by one, two, and three zeros,
|
||||
and then the byte reversal of those as well as the first table */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crc_table[0][n];
|
||||
crc_table[4][n] = REV(c);
|
||||
|
@ -127,6 +146,12 @@ local void make_crc_table()
|
|||
#endif /* BYFOUR */
|
||||
|
||||
crc_table_empty = 0;
|
||||
}
|
||||
else { /* not first */
|
||||
/* wait for the other guy to finish (not efficient, but rare) */
|
||||
while (crc_table_empty)
|
||||
;
|
||||
}
|
||||
|
||||
#ifdef MAKECRCH
|
||||
/* write out CRC tables to crc32.h */
|
||||
|
@ -180,7 +205,8 @@ local void write_table(out, table)
|
|||
const unsigned long FAR * ZEXPORT get_crc_table()
|
||||
{
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (crc_table_empty) make_crc_table();
|
||||
if (crc_table_empty)
|
||||
make_crc_table();
|
||||
#endif /* DYNAMIC_CRC_TABLE */
|
||||
return (const unsigned long FAR *)crc_table;
|
||||
}
|
||||
|
@ -248,7 +274,7 @@ local unsigned long crc32_little(crc, buf, len)
|
|||
len--;
|
||||
}
|
||||
|
||||
buf4 = (const u4 FAR *)buf;
|
||||
buf4 = (const u4 FAR *)(const void FAR *)buf;
|
||||
while (len >= 32) {
|
||||
DOLIT32;
|
||||
len -= 32;
|
||||
|
@ -288,7 +314,7 @@ local unsigned long crc32_big(crc, buf, len)
|
|||
len--;
|
||||
}
|
||||
|
||||
buf4 = (const u4 FAR *)buf;
|
||||
buf4 = (const u4 FAR *)(const void FAR *)buf;
|
||||
buf4--;
|
||||
while (len >= 32) {
|
||||
DOBIG32;
|
||||
|
@ -309,3 +335,89 @@ local unsigned long crc32_big(crc, buf, len)
|
|||
}
|
||||
|
||||
#endif /* BYFOUR */
|
||||
|
||||
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long gf2_matrix_times(mat, vec)
|
||||
unsigned long *mat;
|
||||
unsigned long vec;
|
||||
{
|
||||
unsigned long sum;
|
||||
|
||||
sum = 0;
|
||||
while (vec) {
|
||||
if (vec & 1)
|
||||
sum ^= *mat;
|
||||
vec >>= 1;
|
||||
mat++;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local void gf2_matrix_square(square, mat)
|
||||
unsigned long *square;
|
||||
unsigned long *mat;
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < GF2_DIM; n++)
|
||||
square[n] = gf2_matrix_times(mat, mat[n]);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
||||
uLong crc1;
|
||||
uLong crc2;
|
||||
z_off_t len2;
|
||||
{
|
||||
int n;
|
||||
unsigned long row;
|
||||
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
|
||||
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
|
||||
|
||||
/* degenerate case */
|
||||
if (len2 == 0)
|
||||
return crc1;
|
||||
|
||||
/* put operator for one zero bit in odd */
|
||||
odd[0] = 0xedb88320L; /* CRC-32 polynomial */
|
||||
row = 1;
|
||||
for (n = 1; n < GF2_DIM; n++) {
|
||||
odd[n] = row;
|
||||
row <<= 1;
|
||||
}
|
||||
|
||||
/* put operator for two zero bits in even */
|
||||
gf2_matrix_square(even, odd);
|
||||
|
||||
/* put operator for four zero bits in odd */
|
||||
gf2_matrix_square(odd, even);
|
||||
|
||||
/* apply len2 zeros to crc1 (first square will put the operator for one
|
||||
zero byte, eight zero bits, in even) */
|
||||
do {
|
||||
/* apply zeros operator for this bit of len2 */
|
||||
gf2_matrix_square(even, odd);
|
||||
if (len2 & 1)
|
||||
crc1 = gf2_matrix_times(even, crc1);
|
||||
len2 >>= 1;
|
||||
|
||||
/* if no more bits set, then done */
|
||||
if (len2 == 0)
|
||||
break;
|
||||
|
||||
/* another iteration of the loop with odd and even swapped */
|
||||
gf2_matrix_square(odd, even);
|
||||
if (len2 & 1)
|
||||
crc1 = gf2_matrix_times(odd, crc1);
|
||||
len2 >>= 1;
|
||||
|
||||
/* if no more bits set, then done */
|
||||
} while (len2 != 0);
|
||||
|
||||
/* return combined crc */
|
||||
crc1 ^= crc2;
|
||||
return crc1;
|
||||
}
|
||||
|
|
264
zlib/deflate.c
264
zlib/deflate.c
|
@ -1,5 +1,5 @@
|
|||
/* deflate.c -- compress data using the deflation algorithm
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
#include "deflate.h"
|
||||
|
||||
const char deflate_copyright[] =
|
||||
" deflate 1.2.1 Copyright 1995-2003 Jean-loup Gailly ";
|
||||
" deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
|
@ -264,7 +264,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|||
#endif
|
||||
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
|
||||
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
|
||||
strategy < 0 || strategy > Z_RLE) {
|
||||
strategy < 0 || strategy > Z_FIXED) {
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
|
||||
|
@ -274,6 +274,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|||
s->strm = strm;
|
||||
|
||||
s->wrap = wrap;
|
||||
s->gzhead = Z_NULL;
|
||||
s->w_bits = windowBits;
|
||||
s->w_size = 1 << s->w_bits;
|
||||
s->w_mask = s->w_size - 1;
|
||||
|
@ -333,9 +334,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
|||
if (length < MIN_MATCH) return Z_OK;
|
||||
if (length > MAX_DIST(s)) {
|
||||
length = MAX_DIST(s);
|
||||
#ifndef USE_DICT_HEAD
|
||||
dictionary += dictLength - length; /* use the tail of the dictionary */
|
||||
#endif
|
||||
}
|
||||
zmemcpy(s->window, dictionary, length);
|
||||
s->strstart = length;
|
||||
|
@ -390,6 +389,17 @@ int ZEXPORT deflateReset (strm)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateSetHeader (strm, head)
|
||||
z_streamp strm;
|
||||
gz_headerp head;
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
if (strm->state->wrap != 2) return Z_STREAM_ERROR;
|
||||
strm->state->gzhead = head;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflatePrime (strm, bits, value)
|
||||
z_streamp strm;
|
||||
|
@ -420,7 +430,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|||
#else
|
||||
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
||||
#endif
|
||||
if (level < 0 || level > 9 || strategy < 0 || strategy > Z_RLE) {
|
||||
if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
func = configuration_table[s->level].func;
|
||||
|
@ -440,6 +450,25 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|||
return err;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
||||
z_streamp strm;
|
||||
int good_length;
|
||||
int max_lazy;
|
||||
int nice_length;
|
||||
int max_chain;
|
||||
{
|
||||
deflate_state *s;
|
||||
|
||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
s = strm->state;
|
||||
s->good_match = good_length;
|
||||
s->max_lazy_match = max_lazy;
|
||||
s->nice_match = nice_length;
|
||||
s->max_chain_length = max_chain;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
/* =========================================================================
|
||||
* For the default windowBits of 15 and memLevel of 8, this function returns
|
||||
* a close to exact, as well as small, upper bound on the compressed size.
|
||||
|
@ -548,9 +577,11 @@ int ZEXPORT deflate (strm, flush)
|
|||
if (s->status == INIT_STATE) {
|
||||
#ifdef GZIP
|
||||
if (s->wrap == 2) {
|
||||
strm->adler = crc32(0L, Z_NULL, 0);
|
||||
put_byte(s, 31);
|
||||
put_byte(s, 139);
|
||||
put_byte(s, 8);
|
||||
if (s->gzhead == NULL) {
|
||||
put_byte(s, 0);
|
||||
put_byte(s, 0);
|
||||
put_byte(s, 0);
|
||||
|
@ -559,9 +590,34 @@ int ZEXPORT deflate (strm, flush)
|
|||
put_byte(s, s->level == 9 ? 2 :
|
||||
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
||||
4 : 0));
|
||||
put_byte(s, 255);
|
||||
put_byte(s, OS_CODE);
|
||||
s->status = BUSY_STATE;
|
||||
strm->adler = crc32(0L, Z_NULL, 0);
|
||||
}
|
||||
else {
|
||||
put_byte(s, (s->gzhead->text ? 1 : 0) +
|
||||
(s->gzhead->hcrc ? 2 : 0) +
|
||||
(s->gzhead->extra == Z_NULL ? 0 : 4) +
|
||||
(s->gzhead->name == Z_NULL ? 0 : 8) +
|
||||
(s->gzhead->comment == Z_NULL ? 0 : 16)
|
||||
);
|
||||
put_byte(s, (Byte)(s->gzhead->time & 0xff));
|
||||
put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
|
||||
put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
|
||||
put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
|
||||
put_byte(s, s->level == 9 ? 2 :
|
||||
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
||||
4 : 0));
|
||||
put_byte(s, s->gzhead->os & 0xff);
|
||||
if (s->gzhead->extra != NULL) {
|
||||
put_byte(s, s->gzhead->extra_len & 0xff);
|
||||
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
|
||||
}
|
||||
if (s->gzhead->hcrc)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf,
|
||||
s->pending);
|
||||
s->gzindex = 0;
|
||||
s->status = EXTRA_STATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -592,6 +648,110 @@ int ZEXPORT deflate (strm, flush)
|
|||
strm->adler = adler32(0L, Z_NULL, 0);
|
||||
}
|
||||
}
|
||||
#ifdef GZIP
|
||||
if (s->status == EXTRA_STATE) {
|
||||
if (s->gzhead->extra != NULL) {
|
||||
uInt beg = s->pending; /* start of bytes to update crc */
|
||||
|
||||
while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
|
||||
if (s->pending == s->pending_buf_size) {
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
flush_pending(strm);
|
||||
beg = s->pending;
|
||||
if (s->pending == s->pending_buf_size)
|
||||
break;
|
||||
}
|
||||
put_byte(s, s->gzhead->extra[s->gzindex]);
|
||||
s->gzindex++;
|
||||
}
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
if (s->gzindex == s->gzhead->extra_len) {
|
||||
s->gzindex = 0;
|
||||
s->status = NAME_STATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
s->status = NAME_STATE;
|
||||
}
|
||||
if (s->status == NAME_STATE) {
|
||||
if (s->gzhead->name != NULL) {
|
||||
uInt beg = s->pending; /* start of bytes to update crc */
|
||||
int val;
|
||||
|
||||
do {
|
||||
if (s->pending == s->pending_buf_size) {
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
flush_pending(strm);
|
||||
beg = s->pending;
|
||||
if (s->pending == s->pending_buf_size) {
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
val = s->gzhead->name[s->gzindex++];
|
||||
put_byte(s, val);
|
||||
} while (val != 0);
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
if (val == 0) {
|
||||
s->gzindex = 0;
|
||||
s->status = COMMENT_STATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
s->status = COMMENT_STATE;
|
||||
}
|
||||
if (s->status == COMMENT_STATE) {
|
||||
if (s->gzhead->comment != NULL) {
|
||||
uInt beg = s->pending; /* start of bytes to update crc */
|
||||
int val;
|
||||
|
||||
do {
|
||||
if (s->pending == s->pending_buf_size) {
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
flush_pending(strm);
|
||||
beg = s->pending;
|
||||
if (s->pending == s->pending_buf_size) {
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
val = s->gzhead->comment[s->gzindex++];
|
||||
put_byte(s, val);
|
||||
} while (val != 0);
|
||||
if (s->gzhead->hcrc && s->pending > beg)
|
||||
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
||||
s->pending - beg);
|
||||
if (val == 0)
|
||||
s->status = HCRC_STATE;
|
||||
}
|
||||
else
|
||||
s->status = HCRC_STATE;
|
||||
}
|
||||
if (s->status == HCRC_STATE) {
|
||||
if (s->gzhead->hcrc) {
|
||||
if (s->pending + 2 > s->pending_buf_size)
|
||||
flush_pending(strm);
|
||||
if (s->pending + 2 <= s->pending_buf_size) {
|
||||
put_byte(s, (Byte)(strm->adler & 0xff));
|
||||
put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
|
||||
strm->adler = crc32(0L, Z_NULL, 0);
|
||||
s->status = BUSY_STATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
s->status = BUSY_STATE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Flush as much pending output as possible */
|
||||
if (s->pending != 0) {
|
||||
|
@ -704,7 +864,12 @@ int ZEXPORT deflateEnd (strm)
|
|||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
|
||||
status = strm->state->status;
|
||||
if (status != INIT_STATE && status != BUSY_STATE &&
|
||||
if (status != INIT_STATE &&
|
||||
status != EXTRA_STATE &&
|
||||
status != NAME_STATE &&
|
||||
status != COMMENT_STATE &&
|
||||
status != HCRC_STATE &&
|
||||
status != BUSY_STATE &&
|
||||
status != FINISH_STATE) {
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
|
@ -744,12 +909,12 @@ int ZEXPORT deflateCopy (dest, source)
|
|||
|
||||
ss = source->state;
|
||||
|
||||
*dest = *source;
|
||||
zmemcpy(dest, source, sizeof(z_stream));
|
||||
|
||||
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
|
||||
if (ds == Z_NULL) return Z_MEM_ERROR;
|
||||
dest->state = (struct internal_state FAR *) ds;
|
||||
*ds = *ss;
|
||||
zmemcpy(ds, ss, sizeof(deflate_state));
|
||||
ds->strm = dest;
|
||||
|
||||
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
||||
|
@ -838,9 +1003,11 @@ local void lm_init (s)
|
|||
s->match_length = s->prev_length = MIN_MATCH-1;
|
||||
s->match_available = 0;
|
||||
s->ins_h = 0;
|
||||
#ifndef FASTEST
|
||||
#ifdef ASMV
|
||||
match_init(); /* initialize the asm code */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef FASTEST
|
||||
|
@ -909,7 +1076,12 @@ local uInt longest_match(s, cur_match)
|
|||
match = s->window + cur_match;
|
||||
|
||||
/* Skip to next match if the match length cannot increase
|
||||
* or if the match length is less than 2:
|
||||
* or if the match length is less than 2. Note that the checks below
|
||||
* for insufficient lookahead only occur occasionally for performance
|
||||
* reasons. Therefore uninitialized memory will be accessed, and
|
||||
* conditional jumps will be made that depend on those values.
|
||||
* However the length of the match is limited to the lookahead, so
|
||||
* the output of deflate is not affected by the uninitialized values.
|
||||
*/
|
||||
#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
|
||||
/* This code assumes sizeof(unsigned short) == 2. Do not use
|
||||
|
@ -1131,6 +1303,7 @@ local void fill_window(s)
|
|||
later. (Using level 0 permanently is not an optimal usage of
|
||||
zlib, so we don't care about this pathological case.)
|
||||
*/
|
||||
/* %%% avoid this when Z_RLE */
|
||||
n = s->hash_size;
|
||||
p = &s->head[n];
|
||||
do {
|
||||
|
@ -1309,12 +1482,12 @@ local block_state deflate_fast(s, flush)
|
|||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
#ifdef FASTEST
|
||||
if ((s->strategy < Z_HUFFMAN_ONLY) ||
|
||||
if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
|
||||
(s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
|
||||
s->match_length = longest_match_fast (s, hash_head);
|
||||
}
|
||||
#else
|
||||
if (s->strategy < Z_HUFFMAN_ONLY) {
|
||||
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
|
||||
s->match_length = longest_match (s, hash_head);
|
||||
} else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
|
||||
s->match_length = longest_match_fast (s, hash_head);
|
||||
|
@ -1418,7 +1591,7 @@ local block_state deflate_slow(s, flush)
|
|||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
if (s->strategy < Z_HUFFMAN_ONLY) {
|
||||
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
|
||||
s->match_length = longest_match (s, hash_head);
|
||||
} else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
|
||||
s->match_length = longest_match_fast (s, hash_head);
|
||||
|
@ -1500,3 +1673,64 @@ local block_state deflate_slow(s, flush)
|
|||
return flush == Z_FINISH ? finish_done : block_done;
|
||||
}
|
||||
#endif /* FASTEST */
|
||||
|
||||
#if 0
|
||||
/* ===========================================================================
|
||||
* For Z_RLE, simply look for runs of bytes, generate matches only of distance
|
||||
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
||||
* deflate switches away from Z_RLE.)
|
||||
*/
|
||||
local block_state deflate_rle(s, flush)
|
||||
deflate_state *s;
|
||||
int flush;
|
||||
{
|
||||
int bflush; /* set if current block must be flushed */
|
||||
uInt run; /* length of run */
|
||||
uInt max; /* maximum length of run */
|
||||
uInt prev; /* byte at distance one to match */
|
||||
Bytef *scan; /* scan for end of run */
|
||||
|
||||
for (;;) {
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need MAX_MATCH bytes
|
||||
* for the longest encodable run.
|
||||
*/
|
||||
if (s->lookahead < MAX_MATCH) {
|
||||
fill_window(s);
|
||||
if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
|
||||
return need_more;
|
||||
}
|
||||
if (s->lookahead == 0) break; /* flush the current block */
|
||||
}
|
||||
|
||||
/* See how many times the previous byte repeats */
|
||||
run = 0;
|
||||
if (s->strstart > 0) { /* if there is a previous byte, that is */
|
||||
max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
|
||||
scan = s->window + s->strstart - 1;
|
||||
prev = *scan++;
|
||||
do {
|
||||
if (*scan++ != prev)
|
||||
break;
|
||||
} while (++run < max);
|
||||
}
|
||||
|
||||
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
||||
if (run >= MIN_MATCH) {
|
||||
check_match(s, s->strstart, s->strstart - 1, run);
|
||||
_tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
|
||||
s->lookahead -= run;
|
||||
s->strstart += run;
|
||||
} else {
|
||||
/* No match, output a literal byte */
|
||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
||||
s->lookahead--;
|
||||
s->strstart++;
|
||||
}
|
||||
if (bflush) FLUSH_BLOCK(s, 0);
|
||||
}
|
||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
||||
return flush == Z_FINISH ? finish_done : block_done;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly
|
||||
* Copyright (C) 1995-2004 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -49,6 +49,10 @@
|
|||
/* All codes must not exceed MAX_BITS bits */
|
||||
|
||||
#define INIT_STATE 42
|
||||
#define EXTRA_STATE 69
|
||||
#define NAME_STATE 73
|
||||
#define COMMENT_STATE 91
|
||||
#define HCRC_STATE 103
|
||||
#define BUSY_STATE 113
|
||||
#define FINISH_STATE 666
|
||||
/* Stream status */
|
||||
|
@ -93,9 +97,10 @@ typedef struct internal_state {
|
|||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
int pending; /* nb of bytes in the pending buffer */
|
||||
uInt pending; /* nb of bytes in the pending buffer */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
Byte data_type; /* UNKNOWN, BINARY or ASCII */
|
||||
gz_headerp gzhead; /* gzip header information to write */
|
||||
uInt gzindex; /* where in extra, name, or comment */
|
||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
|
|
36
zlib/trees.c
36
zlib/trees.c
|
@ -1,5 +1,5 @@
|
|||
/* trees.c -- output deflated data using Huffman coding
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -555,7 +555,7 @@ local void gen_bitlen(s, desc)
|
|||
while (n != 0) {
|
||||
m = s->heap[--h];
|
||||
if (m > max_code) continue;
|
||||
if (tree[m].Len != (unsigned) bits) {
|
||||
if ((unsigned) tree[m].Len != (unsigned) bits) {
|
||||
Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
|
||||
s->opt_len += ((long)bits - (long)tree[m].Len)
|
||||
*(long)tree[m].Freq;
|
||||
|
@ -930,8 +930,9 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
|||
/* Build the Huffman trees unless a stored block is forced */
|
||||
if (s->level > 0) {
|
||||
|
||||
/* Check if the file is ascii or binary */
|
||||
if (s->data_type == Z_UNKNOWN) set_data_type(s);
|
||||
/* Check if the file is binary or text */
|
||||
if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
|
||||
set_data_type(s);
|
||||
|
||||
/* Construct the literal and distance trees */
|
||||
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
||||
|
@ -982,7 +983,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
|||
#ifdef FORCE_STATIC
|
||||
} else if (static_lenb >= 0) { /* force static trees */
|
||||
#else
|
||||
} else if (static_lenb == opt_lenb) {
|
||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||
#endif
|
||||
send_bits(s, (STATIC_TREES<<1)+eof, 3);
|
||||
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
||||
|
@ -1117,21 +1118,24 @@ local void compress_block(s, ltree, dtree)
|
|||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Set the data type to ASCII or BINARY, using a crude approximation:
|
||||
* binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
|
||||
* IN assertion: the fields freq of dyn_ltree are set and the total of all
|
||||
* frequencies does not exceed 64K (to fit in an int on 16 bit machines).
|
||||
* Set the data type to BINARY or TEXT, using a crude approximation:
|
||||
* set it to Z_TEXT if all symbols are either printable characters (33 to 255)
|
||||
* or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
|
||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||
*/
|
||||
local void set_data_type(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
int n = 0;
|
||||
unsigned ascii_freq = 0;
|
||||
unsigned bin_freq = 0;
|
||||
while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
|
||||
while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
|
||||
while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
|
||||
s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 9; n++)
|
||||
if (s->dyn_ltree[n].Freq != 0)
|
||||
break;
|
||||
if (n == 9)
|
||||
for (n = 14; n < 32; n++)
|
||||
if (s->dyn_ltree[n].Freq != 0)
|
||||
break;
|
||||
s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
|
|
17
zlib/zconf.h
17
zlib/zconf.h
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -23,15 +23,17 @@
|
|||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
|
@ -39,7 +41,12 @@
|
|||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define zError z_zError
|
||||
|
||||
# define alloc_func z_alloc_func
|
||||
# define free_func z_free_func
|
||||
# define in_func z_in_func
|
||||
# define out_func z_out_func
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
|
@ -61,8 +68,10 @@
|
|||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
|
@ -293,7 +302,7 @@ typedef uLong FAR uLongf;
|
|||
#endif
|
||||
|
||||
#if defined(__OS400__)
|
||||
#define NO_vsnprintf
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(__MVS__)
|
||||
|
|
249
zlib/zlib.h
249
zlib/zlib.h
|
@ -1,7 +1,7 @@
|
|||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.2.1, November 17th, 2003
|
||||
version 1.2.3, July 18th, 2005
|
||||
|
||||
Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -37,8 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.2.1"
|
||||
#define ZLIB_VERNUM 0x1210
|
||||
#define ZLIB_VERSION "1.2.3"
|
||||
#define ZLIB_VERNUM 0x1230
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
|
@ -53,24 +53,22 @@ extern "C" {
|
|||
application must provide more input and/or consume the output
|
||||
(providing more output space) before each call.
|
||||
|
||||
The compressed data format used by the in-memory functions is the zlib
|
||||
format, which is a zlib wrapper documented in RFC 1950, wrapped around a
|
||||
deflate stream, which is itself documented in RFC 1951.
|
||||
The compressed data format used by default by the in-memory functions is
|
||||
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
|
||||
around a deflate stream, which is itself documented in RFC 1951.
|
||||
|
||||
The library also supports reading and writing files in gzip (.gz) format
|
||||
with an interface similar to that of stdio using the functions that start
|
||||
with "gz". The gzip format is different from the zlib format. gzip is a
|
||||
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
||||
|
||||
This library can optionally read and write gzip streams in memory as well.
|
||||
|
||||
The zlib format was designed to be compact and fast for use in memory
|
||||
and on communications channels. The gzip format was designed for single-
|
||||
file compression on file systems, has a larger header than zlib to maintain
|
||||
directory information, and uses a different, slower check method than zlib.
|
||||
|
||||
This library does not provide any functions to write gzip files in memory.
|
||||
However such functions could be easily written using zlib's deflate function,
|
||||
the documentation in the gzip RFC, and the examples in gzio.c.
|
||||
|
||||
The library does not install any signal handler. The decoder checks
|
||||
the consistency of the compressed data, so the library should never
|
||||
crash even in case of corrupted input.
|
||||
|
@ -97,13 +95,36 @@ typedef struct z_stream_s {
|
|||
free_func zfree; /* used to free the internal state */
|
||||
voidpf opaque; /* private data object passed to zalloc and zfree */
|
||||
|
||||
int data_type; /* best guess about the data type: ascii or binary */
|
||||
int data_type; /* best guess about the data type: binary or text */
|
||||
uLong adler; /* adler32 value of the uncompressed data */
|
||||
uLong reserved; /* reserved for future use */
|
||||
} z_stream;
|
||||
|
||||
typedef z_stream FAR *z_streamp;
|
||||
|
||||
/*
|
||||
gzip header information passed to and from zlib routines. See RFC 1952
|
||||
for more details on the meanings of these fields.
|
||||
*/
|
||||
typedef struct gz_header_s {
|
||||
int text; /* true if compressed data believed to be text */
|
||||
uLong time; /* modification time */
|
||||
int xflags; /* extra flags (not used when writing a gzip file) */
|
||||
int os; /* operating system */
|
||||
Bytef *extra; /* pointer to extra field or Z_NULL if none */
|
||||
uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
|
||||
uInt extra_max; /* space at extra (only when reading header) */
|
||||
Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
|
||||
uInt name_max; /* space at name (only when reading header) */
|
||||
Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
|
||||
uInt comm_max; /* space at comment (only when reading header) */
|
||||
int hcrc; /* true if there was or will be a header crc */
|
||||
int done; /* true when done reading gzip header (not used
|
||||
when writing a gzip file) */
|
||||
} gz_header;
|
||||
|
||||
typedef gz_header FAR *gz_headerp;
|
||||
|
||||
/*
|
||||
The application must update next_in and avail_in when avail_in has
|
||||
dropped to zero. It must update next_out and avail_out when avail_out
|
||||
|
@ -168,11 +189,13 @@ typedef z_stream FAR *z_streamp;
|
|||
#define Z_FILTERED 1
|
||||
#define Z_HUFFMAN_ONLY 2
|
||||
#define Z_RLE 3
|
||||
#define Z_FIXED 4
|
||||
#define Z_DEFAULT_STRATEGY 0
|
||||
/* compression strategy; see deflateInit2() below for details */
|
||||
|
||||
#define Z_BINARY 0
|
||||
#define Z_ASCII 1
|
||||
#define Z_TEXT 1
|
||||
#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
|
||||
#define Z_UNKNOWN 2
|
||||
/* Possible values of the data_type field (though see inflate()) */
|
||||
|
||||
|
@ -246,6 +269,10 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
|||
and with zero avail_out, it must be called again after making room in the
|
||||
output buffer because there might be more output pending.
|
||||
|
||||
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
|
||||
decide how much data to accumualte before producing output, in order to
|
||||
maximize compression.
|
||||
|
||||
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
|
||||
flushed to the output buffer and the output is aligned on a byte boundary, so
|
||||
that the decompressor can get all input data available so far. (In particular
|
||||
|
@ -257,7 +284,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
|||
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
|
||||
restart from this point if previous compressed data has been damaged or if
|
||||
random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
|
||||
the compression.
|
||||
compression.
|
||||
|
||||
If deflate returns with avail_out == 0, this function must be called again
|
||||
with the same value of the flush parameter and more output space (updated
|
||||
|
@ -282,8 +309,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
|||
deflate() sets strm->adler to the adler32 checksum of all input read
|
||||
so far (that is, total_in bytes).
|
||||
|
||||
deflate() may update data_type if it can make a good guess about
|
||||
the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
|
||||
deflate() may update strm->data_type if it can make a good guess about
|
||||
the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
|
||||
binary. This field is only for information purposes and does not affect
|
||||
the compression algorithm in any manner.
|
||||
|
||||
|
@ -365,11 +392,11 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
|||
The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
|
||||
Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
|
||||
output as possible to the output buffer. Z_BLOCK requests that inflate() stop
|
||||
if and when it get to the next deflate block boundary. When decoding the zlib
|
||||
or gzip format, this will cause inflate() to return immediately after the
|
||||
header and before the first block. When doing a raw inflate, inflate() will
|
||||
go ahead and process the first block, and will return when it gets to the end
|
||||
of that block, or when it runs out of data.
|
||||
if and when it gets to the next deflate block boundary. When decoding the
|
||||
zlib or gzip format, this will cause inflate() to return immediately after
|
||||
the header and before the first block. When doing a raw inflate, inflate()
|
||||
will go ahead and process the first block, and will return when it gets to
|
||||
the end of that block, or when it runs out of data.
|
||||
|
||||
The Z_BLOCK option assists in appending to or combining deflate streams.
|
||||
Also to assist in this, on return inflate() will set strm->data_type to the
|
||||
|
@ -401,7 +428,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
|||
because Z_BLOCK is used.
|
||||
|
||||
If a preset dictionary is needed after this call (see inflateSetDictionary
|
||||
below), inflate sets strm-adler to the adler32 checksum of the dictionary
|
||||
below), inflate sets strm->adler to the adler32 checksum of the dictionary
|
||||
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
|
||||
strm->adler to the adler32 checksum of all output produced so far (that is,
|
||||
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
|
||||
|
@ -478,7 +505,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
|||
16 to windowBits to write a simple gzip header and trailer around the
|
||||
compressed data instead of a zlib wrapper. The gzip header will have no
|
||||
file name, no extra data, no comment, no modification time (set to zero),
|
||||
no header crc, and the operating system will be set to 255 (unknown).
|
||||
no header crc, and the operating system will be set to 255 (unknown). If a
|
||||
gzip stream is being written, strm->adler is a crc32 instead of an adler32.
|
||||
|
||||
The memLevel parameter specifies how much memory should be allocated
|
||||
for the internal compression state. memLevel=1 uses minimum memory but
|
||||
|
@ -497,7 +525,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
|||
Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
|
||||
Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
|
||||
parameter only affects the compression ratio but not the correctness of the
|
||||
compressed output even if it is not set appropriately.
|
||||
compressed output even if it is not set appropriately. Z_FIXED prevents the
|
||||
use of dynamic Huffman codes, allowing for a simpler decoder for special
|
||||
applications.
|
||||
|
||||
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
||||
|
@ -526,7 +556,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
|||
deflateInit or deflateInit2, a part of the dictionary may in effect be
|
||||
discarded, for example if the dictionary is larger than the window size in
|
||||
deflate or deflate2. Thus the strings most likely to be useful should be
|
||||
put at the end of the dictionary, not at the front.
|
||||
put at the end of the dictionary, not at the front. In addition, the
|
||||
current implementation of deflate will use at most the window size minus
|
||||
262 bytes of the provided dictionary.
|
||||
|
||||
Upon return of this function, strm->adler is set to the adler32 value
|
||||
of the dictionary; the decompressor may later use this value to determine
|
||||
|
@ -592,6 +624,23 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
|||
if strm->avail_out was zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
|
||||
int good_length,
|
||||
int max_lazy,
|
||||
int nice_length,
|
||||
int max_chain));
|
||||
/*
|
||||
Fine tune deflate's internal compression parameters. This should only be
|
||||
used by someone who understands the algorithm used by zlib's deflate for
|
||||
searching for the best matching string, and even then only by the most
|
||||
fanatic optimizer trying to squeeze out the last compressed bit for their
|
||||
specific input data. Read the deflate.c source code for the meaning of the
|
||||
max_lazy, good_length, nice_length, and max_chain parameters.
|
||||
|
||||
deflateTune() can be called after deflateInit() or deflateInit2(), and
|
||||
returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
|
||||
uLong sourceLen));
|
||||
/*
|
||||
|
@ -617,6 +666,30 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
|||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
|
||||
gz_headerp head));
|
||||
/*
|
||||
deflateSetHeader() provides gzip header information for when a gzip
|
||||
stream is requested by deflateInit2(). deflateSetHeader() may be called
|
||||
after deflateInit2() or deflateReset() and before the first call of
|
||||
deflate(). The text, time, os, extra field, name, and comment information
|
||||
in the provided gz_header structure are written to the gzip header (xflag is
|
||||
ignored -- the extra flags are set according to the compression level). The
|
||||
caller must assure that, if not Z_NULL, name and comment are terminated with
|
||||
a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
|
||||
available there. If hcrc is true, a gzip header crc is included. Note that
|
||||
the current versions of the command-line version of gzip (up through version
|
||||
1.3.x) do not support header crc's, and will report that it is a "multi-part
|
||||
gzip file" and give up.
|
||||
|
||||
If deflateSetHeader is not used, the default gzip header has text false,
|
||||
the time set to zero, and os set to 255, with no extra, name, or comment
|
||||
fields. The gzip header is returned to the default state by deflateReset().
|
||||
|
||||
deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||
int windowBits));
|
||||
|
@ -649,14 +722,15 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
|||
windowBits can also be greater than 15 for optional gzip decoding. Add
|
||||
32 to windowBits to enable zlib and gzip decoding with automatic header
|
||||
detection, or add 16 to decode only the gzip format (the zlib format will
|
||||
return a Z_DATA_ERROR).
|
||||
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
|
||||
a crc32 instead of an adler32.
|
||||
|
||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||
memLevel). msg is set to null if there is no error message. inflateInit2
|
||||
does not perform any decompression apart from reading the zlib header if
|
||||
present: this will be done by inflate(). (So next_in and avail_in may be
|
||||
modified, but next_out and avail_out are unchanged.)
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
|
||||
is set to null if there is no error message. inflateInit2 does not perform
|
||||
any decompression apart from reading the zlib header if present: this will
|
||||
be done by inflate(). (So next_in and avail_in may be modified, but next_out
|
||||
and avail_out are unchanged.)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||
|
@ -664,11 +738,14 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
|||
uInt dictLength));
|
||||
/*
|
||||
Initializes the decompression dictionary from the given uncompressed byte
|
||||
sequence. This function must be called immediately after a call of inflate
|
||||
if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||
can be determined from the adler32 value returned by this call of
|
||||
inflate. The compressor and decompressor must use exactly the same
|
||||
dictionary (see deflateSetDictionary).
|
||||
sequence. This function must be called immediately after a call of inflate,
|
||||
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||
can be determined from the adler32 value returned by that call of inflate.
|
||||
The compressor and decompressor must use exactly the same dictionary (see
|
||||
deflateSetDictionary). For raw inflate, this function can be called
|
||||
immediately after inflateInit2() or inflateReset() and before any call of
|
||||
inflate() to set the dictionary. The application must insure that the
|
||||
dictionary that was used for compression is provided.
|
||||
|
||||
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
|
@ -719,8 +796,64 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
|||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
|
||||
int bits,
|
||||
int value));
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits,
|
||||
This function inserts bits in the inflate input stream. The intent is
|
||||
that this function is used to start inflating at a bit position in the
|
||||
middle of a byte. The provided bits will be used before any bytes are used
|
||||
from next_in. This function should only be used with raw inflate, and
|
||||
should be used before the first inflate() call after inflateInit2() or
|
||||
inflateReset(). bits must be less than or equal to 16, and that many of the
|
||||
least significant bits of value will be inserted in the input.
|
||||
|
||||
inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
|
||||
gz_headerp head));
|
||||
/*
|
||||
inflateGetHeader() requests that gzip header information be stored in the
|
||||
provided gz_header structure. inflateGetHeader() may be called after
|
||||
inflateInit2() or inflateReset(), and before the first call of inflate().
|
||||
As inflate() processes the gzip stream, head->done is zero until the header
|
||||
is completed, at which time head->done is set to one. If a zlib stream is
|
||||
being decoded, then head->done is set to -1 to indicate that there will be
|
||||
no gzip header information forthcoming. Note that Z_BLOCK can be used to
|
||||
force inflate() to return immediately after header processing is complete
|
||||
and before any actual data is decompressed.
|
||||
|
||||
The text, time, xflags, and os fields are filled in with the gzip header
|
||||
contents. hcrc is set to true if there is a header CRC. (The header CRC
|
||||
was valid if done is set to one.) If extra is not Z_NULL, then extra_max
|
||||
contains the maximum number of bytes to write to extra. Once done is true,
|
||||
extra_len contains the actual extra field length, and extra contains the
|
||||
extra field, or that field truncated if extra_max is less than extra_len.
|
||||
If name is not Z_NULL, then up to name_max characters are written there,
|
||||
terminated with a zero unless the length is greater than name_max. If
|
||||
comment is not Z_NULL, then up to comm_max characters are written there,
|
||||
terminated with a zero unless the length is greater than comm_max. When
|
||||
any of extra, name, or comment are not Z_NULL and the respective field is
|
||||
not present in the header, then that field is set to Z_NULL to signal its
|
||||
absence. This allows the use of deflateSetHeader() with the returned
|
||||
structure to duplicate the header. However if those fields are set to
|
||||
allocated memory, then the application will need to save those pointers
|
||||
elsewhere so that they can be eventually freed.
|
||||
|
||||
If inflateGetHeader is not used, then the header information is simply
|
||||
discarded. The header is always checked for validity, including the header
|
||||
CRC if present. inflateReset() will reset the process to discard the header
|
||||
information. The application would need to call inflateGetHeader() again to
|
||||
retrieve the header from the next gzip stream.
|
||||
|
||||
inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
|
||||
unsigned char FAR *window));
|
||||
|
||||
Initialize the internal stream state for decompression using inflateBack()
|
||||
|
@ -744,7 +877,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits,
|
|||
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
|
||||
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
||||
|
||||
ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm,
|
||||
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
||||
in_func in, void FAR *in_desc,
|
||||
out_func out, void FAR *out_desc));
|
||||
/*
|
||||
|
@ -813,7 +946,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm,
|
|||
that inflateBack() cannot return Z_OK.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm));
|
||||
ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
|
||||
/*
|
||||
All memory allocated by inflateBackInit() is freed.
|
||||
|
||||
|
@ -1087,6 +1220,12 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
|||
input stream, otherwise zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||
/*
|
||||
Returns 1 if file is being read directly without decompression, otherwise
|
||||
zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||
/*
|
||||
Flushes all pending output if necessary, closes the compressed file
|
||||
|
@ -1119,7 +1258,6 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
|||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
|
@ -1135,12 +1273,21 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
|||
if (adler != original_adler) error();
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
||||
z_off_t len2));
|
||||
/*
|
||||
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
||||
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
||||
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
||||
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Update a running CRC-32 with the bytes buf[0..len-1] and return the
|
||||
updated CRC-32. If buf is NULL, this function returns the required initial
|
||||
value for the for the crc. Pre- and post-conditioning (one's complement) is
|
||||
performed within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
uLong crc = crc32(0L, Z_NULL, 0);
|
||||
|
@ -1151,6 +1298,16 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
|||
if (crc != original_crc) error();
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
|
||||
|
||||
/*
|
||||
Combine two CRC-32 check values into one. For two sequences of bytes,
|
||||
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
|
||||
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
|
||||
check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
|
||||
len2.
|
||||
*/
|
||||
|
||||
|
||||
/* various hacks, don't look :) */
|
||||
|
||||
|
@ -1167,7 +1324,7 @@ ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
|||
int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
|
||||
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||
unsigned char FAR *window,
|
||||
const char *version,
|
||||
int stream_size));
|
||||
|
@ -1189,7 +1346,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
|
|||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||
#endif
|
||||
|
||||
ZEXTERN const char * ZEXPORT zError OF((int err));
|
||||
ZEXTERN const char * ZEXPORT zError OF((int));
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
|
||||
|
|
33
zlib/zutil.c
33
zlib/zutil.c
|
@ -1,5 +1,5 @@
|
|||
/* zutil.c -- target dependent utility functions for the compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -11,10 +11,6 @@
|
|||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
extern void exit OF((int));
|
||||
#endif
|
||||
|
||||
const char * const z_errmsg[10] = {
|
||||
"need dictionary", /* Z_NEED_DICT 2 */
|
||||
"stream end", /* Z_STREAM_END 1 */
|
||||
|
@ -78,38 +74,38 @@ uLong ZEXPORT zlibCompileFlags()
|
|||
flags += 1 << 13;
|
||||
#endif
|
||||
#ifdef NO_GZCOMPRESS
|
||||
flags += 1 << 16;
|
||||
flags += 1L << 16;
|
||||
#endif
|
||||
#ifdef NO_GZIP
|
||||
flags += 1 << 17;
|
||||
flags += 1L << 17;
|
||||
#endif
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
flags += 1 << 20;
|
||||
flags += 1L << 20;
|
||||
#endif
|
||||
#ifdef FASTEST
|
||||
flags += 1 << 21;
|
||||
flags += 1L << 21;
|
||||
#endif
|
||||
#ifdef STDC
|
||||
# ifdef NO_vsnprintf
|
||||
flags += 1 << 25;
|
||||
flags += 1L << 25;
|
||||
# ifdef HAS_vsprintf_void
|
||||
flags += 1 << 26;
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAS_vsnprintf_void
|
||||
flags += 1 << 26;
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
flags += 1 << 24;
|
||||
flags += 1L << 24;
|
||||
# ifdef NO_snprintf
|
||||
flags += 1 << 25;
|
||||
flags += 1L << 25;
|
||||
# ifdef HAS_sprintf_void
|
||||
flags += 1 << 26;
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAS_snprintf_void
|
||||
flags += 1 << 26;
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
@ -141,7 +137,10 @@ const char * ZEXPORT zError(err)
|
|||
}
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
/* does not exist on WCE */
|
||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
||||
* errno. We define it as a global variable to simplify porting.
|
||||
* Its value is always 0 and should not be used.
|
||||
*/
|
||||
int errno = 0;
|
||||
#endif
|
||||
|
||||
|
|
25
zlib/zutil.h
25
zlib/zutil.h
|
@ -1,5 +1,5 @@
|
|||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -17,14 +17,26 @@
|
|||
#include "zlib.h"
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef _WIN32_WCE
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef NO_ERRNO_H
|
||||
# ifdef _WIN32_WCE
|
||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
||||
* errno. We define it as a global variable to simplify porting.
|
||||
* Its value is always 0 and should not be used. We rename it to
|
||||
* avoid conflict with other libraries that use the same workaround.
|
||||
*/
|
||||
# define errno z_errno
|
||||
# endif
|
||||
extern int errno;
|
||||
#else
|
||||
# ifndef _WIN32_WCE
|
||||
# include <errno.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
|
@ -105,6 +117,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 0x06
|
||||
# ifdef M_I86
|
||||
#include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
|
@ -189,12 +204,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define NO_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
#ifdef VMS
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(pyr)
|
||||
|
|
Loading…
Reference in a new issue