It should compile now!

This commit is contained in:
dborth 2008-09-14 21:03:59 +00:00
parent 9644c251ef
commit 5aa3368a51
8 changed files with 2902 additions and 2955 deletions

190
Makefile
View File

@ -1,183 +1,23 @@
#---------------------------------------------------------------------------------
# Generic makefile for Gamecube projects
#
# Tab stops set to 4
# | | | |
# 0 1 2 3
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
.PHONY = all wii gc wii-clean gc-clean wii-run gc-run
HAVEDIST := $(wildcard w)
all: wii gc
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := vba172
BUILD := build
SOURCES := src/gb src src/fileio src/ngc
INCLUDES = -I$(DEVKITPRO)/libogc/include -I$(DEVKITPRO)/libfat/libogc/include src/gb src src/fileio src/ngc
LIBPATHS = -L$(DEVKITPRO)/libogc/lib/wii -L$(DEVKITPRO)/libfat/libogc/lib/wii
clean: wii-clean gc-clean
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -meabi \
-DWORDS_BIGENDIAN -DPACKAGE=\"VisualBoyAdvance\" \
-DVERSION=\"1.7.2\" -DC_CORE -DHAVE_ZUTIL_H \
-DCHANFFS -DSDL -DWII_BUILD
LDFLAGS = $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map -Wl,--cref
PREFIX := powerpc-gekko-
wii:
$(MAKE) -f Makefile.wii
#export PATH:=/c/devkitPPC_r11/bin:/bin
wii-clean:
$(MAKE) -f Makefile.wii clean
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with
#---------------------------------------------------------------------------------
LIBS := -lm -lz -lfat -ldb -lwiiuse -lbte -logc
wii-run:
$(MAKE) -f Makefile.wii run
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
gc:
$(MAKE) -f Makefile.gc
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
gc-clean:
$(MAKE) -f Makefile.gc clean
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) *.elf
#---------------------------------------------------------------------------------
run:
psoload $(TARGET).dol
#---------------------------------------------------------------------------------
reload:
psoload -r $(TARGET).dol
#---------------------------------------------------------------------------------
dist:
@echo Files : $(HAVEDIST)
ifeq ($(strip $(HAVEDIST)),)
rule:
@echo "No file"
else
rule2: A
@echo "Have File"
endif
bindist:
@[ -f $(TARGET).7z ] || rm $(TARGET).7z 2>/dev/null
@7z a -mx=9 -m0=lzma $(TARGET).7z $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
@echo "Output ... "$(notdir $@)
@$(OBJCOPY) -O binary $< $@
#---------------------------------------------------------------------------------
$(OUTPUT).elf: $(OFILES)
@echo "Linking ... "$(notdir $@)
@$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
# Compile Targets for C/C++
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
%.o : %.cpp
@echo Compiling ... $(notdir $<)
@$(CXX) -MMD $(CFLAGS) -o $@ -c $<
#---------------------------------------------------------------------------------
%.o : %.c
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -o $@ -c $<
#---------------------------------------------------------------------------------
%.o : %.S
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -D_LANGUAGE_ASSEMBLY -c $< -o $@
#---------------------------------------------------------------------------------
%.o : %.s
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -D_LANGUAGE_ASSEMBLY -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
cp $(<) $(*).tmp
$(OBJCOPY) -I binary -O elf32-powerpc -B powerpc \
--rename-section .data=.rodata,readonly,data,contents,alloc \
--redefine-sym _binary_$*_tmp_start=$*\
--redefine-sym _binary_$*_tmp_end=$*_end\
--redefine-sym _binary_$*_tmp_size=$*_size\
$(*).tmp $(@)
echo "extern const u8" $(*)"[];" > $(*).h
echo "extern const u32" $(*)_size[]";" >> $(*).h
rm $(*).tmp
endef
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
gc-run:
$(MAKE) -f Makefile.gc run

View File

