FTE_TARGET=win64 (thanks to MinGW64), 64bit MinGW64 static libs, and fix for undefined references to vsnprintf within qclib when using MinGW64

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3688 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Lance 2010-12-08 14:42:05 +00:00
parent 85c2d8afae
commit 6a0549acc1
19 changed files with 9735 additions and 166 deletions

View file

@ -33,6 +33,20 @@ ifeq ($(FTE_TARGET),win32)
endif endif
endif endif
#correct the gcc build when cross compiling
ifeq ($(FTE_TARGET),win64)
ifeq ($(shell $(CC) -v 2>&1 | grep mingw),)
#CC didn't state that it was mingw... so try fixing that up
ifneq ($(shell which amd64-mingw32msvc-gcc 2> /dev/null),)
#yup, the alternative exists (this matches the one debian has)
CC=amd64-mingw32msvc-gcc -m64
WINDRES=amd64-mingw32msvc-windres
STRIP=amd64-mingw32msvc-strip
# BITS?=64
endif
endif
endif
#correct the gcc build when cross compiling #correct the gcc build when cross compiling
ifeq ($(FTE_TARGET),win32_SDL) ifeq ($(FTE_TARGET),win32_SDL)
ifeq ($(shell $(CC) -v 2>&1 | grep mingw),) ifeq ($(shell $(CC) -v 2>&1 | grep mingw),)
@ -183,6 +197,9 @@ endif
ifeq ($(FTE_TARGET),win32) ifeq ($(FTE_TARGET),win32)
BASELDFLAGS=-lm BASELDFLAGS=-lm
endif endif
ifeq ($(FTE_TARGET),win64)
BASELDFLAGS=-lm
endif
ifeq ($(FTE_TARGET),win32_SDL) ifeq ($(FTE_TARGET),win32_SDL)
BASELDFLAGS=-lm BASELDFLAGS=-lm
endif endif
@ -200,6 +217,9 @@ BASELDFLAGS ?= -lm -ldl -lpthread
ifeq ($(FTE_TARGET),win32) ifeq ($(FTE_TARGET),win32)
IMAGELDFLAGS=$(LIBS_DIR)/mingw-libs/libpng.a $(LIBS_DIR)/mingw-libs/libz.a $(LIBS_DIR)/mingw-libs/libjpeg.a IMAGELDFLAGS=$(LIBS_DIR)/mingw-libs/libpng.a $(LIBS_DIR)/mingw-libs/libz.a $(LIBS_DIR)/mingw-libs/libjpeg.a
endif endif
ifeq ($(FTE_TARGET),win64)
IMAGELDFLAGS=$(LIBS_DIR)/mingw64-libs/libpng.a $(LIBS_DIR)/mingw64-libs/libz.a $(LIBS_DIR)/mingw64-libs/libjpeg.a
endif
ifeq ($(FTE_TARGET),win32_SDL) ifeq ($(FTE_TARGET),win32_SDL)
IMAGELDFLAGS=./libs/mingw-libs/libpng.a ./libs/mingw-libs/libz.a ./libs/mingw-libs/libjpeg.a IMAGELDFLAGS=./libs/mingw-libs/libpng.a ./libs/mingw-libs/libz.a ./libs/mingw-libs/libjpeg.a
endif endif
@ -260,6 +280,11 @@ ifeq ($(FTE_TARGET),win32)
#RELEASE_CFLAGS=-fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS) #RELEASE_CFLAGS=-fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
RELEASE_CFLAGS=$(CPUOPTIMIZATIONS) RELEASE_CFLAGS=$(CPUOPTIMIZATIONS)
endif endif
ifeq ($(FTE_TARGET),win64)
# Let's make sure we're not chasing our tails with MinGW32 compiler bugs
#RELEASE_CFLAGS=-fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
RELEASE_CFLAGS=$(CPUOPTIMIZATIONS)
endif
ifeq ($(FTE_TARGET),win32_SDL) ifeq ($(FTE_TARGET),win32_SDL)
# Let's make sure we're not chasing our tails with MinGW32 compiler bugs # Let's make sure we're not chasing our tails with MinGW32 compiler bugs
#RELEASE_CFLAGS=-fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS) -D_SDL #RELEASE_CFLAGS=-fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS) -D_SDL
@ -273,6 +298,10 @@ ifneq ($(FTE_TARGET),win32)
#RELEASE_CFLAGS=-O6 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS) #RELEASE_CFLAGS=-O6 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS)
endif endif
endif endif
ifneq ($(FTE_TARGET),win64)
RELEASE_CFLAGS ?= -O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
#RELEASE_CFLAGS=-O6 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS)
endif
GLCFLAGS=-DGLQUAKE GLCFLAGS=-DGLQUAKE
D3DCFLAGS=-DD3DQUAKE D3DCFLAGS=-DD3DQUAKE
@ -640,6 +669,73 @@ endif
MINGL_EXE_NAME=../fteminglqw.exe MINGL_EXE_NAME=../fteminglqw.exe
MINGL_DIR=mingl_mgw MINGL_DIR=mingl_mgw
endif endif
ifeq ($(FTE_TARGET),win64)
# The extra object file called resources.o is specific for MinGW to link the icon in
#cygwin's gcc requires an extra command to use mingw instead of cygwin (default paths, etc).
ifneq ($(shell $(CC) -v 2>&1 | grep cygwin),)
W32_CFLAGS=-mno-cygwin
endif
SV_CFLAGS=$(SERVER_ONLY_CFLAGS) $(W32_CFLAGS)
LIBS_DIR = $(BASE_DIR)/libs
SV_EXE_NAME=../fteqwsv64.exe
SV_LDFLAGS=$(LIBS_DIR)/mingw64-libs/libz.a -lws2_32 -lwinmm
SV_DIR=sv_mingw64
SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o resources.o
ifeq ($(USEASM),true)
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o resources.o
else
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o
endif
GL_EXE_NAME=../fteglqw64.exe
GLCL_EXE_NAME=../fteglqwcl64.exe
GL_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32
GL_CFLAGS=$(GLCFLAGS) $(W32_CFLAGS)
GLB_DIR=gl_mgw64
GLCL_DIR=glcl_mgw64
ifeq ($(USEASM),true)
NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o npplug.o sys_npqtv.o sys_plugfte.o ../../ftequake/npapi.def
else
NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o npplug.o sys_npqtv.o sys_plugfte.o ../../ftequake/npapi.def
endif
NPQTV_DLL_NAME=../npqtv64.dll
NPQTVCL_DLL_NAME=../npqtvcl64.dll
NPQTV_LDFLAGS=--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 -shared
NPQTV_CFLAGS=$(NPQTVCFLAGS) $(GLCFLAGS) $(W32_CFLAGS)
NPQTVB_DIR=npqtv_mgw64
NPQTVCL_DIR=npqtvcl_mgw64
ifeq ($(USEASM),true)
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) fs_win32.o gl_vidnt.o vid_ddraw.o vid_dib.o vid_win2.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o resources.o
else
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) fs_win32.o gl_vidnt.o vid_ddraw.o vid_dib.o vid_win2.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o
endif
M_EXE_NAME=../fteqw64.exe
MCL_EXE_NAME=../fteqwcl64.exe
M_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32
M_CFLAGS=$(GLCFLAGS) $(W32_CFLAGS)
MB_DIR=m_mgw64
MCL_DIR=mcl_mgw64
D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o
D3D_EXE_NAME=../fted3dqw64.exe
D3DCL_EXE_NAME=../fted3dclqw64.exe
D3D_LDFLAGS= -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32
D3D_CFLAGS=$(D3DCFLAGS) $(W32_CFLAGS) -DMINIMAL
D3DB_DIR=d3d_mgw64
D3DCL_DIR=d3dcl_mgw64
MINGL_EXE_NAME=../fteminglqw64.exe
MINGL_DIR=mingl_mgw64
endif
ifeq ($(FTE_TARGET),bsd) ifeq ($(FTE_TARGET),bsd)
#mostly uses the linux stuff. #mostly uses the linux stuff.
#oss, X, etc. #oss, X, etc.

View file

@ -0,0 +1,54 @@
/* jconfig.h. Generated from jconfig.cfg by configure. */
/* jconfig.cfg --- source file edited by configure script */
/* see jconfig.txt for explanations */
#define HAVE_PROTOTYPES 1
#define HAVE_UNSIGNED_CHAR 1
#define HAVE_UNSIGNED_SHORT 1
/* #undef void */
/* #undef const */
/* #undef CHAR_IS_UNSIGNED */
#define HAVE_STDDEF_H 1
#define HAVE_STDLIB_H 1
#define HAVE_LOCALE_H 1
/* #undef NEED_BSD_STRINGS */
/* #undef NEED_SYS_TYPES_H */
/* #undef NEED_FAR_POINTERS */
/* #undef NEED_SHORT_EXTERNAL_NAMES */
/* Define this if you get warnings about undefined structures. */
/* #undef INCOMPLETE_TYPES_BROKEN */
/* Define "boolean" as unsigned char, not int, on Windows systems. */
#ifdef _WIN32
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif
#ifdef JPEG_INTERNALS
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
#define INLINE __inline__
/* These are for configuring the JPEG memory manager. */
/* #undef DEFAULT_MAX_MEM */
/* #undef NO_MKTEMP */
#endif /* JPEG_INTERNALS */
#ifdef JPEG_CJPEG_DJPEG
#define BMP_SUPPORTED /* BMP image file format */
#define GIF_SUPPORTED /* GIF image file format */
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
/* #undef RLE_SUPPORTED */
#define TARGA_SUPPORTED /* Targa image file format */
/* #undef TWO_FILE_COMMANDLINE */
/* #undef NEED_SIGNAL_CATCHER */
/* #undef DONT_USE_B_MODE */
/* Define this if you want percent-done progress reports from cjpeg/djpeg. */
/* #undef PROGRESS_REPORT */
#endif /* JPEG_CJPEG_DJPEG */

304
engine/libs/mingw64-libs/jerror.h Executable file
View file

