mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c61e6cf190 |
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.68k,v 1.23 2005-01-29 18:05:13 obarthel Exp $
|
||||
# $Id: GNUmakefile.68k,v 1.19 2004-12-26 10:28:56 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@@ -99,10 +99,8 @@ endif
|
||||
##############################################################################
|
||||
|
||||
WARNINGS = \
|
||||
-Wall -W -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
|
||||
-Wundef -Wbad-function-cast -Wmissing-declarations
|
||||
|
||||
# -Wconversion -Wshadow
|
||||
-Wall -W -Wshadow -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
|
||||
-Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion
|
||||
|
||||
INCLUDES = -Iinclude -I. -Inetinclude
|
||||
OPTIONS = -DNDEBUG -fno-builtin
|
||||
@@ -363,12 +361,9 @@ C_LIB = \
|
||||
time_asctime_r.o \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
time_gmtime_r.o \
|
||||
@@ -378,7 +373,6 @@ C_LIB = \
|
||||
time_numbertostring.o \
|
||||
time_strftime.o \
|
||||
time_time.o \
|
||||
time_weekday.o \
|
||||
unistd_access.o \
|
||||
unistd_chdir.o \
|
||||
unistd_chdir_exit.o \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.os4,v 1.23 2005-01-29 18:05:13 obarthel Exp $
|
||||
# $Id: GNUmakefile.os4,v 1.19 2004-12-26 10:28:56 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@@ -15,7 +15,7 @@ NET_INCLUDE = netinclude
|
||||
CC = ppc-amigaos-gcc
|
||||
AR = ppc-amigaos-ar -q
|
||||
RANLIB = ppc-amigaos-ranlib
|
||||
COPY = cp -a
|
||||
COPY = cp
|
||||
DELETE = rm -r
|
||||
MAKEDIR = mkdir
|
||||
|
||||
@@ -365,12 +365,9 @@ C_LIB = \
|
||||
time_asctime_r.o \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
time_gmtime_r.o \
|
||||
@@ -380,7 +377,6 @@ C_LIB = \
|
||||
time_numbertostring.o \
|
||||
time_strftime.o \
|
||||
time_time.o \
|
||||
time_weekday.o \
|
||||
unistd_access.o \
|
||||
unistd_chdir.o \
|
||||
unistd_chdir_exit.o \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "amiga.lib 1.187"
|
||||
#define VSTRING "amiga.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: amiga.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "amiga.lib 1.185"
|
||||
#define VSTRING "amiga.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: amiga.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: amiga_rexxvars.c,v 1.3 2005-01-09 10:10:40 obarthel Exp $
|
||||
* $Id: amiga_rexxvars.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -50,12 +50,12 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static struct Library * RexxSysBase;
|
||||
STATIC struct Library * RexxSysBase;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
static struct RexxSysIFace * IRexxSys;
|
||||
STATIC struct RexxSysIFace * IRexxSys;
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -144,7 +144,7 @@ CheckRexxMsg(struct RexxMsg *message)
|
||||
LONG
|
||||
GetRexxVar(struct RexxMsg *message,STRPTR variable_name,STRPTR *buffer_pointer)
|
||||
{
|
||||
static UBYTE buffer[256];
|
||||
STATIC TEXT buffer[256];
|
||||
LONG result;
|
||||
|
||||
/* The following uses a function which was added to rexxsyslib.library V45.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: amiga_setsuperattrs.c,v 1.3 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: amiga_setsuperattrs.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static ULONG
|
||||
STATIC ULONG
|
||||
SetSuperAttrsA(Class * cl,Object * obj,struct TagItem * tags)
|
||||
{
|
||||
ULONG result = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "c.lib 1.187"
|
||||
#define VSTRING "c.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: c.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "c.lib 1.185"
|
||||
#define VSTRING "c.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: c.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
100
library/changes
100
library/changes
@@ -1,103 +1,3 @@
|
||||
c.lib 1.187 (29.1.2005)
|
||||
|
||||
- The default console output window opened when a program is launched
|
||||
from Workbench would open and stay open. This was not intended to
|
||||
happen and is a side-effect of the new stdio initialization code which
|
||||
checks if the stdio streams are in non-blocking mode. Fixed.
|
||||
|
||||
- Moved the common DateStamp to time_t conversion code into a shared
|
||||
function.
|
||||
|
||||
- The fall-back function for converting time into a string in strftime()
|
||||
now calls itself for the "%c", "%x" and "%X" format specifiers.
|
||||
|
||||
- mktime() is supposed to convert the time specification, given as local
|
||||
time, into the number of seconds since January 1st, 1970, relative to
|
||||
UTC. This didn't really work up until now since the time value returned
|
||||
was given as local time.
|
||||
|
||||
- Plugged in a different algorithm for calculating the day of the week in
|
||||
strftime() and asctime_r(). This one isn't sensitive to the effects of
|
||||
adding/subtracting the local time zone.
|
||||
|
||||
- Changed the algorithm that calculates the number of days that have passed
|
||||
so far as used by the the __convert_time() function and the conversion
|
||||
code in strftime().
|
||||
|
||||
- Also changed the algorithm used by strftime() to produce the week numbers
|
||||
(the '%U' and '%W' format specifiers). The new method is much simpler
|
||||
than the old one.
|
||||
|
||||
- Made the code that converts a 'time_t' value into the 'struct DateStamp',
|
||||
as used by strftime() and utime(), into its own function. This also
|
||||
fixes a bug in the code strftime() would use which was completely
|
||||
unaware of the local time zone settings.
|
||||
|
||||
|
||||
c.lib 1.186 (14.1.2005)
|
||||
|
||||
- Redirecting stderr to a file no longer has the effect of showing error
|
||||
messages and assertion failure notifications as requesters. The exception
|
||||
is in redirecting stderr to NIL: which will prompt the requester use.
|
||||
|
||||
- gettimeofday() now calls GetSysTime() rather than DateStamp() to obtain
|
||||
the current system time. This resolves granularity issues since the
|
||||
DateStamp() result was only accurate by 1/50 of a second.
|
||||
|
||||
- The "ptrdiff_t" definition in <stddef.h> now defaults to type 'int' rather
|
||||
than 'long int'.
|
||||
|
||||
- The "char" limits in <limits.h> are now set up according to the current
|
||||
compiler settings, which can either default to an unsigned or
|
||||
signed definition.
|
||||
|
||||
- Changed the rules again for the use of stderr/stdout redirection when
|
||||
printing error messages. It is always safe to redirect them now and
|
||||
no requester will appear unless you specifically set the value of the
|
||||
"__no_standard_io" variable to TRUE in your program.
|
||||
|
||||
- Removed a misplaced IsInteractive() from the stdio initialization
|
||||
function. Now this could have been big trouble...
|
||||
|
||||
- Removed tests for FileHandle->fh_Type != NULL which used to precede
|
||||
all IsInterative() tests. I verified that IsInteractive() will always
|
||||
return FALSE for NIL: type file handles.
|
||||
|
||||
- Dropped the special flag variable used by the abort() function that
|
||||
tracks whether or not console output is possible. We now use the
|
||||
global "__no_standard_io" instead.
|
||||
|
||||
- Made the <ctype.h> macros more robust.
|
||||
|
||||
- Removed the "NIL:" file handle tests preceding the Open("CONSOLE:",..)
|
||||
calls. As of Kickstart 2.x and beyond these are no longer a source of
|
||||
trouble.
|
||||
|
||||
- The V37/V40 compatibility code is no longer built for the AmigaOS4
|
||||
version of the library.
|
||||
|
||||
- Switched over the last use of DeviceProc() to GetDeviceProc(), etc.
|
||||
|
||||
- open() no longer examines a file after opening it in order to figure
|
||||
out whether read/write accesses are permitted. This decision is now
|
||||
for the file system to make.
|
||||
|
||||
- Whether or not stdio console streams are blocking or non-blocking
|
||||
is now determined at initialization time. The I/O mode is restored before
|
||||
the program exits. Previously, any changes to the I/O mode would persist.
|
||||
|
||||
- Lost some more code that is not required for AmigaOS 4.x and can be
|
||||
handled conveniently through conditional compilation.
|
||||
|
||||
- close() did not reset the non-blocking file property, as it should
|
||||
have. This only worked for files which were closed anyway, but not
|
||||
for the stdio streams. Fixed.
|
||||
|
||||
- Added a missing definition to stdio_init_exit.c which is part of
|
||||
the OS4 header files, but not of the older header file distributions.
|
||||
|
||||
|
||||
|
||||
c.lib 1.185 (2.1.2005)
|
||||
|
||||
- Moved the environment variable cleanup code into a destructor function.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: ctype_table.c,v 1.3 2005-01-09 15:20:31 obarthel Exp $
|
||||
* $Id: ctype_table.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -36,8 +36,22 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
const unsigned char __ctype_table[2 * 128] =
|
||||
/* The construction of this table is rather peculiar. The assumption is that
|
||||
the table index from which a flag value could be fetched is in the range
|
||||
-128..255 since the character to be tested could be a signed or unsigned
|
||||
8 bit value. The table access pointer (declared below) therefore points
|
||||
to the 128th byte of '__ctype_data[]'. */
|
||||
static const unsigned char __ctype_data[3 * 128] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0 */ __CTYPE_CONTROL,
|
||||
/* 1 */ __CTYPE_CONTROL,
|
||||
/* 2 */ __CTYPE_CONTROL,
|
||||
@@ -176,3 +190,7 @@ const unsigned char __ctype_table[2 * 128] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
const unsigned char * const __ctype_table = &__ctype_data[128];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "debug.lib 1.187"
|
||||
#define VSTRING "debug.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: debug.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "debug.lib 1.185"
|
||||
#define VSTRING "debug.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: debug.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: dirent_readdir.c,v 1.5 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: dirent_readdir.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -89,6 +89,7 @@ readdir(DIR * directory_pointer)
|
||||
D_S(struct FileInfoBlock,fib);
|
||||
D_S(struct bcpl_name,bcpl_name);
|
||||
UBYTE * name = bcpl_name->name;
|
||||
struct MsgPort * port;
|
||||
BPTR dir_lock;
|
||||
|
||||
assert( (((ULONG)name) & 3) == 0 );
|
||||
@@ -102,12 +103,10 @@ readdir(DIR * directory_pointer)
|
||||
{
|
||||
if(IsFileSystem(dh->dh_VolumeNode->ln_Name))
|
||||
{
|
||||
struct DevProc * dvp;
|
||||
|
||||
dvp = GetDeviceProc(dh->dh_VolumeNode->ln_Name,NULL);
|
||||
if(dvp != NULL)
|
||||
port = DeviceProc(dh->dh_VolumeNode->ln_Name);
|
||||
if(port != NULL)
|
||||
{
|
||||
dir_lock = DoPkt(dvp->dvp_Port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(name),SHARED_LOCK, 0,0);
|
||||
dir_lock = DoPkt(port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(name),SHARED_LOCK, 0,0);
|
||||
if(dir_lock != ZERO)
|
||||
{
|
||||
if(Examine(dir_lock,fib))
|
||||
@@ -123,8 +122,6 @@ readdir(DIR * directory_pointer)
|
||||
|
||||
UnLock(dir_lock);
|
||||
}
|
||||
|
||||
FreeDeviceProc(dvp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fcntl_close.c,v 1.6 2005-01-14 08:36:54 obarthel Exp $
|
||||
* $Id: fcntl_close.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -45,12 +45,9 @@ int
|
||||
__close(int file_descriptor,int * error_ptr)
|
||||
{
|
||||
DECLARE_UTILITYBASE();
|
||||
|
||||
struct file_hook_message message;
|
||||
struct fd * fd;
|
||||
int result = -1;
|
||||
BOOL no_close;
|
||||
BOOL is_alias;
|
||||
|
||||
ENTER();
|
||||
|
||||
@@ -99,7 +96,6 @@ __close(int file_descriptor,int * error_ptr)
|
||||
}
|
||||
|
||||
no_close = TRUE;
|
||||
is_alias = TRUE;
|
||||
}
|
||||
else if (fd->fd_NextLink != NULL) /* this one has aliases attached; it is the 'original' resource */
|
||||
{
|
||||
@@ -121,36 +117,31 @@ __close(int file_descriptor,int * error_ptr)
|
||||
}
|
||||
|
||||
no_close = TRUE;
|
||||
is_alias = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
no_close = FLAG_IS_SET(fd->fd_Flags,FDF_NO_CLOSE);
|
||||
is_alias = FALSE;
|
||||
}
|
||||
|
||||
/* Reset the console to regular buffered/unbuffered input. We don't do this
|
||||
for aliases and their like since the original stream is still in use. */
|
||||
if(NOT is_alias)
|
||||
(*error_ptr) = OK;
|
||||
|
||||
if(NOT no_close)
|
||||
{
|
||||
if((FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_CLEAR(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)) ||
|
||||
(FLAG_IS_CLEAR(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_SET(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)))
|
||||
struct file_hook_message message;
|
||||
|
||||
/* Reset the console to regular buffered input. */
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING))
|
||||
{
|
||||
SHOWMSG("resetting non-blocking access mode");
|
||||
|
||||
message.action = file_hook_action_set_blocking;
|
||||
message.arg = FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING);
|
||||
message.arg = 1;
|
||||
|
||||
assert( fd->fd_Hook != NULL );
|
||||
|
||||
CallHookPkt(fd->fd_Hook,fd,&message);
|
||||
}
|
||||
}
|
||||
|
||||
(*error_ptr) = OK;
|
||||
|
||||
if(NOT no_close && NOT is_alias)
|
||||
{
|
||||
SHOWMSG("shutting down");
|
||||
|
||||
message.action = file_hook_action_close;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fcntl_open.c,v 1.7 2005-01-09 16:07:27 obarthel Exp $
|
||||
* $Id: fcntl_open.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -53,39 +53,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This is used in place of ChangeMode() in order to work around a bug in
|
||||
dos.library V40 and below: a "NIL:" file handle will crash the
|
||||
caller of the ChangeMode() function. */
|
||||
static LONG
|
||||
safe_change_mode(LONG type,BPTR file_handle,LONG mode)
|
||||
{
|
||||
LONG result = DOSFALSE;
|
||||
|
||||
#ifndef __amigaos4__
|
||||
{
|
||||
struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle);
|
||||
|
||||
assert( type == CHANGE_FH );
|
||||
|
||||
if(fh == NULL || fh->fh_Type == NULL)
|
||||
{
|
||||
SetIoErr(ERROR_OBJECT_WRONG_TYPE);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
PROFILE_OFF();
|
||||
result = ChangeMode(type,file_handle,mode);
|
||||
PROFILE_ON();
|
||||
|
||||
out:
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
open(const char *path_name, int open_flag, ... /* mode_t mode */ )
|
||||
{
|
||||
@@ -97,9 +64,10 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
|
||||
LONG is_file_system = FALSE;
|
||||
LONG open_mode;
|
||||
BPTR lock = ZERO;
|
||||
struct FileHandle * file_handle;
|
||||
BPTR handle = ZERO;
|
||||
BOOL create_new_file = FALSE;
|
||||
LONG is_interactive;
|
||||
LONG is_interactive = FALSE;
|
||||
int fd_slot_number;
|
||||
struct fd * fd;
|
||||
int access_mode;
|
||||
@@ -326,13 +294,60 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
|
||||
goto out;
|
||||
}
|
||||
|
||||
file_handle = BADDR(handle);
|
||||
|
||||
/* NOTE: workaround for a bug in dos.library V40 and below which will
|
||||
* crash the caller if the file handle refers to "NIL:".
|
||||
*/
|
||||
if(file_handle->fh_Type != NULL)
|
||||
{
|
||||
LONG status;
|
||||
|
||||
PROFILE_OFF();
|
||||
status = ExamineFH(handle,fib);
|
||||
PROFILE_ON();
|
||||
|
||||
if(status != DOSFALSE)
|
||||
{
|
||||
BOOL operation_permitted = TRUE;
|
||||
|
||||
/* Check if the file is readable. */
|
||||
if(FLAG_IS_SET(fib->fib_Protection,FIBF_READ))
|
||||
{
|
||||
if(access_mode == O_RDONLY ||
|
||||
access_mode == O_RDWR)
|
||||
{
|
||||
operation_permitted = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the file can be written to. */
|
||||
if(FLAG_IS_SET(fib->fib_Protection,FIBF_WRITE))
|
||||
{
|
||||
if(access_mode == O_WRONLY)
|
||||
operation_permitted = FALSE;
|
||||
}
|
||||
|
||||
if(NOT operation_permitted)
|
||||
{
|
||||
SHOWMSG("this object must not be opened");
|
||||
|
||||
errno = EACCES;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fd = __fd[fd_slot_number];
|
||||
|
||||
__initialize_fd(fd,(HOOKFUNC)__fd_hook_entry,handle,0);
|
||||
|
||||
/* Figure out if this stream is attached to a console. */
|
||||
PROFILE_OFF();
|
||||
|
||||
if(file_handle->fh_Type != NULL)
|
||||
is_interactive = IsInteractive(handle);
|
||||
|
||||
PROFILE_ON();
|
||||
|
||||
if(is_interactive)
|
||||
@@ -353,7 +368,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
|
||||
|
||||
len = 0;
|
||||
|
||||
for(i = 0 ; path_name[i] != '\0' ; i++)
|
||||
for(i = 0 ; i < (int)strlen(path_name) ; i++)
|
||||
{
|
||||
if(path_name[i] == ':')
|
||||
{
|
||||
@@ -387,12 +402,22 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
|
||||
}
|
||||
|
||||
if(is_file_system)
|
||||
{
|
||||
/* NOTE: workaround for a bug in dos.library V40 and below which will
|
||||
* crash the caller if the file handle refers to "NIL:".
|
||||
*/
|
||||
if(file_handle->fh_Type != NULL)
|
||||
{
|
||||
/* We opened the file in exclusive access mode. Switch it back
|
||||
into shared access mode so that its contents can be read
|
||||
while it's still open. */
|
||||
if(open_mode == MODE_NEWFILE)
|
||||
safe_change_mode(CHANGE_FH,handle,SHARED_LOCK);
|
||||
{
|
||||
PROFILE_OFF();
|
||||
ChangeMode(CHANGE_FH,handle,SHARED_LOCK);
|
||||
PROFILE_ON();
|
||||
}
|
||||
}
|
||||
|
||||
/* We should be able to seek in this file. */
|
||||
SET_FLAG(fd->fd_Flags,FDF_CACHE_POSITION);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: ctype.h,v 1.5 2005-01-09 15:20:33 obarthel Exp $
|
||||
* $Id: ctype.h,v 1.4 2005-01-02 09:07:21 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -66,14 +66,15 @@ extern int toupper(int c);
|
||||
/*
|
||||
* If requested, reimplement the character classification functions as macros;
|
||||
* note that the macro variants ignore the current locale and default to the
|
||||
* 'C' locale rules.
|
||||
* 'C' locale rules. Note that the characters to be tested must be either
|
||||
* signed or unsigned 8 bit values.
|
||||
*/
|
||||
|
||||
#ifdef __C_MACROS__
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern const unsigned char __ctype_table[];
|
||||
extern const unsigned char * const __ctype_table;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -88,17 +89,17 @@ extern const unsigned char __ctype_table[];
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define isalnum(c) ((__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define isalpha(c) ((__ctype_table[(c) & 255] & (__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define iscntrl(c) ((__ctype_table[(c) & 255] & __CTYPE_CONTROL) != 0)
|
||||
#define isdigit(c) ((__ctype_table[(c) & 255] & __CTYPE_DIGIT) != 0)
|
||||
#define isxdigit(c) ((__ctype_table[(c) & 255] & __CTYPE_HEX_DIGIT) != 0)
|
||||
#define isgraph(c) ((__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_PUNCTUATION|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define ispunct(c) ((__ctype_table[(c) & 255] & __CTYPE_PUNCTUATION) != 0)
|
||||
#define isprint(c) ((__ctype_table[(c) & 255] & __CTYPE_PRINTABLE) != 0)
|
||||
#define islower(c) ((__ctype_table[(c) & 255] & __CTYPE_LOWER_CASE) != 0)
|
||||
#define isupper(c) ((__ctype_table[(c) & 255] & __CTYPE_UPPER_CASE) != 0)
|
||||
#define isspace(c) ((__ctype_table[(c) & 255] & __CTYPE_WHITE_SPACE) != 0)
|
||||
#define isalnum(c) ((__ctype_table[c] & (__CTYPE_DIGIT|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define isalpha(c) ((__ctype_table[c] & (__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define iscntrl(c) ((__ctype_table[c] & __CTYPE_CONTROL) != 0)
|
||||
#define isdigit(c) ((__ctype_table[c] & __CTYPE_DIGIT) != 0)
|
||||
#define isxdigit(c) ((__ctype_table[c] & __CTYPE_HEX_DIGIT) != 0)
|
||||
#define isgraph(c) ((__ctype_table[c] & (__CTYPE_DIGIT|__CTYPE_PUNCTUATION|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define ispunct(c) ((__ctype_table[c] & __CTYPE_PUNCTUATION) != 0)
|
||||
#define isprint(c) ((__ctype_table[c] & __CTYPE_PRINTABLE) != 0)
|
||||
#define islower(c) ((__ctype_table[c] & __CTYPE_LOWER_CASE) != 0)
|
||||
#define isupper(c) ((__ctype_table[c] & __CTYPE_UPPER_CASE) != 0)
|
||||
#define isspace(c) ((__ctype_table[c] & __CTYPE_WHITE_SPACE) != 0)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: limits.h,v 1.5 2005-01-09 09:40:33 obarthel Exp $
|
||||
* $Id: limits.h,v 1.4 2005-01-02 09:07:21 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -37,49 +37,20 @@
|
||||
/****************************************************************************/
|
||||
|
||||
#define CHAR_BIT 8
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define SCHAR_MIN -128
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
* The following defines the range a 'char' can cover by checking a
|
||||
* preprocessor symbol; we support both SAS/C and GCC here.
|
||||
*/
|
||||
|
||||
#if (defined(__GNUC__) && defined(__CHAR_UNSIGNED__)) || (defined(__SASC) && defined(_UNSCHAR))
|
||||
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX 255
|
||||
|
||||
#else
|
||||
|
||||
#define CHAR_MIN -128
|
||||
#define CHAR_MAX 127
|
||||
|
||||
#endif /* (__GNUC__ && __CHAR_UNSIGNED) || (__SASC && _UNSCHAR) */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define SHRT_MIN -32768
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 65535
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define INT_MIN (-2147483647L - 1)
|
||||
#define CHAR_MIN -128
|
||||
#define INT_MAX 2147483647L
|
||||
#define UINT_MAX 4294967295UL
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define LONG_MIN (-2147483647L - 1)
|
||||
#define INT_MIN (-2147483647L - 1)
|
||||
#define LONG_MAX 2147483647L
|
||||
#define LONG_MIN (-2147483647L - 1)
|
||||
#define SCHAR_MAX 127
|
||||
#define SCHAR_MIN -128
|
||||
#define SHRT_MAX 32767
|
||||
#define SHRT_MIN -32768
|
||||
#define UCHAR_MAX 255
|
||||
#define UINT_MAX 4294967295UL
|
||||
#define ULONG_MAX 4294967295UL
|
||||
#define USHRT_MAX 65535
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stddef.h,v 1.3 2005-01-08 10:21:28 obarthel Exp $
|
||||
* $Id: stddef.h,v 1.2 2005-01-02 09:07:21 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -52,7 +52,7 @@ extern "C" {
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
typedef int ptrdiff_t;
|
||||
typedef long int ptrdiff_t;
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned int wchar_t;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "m.lib 1.187"
|
||||
#define VSTRING "m.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "m.lib 1.185"
|
||||
#define VSTRING "m.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "m881.lib 1.187"
|
||||
#define VSTRING "m881.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m881.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "m881.lib 1.185"
|
||||
#define VSTRING "m881.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m881.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: macros.h,v 1.7 2005-01-29 18:05:14 obarthel Exp $
|
||||
* $Id: macros.h,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -60,9 +60,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This is the difference (in seconds) between the Unix epoch (which began
|
||||
on January 1st, 1970) and the AmigaOS epoch (which began eight years
|
||||
later on January 1st 1978). */
|
||||
#define UNIX_TIME_OFFSET 252460800
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: math_ceil.c,v 1.3 2005-01-26 09:24:38 obarthel Exp $
|
||||
* $Id: math_ceil.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -150,6 +150,7 @@ __ceil(double x)
|
||||
|
||||
#if defined(PPC_FLOATING_POINT_SUPPORT)
|
||||
|
||||
|
||||
static const double huge = 1.0e300;
|
||||
|
||||
INLINE static const double
|
||||
@@ -232,7 +233,6 @@ __ceil(double x)
|
||||
}
|
||||
|
||||
#endif /* PPC_FLOATING_POINT_SUPPORT */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
double
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: math_cos.c,v 1.3 2005-01-26 09:24:38 obarthel Exp $
|
||||
* $Id: math_cos.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -172,7 +172,6 @@ __cos(double x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PPC_FLOATING_POINT_SUPPORT */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: math_log.c,v 1.4 2005-01-18 20:00:08 obarthel Exp $
|
||||
* $Id: math_log.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -244,10 +244,11 @@ log(double x)
|
||||
{
|
||||
double result;
|
||||
|
||||
/* When do we consider 'x' to be invalid? If it's close
|
||||
* enough to zero or negative.
|
||||
/* ZZZ when do we consider 'x' to be invalid? If it's close
|
||||
* enough to zero or negative. How large is epsilon, and how
|
||||
* do we return minus infinity?
|
||||
*/
|
||||
if(x > DBL_EPSILON)
|
||||
if(x > 0.0)
|
||||
{
|
||||
result = __log(x);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: math_log10.c,v 1.3 2005-01-18 20:00:08 obarthel Exp $
|
||||
* $Id: math_log10.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -186,10 +186,11 @@ log10(double x)
|
||||
{
|
||||
double result;
|
||||
|
||||
/* When do we consider 'x' to be invalid? If it's close
|
||||
* enough to zero or negative.
|
||||
/* ZZZ when do we consider 'x' to be invalid? If it's close
|
||||
* enough to zero or negative. How large is epsilon, and how
|
||||
* do we return minus infinity?
|
||||
*/
|
||||
if(x > DBL_EPSILON)
|
||||
if(x > 0.0)
|
||||
{
|
||||
result = __log10(x);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "net.lib 1.187"
|
||||
#define VSTRING "net.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: net.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "net.lib 1.185"
|
||||
#define VSTRING "net.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: net.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: signal_data.c,v 1.4 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: signal_data.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -54,3 +54,7 @@ int __signals_blocked;
|
||||
/****************************************************************************/
|
||||
|
||||
BOOL __check_abort_enabled = TRUE;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
BOOL __termination_message_disabled;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: signal_headers.h,v 1.6 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: signal_headers.h,v 1.5 2005-01-02 09:07:07 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -76,6 +76,10 @@ extern int NOCOMMON __signals_blocked;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern BOOL NOCOMMON __termination_message_disabled;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _STDLIB_HEADERS_H
|
||||
#include "stdlib_headers.h"
|
||||
#endif /* _STDLIB_HEADERS_H */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: smakefile,v 1.18 2005-01-29 18:05:14 obarthel Exp $
|
||||
# $Id: smakefile,v 1.15 2004-12-26 10:28:56 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@@ -471,12 +471,9 @@ TIME_OBJ = \
|
||||
time_asctime_r.o \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_difftime.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
@@ -486,8 +483,7 @@ TIME_OBJ = \
|
||||
time_mktime.o \
|
||||
time_numbertostring.o \
|
||||
time_strftime.o \
|
||||
time_time.o \
|
||||
time_weekday.o
|
||||
time_time.o
|
||||
|
||||
UNISTD_OBJ = \
|
||||
unistd_access.o \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: socket_init_exit.c,v 1.8 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: socket_init_exit.c,v 1.7 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -244,13 +244,15 @@ __socket_init(void)
|
||||
|
||||
SHOWVALUE(daemon_socket);
|
||||
|
||||
/* Whatever happens, the following likely won't end up
|
||||
* in the console...
|
||||
*/
|
||||
__termination_message_disabled = TRUE;
|
||||
|
||||
/* Shut down the three standard I/O streams. */
|
||||
for(i = STDIN_FILENO ; i <= STDERR_FILENO ; i++)
|
||||
close(i);
|
||||
|
||||
/* The standard I/O streams are no longer attached to a console. */
|
||||
__no_standard_io = TRUE;
|
||||
|
||||
/* Put the socket into the three standard I/O streams. */
|
||||
for(i = STDIN_FILENO ; i <= STDERR_FILENO ; i++)
|
||||
{
|
||||
@@ -282,6 +284,9 @@ __socket_init(void)
|
||||
|
||||
/* This program now runs as an internet superserver client (daemon). */
|
||||
__is_daemon = TRUE;
|
||||
|
||||
/* The standard I/O streams are no longer attached to a console. */
|
||||
__no_standard_io = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "stack.lib 1.187"
|
||||
#define VSTRING "stack.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: stack.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "stack.lib 1.185"
|
||||
#define VSTRING "stack.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: stack.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stat_convertfileinfo.c,v 1.5 2005-01-24 10:25:46 obarthel Exp $
|
||||
* $Id: stat_convertfileinfo.c,v 1.4 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -39,10 +39,6 @@
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
@@ -113,7 +109,9 @@ __convert_file_info_to_stat(
|
||||
if(FLAG_IS_SET(flags,FIBF_OTR_EXECUTE))
|
||||
SET_FLAG(mode,S_IXOTH);
|
||||
|
||||
mtime = __convert_datestamp_to_time(&fib->fib_Date);
|
||||
mtime = UNIX_TIME_OFFSET + fib->fib_Date.ds_Days * 24*60*60 + fib->fib_Date.ds_Minute * 60 + (fib->fib_Date.ds_Tick / TICKS_PER_SECOND);
|
||||
if(__default_locale != NULL)
|
||||
mtime += 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
if(fib->fib_DirEntryType < 0)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stat_stat.c,v 1.4 2005-01-24 10:25:46 obarthel Exp $
|
||||
* $Id: stat_stat.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -45,10 +45,6 @@
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
@@ -112,7 +108,9 @@ stat(const char * path_name, struct stat * st)
|
||||
DateStamp(&ds);
|
||||
PROFILE_ON();
|
||||
|
||||
mtime = __convert_datestamp_to_time(&ds);
|
||||
mtime = UNIX_TIME_OFFSET + ds.ds_Days * 24*60*60 + ds.ds_Minute * 60 + (ds.ds_Tick / TICKS_PER_SECOND);
|
||||
if(__default_locale != NULL)
|
||||
mtime += 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
st->st_mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
st->st_mtime = mtime;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.7 2005-01-12 09:15:50 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.5 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -59,21 +59,16 @@
|
||||
static LONG
|
||||
safe_examine_file_handle(BPTR file_handle,struct FileInfoBlock *fib)
|
||||
{
|
||||
struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle);
|
||||
LONG result = DOSFALSE;
|
||||
|
||||
assert( fib != NULL );
|
||||
|
||||
#ifndef __amigaos4__
|
||||
{
|
||||
struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle);
|
||||
|
||||
if(fh == NULL || fh->fh_Type == NULL)
|
||||
{
|
||||
SetIoErr(ERROR_OBJECT_WRONG_TYPE);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
PROFILE_OFF();
|
||||
result = ExamineFH(file_handle,fib);
|
||||
@@ -90,19 +85,14 @@ safe_examine_file_handle(BPTR file_handle,struct FileInfoBlock *fib)
|
||||
static BPTR
|
||||
safe_parent_of_file_handle(BPTR file_handle)
|
||||
{
|
||||
BPTR result = ZERO;
|
||||
|
||||
#ifndef __amigaos4__
|
||||
{
|
||||
struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle);
|
||||
BPTR result = ZERO;
|
||||
|
||||
if(fh == NULL || fh->fh_Type == NULL)
|
||||
{
|
||||
SetIoErr(ERROR_OBJECT_WRONG_TYPE);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
PROFILE_OFF();
|
||||
result = ParentOfFH(file_handle);
|
||||
@@ -253,12 +243,6 @@ obtain_file_lock_semaphore(BOOL shared)
|
||||
PROFILE_OFF();
|
||||
|
||||
if(shared)
|
||||
{
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
ObtainSemaphoreShared((struct SignalSemaphore *)FileLockSemaphore);
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(((struct Library *)SysBase)->lib_Version >= 39)
|
||||
{
|
||||
@@ -274,8 +258,6 @@ obtain_file_lock_semaphore(BOOL shared)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
}
|
||||
else
|
||||
{
|
||||
ObtainSemaphore((struct SignalSemaphore *)FileLockSemaphore);
|
||||
@@ -1848,9 +1830,9 @@ __fd_hook_entry(
|
||||
SHOWMSG("changing the mode");
|
||||
|
||||
if(message->arg != 0)
|
||||
mode = DOSFALSE; /* buffered mode */
|
||||
mode = 0; /* buffered mode */
|
||||
else
|
||||
mode = DOSTRUE; /* single character mode */
|
||||
mode = 1; /* single character mode */
|
||||
|
||||
if(CANNOT SetMode(fd->fd_DefaultFile,mode))
|
||||
{
|
||||
@@ -1903,21 +1885,6 @@ __fd_hook_entry(
|
||||
|
||||
old_current_dir = CurrentDir(parent_dir);
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
if(SetOwner(fib->fib_FileName,(LONG)((((ULONG)message->owner) << 16) | message->group)))
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHOWMSG("that didn't work");
|
||||
|
||||
__translate_io_error_to_errno(IoErr(),&error);
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(((struct Library *)DOSBase)->lib_Version >= 39)
|
||||
{
|
||||
SHOWMSG("changing owner");
|
||||
@@ -1963,8 +1930,6 @@ __fd_hook_entry(
|
||||
__translate_io_error_to_errno(IoErr(),&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
CurrentDir(old_current_dir);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.9 2005-01-12 09:15:50 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.8 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -268,8 +268,6 @@ struct iob
|
||||
mode (sockets only). */
|
||||
#define FDF_IS_INTERACTIVE (1UL<<11) /* File is attached to a console window or
|
||||
something like it. */
|
||||
#define FDF_DEFAULT_NON_BLOCKING (1UL<<12) /* This file defaults to non-blocking I/O
|
||||
mode. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_init_exit.c,v 1.14 2005-01-15 08:17:10 obarthel Exp $
|
||||
* $Id: stdio_init_exit.c,v 1.6 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -51,12 +51,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef ID_RAWCON
|
||||
#define ID_RAWCON 0x52415700L /* "RAW\0" */
|
||||
#endif /* ID_RAWCON */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__close_all_files(void)
|
||||
{
|
||||
@@ -119,8 +113,6 @@ __stdio_init(void)
|
||||
|
||||
ENTER();
|
||||
|
||||
assert( num_standard_files == (STDERR_FILENO-STDIN_FILENO+1) );
|
||||
|
||||
__iob = malloc(sizeof(*__iob) * num_standard_files);
|
||||
if(__iob == NULL)
|
||||
goto out;
|
||||
@@ -177,7 +169,7 @@ __stdio_init(void)
|
||||
|
||||
iob_flags = IOBF_IN_USE | IOBF_WRITE | IOBF_NO_NUL | IOBF_BUFFER_MODE_NONE;
|
||||
fd_flags = FDF_IN_USE | FDF_WRITE;
|
||||
default_file = ZERO; /* NOTE: this is really initialized later; see below... */
|
||||
default_file = ZERO;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -191,37 +183,13 @@ __stdio_init(void)
|
||||
/* Check if this stream is attached to a console window. */
|
||||
if(default_file != ZERO)
|
||||
{
|
||||
struct FileHandle * fh = BADDR(default_file);
|
||||
|
||||
PROFILE_OFF();
|
||||
|
||||
if(IsInteractive(default_file))
|
||||
{
|
||||
if(fh->fh_Type != NULL && IsInteractive(default_file))
|
||||
SET_FLAG(fd_flags,FDF_IS_INTERACTIVE);
|
||||
|
||||
/* Try to figure out if the console is in single
|
||||
character mode. We don't do that if we opened the
|
||||
output console window since this will prevent it
|
||||
from closing, or end up making it visible. */
|
||||
if(__WBenchMsg == NULL)
|
||||
{
|
||||
struct FileHandle * fh;
|
||||
|
||||
fh = BADDR(default_file);
|
||||
if(fh->fh_Type != NULL)
|
||||
{
|
||||
D_S(struct InfoData,id);
|
||||
|
||||
if(DoPkt(fh->fh_Type,ACTION_DISK_INFO,MKBADDR(id),0,0,0,0))
|
||||
{
|
||||
if(id->id_DiskType == ID_RAWCON)
|
||||
{
|
||||
SET_FLAG(fd_flags,FDF_NON_BLOCKING);
|
||||
SET_FLAG(fd_flags,FDF_DEFAULT_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROFILE_ON();
|
||||
}
|
||||
|
||||
@@ -274,8 +242,12 @@ __stdio_init(void)
|
||||
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_NO_CLOSE);
|
||||
}
|
||||
else
|
||||
else if (__fd[STDOUT_FILENO]->fd_DefaultFile != ZERO)
|
||||
{
|
||||
struct FileHandle * fh = (struct FileHandle *)BADDR(__fd[STDOUT_FILENO]->fd_DefaultFile);
|
||||
|
||||
/* Careful, this could be "NIL:". */
|
||||
if(fh->fh_Type != NULL)
|
||||
__fd[STDERR_FILENO]->fd_DefaultFile = Open("CONSOLE:",MODE_NEWFILE);
|
||||
}
|
||||
}
|
||||
@@ -285,34 +257,19 @@ __stdio_init(void)
|
||||
/* Figure out if the standard error stream is bound to a console. */
|
||||
if(__fd[STDERR_FILENO]->fd_DefaultFile != ZERO)
|
||||
{
|
||||
if(IsInteractive(__fd[STDERR_FILENO]->fd_DefaultFile))
|
||||
{
|
||||
struct FileHandle * fh = BADDR(IsInteractive(__fd[STDERR_FILENO]->fd_DefaultFile));
|
||||
|
||||
if(fh->fh_Type != NULL && IsInteractive(__fd[STDERR_FILENO]->fd_DefaultFile))
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_IS_INTERACTIVE);
|
||||
}
|
||||
|
||||
/* Careful: the console handler may open an AUTO console window
|
||||
which so far was hidden when the ACTION_DISK_INFO
|
||||
packet is sent. We don't want that to happen if we
|
||||
can avoid it. */
|
||||
if(__WBenchMsg == NULL)
|
||||
/* Check if the standard/error output refers to a console or must
|
||||
be considered unusable for console output. */
|
||||
if(FLAG_IS_CLEAR(__fd[STDOUT_FILENO]->fd_Flags,FDF_IS_INTERACTIVE) ||
|
||||
FLAG_IS_CLEAR(__fd[STDERR_FILENO]->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
{
|
||||
struct FileHandle * fh;
|
||||
|
||||
fh = BADDR(__fd[STDERR_FILENO]->fd_DefaultFile);
|
||||
if(fh->fh_Type != NULL)
|
||||
{
|
||||
D_S(struct InfoData,id);
|
||||
|
||||
if(DoPkt(fh->fh_Type,ACTION_DISK_INFO,MKBADDR(id),0,0,0,0))
|
||||
{
|
||||
if(id->id_DiskType == ID_RAWCON)
|
||||
{
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_NON_BLOCKING);
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_DEFAULT_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The standard I/O streams are no longer attached to a console. */
|
||||
__no_standard_io = TRUE;
|
||||
}
|
||||
|
||||
PROFILE_ON();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_assertion_failure.c,v 1.6 2005-01-09 09:40:32 obarthel Exp $
|
||||
* $Id: stdlib_assertion_failure.c,v 1.4 2005-01-02 09:07:08 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -61,7 +61,46 @@ __assertion_failure(
|
||||
/* Don't drop into a recursion. */
|
||||
if(been_here_before++ == 0)
|
||||
{
|
||||
if(__no_standard_io || __WBenchMsg != NULL)
|
||||
BOOL use_stderr = FALSE;
|
||||
|
||||
/* Figure out if the assertion failure message can be printed
|
||||
on the stderr stream. */
|
||||
if(__iob != NULL && NOT __no_standard_io)
|
||||
{
|
||||
struct iob * iob;
|
||||
|
||||
iob = (struct iob *)stderr;
|
||||
if(iob != NULL &&
|
||||
FLAG_IS_SET(iob->iob_Flags,IOBF_IN_USE) &&
|
||||
FLAG_IS_SET(iob->iob_Flags,IOBF_WRITE))
|
||||
{
|
||||
struct fd * fd;
|
||||
|
||||
fd = __get_file_descriptor(iob->iob_Descriptor);
|
||||
if(fd != NULL &&
|
||||
FLAG_IS_SET(fd->fd_Flags,FDF_IN_USE) &&
|
||||
FLAG_IS_SET(fd->fd_Flags,FDF_WRITE) &&
|
||||
FLAG_IS_SET(fd->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
{
|
||||
assert( FLAG_IS_CLEAR(fd->fd_Flags,FDF_IS_SOCKET) );
|
||||
|
||||
use_stderr = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(use_stderr)
|
||||
{
|
||||
if(__program_name != NULL)
|
||||
fprintf(stderr,"[%s] ",__program_name);
|
||||
|
||||
fprintf(stderr,
|
||||
"%s:%d: failed assertion '%s'\n",
|
||||
file_name,
|
||||
line_number,
|
||||
expression);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__amigaos4__)
|
||||
struct IntuitionIFace * IIntuition = NULL;
|
||||
@@ -107,17 +146,6 @@ __assertion_failure(
|
||||
CloseLibrary(IntuitionBase);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(__program_name != NULL)
|
||||
fprintf(stderr,"[%s] ",__program_name);
|
||||
|
||||
fprintf(stderr,
|
||||
"%s:%d: failed assertion '%s'\n",
|
||||
file_name,
|
||||
line_number,
|
||||
expression);
|
||||
}
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_main.c,v 1.10 2005-01-13 15:39:39 obarthel Exp $
|
||||
* $Id: stdlib_main.c,v 1.9 2005-01-02 09:07:18 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -250,12 +250,12 @@ detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list
|
||||
{
|
||||
if(__IUtility != NULL)
|
||||
DropInterface((struct Interface *)__IUtility);
|
||||
|
||||
if(IDOS != NULL)
|
||||
DropInterface((struct Interface *)IDOS);
|
||||
}
|
||||
#else
|
||||
{
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
if(__UtilityBase != NULL)
|
||||
CloseLibrary(__UtilityBase);
|
||||
|
||||
/* The following trick is necessary only under dos.library V40 and below. */
|
||||
if(((struct Library *)DOSBase)->lib_Version < 50)
|
||||
{
|
||||
@@ -270,12 +270,14 @@ detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list
|
||||
|
||||
UnLoadSeg(segment_list);
|
||||
}
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
if(IDOS != NULL)
|
||||
DropInterface((struct Interface *)IDOS);
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
if(__UtilityBase != NULL)
|
||||
CloseLibrary(__UtilityBase);
|
||||
|
||||
if(DOSBase != NULL)
|
||||
CloseLibrary(DOSBase);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_malloc.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: stdlib_malloc.c,v 1.5 2005-01-02 09:07:18 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -275,16 +275,8 @@ __memory_init(void)
|
||||
|
||||
NewList((struct List *)&__memory_list);
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
__memory_pool = CreatePool(MEMF_ANY,(ULONG)__default_pool_size,(ULONG)__default_puddle_size);
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(((struct Library *)SysBase)->lib_Version >= 39)
|
||||
__memory_pool = CreatePool(MEMF_ANY,(ULONG)__default_pool_size,(ULONG)__default_puddle_size);
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
LEAVE();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_setenv.c,v 1.5 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: stdlib_setenv.c,v 1.4 2005-01-02 09:07:18 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -61,7 +61,7 @@ struct LocalVariable
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static struct LocalVariable * __lv_root;
|
||||
STATIC struct LocalVariable * __lv_root;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_showerror.c,v 1.9 2005-01-13 15:39:39 obarthel Exp $
|
||||
* $Id: stdlib_showerror.c,v 1.5 2005-01-02 09:07:18 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -99,34 +99,14 @@ __show_error(const char * message)
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
/* If we can't hope to print the error message, show a requester instead. */
|
||||
if(__no_standard_io || __WBenchMsg != NULL)
|
||||
if(__detach || __no_standard_io || __WBenchMsg != NULL)
|
||||
{
|
||||
if(IntuitionBase->lib_Version >= 37)
|
||||
{
|
||||
UBYTE program_name[256];
|
||||
struct EasyStruct es;
|
||||
STRPTR title_string;
|
||||
|
||||
/* The following does not make great sense on OS4. */
|
||||
#if NOT defined(__amigaos4__)
|
||||
{
|
||||
if(IntuitionBase->lib_Version < 37)
|
||||
{
|
||||
static struct TextAttr default_font = { (STRPTR)"topaz.font",8,FS_NORMAL,FPF_ROMFONT|FPF_DESIGNED };
|
||||
static struct IntuiText sorry_text = {0,1,JAM1,6,3,(struct TextAttr *)NULL,(STRPTR)"Sorry",(struct IntuiText *)NULL};
|
||||
static struct IntuiText body_text = {0,1,JAM1,5,3,(struct TextAttr *)NULL,(STRPTR)NULL,(struct IntuiText *)NULL};
|
||||
|
||||
sorry_text.ITextFont = &default_font;
|
||||
body_text.ITextFont = &default_font;
|
||||
|
||||
body_text.IText = (STRPTR)message;
|
||||
|
||||
AutoRequest(NULL,&body_text,NULL,&sorry_text,0,0,37 + 8 * strlen(message),46);
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
if(__WBenchMsg != NULL)
|
||||
{
|
||||
title_string = (STRPTR)FilePart(__WBenchMsg->sm_ArgList[0].wa_Name);
|
||||
@@ -150,30 +130,32 @@ __show_error(const char * message)
|
||||
}
|
||||
else
|
||||
{
|
||||
BPTR output;
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
/* The following does not make great sense on OS4. */
|
||||
#if NOT defined(__amigaos4__)
|
||||
{
|
||||
/* Try to print the error message on the default error output stream. */
|
||||
output = ErrorOutput();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct Process * this_process = (struct Process *)FindTask(NULL);
|
||||
static struct TextAttr default_font = { (STRPTR)"topaz.font",8,FS_NORMAL,FPF_ROMFONT|FPF_DESIGNED };
|
||||
static struct IntuiText sorry_text = {0,1,JAM1,6,3,(struct TextAttr *)NULL,(STRPTR)"Sorry",(struct IntuiText *)NULL};
|
||||
static struct IntuiText body_text = {0,1,JAM1,5,3,(struct TextAttr *)NULL,(STRPTR)NULL,(struct IntuiText *)NULL};
|
||||
|
||||
output = this_process->pr_CES;
|
||||
sorry_text.ITextFont = &default_font;
|
||||
body_text.ITextFont = &default_font;
|
||||
|
||||
body_text.IText = (STRPTR)message;
|
||||
|
||||
AutoRequest(NULL,&body_text,NULL,&sorry_text,0,0,37 + 8 * strlen(message),46);
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BPTR output;
|
||||
|
||||
if(output == ZERO)
|
||||
output = Output();
|
||||
|
||||
if(output != ZERO)
|
||||
{
|
||||
Write(output,(STRPTR)message,(LONG)strlen(message));
|
||||
Write(output,"\n",1);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_startup.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: stdlib_startup.c,v 1.5 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -387,6 +387,9 @@ __startup_init(void)
|
||||
{
|
||||
struct FileHandle * fh = BADDR(input);
|
||||
|
||||
/* Careful: "NIL:" will have a NULL MsgPort in the file handle. */
|
||||
if(fh->fh_Type != NULL)
|
||||
{
|
||||
old_console_task = SetConsoleTask(fh->fh_Type);
|
||||
|
||||
output = Open("CONSOLE:",MODE_NEWFILE);
|
||||
@@ -395,6 +398,7 @@ __startup_init(void)
|
||||
else
|
||||
SetConsoleTask((struct MsgPort *)old_console_task);
|
||||
}
|
||||
}
|
||||
|
||||
if(output == ZERO)
|
||||
output = Open("NIL:",MODE_NEWFILE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_system.c,v 1.3 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: stdlib_system.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -69,7 +69,7 @@ system(const char * command)
|
||||
}
|
||||
else
|
||||
{
|
||||
static const struct TagItem system_tags[2] =
|
||||
STATIC const struct TagItem system_tags[2] =
|
||||
{
|
||||
{ SYS_UserShell, TRUE },
|
||||
{ TAG_END, 0 }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_termination_message.c,v 1.4 2005-01-09 10:10:41 obarthel Exp $
|
||||
* $Id: stdlib_termination_message.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -54,7 +54,7 @@ __print_termination_message(const char * termination_message)
|
||||
{
|
||||
termination_message_printed = TRUE;
|
||||
|
||||
if(NOT __no_standard_io)
|
||||
if(NOT __termination_message_disabled && NOT __no_standard_io)
|
||||
{
|
||||
fputs((termination_message != NULL) ? termination_message : "Abnormal program termination",stderr);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_asctime_r.c,v 1.4 2005-01-26 18:41:39 obarthel Exp $
|
||||
* $Id: time_asctime_r.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -101,14 +101,22 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
|
||||
/* Fill in the week day if it's not in proper range. */
|
||||
if(tm->tm_wday < 0 || tm->tm_wday > 6)
|
||||
{
|
||||
/* We use a peculiar algorithm rather than falling back onto
|
||||
mktime() here in order to avoid trouble with skewed results
|
||||
owing to time zone influence. */
|
||||
struct tm other_tm;
|
||||
time_t seconds;
|
||||
|
||||
other_tm = (*tm);
|
||||
|
||||
seconds = mktime(&other_tm);
|
||||
if(seconds != (time_t)-1)
|
||||
{
|
||||
__convert_time(seconds,0,&other_tm);
|
||||
|
||||
copy_tm = (*tm);
|
||||
copy_tm.tm_wday = __calculate_weekday(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
|
||||
copy_tm.tm_wday = other_tm.tm_wday;
|
||||
|
||||
tm = ©_tm;
|
||||
}
|
||||
}
|
||||
|
||||
if(0 <= tm->tm_wday && tm->tm_wday <= 6)
|
||||
b = __abbreviated_week_day_names[tm->tm_wday];
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* $Id: time_convert_datestamp.c,v 1.1 2005-01-26 09:24:38 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
#ifndef _LOCALE_HEADERS_H
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
time_t
|
||||
__convert_datestamp_to_time(const struct DateStamp * ds)
|
||||
{
|
||||
time_t result;
|
||||
|
||||
ENTER();
|
||||
|
||||
/* If possible, adjust for the local time zone. We do this because the
|
||||
AmigaOS system time is returned in local time and we want to return
|
||||
it in UTC. */
|
||||
result = UNIX_TIME_OFFSET + ds->ds_Days * (24*60*60) + ds->ds_Minute * 60 + (ds->ds_Tick / TICKS_PER_SECOND);
|
||||
if(__default_locale != NULL)
|
||||
result += 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
RETURN(result);
|
||||
return(result);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* $Id: time_convert_time.c,v 1.1 2005-01-29 18:22:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
#ifndef _LOCALE_HEADERS_H
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
BOOL
|
||||
__convert_time_to_datestamp(time_t time_value,struct DateStamp * ds)
|
||||
{
|
||||
BOOL success;
|
||||
|
||||
/* The time has to lie within the AmigaOS epoch. */
|
||||
if(time_value < UNIX_TIME_OFFSET)
|
||||
{
|
||||
success = FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Adjust the time to the AmigaOS epoch. */
|
||||
time_value -= UNIX_TIME_OFFSET;
|
||||
|
||||
/* If possible, adjust the time to match the local time zone settings. */
|
||||
if(__default_locale != NULL)
|
||||
time_value -= 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
ds->ds_Days = (time_value / (24 * 60 * 60));
|
||||
ds->ds_Minute = (time_value % (24 * 60 * 60)) / 60;
|
||||
ds->ds_Tick = (time_value % 60) * TICKS_PER_SECOND;
|
||||
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
return(success);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_converttime.c,v 1.3 2005-01-29 18:05:14 obarthel Exp $
|
||||
* $Id: time_converttime.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -43,6 +43,7 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
DECLARE_UTILITYBASE();
|
||||
struct ClockData clock_data;
|
||||
struct tm * result;
|
||||
ULONG delta;
|
||||
|
||||
ENTER();
|
||||
|
||||
@@ -61,13 +62,8 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
/* Now the local time offset will have to go. */
|
||||
seconds -= gmt_offset;
|
||||
|
||||
/* Convert the number of seconds into a more useful format. */
|
||||
Amiga2Date(seconds, &clock_data);
|
||||
|
||||
/* The 'struct clockdata' layout and contents are very similar
|
||||
* to the 'struct tm' contents. We don't have to convert much,
|
||||
* except for the 'tm.tm_yday' field below.
|
||||
*/
|
||||
tm->tm_sec = clock_data.sec;
|
||||
tm->tm_min = clock_data.min;
|
||||
tm->tm_hour = clock_data.hour;
|
||||
@@ -77,8 +73,12 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
tm->tm_wday = clock_data.wday;
|
||||
tm->tm_isdst = -1;
|
||||
|
||||
/* Now figure out how many days have passed since January 1st. */
|
||||
tm->tm_yday = __calculate_days_per_date(clock_data.year,clock_data.month,clock_data.mday) - __calculate_days_per_date(clock_data.year,1,1);
|
||||
clock_data.mday = 1;
|
||||
clock_data.month = 1;
|
||||
|
||||
delta = Date2Amiga(&clock_data);
|
||||
|
||||
tm->tm_yday = (seconds - delta) / (24 * 60 * 60);
|
||||
|
||||
result = tm;
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* $Id: time_days_per_date.c,v 1.1 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This calculates the number of days that have passed up to the
|
||||
given date. */
|
||||
int
|
||||
__calculate_days_per_date(int year,int month,int day)
|
||||
{
|
||||
int result;
|
||||
|
||||
month = month + 9;
|
||||
year = year - 1 + (month / 12);
|
||||
month = (month % 12) * 306 + 5;
|
||||
|
||||
result = (year * 365) + (year / 4) - (year / 100) + (year / 400) + (month / 10) + day - 1;
|
||||
|
||||
return(result);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_gettimeofday.c,v 1.5 2005-01-24 10:25:46 obarthel Exp $
|
||||
* $Id: time_gettimeofday.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -39,20 +39,12 @@
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
#ifndef _UNISTD_HEADERS_H
|
||||
#include "unistd_headers.h"
|
||||
#endif /* _UNISTD_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#include <proto/timer.h>
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -60,27 +52,18 @@
|
||||
int
|
||||
gettimeofday(struct timeval *tp, struct timezone *tzp)
|
||||
{
|
||||
struct Library * TimerBase = __TimerBase;
|
||||
#if defined(__amigaos4__)
|
||||
struct TimerIFace * ITimer = __ITimer;
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
ULONG seconds,microseconds;
|
||||
struct timeval tv;
|
||||
struct DateStamp ds;
|
||||
|
||||
ENTER();
|
||||
|
||||
/* Obtain the current system time. */
|
||||
GetSysTime(&tv);
|
||||
PROFILE_OFF();
|
||||
DateStamp(&ds);
|
||||
PROFILE_ON();
|
||||
|
||||
/* Convert the number of seconds so that they match the Unix epoch, which
|
||||
starts (January 1st, 1970) eight years before the AmigaOS epoch. */
|
||||
seconds = tv.tv_sec + UNIX_TIME_OFFSET;
|
||||
microseconds = tv.tv_usec;
|
||||
seconds = UNIX_TIME_OFFSET + 60 * ((ULONG)ds.ds_Minute + 24 * 60 * (ULONG)ds.ds_Days) + (ds.ds_Tick / TICKS_PER_SECOND);
|
||||
microseconds = (1000000 * (ds.ds_Tick % TICKS_PER_SECOND)) / TICKS_PER_SECOND;
|
||||
|
||||
/* If possible, adjust for the local time zone. We do this because the
|
||||
AmigaOS system time is returned in local time and we want to return
|
||||
it in UTC. */
|
||||
if(__default_locale != NULL)
|
||||
seconds += 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
@@ -100,8 +83,6 @@ gettimeofday(struct timeval *tp, struct timezone *tzp)
|
||||
else
|
||||
tzp->tz_minuteswest = 0;
|
||||
|
||||
/* The -1 means "we do not know if the time given is in
|
||||
daylight savings time". */
|
||||
tzp->tz_dsttime = -1;
|
||||
|
||||
SHOWVALUE(tzp->tz_minuteswest);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_headers.h,v 1.8 2005-01-29 18:05:14 obarthel Exp $
|
||||
* $Id: time_headers.h,v 1.5 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -94,10 +94,6 @@ extern const char * const NOCOMMON __month_names[12];
|
||||
extern char * __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size);
|
||||
extern char * __number_to_string(unsigned int number,char * string,size_t max_len,size_t min_len);
|
||||
extern struct tm * __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm);
|
||||
extern time_t __convert_datestamp_to_time(const struct DateStamp * ds);
|
||||
extern BOOL __convert_time_to_datestamp(time_t time_value,struct DateStamp * ds);
|
||||
extern int __calculate_weekday(int year,int month,int day);
|
||||
extern int __calculate_days_per_date(int year,int month,int day);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_localtime_r.c,v 1.3 2005-01-25 11:21:00 obarthel Exp $
|
||||
* $Id: time_localtime_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -67,8 +67,8 @@ localtime_r(const time_t *t,struct tm * tm_ptr)
|
||||
}
|
||||
#endif /* CHECK_FOR_NULL_POINTERS */
|
||||
|
||||
/* The time parameter given represents UTC and
|
||||
* must be converted to local time before we proceed.
|
||||
/* The time parameter given represents local time and
|
||||
* must be converted to UTC before we proceed.
|
||||
*/
|
||||
if(__default_locale != NULL)
|
||||
gmt_offset = 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_mktime.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $
|
||||
* $Id: time_mktime.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -41,10 +41,6 @@
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
#ifndef _LOCALE_HEADERS_H
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
time_t
|
||||
@@ -104,12 +100,14 @@ mktime(struct tm *tm)
|
||||
int year;
|
||||
|
||||
/* We need to have the full year number for the
|
||||
leap year calculation below. */
|
||||
* leap year calculation below.
|
||||
*/
|
||||
year = tm->tm_year + 1900;
|
||||
|
||||
/* Now for the famous leap year calculation rules... We
|
||||
need to find out if the number of days in the month
|
||||
of February are appropriate for the data given. */
|
||||
* need to find out if the number of days in the month
|
||||
* of February are appropriate for the data given.
|
||||
*/
|
||||
if((year % 4) != 0)
|
||||
max_month_days = 28;
|
||||
else if ((year % 400) == 0)
|
||||
@@ -179,7 +177,8 @@ mktime(struct tm *tm)
|
||||
seconds = Date2Amiga(&clock_data);
|
||||
|
||||
/* The AmigaOS "epoch" starts with January 1st, 1978, which was
|
||||
a Sunday. */
|
||||
* a Sunday.
|
||||
*/
|
||||
tm->tm_wday = (seconds / (24 * 60 * 60)) % 7;
|
||||
|
||||
clock_data.mday = 1;
|
||||
@@ -189,13 +188,6 @@ mktime(struct tm *tm)
|
||||
|
||||
tm->tm_yday = (seconds - delta) / (24 * 60 * 60);
|
||||
|
||||
/* The data in 'struct tm *tm' was given in local time. We need
|
||||
to convert the result into UTC. */
|
||||
if(__default_locale != NULL)
|
||||
seconds += 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
/* Finally, adjust for the difference between the Unix and the
|
||||
AmigaOS epochs, which differ by 8 years. */
|
||||
result = seconds + UNIX_TIME_OFFSET;
|
||||
|
||||
error = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_strftime.c,v 1.5 2005-01-29 18:05:14 obarthel Exp $
|
||||
* $Id: time_strftime.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -103,26 +103,36 @@ store_string_via_hook(const char * string,int len,struct Hook * hook)
|
||||
/****************************************************************************/
|
||||
|
||||
static void
|
||||
format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook * hook)
|
||||
{
|
||||
struct tm other_tm;
|
||||
struct tm copy_tm;
|
||||
time_t other_time_value = 0; /* ZZZ compiler claims that this assignment is unnecessary. */
|
||||
char buffer[40];
|
||||
const char * str;
|
||||
char c;
|
||||
int i;
|
||||
|
||||
assert( format != NULL && tm != NULL && hook != NULL);
|
||||
|
||||
/* Fill in the week day if it's not in proper range. */
|
||||
if(tm->tm_wday < 0 || tm->tm_wday > 6)
|
||||
{
|
||||
/* We use a peculiar algorithm rather than falling back onto
|
||||
mktime() here in order to avoid trouble with skewed results
|
||||
owing to time zone influence. */
|
||||
time_t seconds;
|
||||
|
||||
other_tm = (*tm);
|
||||
|
||||
seconds = mktime(&other_tm);
|
||||
if(seconds != (time_t)-1)
|
||||
{
|
||||
__convert_time(seconds,0,&other_tm);
|
||||
|
||||
copy_tm = (*tm);
|
||||
copy_tm.tm_wday = __calculate_weekday(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
|
||||
copy_tm.tm_wday = other_tm.tm_wday;
|
||||
|
||||
tm = ©_tm;
|
||||
}
|
||||
}
|
||||
|
||||
while((c = (*format++)) != '\0')
|
||||
{
|
||||
@@ -197,7 +207,55 @@ format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
/* Locale specific date and time ("%a %b %d %H:%M:%S %Y"). */
|
||||
case 'c':
|
||||
|
||||
format_date("%a %b %d %H:%M:%S %Y",tm,hook);
|
||||
assert( 0 <= tm->tm_wday && tm->tm_wday <= 6 );
|
||||
|
||||
if(0 <= tm->tm_wday && tm->tm_wday <= 6)
|
||||
str = __abbreviated_week_day_names[tm->tm_wday];
|
||||
else
|
||||
str = "-";
|
||||
|
||||
store_string_via_hook(str,-1,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_mon && tm->tm_mon <= 11 );
|
||||
|
||||
if(0 <= tm->tm_mon && tm->tm_mon <= 11)
|
||||
str = __abbreviated_month_names[tm->tm_mon];
|
||||
else
|
||||
str = "-";
|
||||
|
||||
store_string_via_hook(str,-1,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 1 <= tm->tm_mday && tm->tm_mday <= 31 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_mday,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_hour && tm->tm_hour <= 23 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_hour,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(":",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_min && tm->tm_min <= 59 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_min,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(":",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_sec && tm->tm_sec <= 59 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_sec,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_year );
|
||||
|
||||
__number_to_string((unsigned int)1900 + tm->tm_year,buffer,sizeof(buffer),0);
|
||||
store_string_via_hook(buffer,-1,hook);
|
||||
|
||||
break;
|
||||
|
||||
/* Day of the month ("01"-"31"). */
|
||||
@@ -231,7 +289,13 @@ format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
/* Day of the year ("001"-"366"). */
|
||||
case 'j':
|
||||
|
||||
__number_to_string(1 + __calculate_days_per_date(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday) - __calculate_days_per_date(tm->tm_year+1900,1,1),buffer,sizeof(buffer),3);
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mday = 1;
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
|
||||
__number_to_string((unsigned int)(other_time_value - time_value) / (24 * 60 * 60) + 1,buffer,sizeof(buffer),3);
|
||||
store_string_via_hook(buffer,-1,hook);
|
||||
break;
|
||||
|
||||
@@ -275,7 +339,32 @@ format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
*/
|
||||
case 'U':
|
||||
|
||||
__number_to_string((tm->tm_yday + 7 - tm->tm_wday) / 7,buffer,sizeof(buffer),2);
|
||||
/* Go back to January and find the first Sunday. */
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
for(i = 0 ; i < 7 ; i++)
|
||||
{
|
||||
other_tm.tm_mday = i+1;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
if(other_tm.tm_wday == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Store the number of weeks difference between
|
||||
* the given day and the first Sunday.
|
||||
*/
|
||||
if(time_value < other_time_value)
|
||||
{
|
||||
/* This must be week zero. */
|
||||
__number_to_string((unsigned int)0,buffer,sizeof(buffer),2);
|
||||
}
|
||||
else
|
||||
{
|
||||
__number_to_string((unsigned int)(time_value - other_time_value) / (7 * 24 * 60 * 60) + 1,buffer,sizeof(buffer),2);
|
||||
}
|
||||
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
break;
|
||||
|
||||
@@ -293,20 +382,90 @@ format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
*/
|
||||
case 'W':
|
||||
|
||||
__number_to_string((tm->tm_yday + 7 - ((tm->tm_wday + 6) % 7)) / 7,buffer,sizeof(buffer),2);
|
||||
/* Go back to January and find the first Monday. */
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
for(i = 0 ; i < 7 ; i++)
|
||||
{
|
||||
other_tm.tm_mday = i+1;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
if(other_tm.tm_wday == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Store the number of weeks difference between
|
||||
* the given day and the first Monday.
|
||||
*/
|
||||
if(time_value < other_time_value)
|
||||
{
|
||||
/* This must be week zero. */
|
||||
__number_to_string((unsigned int)0,buffer,sizeof(buffer),2);
|
||||
}
|
||||
else
|
||||
{
|
||||
__number_to_string((unsigned int)(time_value - other_time_value) / (7 * 24 * 60 * 60) + 1,buffer,sizeof(buffer),2);
|
||||
}
|
||||
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
break;
|
||||
|
||||
/* Locale-specific date ("%a %b %d, %Y"). */
|
||||
case 'x':
|
||||
|
||||
format_date("%a %b %d, %Y",tm,hook);
|
||||
assert( 0 <= tm->tm_wday && tm->tm_wday <= 6 );
|
||||
|
||||
if(0 <= tm->tm_wday && tm->tm_wday <= 6)
|
||||
str = __abbreviated_week_day_names[tm->tm_wday];
|
||||
else
|
||||
str = "-";
|
||||
|
||||
store_string_via_hook(str,-1,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_mon && tm->tm_mon <= 11 );
|
||||
|
||||
if(0 <= tm->tm_mon && tm->tm_mon <= 11)
|
||||
str = __abbreviated_month_names[tm->tm_mon];
|
||||
else
|
||||
str = "-";
|
||||
|
||||
store_string_via_hook(str,-1,hook);
|
||||
store_string_via_hook(" ",1,hook);
|
||||
|
||||
assert( 1 <= tm->tm_mday && tm->tm_mday <= 31 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_mday,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(", ",2,hook);
|
||||
|
||||
assert( 0 <= tm->tm_year );
|
||||
|
||||
__number_to_string((unsigned int)1900 + tm->tm_year,buffer,sizeof(buffer),0);
|
||||
store_string_via_hook(buffer,-1,hook);
|
||||
|
||||
break;
|
||||
|
||||
/* Locale-specific time ("%H:%M:%S"). */
|
||||
case 'X':
|
||||
|
||||
format_date("%H:%M:%S",tm,hook);
|
||||
assert( 0 <= tm->tm_hour && tm->tm_hour <= 23 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_hour,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(":",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_min && tm->tm_min <= 59 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_min,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
store_string_via_hook(":",1,hook);
|
||||
|
||||
assert( 0 <= tm->tm_sec && tm->tm_sec <= 59 );
|
||||
|
||||
__number_to_string((unsigned int)tm->tm_sec,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
break;
|
||||
|
||||
/* Year without century ("00"-"99"). */
|
||||
@@ -377,6 +536,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
struct format_hook_data data;
|
||||
struct Hook hook;
|
||||
size_t result = 0;
|
||||
struct tm tm_copy;
|
||||
time_t time_value;
|
||||
|
||||
ENTER();
|
||||
|
||||
@@ -404,6 +565,15 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
|
||||
if(maxsize > 0)
|
||||
{
|
||||
tm_copy = (*tm);
|
||||
|
||||
time_value = mktime(&tm_copy);
|
||||
if(time_value == (time_t)-1)
|
||||
{
|
||||
SHOWMSG("invalid time");
|
||||
goto out;
|
||||
}
|
||||
|
||||
data.buffer = s;
|
||||
data.max_size = maxsize-1;
|
||||
|
||||
@@ -426,25 +596,12 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
if(__locale_table[LC_TIME] != NULL)
|
||||
{
|
||||
struct DateStamp ds;
|
||||
struct tm tm_copy;
|
||||
time_t time_value;
|
||||
|
||||
tm_copy = (*tm);
|
||||
time_value -= UNIX_TIME_OFFSET;
|
||||
|
||||
time_value = mktime(&tm_copy);
|
||||
if(time_value == (time_t)-1)
|
||||
{
|
||||
SHOWMSG("invalid time");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Convert the number of seconds into a DateStamp, as to be
|
||||
submitted to the FormatDate() function below. */
|
||||
if(CANNOT __convert_time_to_datestamp(time_value,&ds))
|
||||
{
|
||||
SHOWMSG("time conversion to datestamp failed");
|
||||
goto out;
|
||||
}
|
||||
ds.ds_Days = time_value / (24 * 60 * 60);
|
||||
ds.ds_Minute = (time_value % (24 * 60 * 60)) / 60;
|
||||
ds.ds_Tick = (time_value % 60) * TICKS_PER_SECOND;
|
||||
|
||||
assert( LocaleBase != NULL );
|
||||
|
||||
@@ -452,7 +609,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
}
|
||||
else
|
||||
{
|
||||
format_date(format,tm,&hook);
|
||||
format_date(format,tm,time_value,&hook);
|
||||
}
|
||||
|
||||
(*data.buffer) = '\0';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_time.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $
|
||||
* $Id: time_time.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -45,16 +45,22 @@ time_t
|
||||
time(time_t * tptr)
|
||||
{
|
||||
struct DateStamp ds;
|
||||
ULONG seconds;
|
||||
time_t result;
|
||||
|
||||
PROFILE_OFF();
|
||||
DateStamp(&ds);
|
||||
PROFILE_ON();
|
||||
|
||||
/* This converts the DateStamp contents into the number of
|
||||
seconds elapsed since January 1st 1970. The time is
|
||||
given as relative to UTC, not local time. */
|
||||
result = __convert_datestamp_to_time(&ds);
|
||||
seconds = 60 * ((ULONG)ds.ds_Minute + 24 * 60 * (ULONG)ds.ds_Days) + (ds.ds_Tick / TICKS_PER_SECOND);
|
||||
|
||||
/* time() should try to return the current time in UTC form. Thus,
|
||||
* we have to take the local time zone into account.
|
||||
*/
|
||||
if(__default_locale != NULL)
|
||||
result = UNIX_TIME_OFFSET + seconds + 60 * __default_locale->loc_GMTOffset;
|
||||
else
|
||||
result = UNIX_TIME_OFFSET + seconds;
|
||||
|
||||
if(tptr != NULL)
|
||||
(*tptr) = result;
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* $Id: time_weekday.c,v 1.1 2005-01-26 18:41:39 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
__calculate_weekday(int year,int month,int day)
|
||||
{
|
||||
/* This algorithm comes from <http://klausler.com/new-dayofweek.html>. */
|
||||
static const char month_skew[12] =
|
||||
{
|
||||
0,3,3,6,
|
||||
1,4,6,2,
|
||||
5,0,3,5
|
||||
};
|
||||
|
||||
int sum;
|
||||
|
||||
/* Subtract 1900 from the year. */
|
||||
sum = year - 1900;
|
||||
|
||||
/* To that number, add one fourth of itself, discarding
|
||||
any remainder. This sum is the year's skew value. */
|
||||
sum += sum / 4;
|
||||
|
||||
/* If the month in question is January or February in a leap
|
||||
year, subtract 1 from the sum. */
|
||||
if(month == 1 || month == 2)
|
||||
{
|
||||
int leap_year_adjust;
|
||||
|
||||
/* Figure out if the year is a leap year. */
|
||||
if((year % 4) != 0)
|
||||
leap_year_adjust = 0;
|
||||
else if ((year % 400) == 0)
|
||||
leap_year_adjust = 1;
|
||||
else if ((year % 100) == 0)
|
||||
leap_year_adjust = 0;
|
||||
else
|
||||
leap_year_adjust = 1;
|
||||
|
||||
sum -= leap_year_adjust;
|
||||
}
|
||||
|
||||
/* Add the month's skew value from the table. */
|
||||
sum += day + month_skew[month-1];
|
||||
|
||||
/* The sum is the number of days after Sunday on which the date falls. */
|
||||
return(sum % 7);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_chown.c,v 1.4 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: unistd_chown.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -106,19 +106,19 @@ chown(const char * path_name, uid_t owner, gid_t group)
|
||||
|
||||
D(("changing owner of '%s'",path_name));
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
PROFILE_OFF();
|
||||
status = SetOwner((STRPTR)path_name,(LONG)((((ULONG)owner) << 16) | group));
|
||||
PROFILE_ON();
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(((struct Library *)DOSBase)->lib_Version >= 39)
|
||||
{
|
||||
PROFILE_OFF();
|
||||
status = SetOwner((STRPTR)path_name,(LONG)((((ULONG)owner) << 16) | group));
|
||||
PROFILE_ON();
|
||||
|
||||
if(status == DOSFALSE)
|
||||
{
|
||||
__translate_io_error_to_errno(IoErr(),&errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,9 +148,6 @@ chown(const char * path_name, uid_t owner, gid_t group)
|
||||
PROFILE_OFF();
|
||||
status = DoPkt(dvp->dvp_Port,ACTION_SET_OWNER,dvp->dvp_Lock,MKBADDR(new_name),(LONG)((((ULONG)owner) << 16) | group),0,0);
|
||||
PROFILE_ON();
|
||||
}
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
if(status == DOSFALSE)
|
||||
{
|
||||
@@ -159,6 +156,7 @@ chown(const char * path_name, uid_t owner, gid_t group)
|
||||
}
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "unix.lib 1.187"
|
||||
#define VSTRING "unix.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: unix.lib 1.187 (29.1.2005)"
|
||||
#define REVISION 185
|
||||
#define DATE "2.1.2005"
|
||||
#define VERS "unix.lib 1.185"
|
||||
#define VSTRING "unix.lib 1.185 (2.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: unix.lib 1.185 (2.1.2005)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
187
|
||||
185
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: utime_utime.c,v 1.5 2005-01-29 18:05:14 obarthel Exp $
|
||||
* $Id: utime_utime.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -45,10 +45,6 @@
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
@@ -80,20 +76,29 @@ utime(const char * path_name,const struct utimbuf * times)
|
||||
if(__check_abort_enabled)
|
||||
__check_abort();
|
||||
|
||||
/* If a modification time is provided, convert it into the local
|
||||
DateStamp format, as used by the SetFileDate() function. */
|
||||
if(times != NULL)
|
||||
{
|
||||
if(CANNOT __convert_time_to_datestamp(times->modtime,&ds))
|
||||
time_t seconds;
|
||||
|
||||
seconds = times->modtime;
|
||||
|
||||
if(seconds < UNIX_TIME_OFFSET)
|
||||
{
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
seconds -= UNIX_TIME_OFFSET;
|
||||
|
||||
if(__default_locale != NULL)
|
||||
seconds -= 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
ds.ds_Days = (seconds / (24 * 60 * 60));
|
||||
ds.ds_Minute = (seconds % (24 * 60 * 60)) / 60;
|
||||
ds.ds_Tick = (seconds % 60) * TICKS_PER_SECOND;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No special modification time provided; use the current
|
||||
time instead. */
|
||||
DateStamp(&ds);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user