Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 6724 → Rev 6725

/programs/fs/unzip60/acorn/Contents
0,0 → 1,26
Contents of the "acorn" subdirectory for UnZip 5.4 and later:
 
acorn.c.acorn Acorn-specific resources
acorn.c.riscos mainly file-handling routines for FileCore-based filesystems
acorn.Contents this file
acorn.GMakeFile Makefile for gcc
acorn.h.riscos
acorn.h.swiven
acorn.makefile Makefile script for default Acorn C compiler
acorn.README notes about Acorn-specific features
acorn.RunMe1st Obey file to move files into suitable place for compilation
on RISC OS machines
acorn.s.swiven SWI veneers
acorn.srcrename small executable that converts files from Unix style to
RISC OS style, used by RunMe1st
 
Notes:
 
Use the "RunMe1st" file (it is an Obey file) to convert all the files from
"filename/[chs]" to "[chs].filename" (so that UnZip could be easily compiled
under RISC OS). It will also set the correct makefile.
 
To compile just set the CSD to the main UnZip directory and run 'amu'.
 
Currently only the Acorn C V5 compiler has been tested but probably also
Acorn C V4 and the Acorn Assembler V2 will be able to compile UnZip.
/programs/fs/unzip60/acorn/GMakefile
0,0 → 1,138
# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.53 or later)
# using gcc 2.95.4 (or later).
# You may look at <URL:http://hard-mofo.dsvr.net/gcc/> for an up-to-date
# gcc port.
 
CC = gcc -mlibscl
BIND = $(CC)
AS = $(CC) -c
ASM = as
SQUEEZE = squeeze -v
E =
 
# flags
# CFLAGS flags for C compile
# LFLAGS1 flags after output file spec, before obj file list
# LFLAGS2 flags after obj file list (libraries, etc)
#
LIB =
CFLAGS = -O2 -mthrowback -DNO_STRNICMP
ASMFLAGS = -throwback -objasm -upper
LFLAGS1 =
LFLAGS2 = $(LIB)
 
# object file lists
OBJS1 = o.unzip o.crc32 o.crypt o.envargs o.explode
OBJS2 = o.extract o.fileio o.globals o.inflate o.list o.match
OBJS3 = o.process o.ttyio o.unreduce o.unshrink o.zipinfo
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) o.riscos o.swiven o.acorn
OBJF = o.funzip o.crc32 o.cryptf o.globalsf o.inflatef o.ttyiof \
o.riscos o.swiven
OBJX = o.unzipsfx o.crc32 o.crypt_ o.extract_ o.fileio_ o.globals_ \
o.inflate_ o.match_ o.process_ o.ttyio_ o.acorn_ o.swiven o.riscos_
 
UNZIP_H = h.unzip h.unzpriv h.globals acorn.h.riscos acorn.h.swiven
 
all: unzip funzip unzipsfx
 
 
install: unzip funzip unzipsfx
$(SQUEEZE) unzip %.unzip
$(SQUEEZE) funzip %.funzip
$(SQUEEZE) unzipsfx unzipsfx
copy %.unzip %.zipinfo ~CVF
 
# rules for unzip and funzip
o.crc32: c.crc32 $(UNZIP_H) h.zip h.crc32
$(CC) $(CFLAGS) -c c.crc32 -o o.crc32
o.crypt: c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
$(CC) $(CFLAGS) -c c.crypt -o o.crypt
o.envargs: c.envargs $(UNZIP_H)
$(CC) $(CFLAGS) -c c.envargs -o o.envargs
o.explode: c.explode $(UNZIP_H)
$(CC) $(CFLAGS) -c c.explode -o o.explode
o.extract: c.extract $(UNZIP_H) h.crc32 h.crypt
$(CC) $(CFLAGS) -c c.extract -o o.extract
o.fileio: c.fileio $(UNZIP_H) h.crc32 h.crypt h.ttyio h.ebcdic
$(CC) $(CFLAGS) -c c.fileio -o o.fileio
o.funzip: c.funzip $(UNZIP_H) h.crc32 h.crypt h.ttyio
$(CC) $(CFLAGS) -c c.funzip -o o.funzip
o.globals: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -c c.globals -o o.globals
o.inflate: c.inflate h.inflate $(UNZIP_H)
$(CC) $(CFLAGS) -c c.inflate -o o.inflate
o.list: c.list $(UNZIP_H)
$(CC) $(CFLAGS) -c c.list -o o.list
o.match: c.match $(UNZIP_H)
$(CC) $(CFLAGS) -c c.match -o o.match
o.process: c.process $(UNZIP_H) h.crc32
$(CC) $(CFLAGS) -c c.process -o o.process
o.ttyio: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -c c.ttyio -o o.ttyio
o.unreduce: c.unreduce $(UNZIP_H)
$(CC) $(CFLAGS) -c c.unreduce -o o.unreduce
o.unshrink: c.unshrink $(UNZIP_H)
$(CC) $(CFLAGS) -c c.unshrink -o o.unshrink
o.unzip: c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
$(CC) $(CFLAGS) -c c.unzip -o o.unzip
o.zipinfo: c.zipinfo $(UNZIP_H)
$(CC) $(CFLAGS) -c c.zipinfo -o o.zipinfo
 
o.crypt_: c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
$(CC) $(CFLAGS) -DSFX -c c.crypt -o o.crypt_
o.extract_: c.extract $(UNZIP_H) h.crc32 h.crypt
$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
o.fileio_: c.fileio $(UNZIP_H) h.crc32 h.crypt h.ttyio h.ebcdic
$(CC) $(CFLAGS) -DSFX -c c.fileio -o o.fileio_
o.globals_: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.globals -o o.globals_
o.inflate_: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DSFX -c c.inflate -o o.inflate_
o.match_: c.match $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.match -o o.match_
o.process_: c.process $(UNZIP_H) h.crc32
$(CC) $(CFLAGS) -DSFX -c c.process -o o.process_
o.ttyio_: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DSFX -c c.ttyio -o o.ttyio_
 
o.unzipsfx: c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx
 
o.cryptf: c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.cryptf
o.globalsf: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globalsf
o.inflatef: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflatef
o.ttyiof: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyiof
 
o.acorn: acorn.c.acorn $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c acorn.c.acorn
o.acorn_: acorn.c.acorn $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.acorn_ acorn.c.acorn
 
o.riscos: acorn.c.riscos $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c acorn.c.riscos
o.riscos_: acorn.c.riscos $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.riscos_ acorn.c.riscos
 
o.swiven: acorn.s.swiven
$(ASM) $(ASMFLAGS) acorn.s.swiven -o o.swiven
 
unzip: $(OBJS)
$(BIND) -o unzip$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
funzip: $(OBJF)
$(BIND) -o funzip$(E) $(LFLAGS1) $(OBJF) $(LFLAGS2)
unzipsfx: $(OBJX)
$(BIND) -o unzipsfx$(E) $(LFLAGS1) $(OBJX) $(LFLAGS2)
 
clean:
remove unzip
remove funzip
remove zipinfo
remove unzipsfx
create o.!fake! 0
wipe o.* ~cf
 