@ -0,0 +1,304 @@
/*
* jerror.h
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file defines the error and message codes for the JPEG library.
* Edit this file to add new codes, or to translate the message strings to
* some other language.
* A set of error-reporting macros are defined too. Some applications using
* the JPEG library may wish to include this file to get the error codes
* and/or the macros.
*/
/*
* To define the enum list of message codes, include this file without
* defining macro JMESSAGE. To create a message string table, include it
* again with a suitable JMESSAGE definition (see jerror.c for an example).
*/
#ifndef JMESSAGE
#ifndef JERROR_H
/* First time through, define the enum list */
#define JMAKE_ENUM_LIST
#else
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
#define JMESSAGE(code,string)
#endif /* JERROR_H */
#endif /* JMESSAGE */
#ifdef JMAKE_ENUM_LIST
typedef enum {
#define JMESSAGE(code,string) code ,
#endif /* JMAKE_ENUM_LIST */
JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
/* For maintenance convenience, list is alphabetical by message code name */
JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
JMESSAGE(JERR_BAD_DCTSIZE, "DCT scaled block size %dx%d not supported")
JMESSAGE(JERR_BAD_DROP_SAMPLING,
"Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
JMESSAGE(JERR_BAD_LIB_VERSION,
"Wrong JPEG library version: library is %d, caller expects %d")
JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
JMESSAGE(JERR_BAD_PROGRESSION,
"Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
JMESSAGE(JERR_BAD_PROG_SCRIPT,
"Invalid progressive parameters at scan script entry %d")
JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
JMESSAGE(JERR_BAD_STRUCT_SIZE,
"JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
JMESSAGE(JERR_FILE_READ, "Input file read error")
JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
"Cannot transcode due to multiple use of quantization table %d")
JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
JMESSAGE(JERR_QUANT_COMPONENTS,
"Cannot quantize more than %d color components")
JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
JMESSAGE(JERR_TFILE_WRITE,
"Write failed on temporary file --- out of disk space?")
JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
JMESSAGE(JMSG_VERSION, JVERSION)
JMESSAGE(JTRC_16BIT_TABLES,
"Caution: quantization tables are too coarse for baseline JPEG")
JMESSAGE(JTRC_ADOBE,
"Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
JMESSAGE(JTRC_EOI, "End Of Image")
JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
"Warning: thumbnail image size does not match data length %u")
JMESSAGE(JTRC_JFIF_EXTENSION,
"JFIF extension marker: type 0x%02x, length %u")
JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
JMESSAGE(JTRC_RST, "RST%d")
JMESSAGE(JTRC_SMOOTH_NOTIMPL,
"Smoothing not supported with nonstandard sampling ratios")
JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
JMESSAGE(JTRC_SOI, "Start of Image")
JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
JMESSAGE(JTRC_THUMB_JPEG,
"JFIF extension marker: JPEG-compressed thumbnail image, length %u")
JMESSAGE(JTRC_THUMB_PALETTE,
"JFIF extension marker: palette thumbnail image, length %u")
JMESSAGE(JTRC_THUMB_RGB,
"JFIF extension marker: RGB thumbnail image, length %u")
JMESSAGE(JTRC_UNKNOWN_IDS,
"Unrecognized component IDs %d %d %d, assuming YCbCr")
JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
JMESSAGE(JWRN_BOGUS_PROGRESSION,
"Inconsistent progression sequence for component %d coefficient %d")
JMESSAGE(JWRN_EXTRANEOUS_DATA,
"Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
JMESSAGE(JWRN_MUST_RESYNC,
"Corrupt JPEG data: found marker 0x%02x instead of RST%d")
JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
#ifdef JMAKE_ENUM_LIST
JMSG_LASTMSGCODE
} J_MESSAGE_CODE;
#undef JMAKE_ENUM_LIST
#endif /* JMAKE_ENUM_LIST */
/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
#undef JMESSAGE
#ifndef JERROR_H
#define JERROR_H
/* Macros to simplify using the error and trace message stuff */
/* The first parameter is either type of cinfo pointer */
/* Fatal errors (print message and exit) */
#define ERREXIT(cinfo,code) \
((cinfo)->err->msg_code = (code), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT1(cinfo,code,p1) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT2(cinfo,code,p1,p2) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT3(cinfo,code,p1,p2,p3) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(cinfo)->err->msg_parm.i[2] = (p3), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(cinfo)->err->msg_parm.i[2] = (p3), \
(cinfo)->err->msg_parm.i[3] = (p4), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(cinfo)->err->msg_parm.i[2] = (p3), \
(cinfo)->err->msg_parm.i[3] = (p4), \
(cinfo)->err->msg_parm.i[4] = (p5), \
(cinfo)->err->msg_parm.i[5] = (p6), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXITS(cinfo,code,str) \
((cinfo)->err->msg_code = (code), \
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define MAKESTMT(stuff) do { stuff } while (0)
/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
#define WARNMS(cinfo,code) \
((cinfo)->err->msg_code = (code), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
#define WARNMS1(cinfo,code,p1) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
#define WARNMS2(cinfo,code,p1,p2) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
/* Informational/debugging messages */
#define TRACEMS(cinfo,lvl,code) \
((cinfo)->err->msg_code = (code), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
#define TRACEMS1(cinfo,lvl,code,p1) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
#define TRACEMS2(cinfo,lvl,code,p1,p2) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
(cinfo)->err->msg_code = (code); \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
(cinfo)->err->msg_code = (code); \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
_mp[4] = (p5); \
(cinfo)->err->msg_code = (code); \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
_mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
(cinfo)->err->msg_code = (code); \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
#define TRACEMSS(cinfo,lvl,code,str) \
((cinfo)->err->msg_code = (code), \
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
#endif /* JERROR_H */

View file

@ -0,0 +1,371 @@
/*
* jmorecfg.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains additional configuration options that customize the
* JPEG software for special applications or support machine-dependent
* optimizations. Most users will not need to touch this file.
*/
/*
* Define BITS_IN_JSAMPLE as either
* 8 for 8-bit sample values (the usual setting)
* 12 for 12-bit sample values
* Only 8 and 12 are legal data precisions for lossy JPEG according to the
* JPEG standard, and the IJG code does not support anything else!
* We do not support run-time selection of data precision, sorry.
*/
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
/*
* Maximum number of components (color channels) allowed in JPEG image.
* To meet the letter of the JPEG spec, set this to 255. However, darn
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
* really short on memory. (Each allowed component costs a hundred or so
* bytes of storage, whether actually used in an image or not.)
*/
#define MAX_COMPONENTS 10 /* maximum number of image components */
/*
* Basic data types.
* You may need to change these if you have a machine with unusual data
* type sizes; for example, "char" not 8 bits, "short" not 16 bits,
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
* but it had better be at least 16.
*/
/* Representation of a single sample (pixel element value).
* We frequently allocate large arrays of these, so it's important to keep
* them small. But if you have memory to burn and access to char or short
* arrays is very slow on your hardware, you might want to change these.
*/
#if BITS_IN_JSAMPLE == 8
/* JSAMPLE should be the smallest type that will hold the values 0..255.
* You can use a signed char by having GETJSAMPLE mask it with 0xFF.
*/
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#else /* not HAVE_UNSIGNED_CHAR */
typedef char JSAMPLE;
#ifdef CHAR_IS_UNSIGNED
#define GETJSAMPLE(value) ((int) (value))
#else
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
#endif /* CHAR_IS_UNSIGNED */
#endif /* HAVE_UNSIGNED_CHAR */
#define MAXJSAMPLE 255
#define CENTERJSAMPLE 128
#endif /* BITS_IN_JSAMPLE == 8 */
#if BITS_IN_JSAMPLE == 12
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
* On nearly all machines "short" will do nicely.
*/
typedef short JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#define MAXJSAMPLE 4095
#define CENTERJSAMPLE 2048
#endif /* BITS_IN_JSAMPLE == 12 */
/* Representation of a DCT frequency coefficient.
* This should be a signed value of at least 16 bits; "short" is usually OK.
* Again, we allocate large arrays of these, but you can change to int
* if you have memory to burn and "short" is really slow.
*/
typedef short JCOEF;
/* Compressed datastreams are represented as arrays of JOCTET.
* These must be EXACTLY 8 bits wide, at least once they are written to
* external storage. Note that when using the stdio data source/destination
* managers, this is also the data type passed to fread/fwrite.
*/
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char JOCTET;
#define GETJOCTET(value) (value)
#else /* not HAVE_UNSIGNED_CHAR */
typedef char JOCTET;
#ifdef CHAR_IS_UNSIGNED
#define GETJOCTET(value) (value)
#else
#define GETJOCTET(value) ((value) & 0xFF)
#endif /* CHAR_IS_UNSIGNED */
#endif /* HAVE_UNSIGNED_CHAR */
/* These typedefs are used for various table entries and so forth.
* They must be at least as wide as specified; but making them too big
* won't cost a huge amount of memory, so we don't provide special
* extraction code like we did for JSAMPLE. (In other words, these
* typedefs live at a different point on the speed/space tradeoff curve.)
*/
/* UINT8 must hold at least the values 0..255. */
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char UINT8;
#else /* not HAVE_UNSIGNED_CHAR */
#ifdef CHAR_IS_UNSIGNED
typedef char UINT8;
#else /* not CHAR_IS_UNSIGNED */
typedef short UINT8;
#endif /* CHAR_IS_UNSIGNED */
#endif /* HAVE_UNSIGNED_CHAR */
/* UINT16 must hold at least the values 0..65535. */
#ifdef HAVE_UNSIGNED_SHORT
typedef unsigned short UINT16;
#else /* not HAVE_UNSIGNED_SHORT */
typedef unsigned int UINT16;
#endif /* HAVE_UNSIGNED_SHORT */
/* INT16 must hold at least the values -32768..32767. */
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
typedef short INT16;
#endif
/* INT32 must hold at least signed 32-bit values. */
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
#ifndef _BASETSD_H /* MinGW is slightly different */
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
typedef long INT32;
#endif
#endif
#endif
#endif
/* Datatype used for image dimensions. The JPEG standard only supports
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
* "unsigned int" is sufficient on all machines. However, if you need to
* handle larger images and you don't mind deviating from the spec, you
* can change this datatype.
*/
typedef unsigned int JDIMENSION;
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
/* These macros are used in all function definitions and extern declarations.
* You could modify them if you need to change function linkage conventions;
* in particular, you'll need to do that to make the library a Windows DLL.
* Another application is to make all functions global for use with debuggers
* or code profilers that require it.
*/
/* a function called through method pointers: */
#define METHODDEF(type) static type
/* a function used only in its module: */
#define LOCAL(type) static type
/* a function referenced thru EXTERNs: */
#define GLOBAL(type) type
/* a reference to a GLOBAL function: */
#define EXTERN(type) extern type
/* This macro is used to declare a "method", that is, a function pointer.
* We want to supply prototype parameters if the compiler can cope.
* Note that the arglist parameter must be parenthesized!
* Again, you can customize this if you need special linkage keywords.
*/
#ifdef HAVE_PROTOTYPES
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
#else
#define JMETHOD(type,methodname,arglist) type (*methodname) ()
#endif
/* Here is the pseudo-keyword for declaring pointers that must be "far"
* on 80x86 machines. Most of the specialized coding for 80x86 is handled
* by just saying "FAR *" where such a pointer is needed. In a few places
* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
*/
#ifndef FAR
#ifdef NEED_FAR_POINTERS
#define FAR far
#else
#define FAR
#endif
#endif
/*
* On a few systems, type boolean and/or its values FALSE, TRUE may appear
* in standard header files. Or you may have conflicts with application-
* specific header files that you want to include together with these files.
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/
#ifndef HAVE_BOOLEAN
typedef int boolean;
#endif
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
#ifndef TRUE
#define TRUE 1
#endif
/*
* The remaining options affect code selection within the JPEG library,
* but they don't need to be visible to most applications using the library.
* To minimize application namespace pollution, the symbols won't be
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
*/
#ifdef JPEG_INTERNALS
#define JPEG_INTERNAL_OPTIONS
#endif
#ifdef JPEG_INTERNAL_OPTIONS
/*
* These defines indicate whether to include various optional functions.
* Undefining some of these symbols will produce a smaller but less capable
* library. Note that you can leave certain source files out of the
* compilation/linking process if you've #undef'd the corresponding symbols.
* (You may HAVE to do that if your compiler doesn't like null source files.)
*/
/* Capability options common to encoder and decoder: */
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
/* Encoder capability options: */
#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
* precision, so jchuff.c normally uses entropy optimization to compute
* usable tables for higher precision. If you don't want to do optimization,
* you'll have to supply different default Huffman tables.
* The exact same statements apply for progressive JPEG: the default tables
* don't work for progressive mode. (This may get fixed, however.)
*/
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
/* Decoder capability options: */
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
/* more capability options later, no doubt */
/*
* Ordering of RGB data in scanlines passed to or from the application.
* If your application wants to deal with data in the order B,G,R, just
* change these macros. You can also deal with formats such as R,G,B,X
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
* the offsets will also change the order in which colormap data is organized.
* RESTRICTIONS:
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
* useful if you are using JPEG color spaces other than YCbCr or grayscale.
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
* is not 3 (they don't understand about dummy color components!). So you
* can't use color quantization if you change that value.
*/
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
#define RGB_GREEN 1 /* Offset of Green */
#define RGB_BLUE 2 /* Offset of Blue */
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
/* Definitions for speed-related optimizations. */
/* If your compiler supports inline functions, define INLINE
* as the inline keyword; otherwise define it as empty.
*/
#ifndef INLINE
#ifdef __GNUC__ /* for instance, GNU C knows about inline */
#define INLINE __inline__
#endif
#ifndef INLINE
#define INLINE /* default is to define it as empty */
#endif
#endif
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
* as short on such a machine. MULTIPLIER must be at least 16 bits wide.
*/
#ifndef MULTIPLIER
#define MULTIPLIER int /* type for fastest integer multiply */
#endif
/* FAST_FLOAT should be either float or double, whichever is done faster
* by your compiler. (Note that this type is only used in the floating point
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
* Typically, float is faster in ANSI C compilers, while double is faster in
* pre-ANSI compilers (because they insist on converting to double anyway).
* The code below therefore chooses float if we have ANSI-style prototypes.
*/
#ifndef FAST_FLOAT
#ifdef HAVE_PROTOTYPES
#define FAST_FLOAT float
#else
#define FAST_FLOAT double
#endif
#endif
#endif /* JPEG_INTERNAL_OPTIONS */

1158
engine/libs/mingw64-libs/jpeglib.h Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,14 @@
/*
* jversion.h
*
* Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains software version identification.
*/
#define JVERSION "8b 16-May-2010"
#define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding"

Binary file not shown.

BIN
engine/libs/mingw64-libs/libpng.a Executable file

Binary file not shown.

BIN
engine/libs/mingw64-libs/libz.a Executable file

Binary file not shown.

2699
engine/libs/mingw64-libs/png.h Executable file

File diff suppressed because it is too large Load diff

1540
engine/libs/mingw64-libs/pngconf.h Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,954 @@
/* pngpriv.h - private declarations for use inside libpng
*
* libpng version 1.4.4 - September 23, 2010
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* The symbols declared in this file (including the functions declared
* as PNG_EXTERN) are PRIVATE. They are not part of the libpng public
* interface, and are not recommended for use by regular applications.
* Some of them may become public in the future; others may stay private,
* change in an incompatible way, or even disappear.
* Although the libpng users are not forbidden to include this header,
* they should be well aware of the issues that may arise from doing so.
*/
#ifndef PNGPRIV_H
#define PNGPRIV_H
#ifndef PNG_VERSION_INFO_ONLY
#include <stdlib.h>
#ifndef PNG_EXTERN
/* The functions exported by PNG_EXTERN are internal functions, which
* aren't usually used outside the library (as far as I know), so it is
* debatable if they should be exported at all. In the future, when it
* is possible to have run-time registry of chunk-handling functions,
* some of these will be made available again.
# define PNG_EXTERN extern
*/
# define PNG_EXTERN
#endif
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
*/
#ifdef PNG_FLOATING_POINT_SUPPORTED
# ifdef MACOS
/* We need to check that <math.h> hasn't already been included earlier
* as it seems it doesn't agree with <fp.h>, yet we should really use
* <fp.h> if possible.
*/
# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
# include <fp.h>
# endif
# else
# include <math.h>
# endif
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
*/
# include <m68881.h>
# endif
#endif
/* Codewarrior on NT has linking problems without this. */
#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
# define PNG_ALWAYS_EXTERN
#endif
/* This provides the non-ANSI (far) memory allocation routines. */
#if defined(__TURBOC__) && defined(__MSDOS__)
# include <mem.h>
# include <alloc.h>
#endif
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
defined(_WIN32) || defined(__WIN32__)
# include <windows.h> /* defines _WINDOWS_ macro */
#endif
/* Various modes of operation. Note that after an init, mode is set to
* zero automatically when the structure is created.
*/
#define PNG_HAVE_IHDR 0x01
#define PNG_HAVE_PLTE 0x02
#define PNG_HAVE_IDAT 0x04
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
#define PNG_HAVE_IEND 0x10
#define PNG_HAVE_gAMA 0x20
#define PNG_HAVE_cHRM 0x40
#define PNG_HAVE_sRGB 0x80
#define PNG_HAVE_CHUNK_HEADER 0x100
#define PNG_WROTE_tIME 0x200
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
/* Flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
#define PNG_INTERLACE 0x0002
#define PNG_PACK 0x0004
#define PNG_SHIFT 0x0008
#define PNG_SWAP_BYTES 0x0010
#define PNG_INVERT_MONO 0x0020
#define PNG_QUANTIZE 0x0040 /* formerly PNG_DITHER */
#define PNG_BACKGROUND 0x0080
#define PNG_BACKGROUND_EXPAND 0x0100
/* 0x0200 unused */
#define PNG_16_TO_8 0x0400
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000
#define PNG_GRAY_TO_RGB 0x4000
#define PNG_FILLER 0x8000L
#define PNG_PACKSWAP 0x10000L
#define PNG_SWAP_ALPHA 0x20000L
#define PNG_STRIP_ALPHA 0x40000L
#define PNG_INVERT_ALPHA 0x80000L
#define PNG_USER_TRANSFORM 0x100000L
#define PNG_RGB_TO_GRAY_ERR 0x200000L
#define PNG_RGB_TO_GRAY_WARN 0x400000L
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
/* 0x800000L Unused */
#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
/* 0x4000000L unused */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
/* 0x40000000L unused */
/* Flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
#define PNG_STRUCT_INFO 0x0002
/* Scaling factor for filter heuristic weighting calculations */
#define PNG_WEIGHT_SHIFT 8
#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
#define PNG_COST_SHIFT 3
#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
#define PNG_FLAG_ZLIB_FINISHED 0x0020
#define PNG_FLAG_ROW_INIT 0x0040
#define PNG_FLAG_FILLER_AFTER 0x0080
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
/* 0x1000 unused */
/* 0x2000 unused */
/* 0x4000 unused */
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
/* 0x1000000L unused */
/* 0x2000000L unused */
/* 0x4000000L unused */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
/* 0x40000000L unused */
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN)
#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
PNG_FLAG_CRC_CRITICAL_IGNORE)
#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
PNG_FLAG_CRC_CRITICAL_MASK)
/* Save typing and make code easier to understand */
#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
abs((int)((c1).green) - (int)((c2).green)) + \
abs((int)((c1).blue) - (int)((c2).blue)))
/* Added to libpng-1.2.6 JB */
#define PNG_ROWBYTES(pixel_bits, width) \
((pixel_bits) >= 8 ? \
((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
(( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
/* PNG_OUT_OF_RANGE returns true if value is outside the range
* ideal-delta..ideal+delta. Each argument is evaluated twice.
* "ideal" and "delta" should be constants, normally simple
* integers, "value" a variable. Added to libpng-1.2.6 JB
*/
#define PNG_OUT_OF_RANGE(value, ideal, delta) \
( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
/* Constant strings for known chunk types. If you need to add a chunk,
* define the name here, and add an invocation of the macro wherever it's
* needed.
*/
#define PNG_IHDR PNG_CONST png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
#define PNG_IDAT PNG_CONST png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
#define PNG_IEND PNG_CONST png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
#define PNG_PLTE PNG_CONST png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
#define PNG_bKGD PNG_CONST png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
#define PNG_cHRM PNG_CONST png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
#define PNG_gAMA PNG_CONST png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
#define PNG_hIST PNG_CONST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
#define PNG_iCCP PNG_CONST png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
#define PNG_iTXt PNG_CONST png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
#define PNG_oFFs PNG_CONST png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
#define PNG_pCAL PNG_CONST png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
#define PNG_sCAL PNG_CONST png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
#define PNG_pHYs PNG_CONST png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
#define PNG_sBIT PNG_CONST png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
#define PNG_sPLT PNG_CONST png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
#define PNG_sRGB PNG_CONST png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
#define PNG_sTER PNG_CONST png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}
#define PNG_tEXt PNG_CONST png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
#define PNG_tIME PNG_CONST png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* These functions are used internally in the code. They generally
* shouldn't be used unless you are writing code to add or replace some
* functionality in libpng. More information about most functions can
* be found in the files where the functions are located.
*/
/* Allocate memory for an internal libpng struct */
PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
/* Free memory from internal libpng struct */
PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
malloc_fn, png_voidp mem_ptr));
PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
png_free_ptr free_fn, png_voidp mem_ptr));
/* Free any memory that info_ptr points to and reset struct. */
PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
png_infop info_ptr));
/* Function to allocate memory for zlib. PNGAPI is disallowed. */
PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
/* Function to free memory for zlib. PNGAPI is disallowed. */
PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
/* Next four functions are used internally as callbacks. PNGAPI is required
* but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */
PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t length));
#endif
PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
#ifdef PNG_WRITE_FLUSH_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED
PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
#endif
#endif
/* Reset the CRC variable */
PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
/* Write the "data" buffer to whatever output you are using */
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
/* Read the chunk header (length + type name) */
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
/* Read data from whatever input you are using into the "data" buffer */
PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
/* Read bytes into buf, and update png_ptr->crc */
PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
png_size_t length));
/* Decompress data in a chunk that uses compression */
#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
int comp_type, png_size_t chunklength, png_size_t prefix_length,
png_size_t *data_length));
#endif
/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
/* Read the CRC from the file and compare it to the libpng calculated CRC */
PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
/* Calculate the CRC over a section of data. Note that we are only
* passing a maximum of 64K on systems that have this as a memory limit,
* since this is the maximum buffer size we can specify.
*/
PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
png_size_t length));
#ifdef PNG_WRITE_FLUSH_SUPPORTED
PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
#endif
/* Write various chunks */
/* Write the IHDR chunk, and update the png_struct with the necessary
* information.
*/
PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
png_uint_32 height,
int bit_depth, int color_type, int compression_method, int filter_method,
int interlace_method));
PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
png_uint_32 num_pal));
PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
#ifdef PNG_WRITE_gAMA_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
png_fixed_point file_gamma));
#endif
#endif
#ifdef PNG_WRITE_sBIT_SUPPORTED
PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
int color_type));
#endif
#ifdef PNG_WRITE_cHRM_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
double white_x, double white_y,
double red_x, double red_y, double green_x, double green_y,
double blue_x, double blue_y));
#endif
PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
png_fixed_point int_white_x, png_fixed_point int_white_y,
png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
png_fixed_point int_blue_y));
#endif
#ifdef PNG_WRITE_sRGB_SUPPORTED
PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
int intent));
#endif
#ifdef PNG_WRITE_iCCP_SUPPORTED
PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
png_charp name, int compression_type,
png_charp profile, int proflen));
/* Note to maintainer: profile should be png_bytep */
#endif
#ifdef PNG_WRITE_sPLT_SUPPORTED
PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
png_sPLT_tp palette));
#endif
#ifdef PNG_WRITE_tRNS_SUPPORTED
PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
png_color_16p values, int number, int color_type));
#endif
#ifdef PNG_WRITE_bKGD_SUPPORTED
PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
png_color_16p values, int color_type));
#endif
#ifdef PNG_WRITE_hIST_SUPPORTED
PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
int num_hist));
#endif
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
png_charp key, png_charpp new_key));
#endif
#ifdef PNG_WRITE_tEXt_SUPPORTED
PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len));
#endif
#ifdef PNG_WRITE_zTXt_SUPPORTED
PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len, int compression));
#endif
#ifdef PNG_WRITE_iTXt_SUPPORTED
PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
int compression, png_charp key, png_charp lang, png_charp lang_key,
png_charp text));
#endif
#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp text_ptr, int num_text));
#endif
#ifdef PNG_WRITE_oFFs_SUPPORTED
PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
png_int_32 x_offset, png_int_32 y_offset, int unit_type));
#endif
#ifdef PNG_WRITE_pCAL_SUPPORTED
PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
png_int_32 X0, png_int_32 X1, int type, int nparams,
png_charp units, png_charpp params));
#endif
#ifdef PNG_WRITE_pHYs_SUPPORTED
PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
int unit_type));
#endif
#ifdef PNG_WRITE_tIME_SUPPORTED
PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
png_timep mod_time));
#endif
#ifdef PNG_WRITE_sCAL_SUPPORTED
#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
int unit, double width, double height));
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
int unit, png_charp width, png_charp height));
#endif
#endif
#endif
/* Called when finished processing a row of data */
PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
/* Internal use only. Called before first row of data */
PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
#ifdef PNG_READ_GAMMA_SUPPORTED
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
png_byte bit_depth));
#endif
/* Combine a row of data, dealing with alpha, etc. if requested */
PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
int mask));
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Expand an interlaced row */
/* OLD pre-1.0.9 interface:
PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
png_bytep row, int pass, png_uint_32 transformations));
*/
PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
#endif
/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* Grab pixels out of a row for an interlaced pass */
PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
png_bytep row, int pass));
#endif
/* Unfilter a row */
PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
/* Choose the best filter to use and filter the row data */
PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
png_row_infop row_info));
/* Write out the filtered row. */
PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
png_bytep filtered_row));
/* Finish a row while reading, dealing with interlacing passes, etc. */
PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
/* Initialize the row buffers, etc. */
PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
/* Optional call to update the users info structure */
PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
png_infop info_ptr));
/* These are the functions that do the transformations */
#ifdef PNG_READ_FILLER_SUPPORTED
PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
png_bytep row, png_uint_32 filler, png_uint_32 flags));
#endif
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
png_bytep row, png_uint_32 flags));
#endif
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
defined(PNG_WRITE_PACKSWAP_SUPPORTED)
PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
row_info, png_bytep row));
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_READ_PACK_SUPPORTED
PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
#endif
#ifdef PNG_READ_SHIFT_SUPPORTED
PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
png_color_8p sig_bits));
#endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED
PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,
png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup));
# ifdef PNG_CORRECT_PALETTE_SUPPORTED
PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
png_colorp palette, int num_palette));
# endif
#endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
#endif
#ifdef PNG_WRITE_PACK_SUPPORTED
PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
png_bytep row, png_uint_32 bit_depth));
#endif
#ifdef PNG_WRITE_SHIFT_SUPPORTED
PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
png_color_8p bit_depth));
#endif
#ifdef PNG_READ_BACKGROUND_SUPPORTED
#ifdef PNG_READ_GAMMA_SUPPORTED
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
png_color_16p trans_color, png_color_16p background,
png_color_16p background_1,
png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
png_uint_16pp gamma_16_to_1, int gamma_shift));
#else
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
png_color_16p trans_color, png_color_16p background));
#endif
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
png_bytep gamma_table, png_uint_16pp gamma_16_table,
int gamma_shift));
#endif
#ifdef PNG_READ_EXPAND_SUPPORTED
PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
png_bytep row, png_color_16p trans_value));
#endif
/* The following decodes the appropriate chunks, and does error correction,
* then calls the appropriate callback for the chunk if it is valid.
*/
/* Decode the IHDR chunk */
PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#ifdef PNG_READ_bKGD_SUPPORTED
PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_hIST_SUPPORTED
PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_iCCP_SUPPORTED */
#ifdef PNG_READ_iTXt_SUPPORTED
PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_sPLT_SUPPORTED */
#ifdef PNG_READ_sRGB_SUPPORTED
PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_tIME_SUPPORTED
PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
png_bytep chunk_name));
/* Handle the transformations for reading and writing */
PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
png_uint_32 length));
PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t buffer_length));
PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t buffer_length));
PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
#ifdef PNG_READ_tEXt_SUPPORTED
PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
png_infop info_ptr));
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
png_infop info_ptr));
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
png_infop info_ptr));
#endif
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#ifdef PNG_MNG_FEATURES_SUPPORTED
PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
png_bytep row));
PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
png_bytep row));
#endif
/* Added at libpng version 1.4.0 */
#ifdef PNG_cHRM_SUPPORTED
PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
png_fixed_point int_white_x, png_fixed_point int_white_y,
png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
png_fixed_point int_blue_y));
#endif
#ifdef PNG_cHRM_SUPPORTED
#ifdef PNG_CHECK_cHRM_SUPPORTED
/* Added at libpng version 1.2.34 and 1.4.0 */
PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
unsigned long *hi_product, unsigned long *lo_product));
#endif
#endif
/* Added at libpng version 1.4.0 */
PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth,
int color_type, int interlace_type, int compression_type,
int filter_type));
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr));
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */
/* Define PNG_DEBUG at compile time for debugging information. Higher
* numbers for PNG_DEBUG mean more debugging information. This has
* only been added since version 0.95 so it is not implemented throughout
* libpng yet, but more support will be added as needed.
*/
#ifdef PNG_DEBUG
#if (PNG_DEBUG > 0)
#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
#include <crtdbg.h>
#if (PNG_DEBUG > 1)
#ifndef _DEBUG
# define _DEBUG
#endif
#ifndef png_debug
#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
#endif
#ifndef png_debug1
#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
#endif
#ifndef png_debug2
#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
#endif
#endif
#else /* PNG_DEBUG_FILE || !_MSC_VER */
#ifndef PNG_DEBUG_FILE
#define PNG_DEBUG_FILE stderr
#endif /* PNG_DEBUG_FILE */
#if (PNG_DEBUG > 1)
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
* non-ISO compilers
*/
# ifdef __STDC__
# ifndef png_debug
# define png_debug(l,m) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
}
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
}
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
}
# endif
# else /* __STDC __ */
# ifndef png_debug
# define png_debug(l,m) \
{ \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format); \
}
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1); \
}
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1,p2); \
}
# endif
# endif /* __STDC __ */
#endif /* (PNG_DEBUG > 1) */
#endif /* _MSC_VER */
#endif /* (PNG_DEBUG > 0) */
#endif /* PNG_DEBUG */
#ifndef png_debug
#define png_debug(l, m)
#endif
#ifndef png_debug1
#define png_debug1(l, m, p1)
#endif
#ifndef png_debug2
#define png_debug2(l, m, p1, p2)
#endif
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
#ifdef __cplusplus
}
#endif
#endif /* PNG_VERSION_INFO_ONLY */
#endif /* PNGPRIV_H */

428
engine/libs/mingw64-libs/zconf.h Executable file
View file

@ -0,0 +1,428 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
* Even better than compiling with -DZ_PREFIX would be to use configure to set
* this permanently in zconf.h using "./configure --zprefix".
*/
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
/* all linked symbols */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
# define _tr_tally z__tr_tally
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
# define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset
# define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzgetc z_gzgetc
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# define gzprintf z_gzprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define inflateBackInit_ z_inflateBackInit_
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
# define inflateGetHeader z_inflateGetHeader
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# define uncompress z_uncompress
# define zError z_zError
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
/* all zlib typedefs in zlib.h and zconf.h */
# define Byte z_Byte
# define Bytef z_Bytef
# define alloc_func z_alloc_func
# define charf z_charf
# define free_func z_free_func
# define gzFile z_gzFile
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func
# define intf z_intf
# define out_func z_out_func
# define uInt z_uInt
# define uIntf z_uIntf
# define uLong z_uLong
# define uLongf z_uLongf
# define voidp z_voidp
# define voidpc z_voidpc
# define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s
# define internal_state z_internal_state
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#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__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif
#ifdef STDC
# include <sys/types.h> /* for off_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
#if -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
# endif
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define z_off64_t off64_t
#else
# define z_off64_t z_off_t
#endif
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
#pragma map(deflateInit_,"DEIN")
#pragma map(deflateInit2_,"DEIN2")
#pragma map(deflateEnd,"DEEND")
#pragma map(deflateBound,"DEBND")
#pragma map(inflateInit_,"ININ")
#pragma map(inflateInit2_,"ININ2")
#pragma map(inflateEnd,"INEND")
#pragma map(inflateSync,"INSY")
#pragma map(inflateSetDictionary,"INSEDI")
#pragma map(compressBound,"CMBND")
#pragma map(inflate_table,"INTABL")
#pragma map(inflate_fast,"INFA")
#pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