@ -1,15 +1,13 @@
#---------------------------------------------------------------------------------
# Generic makefile for Gamecube projects
#
# Tab stops set to 4
# | | | |
# 0 1 2 3
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
HAVEDIST := $(wildcard w)
include $(DEVKITPPC)/gamecube_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
@ -17,29 +15,33 @@ HAVEDIST := $(wildcard w)
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := vba172
BUILD := build
TARGET := vba172_gc
TARGETDIR := executables
BUILD := build_gc
SOURCES := src/gb src src/fileio src/ngc
INCLUDES = -I$(DEVKITPRO)/libogc/include -I$(DEVKITPRO)/libfat/libogc/include src/gb src src/fileio src/ngc
LIBPATHS = -L$(DEVKITPRO)/libogc/lib/cube -L$(DEVKITPRO)/libfat/libogc/lib/cube
INCLUDES := src/gb src src/fileio src/ngc
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -meabi \
-DWORDS_BIGENDIAN -DPACKAGE=\"VisualBoyAdvance\" \
-DVERSION=\"1.7.2\" -DC_CORE -DHAVE_ZUTIL_H \
-DCHANFFS -DSDL -DGC_BUILD
LDFLAGS = $(MACHDEP) -mogc -Wl,-Map,$(notdir $@).map -Wl,--cref
PREFIX := powerpc-gekko-
#export PATH:=/c/devkitPPC_r11/bin:/bin
CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -meabi \
-DNGC -DWORDS_BIGENDIAN -DPACKAGE=\"VisualBoyAdvance\" \
-DVERSION=\"1.7.2\" -DC_CORE \
-DCHANFFS -DSDL -DNO_DEFLATE
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map -Wl,--cref
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with
#---------------------------------------------------------------------------------
LIBS := -logc -lz -lm -lfat -logc -lz -lm
LIBS := -lm -lz -lfat -ldb -logc
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
@ -47,13 +49,14 @@ LIBS := -logc -lz -lm -lfat -logc -lz -lm
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
@ -61,6 +64,8 @@ CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
@ -70,54 +75,47 @@ else
export LD := $(CXX)
endif
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir $@
@[ -d $@ ] || mkdir -p $@
@[ -d $(TARGETDIR) ] || mkdir -p $(TARGETDIR)
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.gc
@rm -fr $(OUTPUT).elf
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) *.elf
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
psoload $(TARGET).dol
psoload $(OUTPUT).dol
#---------------------------------------------------------------------------------
reload:
psoload -r $(TARGET).dol
psoload -r $(OUTPUT).dol
#---------------------------------------------------------------------------------
dist:
@echo Files : $(HAVEDIST)
ifeq ($(strip $(HAVEDIST)),)
rule:
@echo "No file"
else
rule2: A
@echo "Have File"
endif
bindist:
@[ -f $(TARGET).7z ] || rm $(TARGET).7z 2>/dev/null
@7z a -mx=9 -m0=lzma $(TARGET).7z $(TARGET).dol
#---------------------------------------------------------------------------------
else
@ -128,53 +126,15 @@ DEPENDS := $(OFILES:.o=.d)
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
@echo "Output ... "$(notdir $@)
@$(OBJCOPY) -O binary $< $@
#---------------------------------------------------------------------------------
$(OUTPUT).elf: $(OFILES)
@echo "Linking ... "$(notdir $@)
@$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
# Compile Targets for C/C++
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
%.o : %.cpp
@echo Compiling ... $(notdir $<)
@$(CXX) -MMD $(CFLAGS) -o $@ -c $<
#---------------------------------------------------------------------------------
%.o : %.c
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -o $@ -c $<
#---------------------------------------------------------------------------------
%.o : %.S
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -D_LANGUAGE_ASSEMBLY -c $< -o $@
#---------------------------------------------------------------------------------
%.o : %.s
@echo Compiling ... $(notdir $<)
@$(CC) -MMD $(CFLAGS) -D_LANGUAGE_ASSEMBLY -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
cp $(<) $(*).tmp
$(OBJCOPY) -I binary -O elf32-powerpc -B powerpc \
--rename-section .data=.rodata,readonly,data,contents,alloc \
--redefine-sym _binary_$*_tmp_start=$*\
--redefine-sym _binary_$*_tmp_end=$*_end\
--redefine-sym _binary_$*_tmp_size=$*_size\
$(*).tmp $(@)
echo "extern const u8" $(*)"[];" > $(*).h
echo "extern const u32" $(*)_size[]";" >> $(*).h
rm $(*).tmp
endef
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)

143
Makefile.wii Normal file
View File

@ -0,0 +1,143 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := vba172_wii
TARGETDIR := executables
BUILD := build_wii
SOURCES := src/gb src src/fileio src/ngc
INCLUDES := src/gb src src/fileio src/ngc
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -meabi \
-DNGC -DWORDS_BIGENDIAN -DPACKAGE=\"VisualBoyAdvance\" \
-DVERSION=\"1.7.2\" -DC_CORE \
-DCHANFFS -DSDL -DWII_BUILD -DNO_DEFLATE
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map -Wl,--cref
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with
#---------------------------------------------------------------------------------
LIBS := -lm -lz -lfat -ldb -lwiiuse -lbte -logc
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@[ -d $(TARGETDIR) ] || mkdir -p $(TARGETDIR)
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii
@rm -fr $(OUTPUT).elf
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(OUTPUT).dol
#---------------------------------------------------------------------------------
reload:
wiiload -r $(OUTPUT).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

View File

@ -40,7 +40,6 @@ extern "C"
#include "RTC.h"
#include "Port.h"
extern "C"
{
#include "memgzio.h"
@ -1104,7 +1103,7 @@ gzFile utilGzOpen(const char *file, const char *mode)
gzFile utilMemGzOpen(char *memory, int available, char *mode)
{
utilGzWriteFunc = memgzwrite;
// utilGzWriteFunc = memgzwrite;
utilGzReadFunc = memgzread;
utilGzCloseFunc = memgzclose;

View File

@ -10,7 +10,7 @@
*/
/* @(#) $Id: memgzio.c,v 1.3 2004/01/17 23:07:32 kxu Exp $ */
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@ -70,15 +70,15 @@ typedef struct mem_stream
mem_stream;
local gzFile gz_open OF((char *memory, const int available, const char *mode));
local int do_flush OF((gzFile file, int flush));
local int get_byte OF((mem_stream *s));
local void check_header OF((mem_stream *s));
local int destroy OF((mem_stream *s));
local void putLong OF((MEMFILE *file, uLong x));
local uLong getLong OF((mem_stream *s));
gzFile gz_open OF((char *memory, const int available, const char *mode));
int do_flush OF((gzFile file, int flush));
int get_byte OF((mem_stream *s));
void check_header OF((mem_stream *s));
int destroy OF((mem_stream *s));
void putLong OF((MEMFILE *file, uLong x));
uLong getLong OF((mem_stream *s));
local MEMFILE *memOpen(char *memory, int available, char mode)
MEMFILE *memOpen(char *memory, int available, char mode)
{
MEMFILE *f;
@ -119,7 +119,7 @@ local MEMFILE *memOpen(char *memory, int available, char mode)
return f;
}
local size_t memWrite(const void *buffer, size_t size, size_t count,
size_t memWrite(const void *buffer, size_t size, size_t count,
MEMFILE *file)
{
size_t total = size*count;
@ -140,7 +140,7 @@ local size_t memWrite(const void *buffer, size_t size, size_t count,
return total;
}
local size_t memRead(void *buffer, size_t size, size_t count,
size_t memRead(void *buffer, size_t size, size_t count,
MEMFILE *file)
{
size_t total = size*count;
@ -164,7 +164,7 @@ local size_t memRead(void *buffer, size_t size, size_t count,
return total;
}
local int memPutc(int c, MEMFILE *file)
int memPutc(int c, MEMFILE *file)
{
if(file->mode != 'w')
{
@ -183,17 +183,17 @@ local int memPutc(int c, MEMFILE *file)
return c;
}
local long memTell(MEMFILE *f)
long memTell(MEMFILE *f)
{
return (f->next - f->memory) - 8;
}
local int memError(MEMFILE *f)
int memError(MEMFILE *f)
{
return f->error;
}
local int memClose(MEMFILE *f)
int memClose(MEMFILE *f)
{
if(f->mode == 'w')
{
@ -203,7 +203,7 @@ local int memClose(MEMFILE *f)
return 0;
}
local int memPrintf(MEMFILE *f, const char *format, ...)
int memPrintf(MEMFILE *f, const char *format, ...)
{
char buffer[80];
va_list list;
@ -225,7 +225,7 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR).
*/
local gzFile gz_open (memory, available, mode)
gzFile gz_open (memory, available, mode)
char *memory;
const int available;
const char *mode;
@ -313,7 +313,7 @@ const char *mode;
}
s->stream.avail_out = Z_BUFSIZE;
errno = 0;
//errno = 0;
s->file = memOpen(memory, available, s->mode);
if (s->file == NULL)
@ -325,8 +325,8 @@ const char *mode;
{
/* Write a very simple .gz header:
*/
memPrintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
//memPrintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
// Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
s->startpos = 10L;
/* We use 10L instead of ftell(s->file) to because ftell causes an
* fflush on some systems. This version of the library doesn't use
@ -359,13 +359,13 @@ const char *mode;
for end of file.
IN assertion: the stream s has been sucessfully opened for reading.
*/
local int get_byte(s)
int get_byte(s)
mem_stream *s;
{
if (s->z_eof) return EOF;
if (s->stream.avail_in == 0)
{
errno = 0;
// errno = 0;
s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0)
{
@ -388,7 +388,7 @@ mem_stream *s;
s->stream.avail_in is zero for the first time, but may be non-zero
for concatenated .gz files.
*/
local void check_header(s)
void check_header(s)
mem_stream *s;
{
int method; /* method byte */
@ -449,7 +449,7 @@ mem_stream *s;
* Cleanup then free the given mem_stream. Return a zlib error code.
Try freeing in the reverse order of allocations.
*/
local int destroy (s)
int destroy (s)
mem_stream *s;
{
int err = Z_OK;
@ -520,7 +520,7 @@ unsigned len;
if (n > s->stream.avail_out) n = s->stream.avail_out;
if (n > 0)
{
zmemcpy(s->stream.next_out, s->stream.next_in, n);
// zmemcpy(s->stream.next_out, s->stream.next_in, n);
next_out += n;
s->stream.next_out = next_out;
s->stream.next_in += n;
@ -541,7 +541,7 @@ unsigned len;
if (s->stream.avail_in == 0 && !s->z_eof)
{
errno = 0;
// errno = 0;
s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0)
{
@ -637,7 +637,7 @@ unsigned len;
Flushes all pending output into the compressed file. The parameter
flush is as in the deflate() function.
*/
local int do_flush (file, flush)
int do_flush (file, flush)
gzFile file;
int flush;
{
@ -682,7 +682,7 @@ int flush;
/* ===========================================================================
Outputs a long in LSB order to the given file
*/
local void putLong (file, x)
void putLong (file, x)
MEMFILE *file;
uLong x;
{
@ -698,7 +698,7 @@ uLong x;
Reads a long in LSB order from the given mem_stream. Sets z_err in case
of error.
*/
local uLong getLong (s)
uLong getLong (s)
mem_stream *s;
{
uLong x = (uLong)get_byte(s);
@ -719,7 +719,7 @@ mem_stream *s;
int ZEXPORT memgzclose (file)
gzFile file;
{
int err;
// int err;
mem_stream *s = (mem_stream*)file;
if (s == NULL) return Z_STREAM_ERROR;

View File

@ -8,14 +8,19 @@
/* memgzio.c - IO on .gz files in memory
* Adapted from original gzio.c from zlib library by Forgotten
*/
/*
#ifndef HAVE_ZUTIL_H
#include "../win32/include/zlib/zutil.h"
#else
#include <zutil.h>
#endif
*/
#include <zlib.h>
gzFile ZEXPORT memgzopen(char *memory, int, const char *);
int ZEXPORT memgzread(gzFile, voidp, unsigned);
int ZEXPORT memgzwrite(gzFile, const voidp, unsigned);
int ZEXPORT memgzclose(gzFile);
long ZEXPORT memtell(gzFile);

View File

@ -66,7 +66,7 @@ extern "C"
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#include <zlib.h>
#endif
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)