# end of Makefile
/programs/fs/unzip60/acorn/ReadMe
0,0 → 1,69
Acorn-specific usage instructions
---------------------------------
 
As zipfiles can come from a variety of sources apart from Acorn machines,
consideration had to be given to the handling of dot-extensions, e.g.
"DOSFILE.TXT", "unix-filename.tar.gz". These are extracted as "DOSFILE/TXT"
and "unix-filename/tar/gz"; their names may or may not be truncated,
depending on where the files are being created: what filing system and, for
Filecore-based filing systems such as ADFS or an IDEFS or SCSIFS, which
disk/partition format (names will not be truncated if you're using E+ or F+).
 
Where truncation occurs, you must be REALLY careful about extracting files
from archives. The files
 
dummy_source.c and dummy_source.h
 
will both be extracted as
 
dummy_sour
 
UnZip will prompt you for confirmation of the over-writing of these files,
but you must be really careful unless you wish to lose files! Also, because
UnZip is a unix-ported program, the filenames are CASE SENSITIVE.
 
*unzip new/zip newfile
 
will extract 'newfile', but not 'NewFile', 'NEWFILE' or any other
combinations. However, you can use the -C option to force operations to
disregard the case of filenames.
 
The Acorn UnZip port has an additional feature to cope with the extraction of
files containing 'c' code. As you may be aware, Acorn Desktop C requires all
files called "foo.c" to be renamed to "c.foo", ie "foo" in a directory called
"c".
 
There are two ways of using this feature.
 
- The old way: use a colon-separated environment variable named "Unzip$Exts".
 
Any extensions found in this variable will be extracted to directories
named after the extension, with the extension stripped. For example:
 
*Set Unzip$Exts "c:h:o:s"
*unzip foo/zip
 
- The new way: use the -/ option. For example:
 
Any extensions found in the parameter for this option will be extracted to
directories named after the extension, with the extension stripped. For
example:
 
*unzip -/c:h:o:s foo/zip
 
If foo/zip contains a file named "foo.c", this file will be written as "foo"
in directory "c". This can be used to include "c:h:o:s:txt" to pull all the
text files out to a separate directory.
 
UnZip fully supports SparkFS Extra Field. This means that zipfiles created
with SparkFS or Zip (on RISC OS) will be correctly unzipped, including
filetypes.
 
UnZipSFX can be used to create self-extracting archives. To use it, just
create a common zipfile using Zip (or SparkFS), then load the UnZipSFX
executable into an editor (eg. Edit, Zap), go with the caret the end of the
file (using CTRL-CursorDown) and drag the zipfile to the editor window (in
other words, append the zipfile to the UnZipSFX executable). Now, saving the
resulting file (with filetype Absolute (&FF8)), you have a self-extracting
archive (ie. double-clicking on it will unzip the contents of the original
zipfile to the currently selected directory).
/programs/fs/unzip60/acorn/RunMe1st
0,0 → 1,17
| This Obey file prepares the UnZip port for a Desktop C re-compile.
| Run it and it will copy all the needed files into the correct
| place.
 
| Set the correct type of 'srcrename' so that the only requirement
| for the user is to set 'RunMe1st' to Obey
SetType <Obey$Dir>.srcrename FF8
 
| Run 'srcrename' on the main UnZip directory with recursion enabled
/<Obey$Dir>.srcrename -r -e c:h:s:o <Obey$Dir>.^
 
| Create the 'o' directory
CDir <Obey$Dir>.^.o
 
| Put the Makefile in its correct place and set the correct filetype
SetType <Obey$Dir>.makefile FE1
Copy <Obey$Dir>.makefile <Obey$Dir>.^.makefile ~C ~V F
/programs/fs/unzip60/acorn/acorn.c
0,0 → 1,994
/*
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
 
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
 
acorn.c
 
RISCOS-specific routines for use with Info-ZIP's UnZip 5.2 and later.
 
Contains: do_wild() <-- generic enough to put in fileio.c?
mapattr()
mapname()
checkdir()
mkdir()
setRISCOSexfield()
printRISCOSexfield()
close_outfile()
stamp_file()
version()
 
---------------------------------------------------------------------------*/
 
 
#define UNZIP_INTERNAL
#include "^.unzip.h"
#include "riscos.h"
 
#define FTYPE_FFF (1<<17) /* set filetype to &FFF when extracting */
 
#ifdef WILD_STOP_AT_DIR
# define WESEP , (oU.W_flag ? '.' : '\0')
#else
# define WESEP
#endif
 
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
static int has_mimemap = -1; /* used in mimemap() */
 
extern int mkdir(const char *path, int mode);
static int has_NFS_ext(const char *name);
static void setRISCOSexfield(ZCONST char *path, ZCONST void *ef_spark);
#ifdef DEBUG
static void printRISCOSexfield(int isdir, ZCONST void *extra_field);
#endif
static int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut);
static int mimemap(const char *name);
 
 
#ifndef SFX
 
/**********************/
/* 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 */
{
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 (!notfirstcall) { /* first call: must initialize everything */
notfirstcall = TRUE;
 
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = (ZCONST char *)strrchr(wildspec, '.')) ==
(ZCONST char *)NULL)
{
dirname = ".";
dirnamelen = 1;
have_dirname = FALSE;
wildname = wildspec;
} else {
++wildname; /* point at character after '/' */
dirnamelen = wildname - wildspec;
if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
Info(slide, 0x201, ((char *)slide,
"warning: cannot allocate wildcard buffers\n"));
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
 
if ((wild_dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
if (file->d_name[0] == '/' && wildname[0] != '/')
continue; /* Unix: '*' and '?' do not match leading dot */
if (match(file->d_name, wildname, 0 WESEP)) { /* 0=case sens.*/
if (have_dirname) {
strcpy(matchname, dirname);
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
}
/* if we get to here directory is exhausted, so close it */
closedir(wild_dir);
wild_dir = (DIR *)NULL;
}
 
/* return the raw wildspec in case that works (e.g., directory not
* searchable, but filespec was not wild and file is readable) */
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname;
}
 
/* last time through, might have failed opendir but returned raw wildspec */
if (wild_dir == (DIR *)NULL) {
notfirstcall = FALSE; /* nothing left to try--reset for new wildspec */
if (have_dirname)
free(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(wild_dir)) != (struct dirent *)NULL)
if (match(file->d_name, wildname, 0 WESEP)) { /* 0 == case sens. */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
 
closedir(wild_dir); /* have read at least one dir entry; nothing left */
wild_dir = (DIR *)NULL;
notfirstcall = FALSE; /* reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
 
} /* end function do_wild() */
 
#endif /* !SFX */
 
 
 
/**************************/
/* Function has_NFS_ext() */
/**************************/
 
static int has_NFS_ext(const char* name)
{
int i = strlen(name) - 4;
 
return (i >= 0 && name[i] == ',' && (i > 0 || name[i-1]=='/') &&
isxdigit(name[i+1]) && isxdigit(name[i+2]) && isxdigit(name[i+3]));
} /* end function has_NFS_ext() */
 
 
 
/**********************/
/* Function mapattr() */
/**********************/
 
int mapattr(__G)
__GDEF
{
ulg tmp = G.crec.external_file_attributes;
 
switch (G.pInfo->hostnum) {
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
case THEOS_:
tmp &= 0xF1FFFFFFL;
if ((tmp & 0xF0000000L) != 0x40000000L)
tmp &= 0x01FFFFFFL; /* not a dir, mask all ftype bits */
else
tmp &= 0x41FFFFFFL; /* leave directory bit as set */
/* fall through! */
case ACORN_:
case UNIX_:
case VMS_:
case ATARI_:
case ATHEOS_:
case BEOS_:
case QDOS_:
case TANDEM_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
if (G.pInfo->file_attr != 0 || !G.extra_field) {
break;
} else {
/* Some (non-Info-ZIP) implementations of Zip for Unix and
VMS (and probably others ??) leave 0 in the upper 16-bit
part of the external_file_attributes field. Instead, they
store file permission attributes in some extra field.
As a work-around, we search for the presence of one of
these extra fields and fall back to the MSDOS compatible
part of external_file_attributes if one of the known
e.f. types has been detected.
Later, we might implement extraction of the permission
bits from the VMS extra field. But for now, the work-around
should be sufficient to provide "readable" extracted files.
(For ASI Unix e.f., an experimental remap of the e.f.
mode value IS already provided!)
*/
ush ebID;
unsigned ebLen;
uch *ef = G.extra_field;
unsigned ef_len = G.crec.extra_field_length;
int r = FALSE;
 
while (!r && ef_len >= EB_HEADSIZE) {
ebID = makeword(ef);
ebLen = (unsigned)makeword(ef+EB_LEN);
if (ebLen > (ef_len - EB_HEADSIZE))
/* discoverd some e.f. inconsistency! */
break;
switch (ebID) {
case EF_ASIUNIX:
if (ebLen >= (EB_ASI_MODE+2)) {
G.pInfo->file_attr =
(unsigned)makeword(ef+(EB_HEADSIZE+EB_ASI_MODE));
/* force stop of loop: */
ef_len = (ebLen + EB_HEADSIZE);
break;
}
/* else: fall through! */
case EF_PKVMS:
/* "found nondecypherable e.f. with perm. attr" */
r = TRUE;
default:
break;
}
ef_len -= (ebLen + EB_HEADSIZE);
ef += (ebLen + EB_HEADSIZE);
}
if (!r)
break;
}
/* fall through! */
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
/* PKWARE's PKZip for Unix marks entries as FS_FAT_, but stores the
* Unix attributes in the upper 16 bits of the external attributes
* field, just like Info-ZIP's Zip for Unix. We try to use that
* value, after a check for consistency with the MSDOS attribute
* bits (see below).
*/
G.pInfo->file_attr = (unsigned)(tmp >> 16);
/* fall through! */
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case TOPS20_:
default:
/* Ensure that DOS subdir bit is set when the entry's name ends
* in a '/'. Some third-party Zip programs fail to set the subdir
* bit for directory entries.
*/
if ((tmp & 0x10) == 0) {
extent fnlen = strlen(G.filename);
if (fnlen > 0 && G.filename[fnlen-1] == '/')
tmp |= 0x10;
}
/* read-only bit --> write perms; subdir bit --> dir exec bit */
tmp = !(tmp & 1) << 1 | (tmp & 0x10) >> 4;
if ((G.pInfo->file_attr & 0700) == (unsigned)(0400 | tmp<<6))
/* keep previous G.pInfo->file_attr setting, when its "owner"
* part appears to be consistent with DOS attribute flags!
*/
break;
G.pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
break;
} /* end switch (host-OS-created-by) */
 
G.pInfo->file_attr&=0xFFFF;
 
G.pInfo->file_attr|=(0xFFDu<<20);
 
if (has_NFS_ext(G.filename)) {
int ftype=strtol(G.filename+strlen(G.filename)-3,NULL,16)&0xFFF;
 
G.pInfo->file_attr = (G.pInfo->file_attr & 0x000FFFFF) | (ftype<<20);
} else {
int type = mimemap(G.filename);
if (type == -1)
type = (G.crec.internal_file_attributes & 1) ? 0xFFF : 0xFFD;
G.pInfo->file_attr = (G.pInfo->file_attr & 0x000FFFFF) | (type<<20);
}
 
return 0;
 
} /* end function mapattr() */
 
 
 
/************************/
/* Function mimemap() */
/************************/
 
static int mimemap(const char *name)
{
const char *ext = name;
int type;
 
if (has_mimemap < 0)
has_mimemap =
!(SWI_OS_CLI("%RMEnsure MimeMap 0.05 RMLoad System:Modules.Network.MimeMap")
|| SWI_OS_CLI("%RMEnsure MimeMap 0.05"));
 
if (!has_mimemap)
return -1; /* no MimeMap module; fall back on text flag test */
 
do {
while (*ext && *ext!='.')
ext++;
if (!*ext)
return -1; /* no suitable extension; fallback */
type = SWI_MimeMap_Translate(ext++);
} while (type == -1);
 
return type;
}
 
 
 
/************************/
/* 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 */
int error = MPN_OK;
register unsigned workch; /* hold the character being tested */
char *checkswap=NULL; /* pointer the the extension to check */
 
 
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
 
if (G.pInfo->vollabel)
return MPN_VOL_LABEL; /* can't set disk volume labels in RISCOS */
 
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!uO.fflag || renamed);
 
created_dir = FALSE; /* not yet */
 
/* user gave full pathname: don't prepend rootpath */
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 (((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 */
checkswap=NULL; /* reset checking at start of new leafname */
break;
 
case '.':
*pp++ = '/';
checkswap=pp;
break;
 
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
 
case ' ': /* change spaces to hard-spaces */
*pp++ = 160; /* (ISO 8859-1 Latin-1 codepage) */
break;
 
/* The following substitutions, unless stated otherwise, follow
* those for DOSFS. They translate special symbols into other
* characters which have no special meaning to RISC OS. */
case '#': *pp++ = '?'; break; /* single-char wildcard */
case '&': *pp++ = '+'; break;
case '@': *pp++ = '='; break;
case '%': *pp++ = ';'; break;
case '$': *pp++ = '<'; break;
case '^': *pp++ = '>'; break; /* parent-dir reference */
 
/* The following substitutions deal with the remaining special
* symbols. ('.' is handled above.) */
case '*': *pp++ = 0xD7; break; /* Latin-1 'multiply' */
case '"': *pp++ = '~'; break;
case ':': *pp++ = ';'; break;
case '\\': *pp++ = '/'; break;
case '|': *pp++ = 0xA6; break; /* Latin-1 'broken bar' */
 
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
 
} /* end while loop */
 
/*---------------------------------------------------------------------------
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 (created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, " creating: %s\n",
FnFilter1(G.filename)));
}
/* 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';
}
 
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
FnFilter1(G.filename)));
return (error & ~MPN_MASK) | MPN_ERR_SKIP;
}
 
if (checkswap!=NULL) {
if (checkext(checkswap)) {
if ((error = checkdir(__G__ checkswap, APPEND_DIR)) > 1)
return error;
*(checkswap-1)=0; /* remove extension from pathcomp */
}
}
 
if (!uO.acorn_nfs_ext && has_NFS_ext(pathcomp)) {
/* remove the filetype extension unless requested otherwise */
/* the filetype should be already set by mapattr() */
pathcomp[strlen(pathcomp)-4]=0;
}
 
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH);
 
return error;
 
} /* end function mapname() */
 
 
 
 
/***********************/
/* 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 ((*end = *pathcomp++) != '\0')
++end;
#ifdef SHORT_NAMES /* path components restricted to 14 chars, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(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 ((end-buildpath) > FILNAMSIZ-3)
too_long = TRUE; /* check if extracting dir? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(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(buildpath)));
fflush(stderr);
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: cannot create %s\n\
unable to process %s.\n",
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path didn't exist, tried to create, failed */
return MPN_ERR_SKIP;
}
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(buildpath), FnFilter1(G.filename)));
free(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(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
*end++ = '.'; /************* was '/' *************/
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
return MPN_OK;
 
} /* end if (FUNCTION == APPEND_DIR) */
 
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
 
if (FUNCTION == GETPATH) {
strcpy(pathcomp, buildpath);
Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp)));
free(buildpath);
buildpath = 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 ((*end = *pathcomp++) != '\0') {
++end;
#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(end = old_end + FILENAME_MAX) = '\0';
#endif
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 0x201, ((char *)slide,
"checkdir warning: path too long; truncating\n\
%s\n -> %s\n",
FnFilter1(G.filename), FnFilter2(buildpath)));
return MPN_INF_TRUNC; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(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 "));
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))
== (char *)NULL)
return MPN_NOMEM;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", FnFilter1(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) {
rootlen = 0;
return MPN_OK;
}
if (rootlen > 0) /* rootpath was already set, nothing to do */
return MPN_OK;
if ((rootlen = strlen(pathcomp)) > 0) {
char *tmproot;
 
if ((tmproot = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return MPN_NOMEM;
}
strcpy(tmproot, pathcomp);
if (tmproot[rootlen-1] == '.') { /****** was '/' ********/
tmproot[--rootlen] = '\0';
}
if (rootlen > 0 && (SSTAT(tmproot, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode)))
{ /* path does not exist */
if (!G.create_dirs /* || isshexp(tmproot) */ ) {
free(tmproot);
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",
FnFilter1(tmproot)));
free(tmproot);
rootlen = 0;
/* path didn't exist, tried to create, and failed: */
/* file exists, or 2+ subdir levels required */
return MPN_ERR_SKIP;
}
}
tmproot[rootlen++] = '.'; /*********** was '/' *************/
tmproot[rootlen] = '\0';
if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {
free(tmproot);
rootlen = 0;
return MPN_NOMEM;
}
Trace((stderr, "rootpath now = [%s]\n", FnFilter1(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 (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
 
return MPN_INVALID; /* should never reach */
 
} /* end function checkdir() */
 
 
 
 
 
/********************/
/* Function mkdir() */
/********************/
 
int mkdir(path, mode)
const char *path;
int mode; /* ignored */
/*
* returns: 0 - successful
* -1 - failed (errno not set, however)
*/
{
return (SWI_OS_File_8((char *)path) == NULL)? 0 : -1;
}
 
 
 
 
/*********************************/
/* extra_field-related functions */
/*********************************/
 
static void setRISCOSexfield(ZCONST char *path, ZCONST void *ef_spark)
{
if (ef_spark!=NULL) {
extra_block *block=(extra_block *)ef_spark;
SWI_OS_File_1((char *)path,block->loadaddr,block->execaddr,block->attr);
}
}
 
#ifdef DEBUG
static void printRISCOSexfield(int isdir, ZCONST void *extra_field)
{
extra_block *block=(extra_block *)extra_field;
printf("\n This file has RISC OS file informations in the local extra field.\n");
 
if (isdir) {
/* I prefer not to print this string... should change later... */
/* printf(" The file is a directory.\n");*/
} else if ((block->loadaddr & 0xFFF00000) != 0xFFF00000) {
printf(" Load address: %.8X\n",block->loadaddr);
printf(" Exec address: %.8X\n",block->execaddr);
} else {
/************* should change this to use OS_FSControl 18 to get filetype string ************/
char tmpstr[16];
char ftypestr[32];
int flen;
sprintf(tmpstr,"File$Type_%03x",(block->loadaddr & 0x000FFF00) >> 8);
if (SWI_OS_ReadVarVal(tmpstr,ftypestr,32,&flen)==NULL) {
ftypestr[flen]=0;
printf(" Filetype: %s (&%.3X)\n",ftypestr,(block->loadaddr & 0x000FFF00) >> 8);
} else {
printf(" Filetype: &%.3X\n",(block->loadaddr & 0x000FFF00) >> 8);
}
}
printf(" Access: ");
if (block->attr & (1<<3))
printf("L");
if (block->attr & (1<<0))
printf("W");
if (block->attr & (1<<1))
printf("R");
printf("/");
if (block->attr & (1<<4))
printf("w");
if (block->attr & (1<<5))
printf("r");
printf("\n\n");
}
#endif /* DEBUG */
 
 
/**********************************************/
/* internal help function for time conversion */
/**********************************************/
static int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut)
{
unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */
unsigned timhi; /* 2 high bytes of acorn file-time */
 
timlo = ((unsigned)ut & 0x00ffffffU) * 100 + 0x00996a00U;
timhi = ((unsigned)ut >> 24);
timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
if (timhi & 0xffff0000U)
return 1; /* calculation overflow, do not change time */
 
/* insert the five time bytes into loadaddr and execaddr variables */
*pexadr = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
*pldadr = (*pldadr & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU);
 
return 0; /* subject to future extension to signal overflow */
}
 
 
/****************************/
/* Function close_outfile() */
/****************************/
 
void close_outfile(__G)
__GDEF
{
zvoid *spark_ef;
 
fclose(G.outfile);
 
if ((spark_ef = getRISCOSexfield(G.extra_field, G.lrec.extra_field_length))
!= NULL) {
setRISCOSexfield(G.filename, spark_ef);
} else {
unsigned int loadaddr, execaddr;
int attr;
int mode=G.pInfo->file_attr&0xffff; /* chmod equivalent mode */
 
time_t m_time;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
 
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) {
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
#ifdef IZ_CHECK_TZ
G.tz_is_valid &&
#endif
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
G.lrec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME))
{
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
z_utime.mtime));
m_time = z_utime.mtime;
} else
#endif /* USE_EF_UT_TIME */
m_time = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
 