1613
engine/libs/mingw64-libs/zlib.h Executable file

File diff suppressed because it is too large Load diff

274
engine/libs/mingw64-libs/zutil.h Executable file
View file

@ -0,0 +1,274 @@
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef ZUTIL_H
#define ZUTIL_H
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else
# define ZLIB_INTERNAL
#endif
#include "zlib.h"
#ifdef STDC
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h>
# endif
# include <string.h>
# include <stdlib.h>
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
#else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES 2
/* The three kinds of block type */
#define MIN_MATCH 3
#define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
#ifdef AMIGA
# define OS_CODE 0x01
#endif
#if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
#endif
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
# include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
#endif
#ifdef TOPS20
# define OS_CODE 0x0a
#endif
#ifdef WIN32
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# define OS_CODE 0x0b
# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0f
#endif
#if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
# define fdopen(fd,type) _fdopen(fd,type)
# endif
#endif
#if defined(__BORLANDC__)
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#endif
/* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
#endif
/* common defaults */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef F_OPEN
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#if defined(__CYGWIN__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# define vsnprintf _vsnprintf
# endif
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#if defined(pyr)
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
# define zmemcpy _fmemcpy
# define zmemcmp _fmemcmp
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# define zmemcpy memcpy
# define zmemcmp memcmp
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include <stdio.h>
extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
# define Assert(cond,msg)
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size));
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* ZUTIL_H */

View file

