final cp866 version

git-svn-id: svn://kolibrios.org@6775 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
siemargl 2016-11-30 22:15:12 +00:00
parent bb2b6bba8c
commit bdccb5b1c7
9 changed files with 515 additions and 236 deletions

View File

@ -652,7 +652,9 @@ int extract_or_test_files(__G) /* return PK-type error code */
and GIDs from the deepest level on up. and GIDs from the deepest level on up.
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#ifdef SET_DIR_ATTRIB #ifdef SET_DIR_ATTRIB
//Trace((stderr, "SET_DIR_ATTRIB[%d] \n", num_dirs)); hmm, too big number
if (num_dirs > 0) { if (num_dirs > 0) {
sorted_dirlist = (direntry **)malloc(num_dirs*sizeof(direntry *)); sorted_dirlist = (direntry **)malloc(num_dirs*sizeof(direntry *));
if (sorted_dirlist == (direntry **)NULL) { if (sorted_dirlist == (direntry **)NULL) {
@ -1483,12 +1485,12 @@ startover:
#else /* !WINDLL */ #else /* !WINDLL */
extent fnlen; extent fnlen;
reprompt: reprompt:
Info(slide, 0x81, ((char *)slide, Info(slide, 0x81 & 0xFE, ((char *)slide,
LoadFarString(ReplaceQuery), LoadFarString(ReplaceQuery),
FnFilter1(G.filename))); FnFilter1(G.filename)));
if (fgets(G.answerbuf, sizeof(G.answerbuf), stdin) if (fgets(G.answerbuf, sizeof(G.answerbuf), stdin)
== (char *)NULL) { == (char *)NULL) {
Info(slide, 1, ((char *)slide, Info(slide, 1 & 0xFE, ((char *)slide,
LoadFarString(AssumeNone))); LoadFarString(AssumeNone)));
*G.answerbuf = 'N'; *G.answerbuf = 'N';
if (!error_in_archive) if (!error_in_archive)
@ -1498,7 +1500,7 @@ reprompt:
case 'r': case 'r':
case 'R': case 'R':
do { do {
Info(slide, 0x81, ((char *)slide, Info(slide, 0x81 & 0xFE, ((char *)slide,
LoadFarString(NewNameQuery))); LoadFarString(NewNameQuery)));
fgets(G.filename, FILNAMSIZ, stdin); fgets(G.filename, FILNAMSIZ, stdin);
/* usually get \n here: better check for it */ /* usually get \n here: better check for it */
@ -1538,7 +1540,7 @@ reprompt:
fnlen = strlen(G.answerbuf); fnlen = strlen(G.answerbuf);
if (lastchar(G.answerbuf, fnlen) == '\n') if (lastchar(G.answerbuf, fnlen) == '\n')
G.answerbuf[--fnlen] = '\0'; G.answerbuf[--fnlen] = '\0';
Info(slide, 1, ((char *)slide, Info(slide, 1 & 0xFE, ((char *)slide,
LoadFarString(InvalidResponse), G.answerbuf)); LoadFarString(InvalidResponse), G.answerbuf));
goto reprompt; /* yet another goto? */ goto reprompt; /* yet another goto? */
} /* end switch (*answerbuf) */ } /* end switch (*answerbuf) */

View File

@ -1214,7 +1214,7 @@ static int disk_error(__G)
__GDEF __GDEF
{ {
/* OK to use slide[] here because this file is finished regardless */ /* OK to use slide[] here because this file is finished regardless */
Info(slide, 0x4a1, ((char *)slide, LoadFarString(DiskFullQuery), Info(slide, 0x4a1 & 0xFE, ((char *)slide, LoadFarString(DiskFullQuery),
FnFilter1(G.filename))); FnFilter1(G.filename)));
#ifndef WINDLL #ifndef WINDLL

View File

@ -18,10 +18,10 @@
# emulation environment. # emulation environment.
SDK_DIR:= $(abspath ../../../contrib/sdk) SDK_DIR:= $(abspath ../../../contrib/sdk)
NOASM=1 NOASM=1
CC_CPU_OPT=-march=pentium CC_CPU_OPT=-march=pentium
#USEZLIB=1 #USEZLIB=1
#DEBUG=1 DEBUG=1
### Optional section ### Optional section
@ -97,7 +97,7 @@ CC_ENVIR_OPT = -DWIN32 -DFORCE_WIN32_OVER_UNIX
endif endif
endif endif
### kolibri specific ### kolibri specific
INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib 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 \ CC_ENVIR_OPT = -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOS32 \
@ -164,7 +164,7 @@ LD_SPECIFIC_OPT = -o $@ -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app-dy
ifdef USEZLIB ifdef USEZLIB
LD_RELEASE_LIBS = -lz -lgcc -ldll -lc.dll -lapp LD_RELEASE_LIBS = -lz -lgcc -ldll -lc.dll -lapp
else else
LD_RELEASE_LIBS = -lgcc -ldll -lc.dll -lapp LD_RELEASE_LIBS = -lgcc -ldll -lc.dll
endif endif
LD_DEBUG_LIBS = $(LD_RELEASE_LIBS) LD_DEBUG_LIBS = $(LD_RELEASE_LIBS)
@ -260,7 +260,7 @@ OBJB4 = unreducb$(OBJ) unshrnkb$(OBJ) zipinfob$(OBJ)
###OBJBS = win32b$(OBJ) win32i64b$(OBJ) ntb$(OBJ) ###OBJBS = win32b$(OBJ) win32i64b$(OBJ) ntb$(OBJ)
OBJB = $(OBJLIB) $(OBJB1) $(OBJB2) $(OBJB3) $(OBJB4) $(OBJA) $(OBJBS) OBJB = $(OBJLIB) $(OBJB1) $(OBJB2) $(OBJB3) $(OBJB4) $(OBJA) $(OBJBS)
UNZIP_H = unzip.h unzpriv.h globals.h UNZIP_H = unzip.h unzpriv.h globals.h
###win32/w32cfg.h ###win32/w32cfg.h
###WINDLL_H = windll/windll.h windll/structs.h windll/decs.h ###WINDLL_H = windll/windll.h windll/structs.h windll/decs.h
###DLLDEF = windll/windllgcc.def ###DLLDEF = windll/windllgcc.def
@ -335,7 +335,7 @@ zipinfo$(OBJ): zipinfo.c $(UNZIP_H)
crc_i386$(OBJ): crc_i386.S crc_i386$(OBJ): crc_i386.S
kos32$(OBJ): kolibri/kos32.c kolibri/kos32sys1.h kos32$(OBJ): kolibri/kos32.c kolibri/kos32sys1.h
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $<
dirent$(OBJ): kolibri/dirent.c kolibri/kos32sys1.h dirent$(OBJ): kolibri/dirent.c kolibri/kos32sys1.h
$(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $<

View File

@ -103,7 +103,7 @@ INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib 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 \ CC_ENVIR_OPT = -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOS32 \
$(INCLUDES) -DSTATIC_LIBC -DBUILD_LIBC $(INCLUDES) -DSTATIC_LIBC
### Compiler-specific section ### Compiler-specific section

View File

@ -18,15 +18,40 @@ Started by Siemargl @Nov 2016
#define STRNICMP zstrnicmp #define STRNICMP zstrnicmp
#define NO_CHMOD #define NO_CHMOD
#define NO_FCHOWN #define NO_FCHOWN
//#define SET_DIR_ATTRIB internal unzip bug
#define echoff(f) #define echoff(f)
#define echon() #define echon()
#define getch() getchar() /* not correct, but may not be on a console */ #define getch() getchar() /* not correct, but may not be on a console */
#define HAVE_WORKING_GETCH #define HAVE_WORKING_GETCH
#define UNICODE_SUPPORT /* next line turn on full unicode utf-8 support */
#define UTF8_MAYBE_NATIVE //#define UNICODE_SUPPORT
#define NO_NL_LANGINFO #ifdef UNICODE_SUPPORT
# define UTF8_MAYBE_NATIVE
# define NO_NL_LANGINFO
#else /* cp866 is native */
# define CRTL_CP_IS_OEM
#endif // UNICODE_SUPPORT
/*
# ifdef CRTL_CP_IS_OEM
# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# endif
# define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
# define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
*/
/* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */
// remove for a while
// # define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
/* dummy defines to disable these functions, they are not needed */
# define STR_TO_ISO
# define STR_TO_OEM
/* /*
# ifdef DATE_FORMAT # ifdef DATE_FORMAT
# undef DATE_FORMAT # undef DATE_FORMAT

View File

@ -3,7 +3,7 @@ Kolibri OS port for gcc 5.4
Started by Siemargl @Nov 2016 Started by Siemargl @Nov 2016
Contains realisation of directory handling functions: Contains realization of directory handling functions:
mkdir() mkdir()
closedir() closedir()
opendir() opendir()
@ -20,6 +20,7 @@ Contains realisation of directory handling functions:
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include "kos32sys1.h" #include "kos32sys1.h"
#include "sys/kos_io.h"
/* defined in newlib headers /* defined in newlib headers
int _EXFUN(mkdir,( const char *_path, mode_t __mode )); int _EXFUN(mkdir,( const char *_path, mode_t __mode ));
@ -147,7 +148,7 @@ int mkdir(const char *_path, mode_t m)
char namebuffer[1050]; // need for save data after di!!! char namebuffer[1050]; // need for save data after di!!!
struct fs_dirinfo *di = (struct fs_dirinfo *)namebuffer; struct fs_dirinfo *di = (struct fs_dirinfo *)namebuffer;
debug_board_printf("mkdir start (%s)\n", _path); //debug_board_printf("mkdir start (%s)\n", _path);
memset(di, 0, sizeof(struct fs_dirinfo)); memset(di, 0, sizeof(struct fs_dirinfo));
//di.ppath = (char*)_path; // dont work with 70.9 //di.ppath = (char*)_path; // dont work with 70.9
strcpy(di->path, _path); strcpy(di->path, _path);
@ -159,7 +160,7 @@ debug_board_printf("mkdir start (%s)\n", _path);
return -1; return -1;
} }
debug_board_printf("mkdir end (%s)\n", _path); //debug_board_printf("mkdir end (%s)\n", _path);
return 0; return 0;
} }
@ -230,3 +231,27 @@ void* read_folderdata(char* name)
return retdir; return retdir;
} }
*/ */
// while not in newlib
int set_fileinfo(const char *path, fileinfo_t *info)
{
int retval;
__asm__ __volatile__ (
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %1, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $6 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"r" (path), "b" (info));
return retval;
};

View File

@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="kolibri" />
<Option makefile="kolibri/Makefile.gcc" />
<Option makefile_is_custom="1" />
<Option execution_dir="D:/VSProjects/_kos/programs/fs/unzip60/" />
<Option pch_mode="2" />
<Option compiler="kolibri_gnu_gcc_compiler" />
<MakeCommands>
<Build command="$make -f $makefile " />
<CompileFile command="$make -f $makefile $file" />
<Clean command="$make -f $makefile clean$target" />
<DistClean command="$make -f $makefile distclean$target" />
<AskRebuildNeeded command="$make -q -f $makefile $target" />
<SilentBuild command="$make -f $makefile &gt; $(CMD_NULL)" />
</MakeCommands>
<Build>
<Target title="Debug">
<Option output="Debug/kolibri" prefix_auto="1" extension_auto="1" />
<Option object_output="Debug/" />
<Option type="1" />
<Option compiler="kolibri_gnu_gcc_compiler" />
<MakeCommands>
<Build command="$make -f $makefile" />
<CompileFile command="$make -f $makefile $file" />
<Clean command="$make -f $makefile clean" />
<DistClean command="$make -f $makefile distclean$target" />
<AskRebuildNeeded command="$make -q -f $makefile $target" />
<SilentBuild command="$make -f $makefile &gt; $(CMD_NULL)" />
</MakeCommands>
</Target>
<Target title="Release">
<Option output="Release/kolibri" prefix_auto="1" extension_auto="1" />
<Option object_output="Release/" />
<Option type="1" />
<Option compiler="kolibri_gnu_gcc_compiler" />
</Target>
</Build>
<Unit filename="../acorn/riscos.h" />
<Unit filename="../acorn/swiven.h" />
<Unit filename="../acorn/swiven.s" />
<Unit filename="../amiga/amiga.h" />
<Unit filename="../amiga/z-stat.h" />
<Unit filename="../aosvs/aosvs.h" />
<Unit filename="../api.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../apihelp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../atheos/athcfg.h" />
<Unit filename="../atheos/atheos.h" />
<Unit filename="../beos/beocfg.h" />
<Unit filename="../beos/beos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../beos/beos.h" />
<Unit filename="../beos/beosmain.cpp" />
<Unit filename="../cmsmvs/vmmvs.h" />
<Unit filename="../cmsmvs/vmstat.h" />
<Unit filename="../consts.h" />
<Unit filename="../crc32.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../crc32.h" />
<Unit filename="../crc_i386.S" />
<Unit filename="../crypt.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../crypt.h" />
<Unit filename="../ebcdic.h" />
<Unit filename="../envargs.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../explode.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../extract.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../fileio.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../flexos/flexos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../flexos/flxcfg.h" />
<Unit filename="../funzip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../gbloffs.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../globals.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../globals.h" />
<Unit filename="../human68k/crc_68.s" />
<Unit filename="../human68k/flate.s" />
<Unit filename="../inflate.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../inflate.h" />
<Unit filename="../list.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/UnZp.h" />
<Unit filename="../macos/UnZpLib.h" />
<Unit filename="../macos/UnZpSFX.h" />
<Unit filename="../macos/UnZpSx.h" />
<Unit filename="../macos/source/charmap.h" />
<Unit filename="../macos/source/getenv.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/helpers.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/helpers.h" />
<Unit filename="../macos/source/macbin3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/macbin3.h" />
<Unit filename="../macos/source/maccfg.h" />
<Unit filename="../macos/source/macdir.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/macdir.h" />
<Unit filename="../macos/source/macos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/macscreen.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/macstat.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/macstat.h" />
<Unit filename="../macos/source/macstuff.h" />
<Unit filename="../macos/source/mactime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/mactime.h" />
<Unit filename="../macos/source/macunzip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/pathname.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../macos/source/pathname.h" />
<Unit filename="../macos/source/sxunzip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../match.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../msdos/crc_i86.asm" />
<Unit filename="../msdos/doscfg.h" />
<Unit filename="../msdos/msdos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../netware/netware.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../netware/nlmcfg.h" />
<Unit filename="../os2/os2.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../os2/os2acl.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../os2/os2acl.h" />
<Unit filename="../os2/os2cfg.h" />
<Unit filename="../os2/os2data.h" />
<Unit filename="../os2/rexxapi.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../os2/rexxhelp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../process.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../qdos/callstub.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../qdos/config.S" />
<Unit filename="../qdos/crc68.s" />
<Unit filename="../qdos/izqdos.h" />
<Unit filename="../qdos/makesfx.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../qdos/qdos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../tandem/tandem.h" />
<Unit filename="../tandem/tannsk.h" />
<Unit filename="../theos/charconv.h" />
<Unit filename="../theos/oldstat.h" />
<Unit filename="../theos/stat.h" />
<Unit filename="../theos/thscfg.h" />
<Unit filename="../timezone.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../timezone.h" />
<Unit filename="../tops20/tops20.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../ttyio.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../ttyio.h" />
<Unit filename="../ubz2err.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unix/unix.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unix/unxcfg.h" />
<Unit filename="../unreduce.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unshrink.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unzip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unzip.h" />
<Unit filename="../unzipstb.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../unzpriv.h" />
<Unit filename="../unzvers.h" />
<Unit filename="../vms/bzlib.h" />
<Unit filename="../vms/infback9.h" />
<Unit filename="../vms/unixio_gcc.h" />
<Unit filename="../vms/unixlib_gcc.h" />
<Unit filename="../vms/vms.h" />
<Unit filename="../vms/vmscfg.h" />
<Unit filename="../vms/vmsdefs.h" />
<Unit filename="../vms/zlib.h" />
<Unit filename="../win32/crc_i386.asm" />
<Unit filename="../win32/crc_i386.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../win32/crc_lcc.asm" />
<Unit filename="../win32/nt.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../win32/nt.h" />
<Unit filename="../win32/rsxntwin.h" />
<Unit filename="../win32/w32cfg.h" />
<Unit filename="../win32/win32.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../win32/win32i64.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../win32/winapp.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="../wince/inc/conio.h" />
<Unit filename="../wince/inc/errno.h" />
<Unit filename="../wince/inc/locale.h" />
<Unit filename="../wince/inc/signal.h" />
<Unit filename="../wince/inc/stdio.h" />
<Unit filename="../wince/intrface.cpp" />
<Unit filename="../wince/intrface.h" />
<Unit filename="../wince/punzip.h" />
<Unit filename="../wince/punzip.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="../wince/resource.h" />
<Unit filename="../wince/wcecfg.h" />
<Unit filename="../wince/wcemain.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../wince/wince.cpp" />
<Unit filename="../wince/wince.h" />
<Unit filename="../wince/winmain.cpp" />
<Unit filename="../wince/winmain.h" />
<Unit filename="../windll/decs.h" />
<Unit filename="../windll/guisfx/dialog.h" />
<Unit filename="../windll/guisfx/sfxwiz.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../windll/guisfx/sfxwiz.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="../windll/structs.h" />
<Unit filename="../windll/uzexampl.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../windll/uzexampl.h" />
<Unit filename="../windll/windll.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../windll/windll.h" />
<Unit filename="../windll/windll.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="../zip.h" />
<Unit filename="../zipinfo.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Makefile.gcc" />
<Unit filename="config.h" />
<Unit filename="dirent.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="kos32.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="kos32sys1.h" />
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

View File

@ -16,16 +16,14 @@ Contains:
close_outfile() close_outfile()
get_extattribs() get_extattribs()
do_wild() do_wild()
set_direc_attribs()
defer_dir_attribs()
todo todo
russian filenames in arh datetime restore for dirs. buf in unzip - crash when SET_DIR_ATTRIB
datetime restore fixed partial
overwrite request not in stderr -d dir error (only in unicode). Use -ddir or -d dir/
russian filenames in arhives. Now works cp866 version, unicode need to fix @kos32.c:470 (GETPATH)
too many open files error EMFILE when DEBUG - error in newlib open. fixed
-d dir error. Use -ddir or -d dir/
release, sizing removing old compression methods or zlib
*/ */
#define FATTR FS_HIDDEN+FS_SYSTEM+FS_SUBDIR #define FATTR FS_HIDDEN+FS_SYSTEM+FS_SUBDIR
@ -37,6 +35,12 @@ todo
// Siemargl fork of Kolibri system API // Siemargl fork of Kolibri system API
#include "kos32sys1.h" #include "kos32sys1.h"
static ZCONST char CannotSetItemTimestamps[] =
"warning: cannot set modif./access times for %s\n %s\n";
static ZCONST char CannotGetTimestamps[] =
" (warning) cannot get fileinfo for %s\n";
/********************************************************************************************************************/ /********************************************************************************************************************/
/*** Function version() */ /*** Function version() */
@ -154,7 +158,7 @@ int mapname(__G__ renamed)
else else
++cp; /* point to start of last component of path */ ++cp; /* point to start of last component of path */
fprintf(stderr, "mapname start[%s]\n", cp); Trace((stderr, "mapname start[%s]\n", cp));
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Begin main loop through characters in filename. Begin main loop through characters in filename.
@ -323,7 +327,7 @@ fprintf(stderr, "mapname start[%s]\n", cp);
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */ checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH); checkdir(__G__ G.filename, GETPATH);
fprintf(stderr, "mapname end[%s]\n", pathcomp); Trace((stderr, "mapname end[%s]\n", pathcomp));
return error; return error;
@ -465,14 +469,24 @@ int checkdir(__G__ pathcomp, flag)
GETPATH: copy full path to the string pointed at by pathcomp, and free GETPATH: copy full path to the string pointed at by pathcomp, and free
G.buildpath. G.buildpath.
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) { if (FUNCTION == GETPATH) {
// kolibri UTf8 support
#ifdef UNICODE_SUPPORT
if(G.native_is_utf8) if(G.native_is_utf8)
{ {
pathcomp[0] = 3; // kolibri utf8 flag if (G.buildpath[0] == '/')
strcpy(pathcomp + 1, G.buildpath); {
pathcomp[0] = '/'; // kolibri utf8 flag
pathcomp[1] = 3; // kolibri utf8 flag
strcpy(pathcomp + 2, G.buildpath);
} else
{
pathcomp[0] = 3; // kolibri utf8 flag
strcpy(pathcomp + 1, G.buildpath);
}
} }
else else
#endif // UNICODE_SUPPORT
strcpy(pathcomp, G.buildpath); strcpy(pathcomp, G.buildpath);
Trace((stderr, "getting and freeing path [%s]\n", Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp))); FnFilter1(pathcomp)));
@ -622,59 +636,24 @@ int checkdir(__G__ pathcomp, flag)
} /* end function checkdir() */ } /* end function checkdir() */
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2]));
/****************************/
static int get_extattribs(__G__ pzt, z_uidgid) /* Function dos_to_kolibri_time() */
__GDEF /****************************/
iztimes *pzt; void dos_to_kolibri_time(unsigned dos_datetime, unsigned *fdat, unsigned *ftim)
ulg z_uidgid[2]; {
{ char* pc = (char*)fdat;
/*--------------------------------------------------------------------------- *pc++ = (dos_datetime >> 16) & 0x1F; // day
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT *pc++ = (dos_datetime >> 21) & 0xF; // month
time: adjust base year from 1980 to 1970, do usual conversions from short *ps = (short*)pc;
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day- *ps = (dos_datetime >> 25) + 1980; // year
light savings time differences. If we have a Unix extra field, however, *ftim = 0;
we're laughing: both mtime and atime are ours. On the other hand, we pc = (char*)ftim;
then have to check for restoration of UID/GID. *pc++ = (dos_datetime & 0x1F) << 1; // sec
---------------------------------------------------------------------------*/ *pc++ = (dos_datetime >> 5) & 0x3F; // min
int have_uidgid_flg; *pc = (dos_datetime >> 11) & 0x1F; // hour
unsigned eb_izux_flg; } /* end function dos_to_kolibri_time() */
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() */ /* Function close_outfile() */
@ -683,160 +662,37 @@ static int get_extattribs(__G__ pzt, z_uidgid)
void close_outfile(__G) /* GRR: change to return PK-style warning level */ void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF __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)) #if (defined(NO_FCHOWN))
fclose(G.outfile); fclose(G.outfile);
Trace((stdout, "File (%s) closed\n", FnFilter1(G.filename))); Trace((stdout, "File (%s) closed\n", FnFilter1(G.filename)));
#endif #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 */ /* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) { if (uO.D_flag <= 1) {
/* set the file's access and modification times */ /* set the file's access and modification times */
if (utime(G.filename, &(zt.t2))) { /* siemargl: dont using extra fields */
if (uO.qflag) unsigned ftim, fdat;
Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps, dos_to_kolibri_time(G.lrec.last_mod_dos_datetime, &fdat, &ftim);
FnFilter1(G.filename), strerror(errno)));
else fileinfo_t finfo;
Info(slide, 0x201, ((char *)slide, CannotSetTimestamps, if (get_fileinfo(G.filename, &finfo))
strerror(errno))); {
} Info(slide, 1, ((char *)slide, CannotGetTimestamps,
FnFilter1(G.filename)));
return;
}
finfo.flags = G.pInfo->file_attr;
finfo.cr_time = finfo.acc_time = finfo.mod_time = ftim;
finfo.cr_date = finfo.acc_date = finfo.mod_date = fdat;
Trace((stderr, "Trying to set fileinfo[%s] date %X, time %X, attr %X\n", FnFilter1(G.filename), fdat, ftim, finfo.flags));
if (set_fileinfo(G.filename, &finfo))
{
Info(slide, 1, ((char *)slide, CannotSetItemTimestamps,
FnFilter1(G.filename), strerror(errno)));
return;
}
} }
#if (defined(NO_FCHOWN) || defined(NO_FCHMOD)) #if (defined(NO_FCHOWN) || defined(NO_FCHMOD))
@ -851,7 +707,6 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */
#endif #endif
#endif /* NO_FCHOWN || NO_FCHMOD */ #endif /* NO_FCHOWN || NO_FCHMOD */
#endif // 0
} /* end function close_outfile() */ } /* end function close_outfile() */
@ -977,4 +832,49 @@ char *do_wild(__G__ wildspec)
return (char *)NULL; return (char *)NULL;
} /* end function do_wild() */ } /* end function do_wild() */
#ifdef SET_DIR_ATTRIB
int defer_dir_attribs(__G__ pd)
__GDEF
direntry **pd;
{
// do nothing
return PK_OK;
}
int set_direc_attribs(__G__ d)
__GDEF
direntry *d;
{
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 0) {
/* set the file's access and modification times */
/* siemargl: dont using extra fields */
unsigned ftim, fdat;
dos_to_kolibri_time(G.lrec.last_mod_dos_datetime, &fdat, &ftim);
fileinfo_t finfo;
if (get_fileinfo(G.filename, &finfo))
{
Info(slide, 1, ((char *)slide, CannotGetTimestamps,
FnFilter1(G.filename)));
return PK_WARN;
}
finfo.flags = G.pInfo->file_attr;
finfo.cr_time = finfo.acc_time = finfo.mod_time = ftim;
finfo.cr_date = finfo.acc_date = finfo.mod_date = fdat;
Trace((stderr, "Trying to set dirinfo[%s] date %X, time %X, attr %X\n", FnFilter1(G.filename), fdat, ftim, finfo.flags));
if (set_fileinfo(G.filename, &finfo))
{
Info(slide, 1, ((char *)slide, CannotSetItemTimestamps,
FnFilter1(G.filename), strerror(errno)));
return PK_WARN;
}
}
return PK_OK;
} /* end function set_direc_attribs() */
#endif // SET_DIR_ATTRIB

View File

@ -8,6 +8,7 @@
//#include <newlib.h> //#include <newlib.h>
//#include <stdint.h> //#include <stdint.h>
//#include <sys/kos_io.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
@ -141,7 +142,7 @@ typedef struct __attribute__((packed)) file_op_t
char* args; char* args;
uint32_t res1, res2; uint32_t res1, res2;
char zero; char zero;
char* app_name char* app_name
#ifdef __TINYC__ #ifdef __TINYC__
__attribute__((packed)) __attribute__((packed))
#endif #endif
@ -862,7 +863,7 @@ static inline
int font_size(int color) int font_size(int color)
/// decode font size in pixels from color as SysFn4 /// decode font size in pixels from color as SysFn4
/// returns (width, hight) /// returns (width, hight)
{ {
int font = color >> 24; int font = color >> 24;
int font_multipl = (font & 7) + 1; int font_multipl = (font & 7) + 1;
int width_sym, hight_sym; int width_sym, hight_sym;