/* set the file's time-stamp and attributes */
SWI_OS_File_5(G.filename, NULL, &loadaddr, NULL, NULL, &attr);
 
if (uO.D_flag <= 1)
/* set the file's modification time */
uxtime2acornftime(&execaddr, &loadaddr, m_time);
 
loadaddr = (loadaddr & 0xfff000ffU) |
((G.pInfo->file_attr&0xfff00000) >> 12);
 
attr=(attr&0xffffff00) | ((mode&0400) >> 8) | ((mode&0200) >> 6) |
((mode&0004) << 2) | ((mode&0002) << 4);
 
SWI_OS_File_1(G.filename, loadaddr, execaddr, attr);
}
 
} /* end function close_outfile() */
 
 
 
 
#ifdef TIMESTAMP
 
/***************************/
/* Function stamp_file() */
/***************************/
 
int stamp_file(fname, modtime)
ZCONST char *fname;
time_t modtime;
{
unsigned int loadaddr, execaddr;
int attr;
 
/* set the file's modification time */
if (SWI_OS_File_5((char *)fname, NULL, &loadaddr, NULL, NULL, &attr)
!= NULL)
return -1;
 
if (uxtime2acornftime(&execaddr, &loadaddr, modtime) != 0)
return -1;
 
return (SWI_OS_File_1((char *)fname, loadaddr, execaddr, attr) == NULL) ?
0 : -1;
 
} /* end function stamp_file() */
 
#endif /* TIMESTAMP */
 
 
 
 
#ifndef SFX
 
/************************/
/* Function version() */
/************************/
 
void version(__G)
__GDEF
{
sprintf((char *)slide, LoadFarString(CompiledWith),
#ifdef __GNUC__
"gcc ", __VERSION__,
#else
# ifdef __CC_NORCROFT
"Norcroft ", "cc",
# else
"cc", "",
# endif
#endif
 
"RISC OS",
 
" (Acorn Computers Ltd)",
 
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
 
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);
 
} /* end function version() */
 
#endif /* !SFX */
/programs/fs/unzip60/acorn/makefile
0,0 → 1,128
# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.53 or later)
# last modified: 25 Dec 2006
 
# add -g to CC to debug
# add -d to BIND to debug
CC = cc
BIND = link
AS = $(CC) -c
ASM = objasm
SQUEEZE = squeeze -v
E =
 
# flags
# CFLAGS flags for C compile
# LFLAGS1 flags after output file spec, before obj file list
# LFLAGS2 flags after obj file list (libraries, etc)
#
LIB =
CBASE = -throwback -wn -DNO_STRNICMP
CFLAGS = $(CBASE) -IC:,@.
ASMFLAGS = -Throwback -Stamp -NoCache -CloseExec -quit
LFLAGS1 =
LFLAGS2 = $(LIB) C:o.Stubs
 
# object file lists
OBJS1 = unzip.o crc32.o crypt.o envargs.o explode.o
OBJS2 = extract.o fileio.o globals.o inflate.o list.o match.o
OBJS3 = process.o ttyio.o ubz2err.o unreduce.o unshrink.o zipinfo.o
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) riscos.o swiven.o acorn.o
OBJF = funzip.o crc32.o cryptf.o globalsf.o inflatef.o ttyiof.o \
riscos.o swiven.o
OBJX = unzipsfx.o crc32.o crypt_.o extract_.o fileio_.o globals.o \
inflate.o match.o process_.o ttyio.o ubz2err_.o \
acorn_.o swiven.o riscos_.o
 
UNZIP_H = unzip.h unzpriv.h globals.h acorn/riscos.h acorn/swiven.h
 
all: unzip funzip unzipsfx
 
 
install: unzip funzip unzipsfx
$(SQUEEZE) unzip %.unzip
$(SQUEEZE) funzip %.funzip
$(SQUEEZE) unzipsfx unzipsfx
copy %.unzip %.zipinfo ~CVF
 
# suffix rules
.SUFFIXES: .o .c
.c.o:
$(CC) $(CFLAGS) -c $<
.s.o:
$(ASM) $(ASMFLAGS) -from @*.s -to @*.o
 
# rules for unzip and funzip
crc32.o: crc32.c $(UNZIP_H) zip.h crc32.h
crypt.o: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
envargs.o: envargs.c $(UNZIP_H)
explode.o: explode.c $(UNZIP_H)
extract.o: extract.c $(UNZIP_H) crc32.h crypt.h
fileio.o: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
funzip.o: funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
globals.o: globals.c $(UNZIP_H)
inflate.o: inflate.c inflate.h $(UNZIP_H)
list.o: list.c $(UNZIP_H)
match.o: match.c $(UNZIP_H)
process.o: process.c $(UNZIP_H) crc32.h
ttyio.o: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
ubz2err.o: ubz2err.c $(UNZIP_H)
unreduce.o: unreduce.c $(UNZIP_H)
unshrink.o: unshrink.c $(UNZIP_H)
unzip.o: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo.o: zipinfo.c $(UNZIP_H)
 
crypt_.o: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
$(CC) $(CFLAGS) -DSFX -c c.crypt -o o.crypt_
extract_.o: extract.c $(UNZIP_H) crc32.h crypt.h
$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
fileio_.o: fileio.c $(UNZIP_H) crc32.h crypt.h
$(CC) $(CFLAGS) -DSFX -c c.fileio -o o.fileio_
globals_.o: globals.c $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globals_
inflate_.o: inflate.c inflate.h $(UNZIP_H) crypt.h
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflate_
process_.o: process.c $(UNZIP_H) crc32.h
$(CC) $(CFLAGS) -DSFX -c c.process -o o.process_
ttyio_.o: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyio_
ubz2err_.o: ubz2err.c $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.ubz2err -o o.ubz2err_
 
unzipsfx.o: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx
 
o.cryptf: c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.cryptf
o.globalsf: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globalsf
o.inflatef: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflatef
o.ttyiof: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyiof
 
acorn.o: acorn/acorn.c $(UNZIP_H)
$(CC) $(CFLAGS) -c acorn/acorn.c
acorn_.o: acorn/acorn.c $(UNZIP_H)
$(CC) $(CFLAGS) -c -DSFX -DSFX_EXDIR -o acorn_.o acorn/acorn.c
 
riscos.o: acorn/riscos.c $(UNZIP_H)
$(CC) $(CFLAGS) -c acorn/riscos.c
riscos_.o: acorn/riscos.c $(UNZIP_H)
$(CC) $(CFLAGS) -c -DSFX -DSFX_EXDIR -o riscos_.o acorn/riscos.c
 
swiven.o: acorn/swiven.s
$(ASM) $(ASMFLAGS) -from acorn.s.swiven -to o.swiven
 
unzip: $(OBJS)
$(BIND) -o unzip$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
funzip: $(OBJF)
$(BIND) -o funzip$(E) $(LFLAGS1) $(OBJF) $(LFLAGS2)
unzipsfx: $(OBJX)
$(BIND) -o unzipsfx$(E) $(LFLAGS1) $(OBJX) $(LFLAGS2)
 
clean: ;remove unzip; remove funzip;
remove zipinfo; remove unzipsfx;
create o.!fake! 0
wipe o.* ~cf
 
# end of Makefile
/programs/fs/unzip60/acorn/riscos.c
0,0 → 1,364
/*
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
 
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* riscos.c */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
/* #define NO_UNZIPH_STUFF */
#define UNZIP_INTERNAL
#include "unzip.h"
#include "riscos.h"
 
#define MAXEXT 16
 
char *exts2swap = NULL; /* Extensions to swap (actually, directory names) */
 
int stat(char *filename,struct stat *res)
{
int attr; /* object attributes */
unsigned int load; /* load address */
unsigned int exec; /* exec address */
int type; /* type: 0 not found, 1 file, 2 dir, 3 image */
 
if (!res)
return -1;
 
if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
return -1;
 
if (type==0)
return -1;
 
res->st_dev=0;
res->st_ino=0;
res->st_nlink=0;
res->st_uid=1;
res->st_gid=1;
res->st_rdev=0;
res->st_blksize=1024;
 
res->st_mode = ((attr & 0001) << 8) | ((attr & 0002) << 6) |
((attr & 0020) >> 2) | ((attr & 0040) >> 4);
 
switch (type) {
case 1: /* File */
res->st_mode |= S_IFREG;
break;
case 2: /* Directory */
res->st_mode |= S_IFDIR | 0700;
break;
case 3: /* Image file */
if (uO.scanimage)
res->st_mode |= S_IFDIR | 0700;
else
res->st_mode |= S_IFREG;
break;
}
 
if ((((unsigned int) load) >> 20) == 0xfff) { /* date stamped file */
register unsigned int t1, t2, tc;
 
t1 = (unsigned int) (exec);
t2 = (unsigned int) (load & 0xff);
 
tc = 0x6e996a00U;
if (t1 < tc)
t2--;
t1 -= tc;
t2 -= 0x33; /* 00:00:00 Jan. 1 1970 = 0x336e996a00 */
 
t1 = (t1 / 100) + (t2 * 42949673U); /* 0x100000000 / 100 = 42949672.96 */
t1 -= (t2 / 25); /* compensate for .04 error */
 
res->st_atime = res->st_mtime = res->st_ctime = t1;
}
else
res->st_atime = res->st_mtime = res->st_ctime = 0;
 
return 0;
}
 
#ifndef SFX
 
DIR *opendir(char *dirname)
{
DIR *thisdir;
int type;
int attr;
os_error *er;
 
thisdir=(DIR *)malloc(sizeof(DIR));
if (thisdir==NULL)
return NULL;
 
thisdir->dirname=(char *)malloc(strlen(dirname)+1);
if (thisdir->dirname==NULL) {
free(thisdir);
return NULL;
}
 
strcpy(thisdir->dirname,dirname);
if (thisdir->dirname[strlen(thisdir->dirname)-1]=='.')
thisdir->dirname[strlen(thisdir->dirname)-1]=0;
 
if (er=SWI_OS_File_5(thisdir->dirname,&type,NULL,NULL,NULL,&attr),er!=NULL ||
type<=1 || (type==3 && !uO.scanimage))
{
free(thisdir->dirname);
free(thisdir);
return NULL;
}
 
thisdir->buf=malloc(DIR_BUFSIZE);
if (thisdir->buf==NULL) {
free(thisdir->dirname);
free(thisdir);
return NULL;
}
 
thisdir->size=DIR_BUFSIZE;
thisdir->offset=0;
thisdir->read=0;
 
return thisdir;
}
 
struct dirent *readdir(DIR *d)
{
static struct dirent dent;
 
if (d->read==0) { /* no more objects read in the buffer */
if (d->offset==-1) { /* no more objects to read */
return NULL;
}
 
d->read=255;
if (SWI_OS_GBPB_9(d->dirname,d->buf,&d->read,&d->offset,DIR_BUFSIZE,NULL)!=NULL)
return NULL;
 
if (d->read==0) {
d->offset=-1;
return NULL;
}
d->read--;
d->act=(char *)d->buf;
}
else { /* some object is ready in buffer */
d->read--;
d->act=(char *)(d->act+strlen(d->act)+1);
}
 
strcpy(dent.d_name,d->act);
dent.d_namlen=strlen(dent.d_name);
 
/* If we're returning the last item, check if there are any more.
* If there are, nothing will happen; if not, then d->offset = -1 */
if (!d->read)
SWI_OS_GBPB_9(d->dirname,d->buf,&d->read,&d->offset,0,NULL);
 
return &dent;
}
 
void closedir(DIR *d)
{
if (d->buf!=NULL)
free(d->buf);
if (d->dirname!=NULL)
free(d->dirname);
free(d);
}
 
int unlink(f)
char *f; /* file to delete */
/* Delete the file *f, returning non-zero on failure. */
{
os_error *er;
char canon[256];
int size=255;
 
er=SWI_OS_FSControl_37(f,canon,&size);
if (er==NULL) {
er=SWI_OS_FSControl_27(canon,0x100);
}
else {
er=SWI_OS_FSControl_27(f,0x100);
}
return (int)er;
}
 
int rmdir(char *d)
{
int objtype;
char *s;
int len;
 
len = strlen(d);
if ((s = malloc(len + 1)) == NULL)
return -1;
 
strcpy(s,d);
if (s[len-1]=='.')
s[len-1]=0;
 
if (SWI_OS_File_5(s,&objtype,NULL,NULL,NULL,NULL)!=NULL) {
free(s);
return -1;
}
if (objtype<2 || (!uO.scanimage && objtype==3)) {
/* this is a file or it doesn't exist */
free(s);
return -1;
}
if (SWI_OS_File_6(s)!=NULL) {
free(s);
return -1;
}
free(s);
return 0;
}
 
#endif /* !SFX */
 
int chmod(char *file, int mode)
{
/*************** NOT YET IMPLEMENTED!!!!!! ******************/
/* I don't know if this will be needed or not... */
file=file;
mode=mode;
return 0;
}
 
void setfiletype(char *fname,int ftype)
{
char str[256];
sprintf(str,"SetType %s &%3.3X",fname,ftype);
SWI_OS_CLI(str);
}
 
void getRISCOSexts(char *envstr)
{
char *envptr; /* value returned by getenv */
 
envptr = getenv(envstr);
if (envptr == NULL || *envptr == 0) return;
 
exts2swap=malloc(1+strlen(envptr));
if (exts2swap == NULL)
return;
 
strcpy(exts2swap, envptr);
}
 
int checkext(char *suff)
{
register char *extptr = exts2swap ? exts2swap : "";
register char *suffptr;
register int e,s;
 
while(*extptr) {
suffptr=suff;
e=*extptr; s=*suffptr;
while (e && e!=':' && s && s!='.' && s!='/' && e==s) {
e=*++extptr; s=*++suffptr;
}
if (e==':') e=0;
if (s=='.' || s=='/') s=0;
if (!e && !s) {
return 1;
}
while(*extptr!=':' && *extptr!='\0') /* skip to next extension */
extptr++;
if (*extptr!='\0')
extptr++;
}
return 0;
}
 
void swapext(char *name, char *exptr)
{
char ext[MAXEXT];
register char *p1=exptr+1;
register char *p2=ext;
int extchar=*exptr;
 
while(*p1 && *p1!='.' && *p1!='/')
*p2++=*p1++;
*p2=0;
p2=exptr-1;
p1--;
while(p2 >= name)
*p1--=*p2--;
p1=name;
p2=ext;
while(*p2)
*p1++=*p2++;
*p1=(extchar=='/'?'.':'/');
}
 
void remove_prefix(void)
{
SWI_DDEUtils_Prefix(NULL);
}
 
void set_prefix(void)
{
char *pref;
int size=0;
 
if (SWI_OS_FSControl_37("@",pref,&size)!=NULL)
return;
 
size=1-size;
 
if (pref=malloc(size),pref!=NULL) {
if (SWI_OS_FSControl_37("@",pref,&size)!=NULL) {
free(pref);
return;
}
 
if (SWI_DDEUtils_Prefix(pref)==NULL) {
atexit(remove_prefix);
}
 
free(pref);
}
}
 
#ifdef localtime
# undef localtime
#endif
 
#ifdef gmtime
# undef gmtime
#endif
 
/* Acorn's implementation of localtime() and gmtime()
* doesn't consider the timezone offset, so we have to
* add it before calling the library functions
*/
 
struct tm *riscos_localtime(const time_t *timer)
{
time_t localt=*timer;
 
localt+=SWI_Read_Timezone()/100;
 
return localtime(&localt);
}
 
struct tm *riscos_gmtime(const time_t *timer)
{
time_t localt=*timer;
 
localt+=SWI_Read_Timezone()/100;
 
return gmtime(&localt);
}
/programs/fs/unzip60/acorn/riscos.h
0,0 → 1,136
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
 
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* riscos.h */
 
#ifndef __riscos_h
#define __riscos_h
 
#include <time.h>
 
typedef struct {
int errnum;
char errmess[252];
} os_error;
 
#ifndef __swiven_h
# include "swiven.h"
#endif
 
#define MAXPATHLEN 256
#define MAXFILENAMELEN 64 /* should be 11 for ADFS, 13 for DOS, 64 seems a sensible value... */
#define DIR_BUFSIZE 1024 /* this should be enough to read a whole E-Format directory */
 
struct stat {
unsigned int st_dev;
int st_ino;
unsigned int st_mode;
int st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned int st_rdev;
unsigned int st_size;
unsigned int st_blksize;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
 
typedef struct {
char *dirname;
void *buf;
int size;
char *act;
int offset;
int read;
} DIR;
 
 
struct dirent {
unsigned int d_off; /* offset of next disk directory entry */
int d_fileno; /* file number of entry */
size_t d_reclen; /* length of this record */
size_t d_namlen; /* length of d_name */
char d_name[MAXFILENAMELEN]; /* name */
};
 
typedef struct {
unsigned int load_addr;
unsigned int exec_addr;
int lenght;
int attrib;
int objtype;
char name[13];
} riscos_direntry;
 
typedef struct {
short ID;
short size;
int ID_2;
unsigned int loadaddr;
unsigned int execaddr;
int attr;
int zero;
} extra_block;
 
 
#define S_IFMT 0770000
 
#define S_IFDIR 0040000
#define S_IFREG 0100000 /* 0200000 in UnixLib !?!?!?!? */
 
#ifndef S_IEXEC
# define S_IEXEC 0000100
# define S_IWRITE 0000200
# define S_IREAD 0000400
#endif
 
#ifndef NO_UNZIPH_STUFF
# include <time.h>
# if (!defined(HAVE_STRNICMP) & !defined(NO_STRNICMP))
# define NO_STRNICMP
# endif
# ifndef DATE_FORMAT
# define DATE_FORMAT DF_DMY
# endif
# define lenEOL 1
# define PutNativeEOL *q++ = native(LF);
# define USE_STRM_INPUT
# define USE_FWRITE
# define PIPE_ERROR (errno == 9999) /* always false */
# define isatty(x) (TRUE) /* used in funzip.c to find if stdin redirected:
should find a better way, now just work as if stdin never redirected */
# define USE_EF_UT_TIME
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
# endif
# define localtime riscos_localtime
# define gmtime riscos_gmtime
#endif /* !NO_UNZIPH_STUFF */
 
#define _raw_getc() SWI_OS_ReadC()
 
extern char *exts2swap; /* Extensions to swap */
 
int stat(char *filename,struct stat *res);
DIR *opendir(char *dirname);
struct dirent *readdir(DIR *d);
void closedir(DIR *d);
int unlink(char *f);
int rmdir(char *d);
int chmod(char *file, int mode);
void setfiletype(char *fname,int ftype);
void getRISCOSexts(char *envstr);
int checkext(char *suff);
void swapext(char *name, char *exptr);
void remove_prefix(void);
void set_prefix(void);
struct tm *riscos_localtime(const time_t *timer);
struct tm *riscos_gmtime(const time_t *timer);
 
#endif /* !__riscos_h */
/programs/fs/unzip60/acorn/srcrename
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/unzip60/acorn/swiven.h
0,0 → 1,69
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
 
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* swiven.h */
 
#ifndef __swiven_h
#define __swiven_h
 
os_error *SWI_OS_FSControl_26(char *source, char *dest, int actionmask);
/* copy */
 
os_error *SWI_OS_FSControl_27(char *filename, int actionmask);
/* wipe */
 
os_error *SWI_OS_GBPB_9(char *dirname, void *buf, int *number,
int *offset, int size, char *match);
/* read dir */
 
os_error *SWI_OS_File_1(char *filename, unsigned int loadaddr,
unsigned int execaddr, int attrib);
/* write file attributes */
 
os_error *SWI_OS_File_5(char *filename, int *objtype, unsigned int *loadaddr,
unsigned int *execaddr, int *length, int *attrib);
/* read file info */
 
os_error *SWI_OS_File_6(char *filename);
/* delete */
 
os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size);
/* create an empty file */
 
os_error *SWI_OS_File_8(char *dirname);
/* create a directory */
 
os_error *SWI_OS_File_18(char *filename, int filetype);
/* set a file's type */
 
os_error *SWI_OS_CLI(char *cmd);
/* execute a command */
 
int SWI_OS_ReadC(void);
/* get a key from the keyboard buffer */
 
os_error *SWI_OS_ReadVarVal(char *var, char *buf, int len, int *bytesused);
/* reads an OS varibale */
 
os_error *SWI_OS_FSControl_54(char *buffer, int dir, char *fsname, int *size);
/* reads the path of a specified directory */
 
os_error *SWI_OS_FSControl_37(char *pathname, char *buffer, int *size);
/* canonicalise path */
 
os_error *SWI_DDEUtils_Prefix(char *dir);
/* sets the 'prefix' directory */
 
int SWI_Read_Timezone(void);
/* returns the timezone offset (centiseconds) */
 
int SWI_MimeMap_Translate(const char *ext);
/* given a filename extn, returns the filetype (or -1 if no match).
* Uses the MimeMap module */
 
#endif /* !__swiven_h */
/programs/fs/unzip60/acorn/swiven.s
0,0 → 1,316
;===========================================================================
; Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
;
; See the accompanying file LICENSE, version 2000-Apr-09 or later
; (the contents of which are also included in unzip.h) for terms of use.
; If, for some reason, all these files are missing, the Info-ZIP license
; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
;===========================================================================
; SWI veneers used by Zip/Unzip
;
 
r0 RN 0
r1 RN 1
r2 RN 2
r3 RN 3
r4 RN 4
r5 RN 5
r6 RN 6
r7 RN 7
r8 RN 8
r9 RN 9
r10 RN 10
r11 RN 11
r12 RN 12
sp RN 13
lr RN 14
pc RN 15
 
sl RN 10
fp RN 11
ip RN 12
 
 
XOS_Bit EQU &020000
 
OS_GBPB EQU &00000C
OS_File EQU &000008
OS_FSControl EQU &000029
OS_CLI EQU &000005
OS_ReadC EQU &000004
OS_ReadVarVal EQU &000023
DDEUtils_Prefix EQU &042580
Territory_ReadCurrentTimeZone EQU &043048
MimeMap_Translate EQU &050B00
 
MACRO
STARTCODE $name
EXPORT $name
$name
MEND
 
 
AREA |C$$code|, CODE, READONLY
 
; os_error *SWI_OS_FSControl_26(char *source, char *dest, int actionmask);
 
STARTCODE SWI_OS_FSControl_26
 
MOV ip, lr
 
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #26
 
SWI OS_FSControl + XOS_Bit
 
MOVVC r0, #0
 
MOVS pc, ip
 
 
; os_error *SWI_OS_FSControl_27(char *filename, int actionmask);
 
STARTCODE SWI_OS_FSControl_27
 
MOV ip, lr
 
MOV r3, r1
MOV r1, r0
MOV r0, #27
 
SWI OS_FSControl + XOS_Bit
 
MOVVC r0, #0
 
MOVS pc, ip
 
 
; os_error *SWI_OS_GBPB_9(char *dirname, void *buf, int *number,
; int *offset, int size, char *match);
 
STARTCODE SWI_OS_GBPB_9
 
MOV ip, sp
STMFD sp!, {r2-r6,lr}
LDMIA ip, {r5,r6}
LDR r4, [r3]
LDR r3, [r2]
MOV r2, r1
MOV r1, r0
MOV r0, #9
SWI OS_GBPB + XOS_Bit
LDMVSFD sp!, {r2-r6,pc}^
MOV r0, #0
LDMFD sp, {r5,r6}
STR r3, [r5]
STR r4, [r6]
LDMFD sp!, {r2-r6,pc}^
 
 
; os_error *SWI_OS_File_1(char *filename, int loadaddr, int execaddr, int attrib);
 
STARTCODE SWI_OS_File_1
 
STMFD sp!, {r5,lr}
MOV r5, r3
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #1
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r5,pc}^
 
 
 
; os_error *SWI_OS_File_5(char *filename, int *objtype, int *loadaddr,
; int *execaddr, int *length, int *attrib);
 
STARTCODE SWI_OS_File_5
 
STMFD sp!, {r1-r5,lr}
MOV r1, r0
MOV r0, #5
SWI OS_File + XOS_Bit
LDMVSFD sp!, {r1-r5,pc}^
LDR lr, [sp]
TEQ lr, #0
STRNE r0, [lr]
LDR lr, [sp, #4]
TEQ lr ,#0
STRNE r2, [lr]
LDR lr, [sp, #8]
TEQ lr, #0
STRNE r3, [lr]
LDR lr, [sp ,#24]
TEQ lr, #0
STRNE r4, [lr]
LDR lr, [sp ,#28]
TEQ lr, #0
STRNE r5, [lr]
MOV r0, #0
LDMFD sp!, {r1-r5,pc}^
 
 
; os_error *SWI_OS_File_6(char *filename);
 
STARTCODE SWI_OS_File_6
 
STMFD sp!, {r4-r5,lr}
MOV r1, r0
MOV r0, #6
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
 
 
; os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size);
 
STARTCODE SWI_OS_File_7
 
STMFD sp!, {r4-r5,lr}
MOV r5, r3
MOV r4, #0
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #7
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
 
 
; os_error *SWI_OS_File_8(char *dirname);
 
STARTCODE SWI_OS_File_8
 
STMFD sp!, {r4,lr}
MOV r1, r0
MOV r4, #0
MOV r0, #8
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4,pc}^
 
 
; os_error *SWI_OS_File_18(char *filename, int filetype);
 
STARTCODE SWI_OS_File_18
 
STMFD sp!, {r4-r5,lr}
MOV r2, r1
MOV r1, r0
MOV r0, #18
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
 
 
; os_error *SWI_OS_CLI(char *cmd);
 
STARTCODE SWI_OS_CLI
 
MOV ip, lr
SWI OS_CLI + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
 
 
; int SWI_OS_ReadC(void);
 
STARTCODE SWI_OS_ReadC
 
MOV ip, lr
SWI OS_ReadC + XOS_Bit
MOVS pc, ip
 
 
; os_error *SWI_OS_ReadVarVal(char *var, char *buf, int len, int *bytesused);
 
STARTCODE SWI_OS_ReadVarVal
 
STMFD sp!, {r4,lr}
MOV ip, r3
MOV r3, #0
MOV r4, #0
SWI OS_ReadVarVal + XOS_Bit
LDMVSFD sp!, {r4,pc}^
TEQ ip, #0
STRNE r2, [ip]
MOV r0, #0
LDMFD sp!, {r4,pc}^
 
 
; os_error *SWI_OS_FSControl_54(char *buffer, int dir, char *fsname, int *size);
 
STARTCODE SWI_OS_FSControl_54
 
STMFD sp!, {r3-r6,lr}
LDR r5, [r3]
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #54
SWI OS_FSControl + XOS_Bit
LDMVSFD sp!, {r3-r6,pc}^
MOV r0, #0
LDMFD sp!, {r3}
STR r5, [r3]
LDMFD sp!, {r4-r6,pc}^
 
 
; os_error *SWI_OS_FSControl_37(char *pathname, char *buffer, int *size);
 
STARTCODE SWI_OS_FSControl_37
 
STMFD sp!, {r2,r3-r5,lr}
LDR r5, [r2]
MOV r3, #0
MOV r4, #0
MOV r2, r1
MOV r1, r0
MOV r0, #37
SWI OS_FSControl + XOS_Bit
LDMVSFD sp!, {r2,r3-r5,pc}^
MOV r0, #0
LDMFD sp!, {r2}
STR r5, [r2]
LDMFD sp!, {r3-r5,pc}^
 
 
; os_error *SWI_DDEUtils_Prefix(char *dir);
 
STARTCODE SWI_DDEUtils_Prefix
 
MOV ip, lr
SWI DDEUtils_Prefix + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
 
; int SWI_Read_Timezone(void);
 
STARTCODE SWI_Read_Timezone
 
MOV ip, lr
SWI Territory_ReadCurrentTimeZone + XOS_Bit
MOVVC r0, r1
MOVVS r0, #0
MOVS pc, ip
 
 
; int SWI_MimeMap_Translate(char *ext);
 
STARTCODE SWI_MimeMap_Translate
MOV ip,lr
MOV r1, r0
MOV r0, #3
MOV r2, #0
SWI MimeMap_Translate + XOS_Bit
MOVVC r0, r3
MVNVS r0, #0 ; return -1 on error
MOVS pc, ip
 
 
END