@ -7,6 +7,22 @@
#define Host_Error Sys_Error #define Host_Error Sys_Error
// I put the following here to resolve "undefined reference to `__imp__vsnprintf'" with MinGW64 ~ Moodles
#ifdef _WIN32
#if (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions
#define snprintf linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
#else
//msvc crap
#define snprintf linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif
#endif
//============================================================================= //=============================================================================
@ -28,7 +44,7 @@ return;
for ( ; i<10 ; i++) for ( ; i<10 ; i++)
printf (" "); printf (" ");
} }
if (s->op == OP_IF || s->op == OP_IFNOT) if (s->op == OP_IF || s->op == OP_IFNOT)
printf ("%sbranch %i",PR_GlobalString(progfuncs, s->a),s->b); printf ("%sbranch %i",PR_GlobalString(progfuncs, s->a),s->b);
else if (s->op == OP_GOTO) else if (s->op == OP_GOTO)
@ -84,13 +100,13 @@ void PR_StackTrace (progfuncs_t *progfuncs)
int *globalbase; int *globalbase;
#endif #endif
progs = -1; progs = -1;
if (pr_depth == 0) if (pr_depth == 0)
{ {
printf ("<NO STACK>\n"); printf ("<NO STACK>\n");
return; return;
} }
#ifdef STACKTRACE #ifdef STACKTRACE
globalbase = (int *)pr_globals + pr_xfunction->parm_start - pr_xfunction->locals; globalbase = (int *)pr_globals + pr_xfunction->parm_start - pr_xfunction->locals;
#endif #endif
@ -100,7 +116,7 @@ void PR_StackTrace (progfuncs_t *progfuncs)
for (i=pr_depth ; i>0 ; i--) for (i=pr_depth ; i>0 ; i--)
{ {
f = pr_stack[i].f; f = pr_stack[i].f;
if (!f) if (!f)
{ {
printf ("<NO FUNCTION>\n"); printf ("<NO FUNCTION>\n");
@ -216,8 +232,8 @@ void VARGS PR_RunError (progfuncs_t *progfuncs, char *error, ...)
printf ("\n"); printf ("\n");
//editbadfile(pr_strings + pr_xfunction->s_file, -1); //editbadfile(pr_strings + pr_xfunction->s_file, -1);
// pr_depth = 0; // dump the stack so host_error can shutdown functions // pr_depth = 0; // dump the stack so host_error can shutdown functions
// prinst->exitdepth = 0; // prinst->exitdepth = 0;
Abort ("%s", string); Abort ("%s", string);
@ -244,7 +260,7 @@ int PR_EnterFunction (progfuncs_t *progfuncs, dfunction_t *f, int progsnum)
int i, j, c, o; int i, j, c, o;
pr_stack[pr_depth].s = pr_xstatement; pr_stack[pr_depth].s = pr_xstatement;
pr_stack[pr_depth].f = pr_xfunction; pr_stack[pr_depth].f = pr_xfunction;
pr_stack[pr_depth].progsnum = progsnum; pr_stack[pr_depth].progsnum = progsnum;
pr_stack[pr_depth].pushed = pr_spushed; pr_stack[pr_depth].pushed = pr_spushed;
pr_depth++; pr_depth++;
@ -386,7 +402,7 @@ ddef32_t *ED_FindLocalOrGlobal(progfuncs_t *progfuncs, char *name, eval_t **val)
Sys_Error("Bad int size in ED_FindLocalOrGlobal"); Sys_Error("Bad int size in ED_FindLocalOrGlobal");
def32 = NULL; def32 = NULL;
} }
*val = (eval_t *)&pr_progstate[pr_typecurrent].globals[def32->ofs]; *val = (eval_t *)&pr_progstate[pr_typecurrent].globals[def32->ofs];
return &def; return &def;
} }
@ -426,7 +442,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
c = strchr(key, '.'); c = strchr(key, '.');
if (c) *c = '\0'; if (c) *c = '\0';
def = ED_FindLocalOrGlobal(progfuncs, key, &val); def = ED_FindLocalOrGlobal(progfuncs, key, &val);
if (!def) if (!def)
{ {
if (atoi(key)) if (atoi(key))
@ -440,13 +456,13 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
} }
if (c) *c = '.'; if (c) *c = '.';
if (!def) if (!def)
{ {
return "(Bad string)"; return "(Bad string)";
} }
type = def->type; type = def->type;
//go through ent vars //go through ent vars
c = strchr(key, '.'); c = strchr(key, '.');
while(c) while(c)
{ {
c2 = c+1; c2 = c+1;
@ -461,10 +477,10 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
if (c)*c = '.'; if (c)*c = '.';
if (!fdef) if (!fdef)
return "(Bad string)"; return "(Bad string)";
val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4); val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4);
type = fdef->type; type = fdef->type;
} }
if (assignment) if (assignment)
{ {
assignment++; assignment++;
@ -473,7 +489,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
case ev_string: case ev_string:
*(string_t *)val = PR_StringToProgs(progfuncs, ED_NewString (progfuncs, assignment, 0)); *(string_t *)val = PR_StringToProgs(progfuncs, ED_NewString (progfuncs, assignment, 0));
break; break;
case ev_float: case ev_float:
*(float *)val = (float)atof (assignment); *(float *)val = (float)atof (assignment);
break; break;
@ -481,7 +497,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
case ev_integer: case ev_integer:
*(int *)val = atoi (assignment); *(int *)val = atoi (assignment);
break; break;
/* case ev_vector: /* case ev_vector:
strcpy (string, assignment); strcpy (string, assignment);
v = string; v = string;
@ -576,7 +592,7 @@ void SetExecutionToLine(progfuncs_t *progfuncs, int linenum)
switch(current_progstate->intsize) switch(current_progstate->intsize)
{ {
case 16: case 16:
for (snum = f->first_statement; pr_progstate[pn].linenums[snum] < linenum; snum++) for (snum = f->first_statement; pr_progstate[pn].linenums[snum] < linenum; snum++)
{ {
if (pr_statements16[snum].op == OP_DONE) if (pr_statements16[snum].op == OP_DONE)
return; return;
@ -584,7 +600,7 @@ void SetExecutionToLine(progfuncs_t *progfuncs, int linenum)
break; break;
case 24: case 24:
case 32: case 32:
for (snum = f->first_statement; pr_progstate[pn].linenums[snum] < linenum; snum++) for (snum = f->first_statement; pr_progstate[pn].linenums[snum] < linenum; snum++)
{ {
if (pr_statements32[snum].op == OP_DONE) if (pr_statements32[snum].op == OP_DONE)
return; return;
@ -685,7 +701,7 @@ int PR_ToggleBreakpoint(progfuncs_t *progfuncs, char *filename, int linenum, int
default: default:
Sys_Error("Bad intsize"); Sys_Error("Bad intsize");
op = 0; op = 0;
} }
} }
goto cont; goto cont;
} }
@ -772,7 +788,7 @@ static char *lastfile = 0;
int pn = pr_typecurrent; int pn = pr_typecurrent;
int i; int i;
dfunction_t *f = pr_xfunction; dfunction_t *f = pr_xfunction;
if (f && pr_progstate[pn].linenums && externs->useeditor) if (f && pr_progstate[pn].linenums && externs->useeditor)
{ {
@ -806,7 +822,7 @@ static char *lastfile = 0;
externs->useeditor(progfuncs, f->s_file+progfuncs->stringtable, -1, 0, NULL); externs->useeditor(progfuncs, f->s_file+progfuncs->stringtable, -1, 0, NULL);
return statement; return statement;
} }
return statement; return statement;
} }
@ -881,11 +897,11 @@ restart: //jumped to when the progs might have changed.
#endif #endif
#undef DEBUGABLE #undef DEBUGABLE
} }
while(1) while(1)
{ {
#include "execloop.h" #include "execloop.h"
} }
#undef INTSIZE #undef INTSIZE
Sys_Error("PR_ExecuteProgram - should be unreachable"); Sys_Error("PR_ExecuteProgram - should be unreachable");
break; break;
@ -903,7 +919,7 @@ restart: //jumped to when the progs might have changed.
#endif #endif
#undef DEBUGABLE #undef DEBUGABLE
} }
while(1) while(1)
{ {
#ifdef SEPARATEINCLUDES #ifdef SEPARATEINCLUDES
@ -912,7 +928,7 @@ restart: //jumped to when the progs might have changed.
#include "execloop.h" #include "execloop.h"
#endif #endif
} }
#undef INTSIZE #undef INTSIZE
Sys_Error("PR_ExecuteProgram - should be unreachable"); Sys_Error("PR_ExecuteProgram - should be unreachable");
break; break;
default: default:
@ -1035,7 +1051,7 @@ struct qcthread_s *PR_ForkStack(progfuncs_t *progfuncs)
int localsoffset, baselocalsoffset; int localsoffset, baselocalsoffset;
qcthread_t *thread = memalloc(sizeof(qcthread_t)); qcthread_t *thread = memalloc(sizeof(qcthread_t));
dfunction_t *f; dfunction_t *f;
//copy out the functions stack. //copy out the functions stack.
for (i = 0,localsoffset=0; i < ed; i++) for (i = 0,localsoffset=0; i < ed; i++)
{ {
@ -1048,7 +1064,7 @@ struct qcthread_s *PR_ForkStack(progfuncs_t *progfuncs)
baselocalsoffset = localsoffset; baselocalsoffset = localsoffset;
for (i = ed; i < pr_depth; i++) for (i = ed; i < pr_depth; i++)
{ {
thread->fstack[i-ed].fnum = pr_stack[i].f - pr_progstate[pr_stack[i].progsnum].functions; thread->fstack[i-ed].fnum = pr_stack[i].f - pr_progstate[pr_stack[i].progsnum].functions;
thread->fstack[i-ed].progsnum = pr_stack[i].progsnum; thread->fstack[i-ed].progsnum = pr_stack[i].progsnum;
thread->fstack[i-ed].statement = pr_stack[i].s; thread->fstack[i-ed].statement = pr_stack[i].s;
@ -1138,7 +1154,7 @@ void PR_ResumeThread (progfuncs_t *progfuncs, struct qcthread_s *thread)
else else
{ {
pr_stack[pr_depth].progsnum = thread->fstack[i].progsnum; pr_stack[pr_depth].progsnum = thread->fstack[i].progsnum;
pr_stack[pr_depth].f = pr_progstate[thread->fstack[i].progsnum].functions + thread->fstack[i].fnum; pr_stack[pr_depth].f = pr_progstate[thread->fstack[i].progsnum].functions + thread->fstack[i].fnum;
pr_stack[pr_depth].s = thread->fstack[i].statement; pr_stack[pr_depth].s = thread->fstack[i].statement;
} }
@ -1158,7 +1174,7 @@ void PR_ResumeThread (progfuncs_t *progfuncs, struct qcthread_s *thread)
if (ls != thread->lstackused) if (ls != thread->lstackused)
PR_RunError(progfuncs, "Thread stores incorrect locals count\n"); PR_RunError(progfuncs, "Thread stores incorrect locals count\n");
f = &pr_functions[fnum]; f = &pr_functions[fnum];
// thread->lstackused -= f->locals; //the current function is the odd one out. // thread->lstackused -= f->locals; //the current function is the odd one out.

View file

@ -10,6 +10,22 @@
extern jmp_buf qcccompileerror; extern jmp_buf qcccompileerror;
#endif #endif
// I put the following here to resolve "undefined reference to `__imp__vsnprintf'" with MinGW64 ~ Moodles
#ifdef _WIN32
#if (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions
#define snprintf linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
#else
//msvc crap
#define snprintf linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif
#endif
// set these before calling CheckParm // set these before calling CheckParm
int myargc; int myargc;
char **myargv; char **myargv;
@ -83,13 +99,13 @@ int QCC_Long (int l)
float QCC_SwapFloat (float l) float QCC_SwapFloat (float l)
{ {
union {qbyte b[4]; float f;} in, out; union {qbyte b[4]; float f;} in, out;
in.f = l; in.f = l;
out.b[0] = in.b[3]; out.b[0] = in.b[3];
out.b[1] = in.b[2]; out.b[1] = in.b[2];
out.b[2] = in.b[1]; out.b[2] = in.b[1];
out.b[3] = in.b[0]; out.b[3] = in.b[0];
return out.f; return out.f;
} }
@ -138,13 +154,13 @@ double I_FloatTime (void)
static int secbase; static int secbase;
gettimeofday(&tp, &tzp); gettimeofday(&tp, &tzp);
if (!secbase) if (!secbase)
{ {
secbase = tp.tv_sec; secbase = tp.tv_sec;
return tp.tv_usec/1000000.0; return tp.tv_usec/1000000.0;
} }
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0; return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
} }
@ -155,7 +171,7 @@ double I_FloatTime (void)
int QC_strncasecmp (const char *s1, const char *s2, int n) int QC_strncasecmp (const char *s1, const char *s2, int n)
{ {
int c1, c2; int c1, c2;
while (1) while (1)
{ {
c1 = *s1++; c1 = *s1++;
@ -163,7 +179,7 @@ int QC_strncasecmp (const char *s1, const char *s2, int n)
if (!n--) if (!n--)
return 0; // strings are equal until end point return 0; // strings are equal until end point
if (c1 != c2) if (c1 != c2)
{ {
if (c1 >= 'a' && c1 <= 'z') if (c1 >= 'a' && c1 <= 'z')
@ -178,7 +194,7 @@ int QC_strncasecmp (const char *s1, const char *s2, int n)
// s1++; // s1++;
// s2++; // s2++;
} }
return -1; return -1;
} }
@ -210,13 +226,13 @@ char *QCC_COM_Parse (char *data)
{ {
int c; int c;
int len; int len;
len = 0; len = 0;
qcc_token[0] = 0; qcc_token[0] = 0;
if (!data) if (!data)
return NULL; return NULL;
// skip whitespace // skip whitespace
skipwhite: skipwhite:
while ( (c = *data) <= ' ') while ( (c = *data) <= ' ')
@ -228,7 +244,7 @@ skipwhite:
} }
data++; data++;
} }
// skip // comments // skip // comments
if (c=='/' && data[1] == '/') if (c=='/' && data[1] == '/')
{ {
@ -245,7 +261,7 @@ skipwhite:
data+=2; data+=2;
goto skipwhite; goto skipwhite;
} }
// handle quoted strings specially // handle quoted strings specially
if (c == '\"') if (c == '\"')
@ -297,7 +313,7 @@ skipwhite:
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':' || c=='\"' || c==',') if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':' || c=='\"' || c==',')
break; break;
} while (c>32); } while (c>32);
qcc_token[len] = 0; qcc_token[len] = 0;
return data; return data;
} }
@ -307,13 +323,13 @@ char *QCC_COM_Parse2 (char *data)
{ {
int c; int c;
int len; int len;
len = 0; len = 0;
qcc_token[0] = 0; qcc_token[0] = 0;
if (!data) if (!data)
return NULL; return NULL;
// skip whitespace // skip whitespace
skipwhite: skipwhite:
while ( (c = *data) <= ' ') while ( (c = *data) <= ' ')
@ -325,7 +341,7 @@ skipwhite:
} }
data++; data++;
} }
// skip // comments // skip // comments
if (c=='/' && data[1] == '/') if (c=='/' && data[1] == '/')
{ {
@ -333,7 +349,7 @@ skipwhite:
data++; data++;
goto skipwhite; goto skipwhite;
} }
// handle quoted strings specially // handle quoted strings specially
if (c == '\"') if (c == '\"')
@ -389,7 +405,7 @@ skipwhite:
break; break;
} }
} }
qcc_token[len] = 0; qcc_token[len] = 0;
return data; return data;
} }
@ -403,7 +419,7 @@ skipwhite:
len++; len++;
c = *data; c = *data;
} while ((c>= 'a' && c <= 'z') || (c>= 'A' && c <= 'Z') || c == '_'); } while ((c>= 'a' && c <= 'z') || (c>= 'A' && c <= 'Z') || c == '_');
qcc_token[len] = 0; qcc_token[len] = 0;
return data; return data;
} }
@ -419,7 +435,7 @@ skipwhite:
char *VARGS qcva (char *text, ...) char *VARGS qcva (char *text, ...)
{ {
va_list argptr; va_list argptr;
static char msg[2048]; static char msg[2048];
va_start (argptr,text); va_start (argptr,text);
QC_vsnprintf (msg,sizeof(msg)-1, text,argptr); QC_vsnprintf (msg,sizeof(msg)-1, text,argptr);
@ -475,7 +491,7 @@ void VARGS QCC_Error (int errortype, const char *error, ...)
{ {
extern int numsourcefiles; extern int numsourcefiles;
va_list argptr; va_list argptr;
char msg[2048]; char msg[2048];
va_start (argptr,error); va_start (argptr,error);
QC_vsnprintf (msg,sizeof(msg)-1, error,argptr); QC_vsnprintf (msg,sizeof(msg)-1, error,argptr);
@ -489,7 +505,7 @@ void VARGS QCC_Error (int errortype, const char *error, ...)
numsourcefiles = 0; numsourcefiles = 0;
#ifndef QCC #ifndef QCC
longjmp(qcccompileerror, 1); longjmp(qcccompileerror, 1);
#else #else
print ("Press any key\n"); print ("Press any key\n");
getch(); getch();
@ -532,7 +548,7 @@ int SafeOpenWrite (char *filename)
int handle; int handle;
umask (0); umask (0);
handle = open(filename,O_WRONLY | O_CREAT | O_TRUNC | O_BINARY handle = open(filename,O_WRONLY | O_CREAT | O_TRUNC | O_BINARY
, 0666); , 0666);
@ -776,7 +792,7 @@ int SafeOpenWrite (char *filename, int maxsize)
void ResizeBuf(int hand, int newsize) void ResizeBuf(int hand, int newsize)
{ {
// int wasmal = qccfile[hand].buffismalloc; // int wasmal = qccfile[hand].buffismalloc;
char *nb; char *nb;
if (qccfile[hand].buffsize >= newsize) if (qccfile[hand].buffsize >= newsize)
@ -792,7 +808,7 @@ void ResizeBuf(int hand, int newsize)
// qccfile[hand].buffismalloc = false; // qccfile[hand].buffismalloc = false;
// nb = memalloc(newsize); // nb = memalloc(newsize);
// } // }
memcpy(nb, qccfile[hand].buff, qccfile[hand].maxofs); memcpy(nb, qccfile[hand].buff, qccfile[hand].maxofs);
// if (wasmal) // if (wasmal)
free(qccfile[hand].buff); free(qccfile[hand].buff);
@ -826,7 +842,7 @@ int SafeSeek(int hand, int ofs, int mode)
} }
void SafeClose(int hand) void SafeClose(int hand)
{ {
externs->WriteFile(qccfile[hand].name, qccfile[hand].buff, qccfile[hand].maxofs); externs->WriteFile(qccfile[hand].name, qccfile[hand].buff, qccfile[hand].maxofs);
// if (qccfile[hand].buffismalloc) // if (qccfile[hand].buffismalloc)
free(qccfile[hand].buff); free(qccfile[hand].buff);
// else // else
@ -847,21 +863,21 @@ long QCC_LoadFile (char *filename, void **bufferptr)
return -1; return -1;
// Abort("failed to find file %s", filename); // Abort("failed to find file %s", filename);
} }
mem = qccHunkAlloc(sizeof(qcc_cachedsourcefile_t) + len+2); mem = qccHunkAlloc(sizeof(qcc_cachedsourcefile_t) + len+2);
((qcc_cachedsourcefile_t*)mem)->next = qcc_sourcefile; ((qcc_cachedsourcefile_t*)mem)->next = qcc_sourcefile;
qcc_sourcefile = (qcc_cachedsourcefile_t*)mem; qcc_sourcefile = (qcc_cachedsourcefile_t*)mem;
qcc_sourcefile->size = len; qcc_sourcefile->size = len;
mem += sizeof(qcc_cachedsourcefile_t); mem += sizeof(qcc_cachedsourcefile_t);
strcpy(qcc_sourcefile->filename, filename); strcpy(qcc_sourcefile->filename, filename);
qcc_sourcefile->file = mem; qcc_sourcefile->file = mem;
qcc_sourcefile->type = FT_CODE; qcc_sourcefile->type = FT_CODE;
externs->ReadFile(filename, mem, len+2); externs->ReadFile(filename, mem, len+2);
mem[len] = '\n'; mem[len] = '\n';
mem[len+1] = '\0'; mem[len+1] = '\0';
*bufferptr=mem; *bufferptr=mem;
return len; return len;
} }
void QCC_AddFile (char *filename) void QCC_AddFile (char *filename)
@ -871,12 +887,12 @@ void QCC_AddFile (char *filename)
len = externs->FileSize(filename); len = externs->FileSize(filename);
if (len < 0) if (len < 0)
Abort("failed to find file %s", filename); Abort("failed to find file %s", filename);
mem = qccHunkAlloc(sizeof(qcc_cachedsourcefile_t) + len+1); mem = qccHunkAlloc(sizeof(qcc_cachedsourcefile_t) + len+1);
((qcc_cachedsourcefile_t*)mem)->next = qcc_sourcefile; ((qcc_cachedsourcefile_t*)mem)->next = qcc_sourcefile;
qcc_sourcefile = (qcc_cachedsourcefile_t*)mem; qcc_sourcefile = (qcc_cachedsourcefile_t*)mem;
qcc_sourcefile->size = len; qcc_sourcefile->size = len;
mem += sizeof(qcc_cachedsourcefile_t); mem += sizeof(qcc_cachedsourcefile_t);
strcpy(qcc_sourcefile->filename, filename); strcpy(qcc_sourcefile->filename, filename);
qcc_sourcefile->file = mem; qcc_sourcefile->file = mem;
qcc_sourcefile->type = FT_DATA; qcc_sourcefile->type = FT_DATA;

View file

@ -6,6 +6,22 @@
#endif #endif
#include "time.h" #include "time.h"
// I put the following here to resolve "undefined reference to `__imp__vsnprintf'" with MinGW64 ~ Moodles
#ifdef _WIN32
#if (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions
#define snprintf linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
#else
//msvc crap
#define snprintf linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif
#endif
#define MEMBERFIELDNAME "__m%s" #define MEMBERFIELDNAME "__m%s"
#define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1)) //saves about 2-6 out of 120 - expansion of idea from fastqcc #define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1)) //saves about 2-6 out of 120 - expansion of idea from fastqcc
@ -216,7 +232,7 @@ int ParsePrecompilerIf(void)
int eval; int eval;
char *start = pr_file_p; char *start = pr_file_p;
if (!QCC_PR_SimpleGetToken()) if (!QCC_PR_SimpleGetToken())
{ {
if (*pr_file_p == '(') if (*pr_file_p == '(')
{ {
eval = ParsePrecompilerIf(); eval = ParsePrecompilerIf();
@ -365,7 +381,7 @@ pbool QCC_PR_Precompiler(void)
eval = true; eval = true;
if (ifmode == 1) if (ifmode == 1)
eval = eval?false:true; eval = eval?false:true;
} }
while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
@ -470,11 +486,11 @@ pbool QCC_PR_Precompiler(void)
} }
} }
else if (!strncmp(directive, "endif", 5)) else if (!strncmp(directive, "endif", 5))
{ {
while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
{ {
pr_file_p++; pr_file_p++;
} }
if (ifs <= 0) if (ifs <= 0)
QCC_PR_ParseError(ERR_NOPRECOMPILERIF, "unmatched #endif"); QCC_PR_ParseError(ERR_NOPRECOMPILERIF, "unmatched #endif");
else else
@ -486,7 +502,7 @@ pbool QCC_PR_Precompiler(void)
return true; return true;
} }
else if (!strncmp(directive, "error", 5)) else if (!strncmp(directive, "error", 5))
{ {
pr_file_p = directive+5; pr_file_p = directive+5;
for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++) for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a]; msg[a] = pr_file_p[a];
@ -501,7 +517,7 @@ pbool QCC_PR_Precompiler(void)
QCC_PR_ParseError(ERR_HASHERROR, "#Error: %s", msg); QCC_PR_ParseError(ERR_HASHERROR, "#Error: %s", msg);
} }
else if (!strncmp(directive, "warning", 7)) else if (!strncmp(directive, "warning", 7))
{ {
pr_file_p = directive+7; pr_file_p = directive+7;
for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++) for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a]; msg[a] = pr_file_p[a];
@ -516,7 +532,7 @@ pbool QCC_PR_Precompiler(void)
QCC_PR_ParseWarning(WARN_PRECOMPILERMESSAGE, "#warning: %s", msg); QCC_PR_ParseWarning(WARN_PRECOMPILERMESSAGE, "#warning: %s", msg);
} }
else if (!strncmp(directive, "message", 7)) else if (!strncmp(directive, "message", 7))
{ {
pr_file_p = directive+7; pr_file_p = directive+7;
for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++) for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a]; msg[a] = pr_file_p[a];
@ -553,9 +569,9 @@ pbool QCC_PR_Precompiler(void)
pr_file_p=directive+4; pr_file_p=directive+4;
if (!strncmp(pr_file_p, "id", 2)) if (!strncmp(pr_file_p, "id", 2))
pr_file_p+=3; pr_file_p+=3;
else else
{ {
ifmode = QCC_PR_LexInteger(); ifmode = QCC_PR_LexInteger();
if (ifmode == 0) if (ifmode == 0)
ifmode = 1; ifmode = 1;
pr_file_p++; pr_file_p++;
@ -575,16 +591,16 @@ pbool QCC_PR_Precompiler(void)
else if (ifmode <= 5) else if (ifmode <= 5)
strcpy(QCC_Packname[ifmode-1], msg); strcpy(QCC_Packname[ifmode-1], msg);
else else
QCC_PR_ParseError(ERR_TOOMANYPACKFILES, "No more than 5 packs are allowed"); QCC_PR_ParseError(ERR_TOOMANYPACKFILES, "No more than 5 packs are allowed");
} }
else if (!strncmp(directive, "forcecrc", 8)) else if (!strncmp(directive, "forcecrc", 8))
{ {
pr_file_p=directive+8; pr_file_p=directive+8;
ForcedCRC = QCC_PR_LexInteger(); ForcedCRC = QCC_PR_LexInteger();
pr_file_p++; pr_file_p++;
for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++) for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a]; msg[a] = pr_file_p[a];
@ -593,7 +609,7 @@ pbool QCC_PR_Precompiler(void)
while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
{ {
pr_file_p++; pr_file_p++;
} }
} }
else if (!strncmp(directive, "includelist", 11)) else if (!strncmp(directive, "includelist", 11))
{ {
@ -634,7 +650,7 @@ pbool QCC_PR_Precompiler(void)
pr_file_p++; pr_file_p++;
} }
} }
while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
{ {
pr_file_p++; pr_file_p++;
@ -687,7 +703,7 @@ pbool QCC_PR_Precompiler(void)
} }
} }
else if (!strncmp(directive, "datafile", 8)) else if (!strncmp(directive, "datafile", 8))
{ {
pr_file_p=directive+8; pr_file_p=directive+8;
while(*pr_file_p <= ' ') while(*pr_file_p <= ' ')
@ -722,7 +738,7 @@ pbool QCC_PR_Precompiler(void)
printf("Outputfile: %s\n", destfile); printf("Outputfile: %s\n", destfile);
pr_file_p++; pr_file_p++;
for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++) for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a]; msg[a] = pr_file_p[a];
@ -751,7 +767,7 @@ pbool QCC_PR_Precompiler(void)
} }
msg[a++] = *pr_file_p; msg[a++] = *pr_file_p;
} }
msg[a] = '\0'; msg[a] = '\0';
{ {
char *end; char *end;
@ -868,7 +884,7 @@ pbool QCC_PR_Precompiler(void)
#ifndef QCCONLY #ifndef QCCONLY
p=0; p=0;
s2 = qcc_token; s2 = qcc_token;
if (!strncmp(s2, "./", 2)) if (!strncmp(s2, "./", 2))
s2+=2; s2+=2;
else else
@ -1019,7 +1035,7 @@ void QCC_PR_LexString (void)
int c; int c;
int len; int len;
char tmpbuf[2048]; char tmpbuf[2048];
char *text; char *text;
char *oldf; char *oldf;
int oldline; int oldline;
@ -1088,12 +1104,12 @@ void QCC_PR_LexString (void)
pr_file_p = oldf-1; pr_file_p = oldf-1;
QCC_PR_LexWhitespace(); QCC_PR_LexWhitespace();
if (*pr_file_p != '\"') //annother string if (*pr_file_p != '\"') //annother string
break; break;
} }
QCC_PR_LexWhitespace(); QCC_PR_LexWhitespace();
text = pr_file_p; text = pr_file_p;
} while (1); } while (1);
strcpy(pr_token, tmpbuf); strcpy(pr_token, tmpbuf);
@ -1236,7 +1252,7 @@ void QCC_PR_LexString (void)
pr_token[len] = 0; pr_token[len] = 0;
pr_token_type = tt_immediate; pr_token_type = tt_immediate;
pr_immediate_type = type_string; pr_immediate_type = type_string;
strcpy (pr_immediate_string, pr_token); strcpy (pr_immediate_string, pr_token);
return; return;
} }
else if (c == '#') else if (c == '#')
@ -1313,7 +1329,7 @@ int QCC_PR_LexInteger (void)
{ {
int c; int c;
int len; int len;
len = 0; len = 0;
c = *pr_file_p; c = *pr_file_p;
if (pr_file_p[0] == '0' && pr_file_p[1] == 'x') if (pr_file_p[0] == '0' && pr_file_p[1] == 'x')
@ -1363,7 +1379,7 @@ void QCC_PR_LexNumber (void)
base = 10; base = 10;
while((c = *pr_file_p)) while((c = *pr_file_p))
{ {
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
{ {
pr_token[tokenlen++] = c; pr_token[tokenlen++] = c;
@ -1400,7 +1416,7 @@ void QCC_PR_LexNumber (void)
break; break;
} }
else else
{ {
break; break;
} }
pr_file_p++; pr_file_p++;
@ -1452,7 +1468,7 @@ float QCC_PR_LexFloat (void)
{ {
int c; int c;
int len; int len;
len = 0; len = 0;
c = *pr_file_p; c = *pr_file_p;
do do
@ -1476,7 +1492,7 @@ Parses a single quoted vector
void QCC_PR_LexVector (void) void QCC_PR_LexVector (void)
{ {
int i; int i;
pr_file_p++; pr_file_p++;
if (*pr_file_p == '\\') if (*pr_file_p == '\\')
@ -1554,7 +1570,7 @@ void QCC_PR_LexName (void)
{ {
int c; int c;
int len; int len;
len = 0; len = 0;
c = *pr_file_p; c = *pr_file_p;
do do
@ -1563,11 +1579,11 @@ void QCC_PR_LexName (void)
len++; len++;
pr_file_p++; pr_file_p++;
c = *pr_file_p; c = *pr_file_p;
} while ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' } while ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'
|| (c >= '0' && c <= '9')); || (c >= '0' && c <= '9'));
pr_token[len] = 0; pr_token[len] = 0;
pr_token_type = tt_name; pr_token_type = tt_name;
} }
/* /*
@ -1580,9 +1596,9 @@ void QCC_PR_LexPunctuation (void)
int i; int i;
int len; int len;
char *p; char *p;
pr_token_type = tt_punct; pr_token_type = tt_punct;
for (i=0 ; (p = pr_punctuation[i]) != NULL ; i++) for (i=0 ; (p = pr_punctuation[i]) != NULL ; i++)
{ {
len = strlen(p); len = strlen(p);
@ -1597,11 +1613,11 @@ void QCC_PR_LexPunctuation (void)
return; return;
} }
} }
QCC_PR_ParseError (ERR_UNKNOWNPUCTUATION, "Unknown punctuation"); QCC_PR_ParseError (ERR_UNKNOWNPUCTUATION, "Unknown punctuation");
} }
/* /*
============== ==============
PR_LexWhitespace PR_LexWhitespace
@ -1610,7 +1626,7 @@ PR_LexWhitespace
void QCC_PR_LexWhitespace (void) void QCC_PR_LexWhitespace (void)
{ {
int c; int c;
while (1) while (1)
{ {
// skip whitespace // skip whitespace
@ -1630,7 +1646,7 @@ void QCC_PR_LexWhitespace (void)
pr_file_p++; pr_file_p++;
} }
} }
// skip // comments // skip // comments
if (c=='/' && pr_file_p[1] == '/') if (c=='/' && pr_file_p[1] == '/')
{ {
@ -1642,7 +1658,7 @@ void QCC_PR_LexWhitespace (void)
QCC_PR_NewLine(false); QCC_PR_NewLine(false);
continue; continue;
} }
// skip /* */ comments // skip /* */ comments
if (c=='/' && pr_file_p[1] == '*') if (c=='/' && pr_file_p[1] == '*')
{ {
@ -1663,7 +1679,7 @@ void QCC_PR_LexWhitespace (void)
pr_file_p+=2; pr_file_p+=2;
continue; continue;
} }
break; // a real character has been found break; // a real character has been found
} }
} }
@ -1839,7 +1855,7 @@ Deals with counting sequence numbers and replacing frame macros
============== ==============
*/ */
void QCC_PR_LexGrab (void) void QCC_PR_LexGrab (void)
{ {
pr_file_p++; // skip the $ pr_file_p++; // skip the $
// if (!QCC_PR_SimpleGetToken ()) // if (!QCC_PR_SimpleGetToken ())
// QCC_PR_ParseError ("hanging $"); // QCC_PR_ParseError ("hanging $");
@ -1848,7 +1864,7 @@ void QCC_PR_LexGrab (void)
QCC_PR_LexMacroName(); QCC_PR_LexMacroName();
if (!*pr_token) if (!*pr_token)
QCC_PR_ParseError (ERR_BADFRAMEMACRO, "hanging $"); QCC_PR_ParseError (ERR_BADFRAMEMACRO, "hanging $");
// check for $frame // check for $frame
if (!STRCMP (pr_token, "frame") || !STRCMP (pr_token, "framesave")) if (!STRCMP (pr_token, "frame") || !STRCMP (pr_token, "framesave"))
{ {
@ -1878,7 +1894,7 @@ void QCC_PR_LexGrab (void)
{ {
QCC_PR_LexMacroName (); QCC_PR_LexMacroName ();
pr_macrovalue = atoi(pr_token); pr_macrovalue = atoi(pr_token);
QCC_PR_Lex (); QCC_PR_Lex ();
} }
else if (!STRCMP (pr_token, "framerestore")) else if (!STRCMP (pr_token, "framerestore"))
@ -1886,7 +1902,7 @@ void QCC_PR_LexGrab (void)
QCC_PR_LexMacroName (); QCC_PR_LexMacroName ();
QCC_PR_ExpandMacro(); QCC_PR_ExpandMacro();
pr_macrovalue = (int)pr_immediate._float; pr_macrovalue = (int)pr_immediate._float;
QCC_PR_Lex (); QCC_PR_Lex ();
} }
else if (!STRCMP (pr_token, "modelname")) else if (!STRCMP (pr_token, "modelname"))
@ -1905,7 +1921,7 @@ void QCC_PR_LexGrab (void)
pr_macrovalue = i; pr_macrovalue = i;
else else
i = 0; i = 0;
QCC_PR_Lex (); QCC_PR_Lex ();
} }
// look for a frame name macro // look for a frame name macro
@ -1941,7 +1957,7 @@ CompilerConstant_t *QCC_PR_DefineName(char *name)
if (strlen(name) >= MAXCONSTANTLENGTH || !*name) if (strlen(name) >= MAXCONSTANTLENGTH || !*name)
QCC_PR_ParseError(ERR_NAMETOOLONG, "Compiler constant name length is too long or short"); QCC_PR_ParseError(ERR_NAMETOOLONG, "Compiler constant name length is too long or short");
cnst = pHash_Get(&compconstantstable, name); cnst = pHash_Get(&compconstantstable, name);
if (cnst) if (cnst)
{ {
@ -1984,7 +2000,7 @@ void QCC_PR_ConditionCompilation(void)
QCC_PR_SimpleGetToken (); QCC_PR_SimpleGetToken ();
if (!QCC_PR_SimpleGetToken ()) if (!QCC_PR_SimpleGetToken ())
QCC_PR_ParseError(ERR_NONAME, "No name defined for compiler constant"); QCC_PR_ParseError(ERR_NONAME, "No name defined for compiler constant");
cnst = pHash_Get(&compconstantstable, pr_token); cnst = pHash_Get(&compconstantstable, pr_token);
@ -2056,7 +2072,7 @@ void QCC_PR_ConditionCompilation(void)
*d++ = *s++; *d++ = *s++;
} }
} }
} }
else if(*s == '\r' || *s == '\n' || *s == '\0') else if(*s == '\r' || *s == '\n' || *s == '\0')
{ {
break; break;
@ -2326,7 +2342,7 @@ int QCC_PR_CheakCompConst(void)
return true; return true;
} }
if (!strncmp(pr_file_p, "__FILE__", 8)) if (!strncmp(pr_file_p, "__FILE__", 8))
{ {
static char retbuf[256]; static char retbuf[256];
sprintf(retbuf, "\"%s\"", strings + s_file); sprintf(retbuf, "\"%s\"", strings + s_file);
pr_file_p = retbuf; pr_file_p = retbuf;
@ -2345,7 +2361,7 @@ int QCC_PR_CheakCompConst(void)
return true; return true;
} }
if (!strncmp(pr_file_p, "__FUNC__", 8)) if (!strncmp(pr_file_p, "__FUNC__", 8))
{ {
static char retbuf[256]; static char retbuf[256];
sprintf(retbuf, "\"%s\"",pr_scope->name); sprintf(retbuf, "\"%s\"",pr_scope->name);
pr_file_p = retbuf; pr_file_p = retbuf;
@ -2368,12 +2384,12 @@ int QCC_PR_CheakCompConst(void)
char *QCC_PR_CheakCompConstString(char *def) char *QCC_PR_CheakCompConstString(char *def)
{ {
char *s; char *s;
CompilerConstant_t *c; CompilerConstant_t *c;
c = pHash_Get(&compconstantstable, def); c = pHash_Get(&compconstantstable, def);
if (c) if (c)
{ {
s = QCC_PR_CheakCompConstString(c->value); s = QCC_PR_CheakCompConstString(c->value);
return s; return s;
@ -2401,11 +2417,11 @@ void QCC_PR_Lex (void)
int c; int c;
pr_token[0] = 0; pr_token[0] = 0;
if (!pr_file_p) if (!pr_file_p)
{ {
if (QCC_PR_UnInclude()) if (QCC_PR_UnInclude())
{ {
QCC_PR_Lex(); QCC_PR_Lex();
return; return;
} }
@ -2418,7 +2434,7 @@ void QCC_PR_Lex (void)
if (!pr_file_p) if (!pr_file_p)
{ {
if (QCC_PR_UnInclude()) if (QCC_PR_UnInclude())
{ {
QCC_PR_Lex(); QCC_PR_Lex();
return; return;
} }
@ -2427,11 +2443,11 @@ void QCC_PR_Lex (void)
} }
c = *pr_file_p; c = *pr_file_p;
if (!c) if (!c)
{ {
if (QCC_PR_UnInclude()) if (QCC_PR_UnInclude())
{ {
QCC_PR_Lex(); QCC_PR_Lex();
return; return;
} }
@ -2492,7 +2508,7 @@ void QCC_PR_Lex (void)
return; return;
} }
if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' ) if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' )
{ {
if (flag_hashonly || !QCC_PR_CheakCompConst()) //look for a macro. if (flag_hashonly || !QCC_PR_CheakCompConst()) //look for a macro.
@ -2501,7 +2517,7 @@ void QCC_PR_Lex (void)
if (pr_token_type == tt_eof) if (pr_token_type == tt_eof)
{ {
if (QCC_PR_UnInclude()) if (QCC_PR_UnInclude())
{ {
QCC_PR_Lex(); QCC_PR_Lex();
return; return;
} }
@ -2509,13 +2525,13 @@ void QCC_PR_Lex (void)
} }
return; return;
} }
if (c == '$') if (c == '$')
{ {
QCC_PR_LexGrab (); QCC_PR_LexGrab ();
return; return;
} }
// parse symbol strings until a non-symbol is found // parse symbol strings until a non-symbol is found
QCC_PR_LexPunctuation (); QCC_PR_LexPunctuation ();
} }
@ -2583,7 +2599,7 @@ void VARGS QCC_PR_ParseError (int errortype, char *error, ...)
printf ("%s(%i) : error: %s\n", strings + s_file, pr_source_line, string); printf ("%s(%i) : error: %s\n", strings + s_file, pr_source_line, string);
else else
printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string); printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string);
longjmp (pr_parse_abort, 1); longjmp (pr_parse_abort, 1);
} }
void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error, ...) void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error, ...)
@ -2605,7 +2621,7 @@ void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error
printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string); printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string);
QCC_PR_ParsePrintDef(WARN_ERROR, def); QCC_PR_ParsePrintDef(WARN_ERROR, def);
longjmp (pr_parse_abort, 1); longjmp (pr_parse_abort, 1);
} }
void VARGS QCC_PR_ParseWarning (int type, char *error, ...) void VARGS QCC_PR_ParseWarning (int type, char *error, ...)
@ -2723,7 +2739,7 @@ pbool QCC_PR_CheckToken (char *string)
if (STRCMP (string, pr_token)) if (STRCMP (string, pr_token))
return false; return false;
QCC_PR_Lex (); QCC_PR_Lex ();
return true; return true;
} }
@ -2735,7 +2751,7 @@ pbool QCC_PR_CheckImmediate (char *string)
if (STRCMP (string, pr_token)) if (STRCMP (string, pr_token))
return false; return false;
QCC_PR_Lex (); QCC_PR_Lex ();
return true; return true;
} }
@ -2744,7 +2760,7 @@ pbool QCC_PR_CheckName(char *string)
{ {
if (pr_token_type != tt_name) if (pr_token_type != tt_name)
return false; return false;
if (flag_caseinsensative) if (flag_caseinsensative)
{ {
if (stricmp (string, pr_token)) if (stricmp (string, pr_token))
return false; return false;
@ -2762,7 +2778,7 @@ pbool QCC_PR_CheckKeyword(int keywordenabled, char *string)
{ {
if (!keywordenabled) if (!keywordenabled)
return false; return false;
if (flag_caseinsensative) if (flag_caseinsensative)
{ {
if (stricmp (string, pr_token)) if (stricmp (string, pr_token))
return false; return false;
@ -2789,14 +2805,14 @@ char *QCC_PR_ParseName (void)
{ {
static char ident[MAX_NAME]; static char ident[MAX_NAME];
char *ret; char *ret;
if (pr_token_type != tt_name) if (pr_token_type != tt_name)
QCC_PR_ParseError (ERR_NOTANAME, "\"%s\" - not a name", pr_token); QCC_PR_ParseError (ERR_NOTANAME, "\"%s\" - not a name", pr_token);
if (strlen(pr_token) >= MAX_NAME-1) if (strlen(pr_token) >= MAX_NAME-1)
QCC_PR_ParseError (ERR_NAMETOOLONG, "name too long"); QCC_PR_ParseError (ERR_NAMETOOLONG, "name too long");
strcpy (ident, pr_token); strcpy (ident, pr_token);
QCC_PR_Lex (); QCC_PR_Lex ();
ret = qccHunkAlloc(strlen(ident)+1); ret = qccHunkAlloc(strlen(ident)+1);
strcpy(ret, ident); strcpy(ret, ident);
return ret; return ret;
@ -2945,7 +2961,7 @@ QCC_type_t *QCC_PR_FindType (QCC_type_t *type)
// check = &qcc_typeinfo[t]; // check = &qcc_typeinfo[t];
if (typecmp(&qcc_typeinfo[t], type)) if (typecmp(&qcc_typeinfo[t], type))
continue; continue;
// c2 = check->next; // c2 = check->next;
// n2 = type->next; // n2 = type->next;
@ -3095,7 +3111,7 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype)
strcpy (pr_parm_names[ftype->num_parms], ""); strcpy (pr_parm_names[ftype->num_parms], "");
ftype->num_parms++; ftype->num_parms++;
} while (QCC_PR_CheckToken (",")); } while (QCC_PR_CheckToken (","));
QCC_PR_Expect (")"); QCC_PR_Expect (")");
} }
recursivefunctiontype--; recursivefunctiontype--;
@ -3172,7 +3188,7 @@ QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype)
strcpy (pr_parm_names[ftype->num_parms], name); strcpy (pr_parm_names[ftype->num_parms], name);
ftype->num_parms++; ftype->num_parms++;
} while (QCC_PR_CheckToken (";")); } while (QCC_PR_CheckToken (";"));
QCC_PR_Expect (")"); QCC_PR_Expect (")");
} }
recursivefunctiontype--; recursivefunctiontype--;
@ -3265,7 +3281,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
{ {
newt = &qcc_typeinfo[i]; newt = &qcc_typeinfo[i];
break; break;
} }
} }
if (newt && forwarddeclaration) if (newt && forwarddeclaration)
@ -3287,7 +3303,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
return NULL; return NULL;
} }
if (QCC_PR_CheckToken(":")) if (QCC_PR_CheckToken(":"))
{ {
@ -3403,7 +3419,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
newt = QCC_PR_NewType("union", ev_union); newt = QCC_PR_NewType("union", ev_union);
newt->size=0; newt->size=0;
QCC_PR_Expect("{"); QCC_PR_Expect("{");
type = NULL; type = NULL;
if (QCC_PR_CheckToken(",")) if (QCC_PR_CheckToken(","))
QCC_PR_ParseError(ERR_NOTANAME, "element missing name"); QCC_PR_ParseError(ERR_NOTANAME, "element missing name");
@ -3430,7 +3446,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
if (newparm->size > newt->size) if (newparm->size > newt->size)
newt->size = newparm->size; newt->size = newparm->size;
newt->num_parms++; newt->num_parms++;
if (type) if (type)
type->next = newparm; type->next = newparm;
else else
@ -3472,7 +3488,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
} }
} }
QCC_PR_Lex (); QCC_PR_Lex ();
if (QCC_PR_CheckToken ("(")) //this is followed by parameters. Must be a function. if (QCC_PR_CheckToken ("(")) //this is followed by parameters. Must be a function.
{ {
type_inlinefunction = true; type_inlinefunction = true;
@ -3482,7 +3498,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
{ {
if (newtype) if (newtype)
{ {
type = QCC_PR_DuplicateType(type); type = QCC_PR_DuplicateType(type);
} }
return type; return type;

View file

@ -5,6 +5,22 @@
#define MAX_PARMS 8 #define MAX_PARMS 8
// I put the following here to resolve "undefined reference to `__imp__vsnprintf'" with MinGW64 ~ Moodles
#ifdef _WIN32
#if (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions
#define snprintf linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
#else
//msvc crap
#define snprintf linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif
#endif
typedef struct QCC_type_s typedef struct QCC_type_s
{ {
etype_t type; etype_t type;
@ -13,7 +29,7 @@ typedef struct QCC_type_s
// function types are more complex // function types are more complex
struct QCC_type_s *aux_type; // return type or field type struct QCC_type_s *aux_type; // return type or field type
int num_parms; // -1 = variable args int num_parms; // -1 = variable args
// struct QCC_type_s *parm_types[MAX_PARMS]; // only [num_parms] allocated // struct QCC_type_s *parm_types[MAX_PARMS]; // only [num_parms] allocated
int ofs; //inside a structure. int ofs; //inside a structure.
int size; int size;
@ -107,7 +123,7 @@ char *VarAtOfs(progfuncs_t *progfuncs, int ofs)
typen = current_progstate->types[def->type & ~DEF_SHARED].type; typen = current_progstate->types[def->type & ~DEF_SHARED].type;
else else
typen = def->type & ~(DEF_SHARED|DEF_SAVEGLOBAL); typen = def->type & ~(DEF_SHARED|DEF_SAVEGLOBAL);
evaluateimmediate: evaluateimmediate:
// return PR_UglyValueString(def->type, (eval_t *)&current_progstate->globals[def->ofs]); // return PR_UglyValueString(def->type, (eval_t *)&current_progstate->globals[def->ofs]);
switch(typen) switch(typen)
@ -173,7 +189,7 @@ int ImmediateReadLater(progfuncs_t *progfuncs, progstate_t *progs, unsigned int
dstatement16_t *st; dstatement16_t *st;
if (ofsflags[ofs] & 8) if (ofsflags[ofs] & 8)
return false; //this is a global/local/pramater, not a temp return false; //this is a global/local/pramater, not a temp
if (!(ofsflags[ofs] & 3)) if (!(ofsflags[ofs] & 3))
return false; //this is a constant. return false; //this is a constant.
for (st = &((dstatement16_t*)progs->statements)[firstst]; ; st++,firstst++) for (st = &((dstatement16_t*)progs->statements)[firstst]; ; st++,firstst++)
{ //if written, return false, if read, return true. { //if written, return false, if read, return true.
@ -453,7 +469,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
def->s_name = (char*)malloc(strlen(mem)+1)-progfuncs->stringtable; def->s_name = (char*)malloc(strlen(mem)+1)-progfuncs->stringtable;
strcpy(def->s_name+progfuncs->stringtable, mem); strcpy(def->s_name+progfuncs->stringtable, mem);
} }
if (current_progstate->types) if (current_progstate->types)
writes(f, "%s %s", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name); writes(f, "%s %s", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name);
else else
@ -471,7 +487,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
case ev_vector: case ev_vector:
writes(f, "%s %s", "vector", progfuncs->stringtable+def->s_name); writes(f, "%s %s", "vector", progfuncs->stringtable+def->s_name);
break; break;
default: default:
writes(f, "%s %s", "randomtype", progfuncs->stringtable+def->s_name); writes(f, "%s %s", "randomtype", progfuncs->stringtable+def->s_name);
break; break;
} }
@ -542,7 +558,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
writes(f, ";\r\n"); writes(f, ";\r\n");
return; return;
} }
fileofs = SafeSeek(f, 0, SEEK_CUR); fileofs = SafeSeek(f, 0, SEEK_CUR);
if (setjmp(decompilestatementfailure)) if (setjmp(decompilestatementfailure))
{ {
@ -555,7 +571,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
{ {
def = ED_GlobalAtOfs16(progfuncs, ofs); def = ED_GlobalAtOfs16(progfuncs, ofs);
if (def) if (def)
{ {
v = (eval_t *)&((int *)progs->globals)[def->ofs]; v = (eval_t *)&((int *)progs->globals)[def->ofs];
if (current_progstate->types) if (current_progstate->types)
writes(f, "\tlocal %s %s;\r\n", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name); writes(f, "\tlocal %s %s;\r\n", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name);
@ -583,11 +599,11 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
case ev_vector: case ev_vector:
if (v->_vector[0] || v->_vector[1] || v->_vector[2]) if (v->_vector[0] || v->_vector[1] || v->_vector[2])
writes(f, "\tlocal vector %s = '%f %f %f';\r\n", progfuncs->stringtable+def->s_name, v->_vector[0], v->_vector[1], v->_vector[2]); writes(f, "\tlocal vector %s = '%f %f %f';\r\n", progfuncs->stringtable+def->s_name, v->_vector[0], v->_vector[1], v->_vector[2]);
else else
writes(f, "\tlocal %s %s;\r\n", "vector", progfuncs->stringtable+def->s_name); writes(f, "\tlocal %s %s;\r\n", "vector", progfuncs->stringtable+def->s_name);
ofs+=2; //skip floats; ofs+=2; //skip floats;
break; break;
default: default:
writes(f, "\tlocal %s %s;\r\n", "randomtype", progfuncs->stringtable+def->s_name); writes(f, "\tlocal %s %s;\r\n", "randomtype", progfuncs->stringtable+def->s_name);
break; break;
} }
@ -600,7 +616,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
st = &((dstatement16_t*)progs->statements)[stn]; st = &((dstatement16_t*)progs->statements)[stn];
if (!st->op) //end of function statement! if (!st->op) //end of function statement!
break; break;
op = &pr_opcodes[st->op]; op = &pr_opcodes[st->op];
writes(f, "\t%s", op->opname); writes(f, "\t%s", op->opname);
if (op->priority==-1&&op->associative==ASSOC_RIGHT) //last param is a goto if (op->priority==-1&&op->associative==ASSOC_RIGHT) //last param is a goto
@ -651,7 +667,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
writes(f, " %s", VarAtOfs(progfuncs, st->c)); writes(f, " %s", VarAtOfs(progfuncs, st->c));
} }
} }
writes(f, ";\r\n"); writes(f, ";\r\n");
stn++; stn++;
@ -671,7 +687,7 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
{ {
def = ED_GlobalAtOfs16(progfuncs, ofs); def = ED_GlobalAtOfs16(progfuncs, ofs);
if (def) if (def)
{ {
v = (eval_t *)&((int *)progs->globals)[def->ofs]; v = (eval_t *)&((int *)progs->globals)[def->ofs];
if (current_progstate->types) if (current_progstate->types)
writes(f, "\tlocal %s %s;\r\n", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name); writes(f, "\tlocal %s %s;\r\n", current_progstate->types[def->type&~(DEF_SHARED|DEF_SAVEGLOBAL)].name, def->s_name);
@ -699,11 +715,11 @@ void WriteAsmStatements(progfuncs_t *progfuncs, progstate_t *progs, int num, int
case ev_vector: case ev_vector:
if (v->_vector[0] || v->_vector[1] || v->_vector[2]) if (v->_vector[0] || v->_vector[1] || v->_vector[2])
writes(f, "\tlocal vector %s = '%f %f %f';\r\n", def->s_name, v->_vector[0], v->_vector[1], v->_vector[2]); writes(f, "\tlocal vector %s = '%f %f %f';\r\n", def->s_name, v->_vector[0], v->_vector[1], v->_vector[2]);
else else
writes(f, "\tlocal %s %s;\r\n", "vector",progfuncs->stringtable+def->s_name); writes(f, "\tlocal %s %s;\r\n", "vector",progfuncs->stringtable+def->s_name);
ofs+=2; //skip floats; ofs+=2; //skip floats;
break; break;
default: default:
writes(f, "\tlocal %s %s;\r\n", "randomtype", progfuncs->stringtable+def->s_name); writes(f, "\tlocal %s %s;\r\n", "randomtype", progfuncs->stringtable+def->s_name);
break; break;
} }
@ -736,7 +752,7 @@ void FigureOutTypes(progfuncs_t *progfuncs)
dstatement16_t *st; dstatement16_t *st;
int parmofs[8]; int parmofs[8];
ofstype = realloc(ofstype, sizeof(*ofstype)*65535); ofstype = realloc(ofstype, sizeof(*ofstype)*65535);
ofsflags = realloc(ofsflags, sizeof(*ofsflags)*65535); ofsflags = realloc(ofsflags, sizeof(*ofsflags)*65535);
@ -752,9 +768,9 @@ void FigureOutTypes(progfuncs_t *progfuncs)
type_float = QCC_PR_NewType("float", ev_float); type_float = QCC_PR_NewType("float", ev_float);
type_vector = QCC_PR_NewType("vector", ev_vector); type_vector = QCC_PR_NewType("vector", ev_vector);
type_entity = QCC_PR_NewType("entity", ev_entity); type_entity = QCC_PR_NewType("entity", ev_entity);
type_field = QCC_PR_NewType("field", ev_field); type_field = QCC_PR_NewType("field", ev_field);
type_function = QCC_PR_NewType("function", ev_function); type_function = QCC_PR_NewType("function", ev_function);
type_pointer = QCC_PR_NewType("pointer", ev_pointer); type_pointer = QCC_PR_NewType("pointer", ev_pointer);
type_integer = QCC_PR_NewType("integer", ev_integer); type_integer = QCC_PR_NewType("integer", ev_integer);
// type_variant = QCC_PR_NewType("__variant", ev_variant); // type_variant = QCC_PR_NewType("__variant", ev_variant);
@ -843,7 +859,7 @@ pbool Decompile(progfuncs_t *progfuncs, char *fname)
qccprogfuncs = progfuncs; qccprogfuncs = progfuncs;
op=current_progstate; op=current_progstate;
if (!PR_ReallyLoadProgs(progfuncs, fname, -1, &progs, false)) if (!PR_ReallyLoadProgs(progfuncs, fname, -1, &progs, false))
{ {
return false; return false;
@ -947,10 +963,10 @@ pbool Decompile(progfuncs_t *progfuncs, char *fname)
break; break;
case ev_function: case ev_function:
//wierd //wierd
WriteAsmStatements(progfuncs, &progs, ((int *)progs.globals)[pr_globaldefs16[i].ofs], f, pr_globaldefs16[i].s_name+progfuncs->stringtable); WriteAsmStatements(progfuncs, &progs, ((int *)progs.globals)[pr_globaldefs16[i].ofs], f, pr_globaldefs16[i].s_name+progfuncs->stringtable);
break; break;
case ev_pointer: case ev_pointer:
writes(f, "pointer %s;\r\n", progfuncs->stringtable+pr_globaldefs16[i].s_name); writes(f, "pointer %s;\r\n", progfuncs->stringtable+pr_globaldefs16[i].s_name);
break; break;
@ -964,9 +980,9 @@ pbool Decompile(progfuncs_t *progfuncs, char *fname)
case ev_struct: case ev_struct:
writes(f, "struct %s;\r\n", progfuncs->stringtable+pr_globaldefs16[i].s_name); writes(f, "struct %s;\r\n", progfuncs->stringtable+pr_globaldefs16[i].s_name);
break; break;
default: default:
break; break;
} }
} }