/programs/fs/unzip60/kolibri/Makefile.gcc |
---|
0,0 → 1,589 |
# Makefile for UnZip, fUnZip and UnZipSFX for native Win32-Intel ports of gcc. |
# Currently supported implementations: Cygnus/Win32 and MinGW32. |
# |
# First version: Cosmin Truta, Dec 1997. |
# Last revision: Christian Spieler, 09-Aug-2008. |
# |
# To use, do "make -f win32/makefile.gcc". |
# configuration switches supported: |
# NOASM=1 disable assembler crc32 code, the generic C source code |
# is used instead. |
# NOCRC_OPT=1 disable "unfolding CRC tables" optimization. |
# OPT_P6=1 add "modern gcc" tuning option for PentiumPro family CPU. |
# USEBZ2=1 activate integrated compilation of bzip2 compression support, |
# this requires the bzip2 sources present in the bzip2 subfolder. |
# USEZLIB=1 replace internal deflate code by externally provided zlib. |
# USE_POSIX=1 build posix-style binaries targeted for the CygWin unix |
# emulation environment. |
SDK_DIR:= $(abspath ../../../contrib/sdk) |
NOASM=1 |
CC_CPU_OPT=-march=pentium |
### Optional section |
# The following options allow to override the default assembler code usage |
ifdef NOASM |
APPLY_ASMCRC=0 |
endif |
ifdef USEASM |
APPLY_ASMCRC=1 |
endif |
# The external zlib library supplies its own crc32 implementation... |
ifdef USEZLIB |
APPLY_ASMCRC=0 |
endif |
# default is ASM CRC code (from .S source) for now... |
ifndef APPLY_ASMCRC |
APPLY_ASMCRC=1 |
endif |
# optional inclusion of bzip2 decompression |
IZ_BZIP2 = bzip2 |
ifdef USEBZ2 |
INC_BZ2LIB = -I$(IZ_BZIP2) |
LOCFLAGS = $(INC_BZ2LIB) -DUSE_BZIP2 |
LD_BZ2LIB = -L$(IZ_BZIP2) -lbz2 |
LIBBZIP2 = $(IZ_BZIP2)/libbz2.a |
else |
INC_BZ2LIB = |
LOCFLAGS = |
LD_BZ2LIB = |
LIBBZIP2 = |
endif |
LIBBZIP2X = $(LIBBZIP2) |
ifndef USEZLIB |
# Apply the "CRC unfolding tables" optimization unless explicitly disabled. |
# (This optimization might have negative effects on old CPU designs with a |
# small first-level data cache.) |
ifndef NOCRC_OPT |
LOCFLAGS += -DIZ_CRCOPTIM_UNFOLDTBL |
endif |
# Optional nonstandard preprocessor flags (as -DUSE_ZLIB or -DUSE_SMITH_CODE) |
# should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added |
# to the declaration of LOCFLAGS here: |
ifneq ($(APPLY_ASMCRC),0) |
LOCFLAGS += -DASM_CRC |
endif |
else # ifndef USEZLIB |
LOCFLAGS += -DUSE_ZLIB |
endif # ifndef USEZLIB ... else ... |
# Finally, append additional externally supplied options. |
LOCFLAGS += $(LOCAL_UNZIP) |
# Some gcc distributions for Win32 (e.g. CygWin) try to emulate a POSIX- |
# compatible (Unix-style) environment. This Makefile defaults to a |
# "native Win32" build. To build POSIX-mode binaries, it is recommended |
# to use the Makefile of the Unix port. However, by defining the variable |
# "USE_POSIX", building binaries for the POSIX environment can be enabled |
# here as well. |
ifdef 0 |
ifdef USE_POSIX |
CC_ENVIR_OPT = -DUNIX -DFORCE_UNIX_OVER_WIN32 |
else |
CC_ENVIR_OPT = -DWIN32 -DFORCE_WIN32_OVER_UNIX |
endif |
endif |
### kolibri specific |
INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include |
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib |
CC_ENVIR_OPT = -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOS32 \ |
$(INCLUDES) |
### Compiler-specific section |
# ------------ GNU C ------------ |
CC = kos32-gcc |
#AS = as |
AS = $(CC) |
LD = kos32-ld |
###LD = $(CC) |
AR = ar |
###RC = windres |
# Quiet |
CC_QUIET_OPT = |
AS_QUIET_OPT = $(CC_QUIET_OPT) |
LD_QUIET_OPT = $(CC_QUIET_OPT) |
# Warnings |
CC_WARN_OPT = -Wall |
AS_WARN_OPT = $(CC_WARN_OPT) |
LD_WARN_OPT = |
# Debug version |
CC_DEBUG_OPT = -g |
AS_DEBUG_OPT = $(CC_DEBUG_OPT) |
LD_DEBUG_OPT = $(CC_DEBUG_OPT) |
# Release version |
CC_RELEASE_OPT = |
AS_RELEASE_OPT = |
LD_RELEASE_OPT = -s |
# Prefered target CPU (instruction scheduling optimized for...) |
ifndef CC_CPU_OPT |
CC_CPU_OPT = -mcpu=pentiumpro |
endif |
# Smallest code (-Os is new since EGC 1.1, use -O1 for 2.8.1 and earlier) |
CC_SIZE_OPT = -Os $(CC_CPU_OPT) |
# Fastest code |
CC_SPEED_OPT = -O2 $(CC_CPU_OPT) |
# Output object file name |
CC_OUT_OPT = -o |
# Other specific options |
CC_SPECIFIC_OPT = -c $(CC_ENVIR_OPT) |
AS_SPECIFIC_OPT = -c |
LD_SPECIFIC_OPT = -o $@ -static -S -nostdlib -T $(SDK_DIR)/lib/app-dynamic.lds \ |
--image-base 0 $(LIBPATH) |
# Libraries for the debug & release version |
# (GCC 2.95 and newer does not require the system library specifications) |
ifdef USEZLIB |
LD_RELEASE_LIBS = -lz -lgcc -ldll -lc.dll |
else |
LD_RELEASE_LIBS = -lgcc -ldll -lc.dll |
endif |
LD_DEBUG_LIBS = $(LD_RELEASE_LIBS) |
### System-specific section |
# Suffixes |
OBJ = .o |
EXE = .exe |
.SUFFIXES: .c .S $(OBJ) $(EXE) |
.PHONY: FORCE |
# Commands |
RM = del /q |
### General section |
CFLAGS = $(CC_SPECIFIC_OPT) $(CC_QUIET_OPT) $(CC_WARN_OPT) $(LOCFLAGS) \ |
$(CC_OUT_OPT) $@ |
ASFLAGS = $(AS_SPECIFIC_OPT) $(AS_QUIET_OPT) $(AS_WARN_OPT) $(LOCFLAGS) |
LDFLAGS = $(LD_SPECIFIC_OPT) $(LD_QUIET_OPT) $(LD_WARN_OPT) |
# To build with debug info, use 'make DEBUG=1'. |
ifdef DEBUG |
CVER = $(CC_DEBUG_OPT) |
ASVER = $(AS_DEBUG_OPT) |
LDVER = $(LD_DEBUG_OPT) |
GENFLAGS = |
FFLAGS = -DFUNZIP |
SFXFLAGS = -DSFX |
GENDLLFL = -DDLL -DWINDLL |
GENGUILB = -DSFX -DDLL -DWINDLL -DUNZIPLIB |
GENGUISX = -DSFX |
GENLIBFL = -DDLL -DWINDLL -DUNZIPLIB |
LDLIBS = $(LD_DEBUG_LIBS) |
else |
CVER = $(CC_RELEASE_OPT) |
ASVER = $(AS_RELEASE_OPT) |
LDVER = $(LD_RELEASE_OPT) |
GENFLAGS = $(CC_SPEED_OPT) |
FFLAGS = $(CC_SPEED_OPT) -DFUNZIP |
SFXFLAGS = $(CC_SIZE_OPT) -DSFX |
GENDLLFL = $(CC_SPEED_OPT) -DDLL -DWINDLL |
GENGUILB = $(CC_SIZE_OPT) -DSFX -DDLL -DWINDLL -DUNZIPLIB |
GENGUISX = $(CC_SIZE_OPT) -DSFX |
GENLIBFL = $(CC_SPEED_OPT) -DDLL -DWINDLL -DUNZIPLIB |
LDLIBS = $(LD_RELEASE_LIBS) |
endif |
GUILDFLAG=-mwindows |
# Object files |
ifneq ($(APPLY_ASMCRC),0) |
OBJA = crc_i386$(OBJ) |
else |
OBJA = |
endif |
OBJU1 = unzip$(OBJ) crc32$(OBJ) crypt$(OBJ) envargs$(OBJ) |
OBJU2 = explode$(OBJ) extract$(OBJ) fileio$(OBJ) globals$(OBJ) inflate$(OBJ) |
OBJU3 = list$(OBJ) match$(OBJ) process$(OBJ) ttyio$(OBJ) ubz2err$(OBJ) |
OBJU4 = unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ) |
OBJUS= kos32$(OBJ) dirent$(OBJ) |
###OBJUS = win32$(OBJ) win32i64$(OBJ) nt$(OBJ) winapprc$(OBJ) |
OBJU = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJU4) $(OBJA) $(OBJUS) |
OBJX1 = unzipsfx$(OBJ) crc32x$(OBJ) cryptx$(OBJ) extractx$(OBJ) |
OBJX2 = fileiox$(OBJ) globalsx$(OBJ) inflatex$(OBJ) matchx$(OBJ) processx$(OBJ) |
OBJX3 = ttyiox$(OBJ) ubz2errx$(OBJ) |
###OBJXS = win32x$(OBJ) win32i64x$(OBJ) ntx$(OBJ) |
OBJX = $(OBJX1) $(OBJX2) $(OBJX3) $(OBJA) $(OBJXS) |
OBJF1 = funzip$(OBJ) crc32$(OBJ) cryptf$(OBJ) globalsf$(OBJ) inflatef$(OBJ) |
OBJF2 = ttyiof$(OBJ) |
###OBJFS = win32f$(OBJ) win32i64f$(OBJ) |
OBJF = $(OBJF1) $(OBJF2) $(OBJA) $(OBJFS) |
OBJDLL = windll$(OBJ) windllrc$(OBJ) api$(OBJ) |
OBJD1 = crc32l$(OBJ) cryptl$(OBJ) |
OBJD2 = explodel$(OBJ) extractl$(OBJ) fileiol$(OBJ) globalsl$(OBJ) |
OBJD3 = inflatel$(OBJ) listl$(OBJ) matchl$(OBJ) processl$(OBJ) ubz2errl$(OBJ) |
OBJD4 = unreducl$(OBJ) unshrnkl$(OBJ) zipinfol$(OBJ) |
###OBJDS = win32l$(OBJ) win32i64l$(OBJ) ntl$(OBJ) |
OBJD = $(OBJDLL) $(OBJD1) $(OBJD2) $(OBJD3) $(OBJD4) $(OBJA) $(OBJDS) |
OBLX1 = apig$(OBJ) crc32g$(OBJ) cryptg$(OBJ) |
OBLX2 = extractg$(OBJ) fileiog$(OBJ) globalsg$(OBJ) inflateg$(OBJ) |
OBLX3 = matchg$(OBJ) processg$(OBJ) ubz2errg$(OBJ) |
###OBLXS = win32g$(OBJ) win32i64g$(OBJ) ntg$(OBJ) windllg$(OBJ) |
OBLX = $(OBLX1) $(OBLX2) $(OBLX3) $(OBJA) $(OBLXS) |
OBGX = sfxwiz$(OBJ) sfxwizrc$(OBJ) |
OBJLIB = windllb$(OBJ) apib$(OBJ) |
OBJB1 = crc32b$(OBJ) cryptb$(OBJ) |
OBJB2 = explodeb$(OBJ) extractb$(OBJ) fileiob$(OBJ) globalsb$(OBJ) |
OBJB3 = inflateb$(OBJ) listb$(OBJ) matchb$(OBJ) processb$(OBJ) ubz2errb$(OBJ) |
OBJB4 = unreducb$(OBJ) unshrnkb$(OBJ) zipinfob$(OBJ) |
###OBJBS = win32b$(OBJ) win32i64b$(OBJ) ntb$(OBJ) |
OBJB = $(OBJLIB) $(OBJB1) $(OBJB2) $(OBJB3) $(OBJB4) $(OBJA) $(OBJBS) |
UNZIP_H = unzip.h unzpriv.h globals.h |
###win32/w32cfg.h |
###WINDLL_H = windll/windll.h windll/structs.h windll/decs.h |
###DLLDEF = windll/windllgcc.def |
###WINDLL_IMP_H = windll/decs.h windll/structs.h |
# Default target is all the executables |
###unzips: unzip$(EXE) funzip$(EXE) unzipsfx$(EXE) |
###dll: unzip32.dll |
###dllsample: uzexampl$(EXE) |
###guisfx: SFXWiz32$(EXE) |
#lib: libunzip32.a |
###all: unzips dll dllsample guisfx lib |
all: unzip$(EXE) |
unzip$(EXE): $(OBJU) $(LIBBZIP2) |
$(LD) $(LDFLAGS) $(LDVER) $(OBJU) $(LD_BZ2LIB) $(LDLIBS) |
kos32-objcopy $@ -O binary |
unzipsfx$(EXE): $(OBJX) $(LIBBZIP2X) |
$(LD) $(LDFLAGS) $(LDVER) $(OBJX) $(LDLIBS) |
funzip$(EXE): $(OBJF) |
$(LD) $(LDFLAGS) $(LDVER) $(OBJF) $(LDLIBS) |
unzip32.dll: $(DLLDEF) $(OBJD) $(LIBBZIP2) |
dllwrap --driver-name $(CC) --def $(DLLDEF) $(LDFLAGS) $(LDVER) $(OBJD) $(LD_BZ2LIB) $(LDLIBS) |
libunzsfx32.a: $(OBLX) |
$(AR) -rus $@ $(OBLX) |
SFXWiz32$(EXE): $(OBGX) libunzsfx32.a $(LIBBZIP2X) |
$(LD) $(GUILDFLAG) $(LDFLAGS) $(LDVER) $(OBGX) -L. -lunzsfx32 $(LDLIBS) |
uzexampl$(EXE): uzexampl$(OBJ) |
$(CC) $(LDFLAGS) $(LDVER) uzexampl$(OBJ) -lversion $(LDLIBS) |
libunzip32.a: $(OBJB) |
$(AR) -rus $@ $(OBJB) |
# create/update the library for the optional bzip2 support: |
$(IZ_BZIP2)/libbz2.a: FORCE |
$(subst /,\,$(MAKE)) -C $(IZ_BZIP2) -f Makebz2.iz CC="$(CC)" RM="$(RM)" |
FORCE: |
# How to compile sources |
.c$(OBJ): |
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) $< |
.S$(OBJ): |
$(AS) $(ASFLAGS) $(ASVER) $(GENFLAGS) $< |
# Dependencies |
crc32$(OBJ): crc32.c $(UNZIP_H) zip.h crc32.h |
crypt$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
envargs$(OBJ): envargs.c $(UNZIP_H) |
explode$(OBJ): explode.c $(UNZIP_H) |
extract$(OBJ): extract.c $(UNZIP_H) crc32.h crypt.h |
fileio$(OBJ): fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h |
funzip$(OBJ): funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h |
globals$(OBJ): globals.c $(UNZIP_H) |
inflate$(OBJ): inflate.c inflate.h $(UNZIP_H) |
list$(OBJ): list.c $(UNZIP_H) |
match$(OBJ): match.c $(UNZIP_H) |
process$(OBJ): process.c $(UNZIP_H) crc32.h |
ttyio$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h |
ubz2err$(OBJ): ubz2err.c $(UNZIP_H) |
unreduce$(OBJ): unreduce.c $(UNZIP_H) |
unshrink$(OBJ): unshrink.c $(UNZIP_H) |
unzip$(OBJ): unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h |
zipinfo$(OBJ): zipinfo.c $(UNZIP_H) |
crc_i386$(OBJ): crc_i386.S |
kos32$(OBJ): kolibri/kos32.c kolibri/kos32sys1.h |
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
dirent$(OBJ): kolibri/dirent.c kolibri/kos32sys1.h |
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
###win32$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
### $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
###win32i64$(OBJ): win32/win32i64.c $(UNZIP_H) |
### $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
###nt$(OBJ): win32/nt.c $(UNZIP_H) win32/nt.h |
### $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
###winapprc$(OBJ): win32/winapp.rc unzvers.h |
### - $(RC) -o $@ $< |
# UnZipSFX compilation section |
crc32x$(OBJ): crc32.c $(UNZIP_H) zip.h crc32.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
cryptx$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
extractx$(OBJ): extract.c $(UNZIP_H) crc32.h crypt.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
fileiox$(OBJ): fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
globalsx$(OBJ): globals.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
inflatex$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
matchx$(OBJ): match.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
processx$(OBJ): process.c $(UNZIP_H) crc32.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
ttyiox$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
ubz2errx$(OBJ): ubz2err.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
unzipsfx$(OBJ): unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) $< |
win32x$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) -I. $< |
win32i64x$(OBJ): win32/win32i64.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) -I. $< |
ntx$(OBJ): win32/nt.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(SFXFLAGS) -I. $< |
# fUnZip compilation section |
cryptf$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) $< |
globalsf$(OBJ): globals.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) $< |
inflatef$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) $< |
ttyiof$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) $< |
win32f$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) -I. $< |
win32i64f$(OBJ): win32/win32i64.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(FFLAGS) -I. $< |
# WINDLL sample |
uzexampl$(OBJ): windll/uzexampl.c windll/uzexampl.h |
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< |
# DLL compilation section |
api$(OBJ): api.c $(UNZIP_H) $(WINDLL_H) unzvers.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
crc32l$(OBJ): crc32.c $(UNZIP_H) zip.h crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
cryptl$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
explodel$(OBJ): explode.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
extractl$(OBJ): extract.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
fileiol$(OBJ): fileio.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h ttyio.h ebcdic.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
globalsl$(OBJ): globals.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
inflatel$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
listl$(OBJ): list.c $(UNZIP_H) $(WINDLL_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
matchl$(OBJ): match.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
processl$(OBJ): process.c $(UNZIP_H) $(WINDLL_H) crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
ubz2errl$(OBJ): ubz2err.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
unreducl$(OBJ): unreduce.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
unshrnkl$(OBJ): unshrink.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
zipinfol$(OBJ): zipinfo.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) $< |
win32l$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) -I. $< |
win32i64l$(OBJ): win32/win32i64.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) -I. $< |
ntl$(OBJ): win32/nt.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) -I. $< |
windll$(OBJ): windll/windll.c $(UNZIP_H) $(WINDLL_H) crypt.h unzvers.h consts.h |
$(CC) $(CFLAGS) $(CVER) $(GENDLLFL) -I. $< |
windllrc$(OBJ): windll/windll.rc unzvers.h |
- $(RC) -o $@ $< |
# SFX Lib compilation section |
apig$(OBJ): api.c $(UNZIP_H) $(WINDLL_H) unzvers.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
crc32g$(OBJ): crc32.c $(UNZIP_H) zip.h crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
cryptg$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
extractg$(OBJ): extract.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
fileiog$(OBJ): fileio.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h ttyio.h ebcdic.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
globalsg$(OBJ): globals.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
inflateg$(OBJ): inflate.c inflate.h $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
matchg$(OBJ): match.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
processg$(OBJ): process.c $(UNZIP_H) $(WINDLL_H) crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
ubz2errg$(OBJ): ubz2err.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) $< |
win32g$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) -I. $< |
win32i64g$(OBJ): win32/win32i64.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) -I. $< |
ntg$(OBJ): win32/nt.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) -I. $< |
windllg$(OBJ): windll/windll.c $(UNZIP_H) $(WINDLL_H) crypt.h unzvers.h consts.h |
$(CC) $(CFLAGS) $(CVER) $(GENGUILB) -I. $< |
sfxwiz$(OBJ): windll/guisfx/sfxwiz.c windll/guisfx/dialog.h $(WINDLL_IMP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENGUISX) -I. $< |
sfxwizrc$(OBJ): windll/guisfx/sfxwiz.rc |
- $(RC) --include-dir windll/guisfx --define WIN32 -o$@ $< |
# Static LIB compilation section |
apib$(OBJ): api.c $(UNZIP_H) $(WINDLL_H) unzvers.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
crc32b$(OBJ): crc32.c $(UNZIP_H) zip.h crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
cryptb$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
explodeb$(OBJ): explode.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
extractb$(OBJ): extract.c $(UNZIP_H) crc32.h crypt.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
fileiob$(OBJ): fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
globalsb$(OBJ): globals.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
inflateb$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
listb$(OBJ): list.c $(UNZIP_H) $(WINDLL_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
matchb$(OBJ): match.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
processb$(OBJ): process.c $(UNZIP_H) crc32.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
ubz2errb$(OBJ): ubz2err.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
unreducb$(OBJ): unreduce.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
unshrnkb$(OBJ): unshrink.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
zipinfob$(OBJ): zipinfo.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) $< |
win32b$(OBJ): win32/win32.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) -I. $< |
win32i64b$(OBJ): win32/win32i64.c $(UNZIP_H) |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) -I. $< |
ntb$(OBJ): win32/nt.c $(UNZIP_H) win32/nt.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) -I. $< |
windllb$(OBJ): windll/windll.c $(UNZIP_H) $(WINDLL_H) crypt.h unzvers.h consts.h |
$(CC) $(CFLAGS) $(CVER) $(GENLIBFL) -I. $< |
clean: |
-$(subst /,\,$(MAKE)) -C $(IZ_BZIP2) -f Makebz2.iz RM="$(RM)" clean |
-$(RM) *$(OBJ) |
-$(RM) unzip$(EXE) funzip$(EXE) unzipsfx$(EXE) |
-$(RM) unzip32.dll uzexampl$(EXE) SFXWiz32$(EXE) |
-$(RM) libunzip32.a libunzsfx32.a |
/programs/fs/unzip60/kolibri/config.h |
---|
0,0 → 1,51 |
/* |
Kolibri OS config for gcc 5.4 |
Started by Siemargl @Nov 2016 |
*/ |
#include <sys/types.h> /* off_t, time_t, dev_t, ... */ |
#include <sys/stat.h> |
#include <sys/kos_io.h> /* lseek(), open(), setftime(), dup(), creat() */ |
#include <time.h> /* localtime() */ |
#include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */ |
#include <sys/time.h> |
#include <unistd.h> |
#include <dirent.h> |
#define DEBUG |
#define DIR_END '/' |
#define NO_STRNICMP |
#define STRNICMP zstrnicmp |
#define NO_CHMOD |
#define NO_FCHOWN |
#define echoff(f) |
#define echon() |
#define getch() getchar() /* not correct, but may not be on a console */ |
#define HAVE_WORKING_GETCH |
/* |
# ifdef DATE_FORMAT |
# undef DATE_FORMAT |
# endif |
# define DATE_FORMAT dateformat() |
*/ |
#define lenEOL 2 |
#define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);} |
/* |
# if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)) |
# define USE_EF_UT_TIME |
# endif |
*/ |
/* Static variables that we have to add to Uz_Globs: */ |
#define SYSTEM_SPECIFIC_GLOBALS \ |
int created_dir, renamed_fullpath;\ |
char *rootpath, *buildpath, *end;\ |
ZCONST char *wildname;\ |
char *dirname, matchname[FILNAMSIZ];\ |
int rootlen, have_dirname, dirnamelen, notfirstcall;\ |
zvoid *wild_dir; |
/programs/fs/unzip60/kolibri/dirent.c |
---|
0,0 → 1,200 |
/* |
Kolibri OS port for gcc 5.4 |
Started by Siemargl @Nov 2016 |
Contains realisation of directory handling functions: |
mkdir() |
closedir() |
opendir() |
readdir() |
rewinddir() |
!!non reentrant |
*/ |
#include <stdio.h> |
#include <string.h> |
#include <dirent.h> |
#include <errno.h> |
#include <sys/stat.h> |
#include <assert.h> |
#include "kos32sys1.h" |
/* defined in newlib headers |
int _EXFUN(mkdir,( const char *_path, mode_t __mode )); |
struct dirent { |
char d_namlen; |
char d_name[256]; |
}; |
typedef struct |
{ |
// struct systree_info2 fileinfo; |
struct dirent entry; |
// __u8 bdfeheader[0x20]; |
// struct bdfe_item bdfebase; |
// __u8 bdfename[264]; |
} DIR; |
int closedir(DIR *dirp); |
DIR * opendir(const char *_dirname); |
struct dirent * readdir(DIR *_dirp); |
void rewinddir(DIR *_dirp); |
*/ |
static int32_t lastread_block = -1; // non reentrant, must me -1ed in closedir, or will assert |
static uint32_t lastread_dir_size; |
static DIR lastread_dir; |
DIR *opendir(const char *_dirname) |
{ |
assert(sizeof(struct fs_dirinfo) == 25); // check struct aligment |
assert(lastread_block == -1); |
struct fs_dirinfo di; |
struct fs_dirheader dhead; |
memset(&di, 0, sizeof di); |
di.ppath = (char*)_dirname; |
di.retval = (uint32_t)&dhead; |
int rc = sf_file(1, &di); // read dir size |
if(rc) { |
fprintf(stderr, "Error reading dir size %s\n", _dirname); |
errno = rc; |
return NULL; |
} |
lastread_dir_size = dhead.totl_blocks; |
lastread_dir.entry.d_namlen = strlen(_dirname); |
assert (lastread_dir.entry.d_namlen < sizeof(lastread_dir.entry.d_name)); |
strcpy(lastread_dir.entry.d_name, _dirname); |
return &lastread_dir; |
}; |
int closedir(DIR *dirp) |
{ |
assert (lastread_block != -1); // was opened |
if (!dirp || lastread_block == -1) |
{ |
errno = EBADF; |
return -1; |
} |
lastread_block = -1; |
lastread_dir_size = 0; |
lastread_dir.entry.d_namlen = 0; |
lastread_dir.entry.d_name[0] = '\0'; |
return 0; |
}; |
struct dirent* readdir(DIR *dirp) |
{ |
assert (lastread_block != -1); // was opened |
if (!dirp || lastread_block == -1) |
{ |
errno = EBADF; |
return NULL; |
} |
struct fs_dirinfo di; |
assert (lastread_block != -1); // was opened |
char retdir[sizeof(struct fs_dirheader) + sizeof(struct fsBDFE)]; // 1 block w/cp866 encoding |
struct fsBDFE *bdfe = (struct fsBDFE *)(retdir + sizeof(struct fs_dirheader)); |
memset(&di, 0, sizeof di); |
di.ppath = dirp->entry.d_name; |
di.retval = (uint32_t)retdir; |
di.start = lastread_block; |
di.size = 1; |
int rc = sf_file(1, &di); // read dir |
if(rc) { |
fprintf(stderr, "Error %d reading dir item %s", rc, dirp->entry.d_name); |
errno = rc; |
return NULL; |
} |
static struct dirent ent; |
ent.d_namlen = strlen(bdfe->fname); |
assert (ent.d_namlen < sizeof(ent.d_name)); |
strcpy(ent.d_name, bdfe->fname); |
lastread_block++; |
return &ent; |
}; |
void rewinddir(DIR *dirp) |
{ |
if (!dirp || lastread_block == -1) |
{ |
return; |
} |
lastread_block = 0; |
} |
int mkdir(const char *_path, mode_t m) |
{ |
struct fs_dirinfo di; |
memset(&di, 0, sizeof di); |
di.ppath = (char*)_path; |
int rc = sf_file(9, &di); // creat dir |
if(rc) { |
fprintf(stderr, "Error %d creating dir item %s", rc, _path); |
errno = rc; |
return -1; |
} |
return 0; |
} |
/* tested example |
void* read_folderdata(char* name) |
{ |
struct fs_dirinfo di; |
struct fs_dirheader dhead; |
assert(sizeof di == 25); |
memset(&di, 0, sizeof di); |
di.ppath = name; |
di.retval = (uint32_t)&dhead; |
int rc = sf_file(1, &di); // read dir size |
if(rc) { |
debug_board_printf("Error reading dir size %s", name); |
exit(1); |
} |
di.size = dhead.totl_blocks; |
char *retdir = malloc(sizeof dhead + dhead.totl_blocks * sizeof(struct fsBDFE)); |
if(!retdir) { |
debug_board_printf("No memory for dir %s", name); |
exit(1); |
} |
di.retval = (uint32_t)retdir; |
rc = sf_file(1, &di); // read dir |
if(rc) { |
debug_board_printf("Error 2 reading dir size %s", name); |
exit(1); |
} |
// manual clear mark flag (random junk in fname free space) |
int i; |
for (i = 0; i < dhead.totl_blocks; i++) |
((struct fsBDFE*)(retdir+32))[i].fname[259] = 0; |
debug_board_printf("Loaded dir [%s] etnries %d,\n first file [%s]\n", name, ((struct fs_dirheader*)(retdir))->curn_blocks, ((struct fsBDFE*)(retdir+32))->fname); |
return retdir; |
} |
*/ |
/programs/fs/unzip60/kolibri/kos32.c |
---|
0,0 → 1,968 |
/* |
Kolibri OS port for gcc 5.4 |
Started by Siemargl @Nov 2016 |
Borrowed code parts from other unzip ports |
howto make: |
go in unzip60 directory (below this file) and |
>make -f kolibri\makefile.gcc |
Contains: |
version() |
mapattr() |
checkdir() |
extract.o:extract.c:(.text+0x1410): undefined reference to `mapname' |
extract.o:extract.c:(.text+0x241d): undefined reference to `close_outfile' |
extract.o:extract.c:(.text+0x2e09): undefined reference to `checkdir' |
process.o:process.c:(.text+0x13e9): undefined reference to `checkdir' |
process.o:process.c:(.text+0x15a1): undefined reference to `do_wild' |
kolibri\makefile.gcc:276: recipe for target 'unzip.exe' failed |
*/ |
#define FATTR FS_HIDDEN+FS_SYSTEM+FS_SUBDIR |
#define UNZIP_INTERNAL |
#include "unzip.h" |
// Siemargl fork of Kolibri system API |
#include "kos32sys1.h" |
/********************************************************************************************************************/ |
/*** Function version() */ |
/********************************************************************************************************************/ |
void version(__G) |
__GDEF |
{ |
sprintf((char *)slide, LoadFarString(CompiledWith), |
#if defined(__TINYC__) |
"TinyC", "", |
#elif defined(__GNUC__) |
"GNU C ", __VERSION__, |
#else |
"(unknown compiler) ","", |
#endif |
"KolibriOS ", |
#ifdef __POWERPC__ |
"(PowerPC)", |
#else |
# ifdef __INTEL__ |
"(x86)", |
# else |
"(unknown)", /* someday we may have other architectures... */ |
# endif |
#endif |
#ifdef __DATE__ |
" on ", __DATE__ |
#else |
"", "" |
#endif |
); |
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0); |
} /* end function version() */ |
/********************************************************************************************************************/ |
/*** Function mapattr() */ |
/********************************************************************************************************************/ |
/* Identical to MS-DOS, OS/2 versions. However, NT has a lot of extra |
* permission stuff, so this function should probably be extended in the |
* future. */ |
int mapattr(__G) |
__GDEF |
{ |
/* set archive bit for file entries (file is not backed up): */ |
G.pInfo->file_attr = ((unsigned)G.crec.external_file_attributes | |
(G.crec.external_file_attributes & FS_SUBDIR ? |
0 : FS_ARCHIV)) & 0xff; |
return 0; |
} /* end function mapattr() */ |
/********************************************************************************************************************/ |
/*** Function checkdir() */ |
/********************************************************************************************************************/ |
/************************/ |
/* Function mapname() */ |
/************************/ |
int mapname(__G__ renamed) |
__GDEF |
int renamed; |
/* |
* returns: |
* MPN_OK - no problem detected |
* MPN_INF_TRUNC - caution (truncated filename) |
* MPN_INF_SKIP - info "skip entry" (dir doesn't exist) |
* MPN_ERR_SKIP - error -> skip entry |
* MPN_ERR_TOOLONG - error -> path is too long |
* MPN_NOMEM - error (memory allocation failed) -> skip entry |
* [also MPN_VOL_LABEL, MPN_CREATED_DIR] |
*/ |
{ |
char pathcomp[FILNAMSIZ]; /* path-component buffer */ |
char *pp, *cp=(char *)NULL; /* character pointers */ |
char *lastsemi=(char *)NULL; /* pointer to last semi-colon in pathcomp */ |
#ifdef ACORN_FTYPE_NFS |
char *lastcomma=(char *)NULL; /* pointer to last comma in pathcomp */ |
RO_extra_block *ef_spark; /* pointer Acorn FTYPE ef block */ |
#endif |
int killed_ddot = FALSE; /* is set when skipping "../" pathcomp */ |
int error = MPN_OK; |
register unsigned workch; /* hold the character being tested */ |
/*--------------------------------------------------------------------------- |
Initialize various pointers and counters and stuff. |
---------------------------------------------------------------------------*/ |
if (G.pInfo->vollabel) |
return MPN_VOL_LABEL; /* can't set disk volume labels in Unix */ |
/* can create path as long as not just freshening, or if user told us */ |
G.create_dirs = (!uO.fflag || renamed); |
G.created_dir = FALSE; /* not yet */ |
/* user gave full pathname: don't prepend rootpath */ |
G.renamed_fullpath = (renamed && (*G.filename == '/')); |
if (checkdir(__G__ (char *)NULL, INIT) == MPN_NOMEM) |
return MPN_NOMEM; /* initialize path buffer, unless no memory */ |
*pathcomp = '\0'; /* initialize translation buffer */ |
pp = pathcomp; /* point to translation buffer */ |
if (uO.jflag) /* junking directories */ |
cp = (char *)strrchr(G.filename, '/'); |
if (cp == (char *)NULL) /* no '/' or not junking dirs */ |
cp = G.filename; /* point to internal zipfile-member pathname */ |
else |
++cp; /* point to start of last component of path */ |
/*--------------------------------------------------------------------------- |
Begin main loop through characters in filename. |
---------------------------------------------------------------------------*/ |
while ((workch = (uch)*cp++) != 0) { |
switch (workch) { |
case '/': /* can assume -j flag not given */ |
*pp = '\0'; |
if (strcmp(pathcomp, ".") == 0) { |
/* don't bother appending "./" to the path */ |
*pathcomp = '\0'; |
} else if (!uO.ddotflag && strcmp(pathcomp, "..") == 0) { |
/* "../" dir traversal detected, skip over it */ |
*pathcomp = '\0'; |
killed_ddot = TRUE; /* set "show message" flag */ |
} |
/* when path component is not empty, append it now */ |
if (*pathcomp != '\0' && |
((error = checkdir(__G__ pathcomp, APPEND_DIR)) |
& MPN_MASK) > MPN_INF_TRUNC) |
return error; |
pp = pathcomp; /* reset conversion buffer for next piece */ |
lastsemi = (char *)NULL; /* leave direct. semi-colons alone */ |
break; |
#ifdef __CYGWIN__ /* Cygwin runs on Win32, apply FAT/NTFS filename rules */ |
case ':': /* drive spec not stored, so no colon allowed */ |
case '\\': /* '\\' may come as normal filename char (not */ |
case '<': /* dir sep char!) from unix-like file system */ |
case '>': /* no redirection symbols allowed either */ |
case '|': /* no pipe signs allowed */ |
case '"': /* no double quotes allowed */ |
case '?': /* no wildcards allowed */ |
case '*': |
*pp++ = '_'; /* these rules apply equally to FAT and NTFS */ |
break; |
#endif |
case ';': /* VMS version (or DEC-20 attrib?) */ |
lastsemi = pp; |
*pp++ = ';'; /* keep for now; remove VMS ";##" */ |
break; /* later, if requested */ |
#ifdef ACORN_FTYPE_NFS |
case ',': /* NFS filetype extension */ |
lastcomma = pp; |
*pp++ = ','; /* keep for now; may need to remove */ |
break; /* later, if requested */ |
#endif |
#ifdef MTS |
case ' ': /* change spaces to underscore under */ |
*pp++ = '_'; /* MTS; leave as spaces under Unix */ |
break; |
#endif |
default: |
/* disable control character filter when requested, |
* else allow 8-bit characters (e.g. UTF-8) in filenames: |
*/ |
; |
/*kos |
if (uO.cflxflag || |
(isprint(workch) || (128 <= workch && workch <= 254))) |
*pp++ = (char)workch; |
*/ |
} /* end switch */ |
} /* end while loop */ |
/* Show warning when stripping insecure "parent dir" path components */ |
if (killed_ddot && QCOND2) { |
Info(slide, 0, ((char *)slide, |
"warning: skipped \"../\" path component(s) in %s\n", |
FnFilter1(G.filename))); |
if (!(error & ~MPN_MASK)) |
error = (error & MPN_MASK) | PK_WARN; |
} |
/*--------------------------------------------------------------------------- |
Report if directory was created (and no file to create: filename ended |
in '/'), check name to be sure it exists, and combine path and name be- |
fore exiting. |
---------------------------------------------------------------------------*/ |
if (G.filename[strlen(G.filename) - 1] == '/') { |
checkdir(__G__ G.filename, GETPATH); |
if (G.created_dir) { |
if (QCOND2) { |
Info(slide, 0, ((char *)slide, " creating: %s\n", |
FnFilter1(G.filename))); |
} |
#ifndef NO_CHMOD |
/* Filter out security-relevant attributes bits. */ |
G.pInfo->file_attr = filtattr(__G__ G.pInfo->file_attr); |
/* When extracting non-UNIX directories or when extracting |
* without UID/GID restoration or SGID preservation, any |
* SGID flag inherited from the parent directory should be |
* maintained to allow files extracted into this new folder |
* to inherit the GID setting from the parent directory. |
*/ |
if (G.pInfo->hostnum != UNIX_ || !(uO.X_flag || uO.K_flag)) { |
/* preserve SGID bit when inherited from parent dir */ |
if (!SSTAT(G.filename, &G.statbuf)) { |
G.pInfo->file_attr |= G.statbuf.st_mode & S_ISGID; |
} else { |
perror("Could not read directory attributes"); |
} |
} |
/* set approx. dir perms (make sure can still read/write in dir) */ |
if (chmod(G.filename, G.pInfo->file_attr | 0700)) |
perror("chmod (directory attributes) error"); |
#endif |
/* set dir time (note trailing '/') */ |
return (error & ~MPN_MASK) | MPN_CREATED_DIR; |
} |
/* dir existed already; don't look for data to extract */ |
return (error & ~MPN_MASK) | MPN_INF_SKIP; |
} |
*pp = '\0'; /* done with pathcomp: terminate it */ |
/* if not saving them, remove VMS version numbers (appended ";###") */ |
if (!uO.V_flag && lastsemi) { |
pp = lastsemi + 1; |
while (isdigit((uch)(*pp))) |
++pp; |
if (*pp == '\0') /* only digits between ';' and end: nuke */ |
*lastsemi = '\0'; |
} |
/* On UNIX (and compatible systems), "." and ".." are reserved for |
* directory navigation and cannot be used as regular file names. |
* These reserved one-dot and two-dot names are mapped to "_" and "__". |
*/ |
if (strcmp(pathcomp, ".") == 0) |
*pathcomp = '_'; |
else if (strcmp(pathcomp, "..") == 0) |
strcpy(pathcomp, "__"); |
#ifdef ACORN_FTYPE_NFS |
/* translate Acorn filetype information if asked to do so */ |
if (uO.acorn_nfs_ext && |
(ef_spark = (RO_extra_block *) |
getRISCOSexfield(G.extra_field, G.lrec.extra_field_length)) |
!= (RO_extra_block *)NULL) |
{ |
/* file *must* have a RISC OS extra field */ |
long ft = (long)makelong(ef_spark->loadaddr); |
/*32-bit*/ |
if (lastcomma) { |
pp = lastcomma + 1; |
while (isxdigit((uch)(*pp))) ++pp; |
if (pp == lastcomma+4 && *pp == '\0') *lastcomma='\0'; /* nuke */ |
} |
if ((ft & 1<<31)==0) ft=0x000FFD00; |
sprintf(pathcomp+strlen(pathcomp), ",%03x", (int)(ft>>8) & 0xFFF); |
} |
#endif /* ACORN_FTYPE_NFS */ |
if (*pathcomp == '\0') { |
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n", |
FnFilter1(G.filename))); |
return (error & ~MPN_MASK) | MPN_ERR_SKIP; |
} |
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */ |
checkdir(__G__ G.filename, GETPATH); |
return error; |
} /* end function mapname() */ |
#if 0 /*========== NOTES ==========*/ |
extract-to dir: a:path/ |
buildpath: path1/path2/ ... (NULL-terminated) |
pathcomp: filename |
mapname(): |
loop over chars in zipfile member name |
checkdir(path component, COMPONENT | CREATEDIR) --> map as required? |
(d:/tmp/unzip/) (disk:[tmp.unzip.) |
(d:/tmp/unzip/jj/) (disk:[tmp.unzip.jj.) |
(d:/tmp/unzip/jj/temp/) (disk:[tmp.unzip.jj.temp.) |
finally add filename itself and check for existence? (could use with rename) |
(d:/tmp/unzip/jj/temp/msg.outdir) (disk:[tmp.unzip.jj.temp]msg.outdir) |
checkdir(name, GETPATH) --> copy path to name and free space |
#endif /* 0 */ |
/***********************/ |
/* Function checkdir() */ |
/***********************/ |
int checkdir(__G__ pathcomp, flag) |
__GDEF |
char *pathcomp; |
int flag; |
/* |
* returns: |
* MPN_OK - no problem detected |
* MPN_INF_TRUNC - (on APPEND_NAME) truncated filename |
* MPN_INF_SKIP - path doesn't exist, not allowed to create |
* MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path |
* exists and is not a directory, but is supposed to be |
* MPN_ERR_TOOLONG - path is too long |
* MPN_NOMEM - can't allocate memory for filename buffers |
*/ |
{ |
/* static int rootlen = 0; */ /* length of rootpath */ |
/* static char *rootpath; */ /* user's "extract-to" directory */ |
/* static char *buildpath; */ /* full path (so far) to extracted file */ |
/* static char *end; */ /* pointer to end of buildpath ('\0') */ |
# define FN_MASK 7 |
# define FUNCTION (flag & FN_MASK) |
/*--------------------------------------------------------------------------- |
APPEND_DIR: append the path component to the path being built and check |
for its existence. If doesn't exist and we are creating directories, do |
so for this one; else signal success or error as appropriate. |
---------------------------------------------------------------------------*/ |
if (FUNCTION == APPEND_DIR) { |
int too_long = FALSE; |
#ifdef SHORT_NAMES |
char *old_end = end; |
#endif |
Trace((stderr, "appending dir segment [%s]\n", FnFilter1(pathcomp))); |
while ((*G.end = *pathcomp++) != '\0') |
++G.end; |
#ifdef SHORT_NAMES /* path components restricted to 14 chars, typically */ |
if ((G.end-old_end) > FILENAME_MAX) /* GRR: proper constant? */ |
*(G.end = old_end + FILENAME_MAX) = '\0'; |
#endif |
/* GRR: could do better check, see if overrunning buffer as we go: |
* check end-buildpath after each append, set warning variable if |
* within 20 of FILNAMSIZ; then if var set, do careful check when |
* appending. Clear variable when begin new path. */ |
/* next check: need to append '/', at least one-char name, '\0' */ |
if ((G.end-G.buildpath) > FILNAMSIZ-3) |
too_long = TRUE; /* check if extracting dir? */ |
if (SSTAT(G.buildpath, &G.statbuf)) { /* path doesn't exist */ |
if (!G.create_dirs) { /* told not to create (freshening) */ |
free(G.buildpath); |
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */ |
} |
if (too_long) { |
Info(slide, 1, ((char *)slide, |
"checkdir error: path too long: %s\n", |
FnFilter1(G.buildpath))); |
free(G.buildpath); |
/* no room for filenames: fatal */ |
return MPN_ERR_TOOLONG; |
} |
if (mkdir(G.buildpath, 0777) == -1) { /* create the directory */ |
Info(slide, 1, ((char *)slide, |
"checkdir error: cannot create %s\n\ |
%s\n\ |
unable to process %s.\n", |
FnFilter2(G.buildpath), |
strerror(errno), |
FnFilter1(G.filename))); |
free(G.buildpath); |
/* path didn't exist, tried to create, failed */ |
return MPN_ERR_SKIP; |
} |
G.created_dir = TRUE; |
} else if (!S_ISDIR(G.statbuf.st_mode)) { |
Info(slide, 1, ((char *)slide, |
"checkdir error: %s exists but is not directory\n\ |
unable to process %s.\n", |
FnFilter2(G.buildpath), FnFilter1(G.filename))); |
free(G.buildpath); |
/* path existed but wasn't dir */ |
return MPN_ERR_SKIP; |
} |
if (too_long) { |
Info(slide, 1, ((char *)slide, |
"checkdir error: path too long: %s\n", FnFilter1(G.buildpath))); |
free(G.buildpath); |
/* no room for filenames: fatal */ |
return MPN_ERR_TOOLONG; |
} |
*G.end++ = '/'; |
*G.end = '\0'; |
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(G.buildpath))); |
return MPN_OK; |
} /* end if (FUNCTION == APPEND_DIR) */ |
/*--------------------------------------------------------------------------- |
GETPATH: copy full path to the string pointed at by pathcomp, and free |
G.buildpath. |
---------------------------------------------------------------------------*/ |
if (FUNCTION == GETPATH) { |
strcpy(pathcomp, G.buildpath); |
Trace((stderr, "getting and freeing path [%s]\n", |
FnFilter1(pathcomp))); |
free(G.buildpath); |
G.buildpath = G.end = (char *)NULL; |
return MPN_OK; |
} |
/*--------------------------------------------------------------------------- |
APPEND_NAME: assume the path component is the filename; append it and |
return without checking for existence. |
---------------------------------------------------------------------------*/ |
if (FUNCTION == APPEND_NAME) { |
#ifdef SHORT_NAMES |
char *old_end = end; |
#endif |
Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp))); |
while ((*G.end = *pathcomp++) != '\0') { |
++G.end; |
#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */ |
if ((G.end-old_end) > FILENAME_MAX) /* GRR: proper constant? */ |
*(G.end = old_end + FILENAME_MAX) = '\0'; |
#endif |
if ((G.end-G.buildpath) >= FILNAMSIZ) { |
*--G.end = '\0'; |
Info(slide, 0x201, ((char *)slide, |
"checkdir warning: path too long; truncating\n\ |
%s\n -> %s\n", |
FnFilter1(G.filename), FnFilter2(G.buildpath))); |
return MPN_INF_TRUNC; /* filename truncated */ |
} |
} |
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(G.buildpath))); |
/* could check for existence here, prompt for new name... */ |
return MPN_OK; |
} |
/*--------------------------------------------------------------------------- |
INIT: allocate and initialize buffer space for the file currently being |
extracted. If file was renamed with an absolute path, don't prepend the |
extract-to path. |
---------------------------------------------------------------------------*/ |
/* GRR: for VMS and TOPS-20, add up to 13 to strlen */ |
if (FUNCTION == INIT) { |
Trace((stderr, "initializing buildpath to ")); |
#ifdef ACORN_FTYPE_NFS |
if ((G.buildpath = (char *)malloc(strlen(G.filename)+G.rootlen+ |
(uO.acorn_nfs_ext ? 5 : 1))) |
#else |
if ((G.buildpath = (char *)malloc(strlen(G.filename)+G.rootlen+1)) |
#endif |
== (char *)NULL) |
return MPN_NOMEM; |
if ((G.rootlen > 0) && !G.renamed_fullpath) { |
strcpy(G.buildpath, G.rootpath); |
G.end = G.buildpath + G.rootlen; |
} else { |
*G.buildpath = '\0'; |
G.end = G.buildpath; |
} |
Trace((stderr, "[%s]\n", FnFilter1(G.buildpath))); |
return MPN_OK; |
} |
/*--------------------------------------------------------------------------- |
ROOT: if appropriate, store the path in rootpath and create it if |
necessary; else assume it's a zipfile member and return. This path |
segment gets used in extracting all members from every zipfile specified |
on the command line. |
---------------------------------------------------------------------------*/ |
#if (!defined(SFX) || defined(SFX_EXDIR)) |
if (FUNCTION == ROOT) { |
Trace((stderr, "initializing root path to [%s]\n", |
FnFilter1(pathcomp))); |
if (pathcomp == (char *)NULL) { |
G.rootlen = 0; |
return MPN_OK; |
} |
if (G.rootlen > 0) /* rootpath was already set, nothing to do */ |
return MPN_OK; |
if ((G.rootlen = strlen(pathcomp)) > 0) { |
char *tmproot; |
if ((tmproot = (char *)malloc(G.rootlen+2)) == (char *)NULL) { |
G.rootlen = 0; |
return MPN_NOMEM; |
} |
strcpy(tmproot, pathcomp); |
if (tmproot[G.rootlen-1] == '/') { |
tmproot[--G.rootlen] = '\0'; |
} |
if (G.rootlen > 0 && (SSTAT(tmproot, &G.statbuf) || |
!S_ISDIR(G.statbuf.st_mode))) |
{ /* path does not exist */ |
if (!G.create_dirs /* || iswild(tmproot) */ ) { |
free(tmproot); |
G.rootlen = 0; |
/* skip (or treat as stored file) */ |
return MPN_INF_SKIP; |
} |
/* create the directory (could add loop here scanning tmproot |
* to create more than one level, but why really necessary?) */ |
if (mkdir(tmproot, 0777) == -1) { |
Info(slide, 1, ((char *)slide, |
"checkdir: cannot create extraction directory: %s\n\ |
%s\n", |
FnFilter1(tmproot), strerror(errno))); |
free(tmproot); |
G.rootlen = 0; |
/* path didn't exist, tried to create, and failed: */ |
/* file exists, or 2+ subdir levels required */ |
return MPN_ERR_SKIP; |
} |
} |
tmproot[G.rootlen++] = '/'; |
tmproot[G.rootlen] = '\0'; |
if ((G.rootpath = (char *)realloc(tmproot, G.rootlen+1)) == NULL) { |
free(tmproot); |
G.rootlen = 0; |
return MPN_NOMEM; |
} |
Trace((stderr, "rootpath now = [%s]\n", FnFilter1(G.rootpath))); |
} |
return MPN_OK; |
} |
#endif /* !SFX || SFX_EXDIR */ |
/*--------------------------------------------------------------------------- |
END: free rootpath, immediately prior to program exit. |
---------------------------------------------------------------------------*/ |
if (FUNCTION == END) { |
Trace((stderr, "freeing rootpath\n")); |
if (G.rootlen > 0) { |
free(G.rootpath); |
G.rootlen = 0; |
} |
return MPN_OK; |
} |
return MPN_INVALID; /* should never reach */ |
} /* end function checkdir() */ |
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2])); |
static int get_extattribs(__G__ pzt, z_uidgid) |
__GDEF |
iztimes *pzt; |
ulg z_uidgid[2]; |
{ |
/*--------------------------------------------------------------------------- |
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT |
time: adjust base year from 1980 to 1970, do usual conversions from |
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day- |
light savings time differences. If we have a Unix extra field, however, |
we're laughing: both mtime and atime are ours. On the other hand, we |
then have to check for restoration of UID/GID. |
---------------------------------------------------------------------------*/ |
int have_uidgid_flg; |
unsigned eb_izux_flg; |
eb_izux_flg = 0; // kos32 |
/* |
(G.extra_field ? ef_scan_for_izux(G.extra_field, |
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime, |
#ifdef IZ_CHECK_TZ |
(G.tz_is_valid ? pzt : NULL), |
#else |
pzt, |
#endif |
z_uidgid) : 0); |
*/ |
if (eb_izux_flg & EB_UT_FL_MTIME) { |
TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n", |
pzt->mtime)); |
} else { |
pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime); |
} |
if (eb_izux_flg & EB_UT_FL_ATIME) { |
TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n", |
pzt->atime)); |
} else { |
pzt->atime = pzt->mtime; |
TTrace((stderr, "\nget_extattribs: modification/access times = %ld\n", |
pzt->mtime)); |
} |
/* if -X option was specified and we have UID/GID info, restore it */ |
have_uidgid_flg = |
#ifdef RESTORE_UIDGID |
(uO.X_flag && (eb_izux_flg & EB_UX2_VALID)); |
#else |
0; |
#endif |
return have_uidgid_flg; |
} |
/****************************/ |
/* Function close_outfile() */ |
/****************************/ |
void close_outfile(__G) /* GRR: change to return PK-style warning level */ |
__GDEF |
{ |
union { |
iztimes t3; /* mtime, atime, ctime */ |
ztimbuf t2; /* modtime, actime */ |
} zt; |
ulg z_uidgid[2]; |
int have_uidgid_flg; |
have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid); |
/*--------------------------------------------------------------------------- |
If symbolic links are supported, allocate storage for a symlink control |
structure, put the uncompressed "data" and other required info in it, and |
add the structure to the "deferred symlinks" chain. Since we know it's a |
symbolic link to start with, we shouldn't have to worry about overflowing |
unsigned ints with unsigned longs. |
---------------------------------------------------------------------------*/ |
#ifdef SYMLINKS |
if (G.symlnk) { |
extent ucsize = (extent)G.lrec.ucsize; |
# ifdef SET_SYMLINK_ATTRIBS |
extent attribsize = sizeof(unsigned) + |
(have_uidgid_flg ? sizeof(z_uidgid) : 0); |
# else |
extent attribsize = 0; |
# endif |
/* size of the symlink entry is the sum of |
* (struct size (includes 1st '\0') + 1 additional trailing '\0'), |
* system specific attribute data size (might be 0), |
* and the lengths of name and link target. |
*/ |
extent slnk_entrysize = (sizeof(slinkentry) + 1) + attribsize + |
ucsize + strlen(G.filename); |
slinkentry *slnk_entry; |
if (slnk_entrysize < ucsize) { |
Info(slide, 0x201, ((char *)slide, |
"warning: symbolic link (%s) failed: mem alloc overflow\n", |
FnFilter1(G.filename))); |
fclose(G.outfile); |
return; |
} |
if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) { |
Info(slide, 0x201, ((char *)slide, |
"warning: symbolic link (%s) failed: no mem\n", |
FnFilter1(G.filename))); |
fclose(G.outfile); |
return; |
} |
slnk_entry->next = NULL; |
slnk_entry->targetlen = ucsize; |
slnk_entry->attriblen = attribsize; |
# ifdef SET_SYMLINK_ATTRIBS |
memcpy(slnk_entry->buf, &(G.pInfo->file_attr), |
sizeof(unsigned)); |
if (have_uidgid_flg) |
memcpy(slnk_entry->buf + 4, z_uidgid, sizeof(z_uidgid)); |
# endif |
slnk_entry->target = slnk_entry->buf + slnk_entry->attriblen; |
slnk_entry->fname = slnk_entry->target + ucsize + 1; |
strcpy(slnk_entry->fname, G.filename); |
/* move back to the start of the file to re-read the "link data" */ |
rewind(G.outfile); |
if (fread(slnk_entry->target, 1, ucsize, G.outfile) != ucsize) |
{ |
Info(slide, 0x201, ((char *)slide, |
"warning: symbolic link (%s) failed\n", |
FnFilter1(G.filename))); |
free(slnk_entry); |
fclose(G.outfile); |
return; |
} |
fclose(G.outfile); /* close "link" file for good... */ |
slnk_entry->target[ucsize] = '\0'; |
if (QCOND2) |
Info(slide, 0, ((char *)slide, "-> %s ", |
FnFilter1(slnk_entry->target))); |
/* add this symlink record to the list of deferred symlinks */ |
if (G.slink_last != NULL) |
G.slink_last->next = slnk_entry; |
else |
G.slink_head = slnk_entry; |
G.slink_last = slnk_entry; |
return; |
} |
#endif /* SYMLINKS */ |
#ifdef QLZIP |
if (G.extra_field) { |
static void qlfix OF((__GPRO__ uch *ef_ptr, unsigned ef_len)); |
qlfix(__G__ G.extra_field, G.lrec.extra_field_length); |
} |
#endif |
#if (defined(NO_FCHOWN)) |
fclose(G.outfile); |
#endif |
// kos. add set file datetime ? |
#ifndef KOS32 |
/* if -X option was specified and we have UID/GID info, restore it */ |
if (have_uidgid_flg |
/* check that both uid and gid values fit into their data sizes */ |
&& ((ulg)(uid_t)(z_uidgid[0]) == z_uidgid[0]) |
&& ((ulg)(gid_t)(z_uidgid[1]) == z_uidgid[1])) { |
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n")); |
#if (defined(NO_FCHOWN)) |
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1])) |
#else |
if (fchown(fileno(G.outfile), (uid_t)z_uidgid[0], (gid_t)z_uidgid[1])) |
#endif |
{ |
if (uO.qflag) |
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid, |
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename), |
strerror(errno))); |
else |
Info(slide, 0x201, ((char *)slide, CannotSetUidGid, |
z_uidgid[0], z_uidgid[1], strerror(errno))); |
} |
} |
#if (!defined(NO_FCHOWN) && defined(NO_FCHMOD)) |
fclose(G.outfile); |
#endif |
#if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD)) |
/*--------------------------------------------------------------------------- |
Change the file permissions from default ones to those stored in the |
zipfile. |
---------------------------------------------------------------------------*/ |
if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr))) |
perror("fchmod (file attributes) error"); |
fclose(G.outfile); |
#endif /* !NO_FCHOWN && !NO_FCHMOD */ |
/* skip restoring time stamps on user's request */ |
if (uO.D_flag <= 1) { |
/* set the file's access and modification times */ |
if (utime(G.filename, &(zt.t2))) { |
if (uO.qflag) |
Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps, |
FnFilter1(G.filename), strerror(errno))); |
else |
Info(slide, 0x201, ((char *)slide, CannotSetTimestamps, |
strerror(errno))); |
} |
} |
#if (defined(NO_FCHOWN) || defined(NO_FCHMOD)) |
/*--------------------------------------------------------------------------- |
Change the file permissions from default ones to those stored in the |
zipfile. |
---------------------------------------------------------------------------*/ |
#ifndef NO_CHMOD |
if (chmod(G.filename, filtattr(__G__ G.pInfo->file_attr))) |
perror("chmod (file attributes) error"); |
#endif |
#endif /* NO_FCHOWN || NO_FCHMOD */ |
#endif // 0 |
} /* end function close_outfile() */ |
/**********************/ |
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */ |
/**********************/ |
char *do_wild(__G__ wildspec) |
__GDEF |
ZCONST char *wildspec; /* only used first time on a given dir */ |
{ |
/* these statics are now declared in SYSTEM_SPECIFIC_GLOBALS in unxcfg.h: |
static DIR *wild_dir = (DIR *)NULL; |
static ZCONST char *wildname; |
static char *dirname, matchname[FILNAMSIZ]; |
static int notfirstcall=FALSE, have_dirname, dirnamelen; |
*/ |
struct dirent *file; |
/* Even when we're just returning wildspec, we *always* do so in |
* matchname[]--calling routine is allowed to append four characters |
* to the returned string, and wildspec may be a pointer to argv[]. |
*/ |
if (!G.notfirstcall) { /* first call: must initialize everything */ |
G.notfirstcall = TRUE; |
if (!iswild(wildspec)) { |
strncpy(G.matchname, wildspec, FILNAMSIZ); |
G.matchname[FILNAMSIZ-1] = '\0'; |
G.have_dirname = FALSE; |
G.wild_dir = NULL; |
return G.matchname; |
} |
/* break the wildspec into a directory part and a wildcard filename */ |
if ((G.wildname = (ZCONST char *)strrchr(wildspec, '/')) == NULL) { |
G.dirname = "."; |
G.dirnamelen = 1; |
G.have_dirname = FALSE; |
G.wildname = wildspec; |
} else { |
++G.wildname; /* point at character after '/' */ |
G.dirnamelen = G.wildname - wildspec; |
if ((G.dirname = (char *)malloc(G.dirnamelen+1)) == (char *)NULL) { |
Info(slide, 0x201, ((char *)slide, |
"warning: cannot allocate wildcard buffers\n")); |
strncpy(G.matchname, wildspec, FILNAMSIZ); |
G.matchname[FILNAMSIZ-1] = '\0'; |
return G.matchname; /* but maybe filespec was not a wildcard */ |
} |
strncpy(G.dirname, wildspec, G.dirnamelen); |
G.dirname[G.dirnamelen] = '\0'; /* terminate for strcpy below */ |
G.have_dirname = TRUE; |
} |
if ((G.wild_dir = (zvoid *)opendir(G.dirname)) != (zvoid *)NULL) { |
while ((file = readdir((DIR *)G.wild_dir)) != |
(struct dirent *)NULL) { |
Trace((stderr, "do_wild: readdir returns %s\n", |
FnFilter1(file->d_name))); |
if (file->d_name[0] == '.' && G.wildname[0] != '.') |
continue; /* Unix: '*' and '?' do not match leading dot */ |
if (match(file->d_name, G.wildname, 0 WISEP) &&/*0=case sens.*/ |
/* skip "." and ".." directory entries */ |
strcmp(file->d_name, ".") && strcmp(file->d_name, "..")) { |
Trace((stderr, "do_wild: match() succeeds\n")); |
if (G.have_dirname) { |
strcpy(G.matchname, G.dirname); |
strcpy(G.matchname+G.dirnamelen, file->d_name); |
} else |
strcpy(G.matchname, file->d_name); |
return G.matchname; |
} |
} |
/* if we get to here directory is exhausted, so close it */ |
closedir((DIR *)G.wild_dir); |
G.wild_dir = (zvoid *)NULL; |
} |
Trace((stderr, "do_wild: opendir(%s) returns NULL\n", |
FnFilter1(G.dirname))); |
/* return the raw wildspec in case that works (e.g., directory not |
* searchable, but filespec was not wild and file is readable) */ |
strncpy(G.matchname, wildspec, FILNAMSIZ); |
G.matchname[FILNAMSIZ-1] = '\0'; |
return G.matchname; |
} |
/* last time through, might have failed opendir but returned raw wildspec */ |
if ((DIR *)G.wild_dir == (DIR *)NULL) { |
G.notfirstcall = FALSE; /* nothing left--reset for new wildspec */ |
if (G.have_dirname) |
free(G.dirname); |
return (char *)NULL; |
} |
/* If we've gotten this far, we've read and matched at least one entry |
* successfully (in a previous call), so dirname has been copied into |
* matchname already. |
*/ |
while ((file = readdir((DIR *)G.wild_dir)) != (struct dirent *)NULL) { |
Trace((stderr, "do_wild: readdir returns %s\n", |
FnFilter1(file->d_name))); |
if (file->d_name[0] == '.' && G.wildname[0] != '.') |
continue; /* Unix: '*' and '?' do not match leading dot */ |
if (match(file->d_name, G.wildname, 0 WISEP)) { /* 0 == case sens. */ |
Trace((stderr, "do_wild: match() succeeds\n")); |
if (G.have_dirname) { |
/* strcpy(G.matchname, G.dirname); */ |
strcpy(G.matchname+G.dirnamelen, file->d_name); |
} else |
strcpy(G.matchname, file->d_name); |
return G.matchname; |
} |
} |
closedir((DIR *)G.wild_dir); /* at least one entry read; nothing left */ |
G.wild_dir = (zvoid *)NULL; |
G.notfirstcall = FALSE; /* reset for new wildspec */ |
if (G.have_dirname) |
free(G.dirname); |
return (char *)NULL; |
} /* end function do_wild() */ |
/programs/fs/unzip60/kolibri/kos32sys1.h |
---|
0,0 → 1,994 |
#ifndef __KOS_32_SYS_H__ |
#define __KOS_32_SYS_H__ |
// file header taken from newlib |
// added many sys functions, compatible with tcc |
// with gcc USE gcc -mno-ms-bitfields!!! |
//#include <newlib.h> |
//#include <stdint.h> |
#include <stddef.h> |
#include <stdarg.h> |
typedef unsigned int uint32_t; |
typedef int int32_t; |
typedef unsigned char uint8_t; |
typedef unsigned short int uint16_t; |
typedef unsigned long long uint64_t; |
#ifdef __cplusplus |
extern "C" { |
#endif |
//#ifdef CONFIG_DEBUF |
// #define DBG(format,...) printf(format,##__VA_ARGS__) |
//#else |
// #define DBG(format,...) |
//#endif |
#define TYPE_3_BORDER_WIDTH 5 |
#define WIN_STATE_MINIMIZED 0x02 |
#define WIN_STATE_ROLLED 0x04 |
#define POS_SCREEN 0 |
#define POS_WINDOW 1 |
#define IPC_NOBUFFER 1 |
#define IPC_LOCKED 2 |
#define IPC_OVERFLOW 3 |
#define IPC_NOPID 4 |
#define SHM_OPEN 0x00 |
#define SHM_OPEN_ALWAYS 0x04 |
#define SHM_CREATE 0x08 |
#define SHM_READ 0x00 |
#define SHM_WRITE 0x01 |
typedef unsigned int color_t; |
typedef union __attribute__((packed)) pos_t |
{ |
uint32_t val; |
struct |
{ |
short x; |
short y; |
}; |
} pos_t; |
typedef union __attribute__((packed)) oskey_t |
{ |
uint32_t val; |
struct |
{ |
uint8_t state; |
uint8_t code; |
uint16_t ctrl_key; |
}; |
} oskey_t; |
typedef struct |
{ |
unsigned handle; |
unsigned io_code; |
void *input; |
int inp_size; |
void *output; |
int out_size; |
}ioctl_t; |
typedef union |
{ |
struct |
{ |
void *data; |
size_t size; |
} x; |
unsigned long long raw; |
}ufile_t; |
struct kolibri_system_colors { |
color_t frame_area; |
color_t grab_bar; |
color_t grab_bar_button; |
color_t grab_button_text; |
color_t grab_text; |
color_t work_area; |
color_t work_button; |
color_t work_button_text; |
color_t work_text; |
color_t work_graph; |
}; |
struct blit_call |
{ |
int dstx; |
int dsty; |
int w; |
int h; |
int srcx; |
int srcy; |
int srcw; |
int srch; |
void *bitmap; |
int stride; |
}; |
struct ipc_message |
{ |
uint32_t pid; // PID of sending thread |
uint32_t datalen; // data bytes |
char data[0]; // data begin |
}; |
struct ipc_buffer |
{ |
uint32_t lock; // nonzero is locked |
uint32_t used; // used bytes in buffer |
struct ipc_message data[0]; // data begin |
}; |
typedef struct __attribute__((packed)) file_op_t |
{ |
uint32_t fn; |
uint32_t flags; |
char* args; |
uint32_t res1, res2; |
char zero; |
char* app_name |
#ifdef __TINYC__ |
__attribute__((packed)) |
#endif |
; |
} file_op_t; |
static inline void begin_draw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(1)); |
}; |
static inline |
void end_draw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(2)); |
}; |
static inline |
void sys_create_window(int x, int y, int w, int h, const char *name, |
color_t workcolor, uint32_t style) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(0), |
"b"((x << 16) | ((w-1) & 0xFFFF)), |
"c"((y << 16) | ((h-1) & 0xFFFF)), |
"d"((style << 24) | (workcolor & 0xFFFFFF)), |
"D"(name), |
"S"(0) : "memory"); |
}; |
static inline |
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(8), |
"b"(x_w), |
"c"(y_h), |
"d"(id), |
"S"(color)); |
}; |
static inline |
void draw_line(int xs, int ys, int xe, int ye, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(38), "d"(color), |
"b"((xs << 16) | xe), |
"c"((ys << 16) | ye)); |
} |
static inline |
void draw_bar(int x, int y, int w, int h, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(13), "d"(color), |
"b"((x << 16) | w), |
"c"((y << 16) | h)); |
} |
static inline |
void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(7), "b"(bitmap), |
"c"((w << 16) | h), |
"d"((x << 16) | y)); |
} |
static inline |
void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(4),"d"(text), |
"b"((x << 16) | y), |
"S"(len),"c"(color) |
:"memory"); |
} |
static inline |
uint32_t get_skin_height(void) |
{ |
uint32_t height; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
:"=a"(height) |
:"a"(48),"b"(4)); |
return height; |
}; |
static inline |
pos_t get_mouse_pos(int origin) |
{ |
pos_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(origin)); |
return val; |
} |
static inline |
uint32_t get_mouse_buttons(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(2)); |
return val; |
}; |
static inline |
uint32_t get_mouse_wheels(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
:"=a"(val) |
:"a"(37),"b"(7)); |
return val; |
}; |
static inline uint32_t load_cursor(void *path, uint32_t flags) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37), "b"(4), "c"(path), "d"(flags)); |
return val; |
} |
static inline uint32_t set_cursor(uint32_t cursor) |
{ |
uint32_t old; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(old) |
:"a"(37), "b"(5), "c"(cursor)); |
return old; |
}; |
static inline int destroy_cursor(uint32_t cursor) |
{ |
int ret; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(ret) |
:"a"(37), "b"(6), "c"(cursor) |
:"memory"); |
return ret; |
}; |
static inline |
uint32_t wait_for_event(uint32_t time) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(23), "b"(time)); |
return val; |
}; |
static inline uint32_t check_os_event() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(11)); |
return val; |
}; |
static inline uint32_t get_os_event() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(10)); |
return val; |
}; |
static inline |
uint32_t get_tick_count(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(26),"b"(9)); |
return val; |
}; |
static inline |
uint64_t get_ns_count(void) |
{ |
uint64_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=A"(val) |
:"a"(26), "b"(10)); |
return val; |
}; |
static inline |
oskey_t get_key(void) |
{ |
oskey_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(2)); |
return val; |
} |
static inline |
uint32_t get_os_button() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(17)); |
return val>>8; |
}; |
static inline uint32_t get_service(char *name) |
{ |
uint32_t retval = 0; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(retval) |
:"a"(68),"b"(16),"c"(name) |
:"memory"); |
return retval; |
}; |
static inline int call_service(ioctl_t *io) |
{ |
int retval; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(retval) |
:"a"(68),"b"(17),"c"(io) |
:"memory","cc"); |
return retval; |
}; |
static inline void yield(void) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(68), "b"(1)); |
}; |
static inline void delay(uint32_t time) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(5), "b"(time) |
:"memory"); |
}; |
static inline |
void *user_alloc(size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(13),"c"(mem)); |
return val; |
} |
static inline |
void* user_realloc(void *mem, size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(20),"c"(size),"d"(mem) |
:"memory"); |
return val; |
}; |
static inline |
int *user_unmap(void *base, size_t offset, size_t size) |
{ |
int *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
return val; |
}; |
static inline ufile_t load_file(const char *path) |
{ |
ufile_t uf; |
__asm__ __volatile__ ( |
"int $0x40" |
:"=A"(uf.raw) |
:"a" (68), "b"(27),"c"(path)); |
return uf; |
}; |
static inline int GetScreenSize() |
{ |
int retval; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(retval) |
:"a"(61), "b"(1)); |
return retval; |
} |
static inline void get_proc_info(char *info) |
{ |
__asm__ __volatile__( |
"int $0x40" |
: |
:"a"(9), "b"(info), "c"(-1) |
:"memory"); |
}; |
static inline void Blit(void *bitmap, int dst_x, int dst_y, |
int src_x, int src_y, int w, int h, |
int src_w, int src_h, int stride) |
{ |
volatile struct blit_call bc; |
bc.dstx = dst_x; |
bc.dsty = dst_y; |
bc.w = w; |
bc.h = h; |
bc.srcx = src_x; |
bc.srcy = src_y; |
bc.srcw = src_w; |
bc.srch = src_h; |
bc.stride = stride; |
bc.bitmap = bitmap; |
__asm__ __volatile__( |
"int $0x40" |
::"a"(73),"b"(0),"c"(&bc.dstx)); |
}; |
// newlib exclusive |
#ifndef __TINYC__ |
int create_thread(int (*proc)(void *param), void *param, int stack_size); |
void* load_library(const char *name); |
void* get_proc_address(void *handle, const char *proc_name); |
void enumerate_libraries(int (*callback)(void *handle, const char* name, |
uint32_t base, uint32_t size, void *user_data), |
void *user_data); |
#endif |
/////////////////////////////////////////////////////////////////////////////// |
/// May be next section need to be added in newlibc |
// Siemargl addenium |
#define X_Y(x,y) (((x)<<16)|(y)) |
enum KOLIBRI_GUI_EVENTS { |
KOLIBRI_EVENT_NONE = 0, /* Event queue is empty */ |
KOLIBRI_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */ |
KOLIBRI_EVENT_KEY = 2, /* A key on the keyboard was pressed */ |
KOLIBRI_EVENT_BUTTON = 3, /* A button was clicked with the mouse */ |
KOLIBRI_EVENT_DESKTOP = 5, /* Desktop redraw finished */ |
KOLIBRI_EVENT_MOUSE = 6, /* Mouse activity (movement, button press) was detected */ |
KOLIBRI_EVENT_IPC = 7, /* Interprocess communication notify */ |
KOLIBRI_EVENT_NETWORK = 8, /* Network event */ |
KOLIBRI_EVENT_DEBUG = 9, /* Debug subsystem event */ |
KOLIBRI_EVENT_IRQBEGIN = 16 /* 16..31 IRQ0..IRQ15 interrupt =IRQBEGIN+IRQn */ |
}; |
enum control_keys { |
KM_SHIFT = 0x00010000, |
KM_CTRL = 0x00020000, |
KM_ALT = 0x00040000, |
KM_NUMLOCK = 0x00080000 |
}; |
struct __attribute__ ((__packed__)) fs_dirinfo { |
uint32_t subfn; // 1 read dir |
uint32_t start; |
uint32_t flags; |
uint32_t size; |
uint32_t retval; |
union { |
struct __attribute__ ((__packed__)) { |
uint8_t zero; // 0 |
char* ppath; |
}; |
char path[5]; // up to 4096 |
} ; |
}; |
static inline |
uint32_t sf_file(int subfn, struct fs_dirinfo* dinfo) |
/// SysFn70 call with subfunction |
/// retval 0 if ok |
{ |
uint32_t retval; |
dinfo->subfn = subfn; |
__asm__ __volatile__( |
"int $0x40 " |
:"=a"(retval) |
:"a"(70),"b"(dinfo) |
:); |
return retval; |
}; |
struct fs_dirheader { |
uint32_t version; // 1 |
uint32_t curn_blocks; // number of read dir items (BDFE) |
uint32_t totl_blocks; // directory full size |
char other[20]; // reserved 0 |
}; |
enum filetype |
{ |
FS_RONLY = 1, |
FS_HIDDEN = 2, |
FS_SYSTEM = 4, |
FS_VOLID = 8, |
FS_SUBDIR = 16, |
FS_FOLDER = 16, |
FS_ARCHIV = 32 |
}; |
struct __attribute__ ((__packed__)) fs_filetime { |
uint8_t sec; |
uint8_t mm; |
uint8_t hour; |
uint8_t zero; |
}; |
struct __attribute__ ((__packed__)) fs_filedate { |
uint8_t day; |
uint8_t month; |
uint16_t year; |
}; |
/// directory entry cp866 |
struct fsBDFE { |
uint32_t filetype; |
uint32_t encoding; // 0 - cp866, 1 - utf16le |
struct fs_filetime tm_created; |
struct fs_filedate dt_created; |
struct fs_filetime tm_accessed; |
struct fs_filedate dt_accessed; |
struct fs_filetime tm_modified; |
struct fs_filedate dt_modified; |
uint64_t size; |
char fname[264]; |
}; // must be sized 304 |
/// directory entry UTF16LE |
struct fsBDFE_16 { |
uint32_t filetype; |
uint32_t encoding; // 0 - cp866, 1 - utf16le |
struct fs_filetime tm_created; |
struct fs_filedate dt_created; |
struct fs_filetime tm_accessed; |
struct fs_filedate dt_accessed; |
struct fs_filetime tm_modified; |
struct fs_filedate dt_modified; |
uint64_t size; |
wchar_t fname[260]; |
}; // must be sized 560 |
// copied from /programs/system/shell/system/kolibri.c |
// fn's returned -1 as syserror, 1 as error, 0 as OK |
static inline |
int kol_clip_num() |
{ |
register uint32_t val; |
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(0)); |
return val; |
} |
static inline |
char* kol_clip_get(int n) |
// returned buffer must be freed by user_free() |
{ |
register char* val; |
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(1), "c"(n)); |
return val; |
} |
static inline |
int kol_clip_set(int n, char buffer[]) |
{ |
register uint32_t val; |
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(2), "c"(n), "d"(buffer)); |
return val; |
} |
static inline |
int kol_clip_pop() |
{ |
register uint32_t val; |
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(3)); |
return val; |
} |
static inline |
int kol_clip_unlock() |
{ |
register uint32_t val; |
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(4)); |
return val; |
} |
static inline void get_system_colors(struct kolibri_system_colors *color_table) |
{ |
__asm__ volatile ("int $0x40" |
: |
:"a"(48),"b"(3),"c"(color_table),"d"(40) |
); |
/* color_table should point to the system color table */ |
} |
static inline void debug_board_write_byte(const char ch){ |
__asm__ __volatile__( |
"int $0x40" |
: |
:"a"(63), "b"(1), "c"(ch)); |
} |
static inline void draw_number_sys(int32_t number, int x, int y, int len, color_t color){ |
register uint32_t fmt; |
fmt = len << 16 | 0x80000000; // no leading zeros + width |
// fmt = len << 16 | 0x00000000; // leading zeros + width |
__asm__ __volatile__( |
"int $0x40" |
: |
:"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color)); |
} |
static inline |
uint32_t get_mouse_eventstate(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(3)); |
return val; |
}; |
static inline |
uint32_t set_event_mask(uint32_t mask) |
{ |
register uint32_t val; |
asm volatile ("int $0x40":"=a"(val):"a"(40), "b"(mask)); |
return val; |
} |
typedef void (*thread_proc)(void*); |
static inline |
int start_thread(thread_proc proc, char* stack_top) |
{ |
register int val; |
asm volatile ("int $0x40":"=a"(val):"a"(51), "b"(1), "c"(proc), "d"(stack_top)); |
return val; |
} |
static inline |
void kos_exit() |
{ |
asm volatile ("int $0x40"::"a"(-1)); |
} |
static inline void focus_window(int slot){ |
asm volatile ("int $0x40"::"a"(18), "b"(3), "c"(slot)); |
} |
static inline int get_thread_slot(int tid){ |
register int val; |
asm volatile ("int $0x40":"=a"(val):"a"(18), "b"(21), "c"(tid)); |
return val; |
} |
static inline void set_current_folder(char* dir){ |
asm volatile ("int $0x40"::"a"(30), "b"(1), "c"(dir)); |
} |
static inline int get_current_folder(char* buf, int bufsize){ |
register int val; |
asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize)); |
return val; |
} |
static inline |
void ipc_set_area(void* buf, int bufsize){ |
asm volatile ("int $0x40"::"a"(60), "b"(1), "c"(buf), "d"(bufsize)); |
} |
static inline |
int ipc_send_message(int pid_reciever, void *data, int datalen) { |
register int val; |
asm volatile ("int $0x40":"=a"(val):"a"(60), "b"(2), "c"(pid_reciever), "d"(data), "S"(datalen)); |
return val; |
} |
static inline |
void* shm_open(char *shm_name, int msize, int flags, int *retsz){ |
register int val, cod; |
asm volatile ("int $0x40":"=a"(val),"=d"(cod):"a"(68), "b"(22), "c"(shm_name), "d"(msize), "S"(flags)); |
if(retsz) *retsz = cod; // errcode if NULL or memsize when open |
return (void*)val; |
} |
static inline |
void shm_close(char *shm_name){ |
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(shm_name)); |
} |
static inline |
int start_app(char *app_name, char *args){ |
file_op_t file_op; |
memset(&file_op, 0, sizeof(file_op)); |
file_op.fn = 7; |
file_op.args = args; |
file_op.app_name = app_name; |
register int val; |
asm volatile ("int $0x40":"=a"(val):"a"(70), "b"(&file_op)); |
return val; |
} |
static inline |
uint32_t get_control_keys(void) |
{ |
uint32_t ctrl; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
:"=a"(ctrl) |
:"a"(66),"b"(3)); |
return ctrl; |
}; |
static inline |
int get_keyboard_layout(int opt, char* buf) |
/// 128 byte buffer |
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language |
{ |
uint32_t lang; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
:"=a"(lang) |
:"a"(26),"b"(2), "c"(opt), "d"(buf)); |
return lang; |
}; |
static inline |
int font_size(int color) |
/// decode font size in pixels from color as SysFn4 |
/// returns (width, hight) |
{ |
int font = color >> 24; |
int font_multipl = (font & 7) + 1; |
int width_sym, hight_sym; |
if (font & 0x10) // 8x16 |
{ |
width_sym = 8 * font_multipl; |
hight_sym = 16 * font_multipl; |
} else // 6x9 |
{ |
width_sym = 6 * font_multipl; |
hight_sym = 9 * font_multipl; |
} |
return hight_sym + (width_sym << 16); |
} |
/* |
static inline char *getcwd(char *buf, size_t size) |
{ |
int rc = get_current_folder(buf, size); |
if (rc > size) |
{ |
errno = ERANGE; |
return 0; |
} |
else |
return buf; |
} |
*/ |
/* not finished |
void staticnum_draw(staticnum *st) |
{ |
register uint32_t fmt; |
if (st->width < 0) |
fmt = (-st->width << 16); // leading zeros, decimal |
else |
fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal |
__asm__ __volatile__( |
"int $0x40" |
::"a"(47), |
"b"(fmt), |
"c"(st->number), |
"d"(st->start_xy), |
"S"(st->color_flags), |
"D"(st->bg_color) |
:); |
} |
*/ |
//////////// end section |
//added nonstatic inline because incomfortabre stepping in in debugger |
void __attribute__ ((noinline)) debug_board_write_str(const char* str); |
void __attribute__ ((noinline)) debug_board_printf(const char *format,...); |
/* copy body to only one project file |
void __attribute__ ((noinline)) debug_board_write_str(const char* str){ |
while(*str) |
debug_board_write_byte(*str++); |
} |
void __attribute__ ((noinline)) debug_board_printf(const char *format,...) |
{ |
va_list ap; |
char log_board[300]; |
va_start (ap, format); |
vsnprintf(log_board, sizeof log_board, format, ap); |
va_end(ap); |
debug_board_write_str(log_board); |
} |
__attribute__ ((noinline)) void trap(int n) |
{ |
// nothing todo, just see n in debugger. use "bp trap" command |
__asm__ __volatile__( |
"nop" |
: |
:"a"(n)); |
} |
*/ |
// TinyC don't support aliasing of static inline funcs |
#ifndef __TINYC__ |
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw"))); |
static inline void EndDraw(void) __attribute__ ((alias ("end_draw"))); |
static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
color_t workcolor, uint32_t style) |
__attribute__ ((alias ("sys_create_window"))); |
static inline void DefineButton(void) __attribute__ ((alias ("define_button"))); |
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color) |
__attribute__ ((alias ("draw_line"))); |
static inline void DrawBar(int x, int y, int w, int h, color_t color) |
__attribute__ ((alias ("draw_bar"))); |
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h) |
__attribute__ ((alias ("draw_bitmap"))); |
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
static inline uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor"))); |
static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor"))); |
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor"))); |
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event"))); |
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc"))); |
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free"))); |
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc"))); |
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap"))); |
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file"))); |
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif |