diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 6130b5a..91aca8f 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.14 2004-11-13 12:55:39 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.15 2004-11-14 11:06:27 obarthel Exp $ # # :ts=8 # @@ -286,6 +286,10 @@ C_LIB = \ stdlib_modsi3.o \ stdlib_mulsi3.o \ stdlib_never_free.o \ + stdlib_osliberror.o \ + stdlib_oslibversion.o \ + stdlib_priority.o \ + stdlib_process_name.o \ stdlib_putenv.o \ stdlib_qsort.o \ stdlib_rand.o \ @@ -318,6 +322,7 @@ C_LIB = \ stdlib_umodsi3.o \ stdlib_unsetenv.o \ stdlib_wildcard_expand.o \ + stdlib_stdio_window_spec.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ string_bcmp.o \ @@ -338,6 +343,8 @@ C_LIB = \ string_strcspn.o \ string_strdup.o \ string_strerror.o \ + string_strlcat.o \ + string_strlcpy.o \ string_strlen.o \ string_strncat.o \ string_strncmp.o \ @@ -677,6 +684,7 @@ AMIGA_LIB = \ amiga_newlist.o \ amiga_rangerand.o \ amiga_remtof.o \ + amiga_rexxvars.o \ amiga_setsuperattrs.o \ amiga_timedelay.o \ amiga_waitbeam.o @@ -686,7 +694,7 @@ AMIGA_LIB = \ LIBS_68K := $(LIBC_OBJS)/libc.a $(LIBSTACK_OBJS)/libstack.a $(LIBUNIX_OBJS)/libunix.a \ $(LIBNET_OBJS)/libnet.a $(LIBDEBUG_OBJS)/libdebug.a $(LIBAMIGA_OBJS)/libamiga.a \ $(LIBM_OBJS)/libm.a - LIBS_020 := $(LIBM881_OBJS)/libm881.a $(LIBS_68K) +LIBS_020 := $(LIBM881_OBJS)/libm881.a $(LIBS_68K) ############################################################################## @@ -985,28 +993,3 @@ mainb.o : stdlib_main.c mainnb.o : stdlib_main.c $(CC) -o mainnb.o -c $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(INCLUDES) -m68000 stdlib_main.c - -############################################################################## - -#test: test.o ncrt0.o libc.a libunix.a libm.a libdebug.a libamiga.a -# $(CC) -Wl,--verbose $(CFLAGS) -DIEEE_FLOATING_POINT_SUPPORT \ -# -o $@ -nostdlib ncrt0.o test.o -L. -lm -lunix -ldebug -lc -lamiga - -#test: test.o ncrt0.o nbcrt0.o nrcrt0.o libc.a libunix.a libm.a libdebug.a libamiga.a -# $(CC) -resident -Wl,--verbose $(CFLAGS) -DIEEE_FLOATING_POINT_SUPPORT -fbaserel32 -DSMALL_DATA \ -# -o $@ -nostdlib nbcrt0.o test.o -L. -lm -lunix -ldebug -lc -lamiga - -test : test.c - gcc -o test test.c -D__MEM_DEBUG -DFLOATING_POINT_SUPPORT -Llib -lunix -lm - -#test: test.o ncrt0.o nbcrt0.o nrcrt0.o libc.a libunix.a libm.a libdebug.a libamiga.a -# $(CC) -resident -Wl,--verbose $(CFLAGS) -DIEEE_FLOATING_POINT_SUPPORT -fbaserel -DSMALL_DATA \ -# -o $@ -nostdlib nrcrt0.o test.o -L. -lm -lunix -ldebug -lc -lamiga - -############################################################################## - -mkid: - mkid -v #?.(c|h|asm|i) include/#?.(c|h|asm|i) include/sys/#?.(c|h|asm|i) - -update: - mkid -v -u diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index 5ff3155..93d713e 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.13 2004-11-13 12:55:39 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.14 2004-11-14 11:06:27 obarthel Exp $ # # :ts=8 # @@ -103,7 +103,7 @@ WARNINGS = \ -Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion INCLUDES = -Iinclude -I. -I$(SDK_INCLUDE) -OPTIONS = -DNDEBUG -DUSE_64_BIT_INTS -fno-builtin -D__USE_INLINE__ -Wa,-mregnames +OPTIONS = -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames OPTIMIZE = -O -fomit-frame-pointer -funroll-loops #DEBUG = -g @@ -284,6 +284,10 @@ C_LIB = \ stdlib_modsi3.o \ stdlib_mulsi3.o \ stdlib_never_free.o \ + stdlib_osliberror.o \ + stdlib_oslibversion.o \ + stdlib_priority.o \ + stdlib_process_name.o \ stdlib_putenv.o \ stdlib_qsort.o \ stdlib_rand.o \ @@ -316,6 +320,7 @@ C_LIB = \ stdlib_umodsi3.o \ stdlib_unsetenv.o \ stdlib_wildcard_expand.o \ + stdlib_stdio_window_spec.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ string_bcmp.o \ @@ -336,6 +341,8 @@ C_LIB = \ string_strcspn.o \ string_strdup.o \ string_strerror.o \ + string_strlcat.o \ + string_strlcpy.o \ string_strlen.o \ string_strncat.o \ string_strncmp.o \ @@ -638,6 +645,7 @@ AMIGA_LIB = \ amiga_newlist.o \ amiga_rangerand.o \ amiga_remtof.o \ + amiga_rexxvars.o \ amiga_setsuperattrs.o \ amiga_timedelay.o \ amiga_waitbeam.o diff --git a/library/amiga_rexxvars.c b/library/amiga_rexxvars.c new file mode 100644 index 0000000..550f537 --- /dev/null +++ b/library/amiga_rexxvars.c @@ -0,0 +1,193 @@ +/* + * $Id: amiga_rexxvars.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +/* We don't want to pull in */ +#define CLIB_ALIB_PROTOS_H + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +#include +#include + +/****************************************************************************/ + +#define __NOLIBBASE__ +#include + +/****************************************************************************/ + +STATIC struct Library * RexxSysBase; + +/****************************************************************************/ + +#if defined(__amigaos4__) +STATIC struct RexxSysIFace * IRexxSys; +#endif /* __amigaos4__ */ + +/****************************************************************************/ + +CLIB_CONSTRUCTOR(__rexxvars_init) +{ + ENTER(); + + RexxSysBase = OpenLibrary(RXSNAME,0); + + #if defined(__amigaos4__) + { + if(RexxSysBase != NULL) + { + IRexxSys = (struct RexxSysIFace *)GetInterface(RexxSysBase, "main", 1, 0); + if(IRexxSys == NULL) + { + CloseLibrary(RexxSysBase); + RexxSysBase = NULL; + } + } + } + #endif /* __amigaos4__ */ + + CONSTRUCTOR_SUCCEED(); +} + +/****************************************************************************/ + +CLIB_DESTRUCTOR(__rexxvars_exit) +{ + ENTER(); + + #if defined(__amigaos4__) + { + if(IRexxSys != NULL) + DropInterface((struct Interface *)IRexxSys); + + IRexxSys = NULL; + } + #endif /* __amigaos4__ */ + + if(RexxSysBase != NULL) + { + CloseLibrary(RexxSysBase); + RexxSysBase = NULL; + } + + LEAVE(); +} + +/****************************************************************************/ + +/* This is modeled after the original assembly language code. Except for the + fact that we compare the library base against a local, static variable + rather then opening the library for each check. */ +BOOL +CheckRexxMsg(struct RexxMsg *message) +{ + BOOL result = FALSE; + + if(RexxSysBase == NULL) + goto out; + + if(message->rm_LibBase != RexxSysBase) + goto out; + + if(message->rm_TaskBlock == NULL) + goto out; + + if(NOT IsRexxMsg(message)) + goto out; + + result = TRUE; + + out: + + return(result); +} + +/****************************************************************************/ + +/* The following function works in about like the original, except that it's + not reentrant, does not fill in a pointer to the variable itself and + requires rexxsyslib.library V45. */ +LONG +GetRexxVar(struct RexxMsg *message,STRPTR variable_name,STRPTR *buffer_pointer) +{ + STATIC TEXT buffer[256]; + LONG result; + + /* The following uses a function which was added to rexxsyslib.library V45. + We therefore have a minimum library version requirement. */ + if(RexxSysBase == NULL || RexxSysBase->lib_Version < 45 || NOT IsRexxMsg(message)) + { + result = ERR10_010; /* invalid message packet */ + goto out; + } + + /* The 256 character limit isn't good. This should be done differently. */ + result = GetRexxVarFromMsg(variable_name,buffer,message); + if(result != 0) + goto out; + + (*buffer_pointer) = buffer; + + out: + + return(result); +} + +/****************************************************************************/ + +/* The following function works in about like the original, except that it + ignores the length parameter (the value needs to be a NUL-terminated string) + and requires rexxsyslib.library V45. */ +LONG +SetRexxVar(struct RexxMsg *message,STRPTR variable_name,STRPTR value,ULONG length) +{ + LONG result; + + /* The following uses a function which was added to rexxsyslib.library V45. + We therefore have a minimum library version requirement. */ + if(RexxSysBase == NULL || RexxSysBase->lib_Version < 45 || NOT IsRexxMsg(message)) + { + result = ERR10_010; /* invalid message packet */ + goto out; + } + + result = SetRexxVarFromMsg(variable_name,value,message); + + out: + + return(result); +} diff --git a/library/changes b/library/changes index c9d0e81..9aee935 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,32 @@ +- Added stubs for the Rexx Variables Interface code that used to + be part of amiga.lib. While comparable functionality is available + in rexxsyslib.library V45, the new stubs might be helpful during + porting. Care must be taken since these functions don't work + exactly like the originals. + +- Integrated strlcpy() and strlcat() which are intended to be safer + replacements for strncpy() and strncat(). + +- The program's task priority is now configurable through an external + variable '__priority'. + +- The process name to be used when detaching can be configured through + the new '__process_name' variable. + +- The minimum required operating system version can be configured + through the new '__minimum_os_lib_version' variable; a matching + error message can be provided through the new '__minimum_os_lib_error' + variable. + +- The default console window specification can be overriden through + the new '__stdio_window_specification' variable. + +- The socket initialization code did not set up a reference to the + 'h_errno' variable correctly. This had the effect of making name + and address resolution errors trash the 'errno' variable instead + and leaving 'h_errno' always set to 0. Fixed. + + c.lib 1.183 (13.11.2004) - Cleaned up the OS4 build makefile, losing redundant libraries, diff --git a/library/debug.h b/library/debug.h index 0177e78..b267008 100644 --- a/library/debug.h +++ b/library/debug.h @@ -1,5 +1,5 @@ /* - * $Id: debug.h,v 1.1.1.1 2004-07-26 16:30:26 obarthel Exp $ + * $Id: debug.h,v 1.2 2004-11-14 11:06:27 obarthel Exp $ * * :ts=8 * @@ -57,9 +57,17 @@ /****************************************************************************/ +#ifndef _STDLIB_H +#include +#endif /* _STDLIB_H */ + +#ifndef _DOS_H +#include +#endif /* _DOS_H */ + +/****************************************************************************/ + extern void kprintf(const char *format,...); -extern void abort(void); -extern char * __program_name; /****************************************************************************/ diff --git a/library/include/dos.h b/library/include/dos.h index 35197c8..20d9b0b 100644 --- a/library/include/dos.h +++ b/library/include/dos.h @@ -1,5 +1,5 @@ /* - * $Id: dos.h,v 1.3 2004-08-25 15:27:28 obarthel Exp $ + * $Id: dos.h,v 1.4 2004-11-14 11:06:28 obarthel Exp $ * * :ts=4 * @@ -164,6 +164,28 @@ extern ULONG __free_memory_threshold; * them initialized to certain well-defined values to get the desired effect. */ +/* + * The minimum required operating system version number is 37, which + * corresponds to Workbench/Kickstart 2.04. You may request a higher + * version number by defining the following variable; if you do so, + * please provide a fitting error message, too. Note that you cannot + * request a minimum version number lower than 37. + */ +extern int __minimum_os_lib_version; +extern char * __minimum_os_lib_error; + +/* + * If your program is launched from Workbench it will not necessarily + * have a window to send console output to and from which console + * input can be read. The startup code attempts to set up such a console + * window for you, but it uses defaults for the window specification. + * These defaults can be overridden by your program if you define a + * variable to point to the specification string. Note that if you + * request a specific window specification, this will also override + * any tool window definition stored in the program's icon. + */ +extern char * __stdio_window_specification; + /* * If set to TRUE, your program's process->pr_WindowPtr will be set to -1 * when it starts. The process->pr_WindowPtr will be automatically restored @@ -192,6 +214,20 @@ extern BOOL __detach; */ extern BOOL (* __check_detach)(void); +/* + * If this pointer is not NULL, it refers the name that will be given to + * the process which is created when the program detaches. The default + * is to reuse the program name instead. + */ +extern char * __process_name; + +/* + * This variable controls the task priority of the program, when running. + * It must be in the range -128..127 to be useful. By default, the task + * priority will not be changed. + */ +extern int __priority; + /* * This variable can be set up to contain the minimum stack size the program * should be launched with. If the startup code finds that there is not enough diff --git a/library/include/string.h b/library/include/string.h index 2c0c5b3..2ce906e 100644 --- a/library/include/string.h +++ b/library/include/string.h @@ -1,5 +1,5 @@ /* - * $Id: string.h,v 1.3 2004-08-07 09:15:33 obarthel Exp $ + * $Id: string.h,v 1.4 2004-11-14 11:06:29 obarthel Exp $ * * :ts=4 * @@ -122,6 +122,11 @@ extern int bcmp(const void *a,const void *b,size_t len); /****************************************************************************/ +extern size_t strlcpy(char *dst, const char *src, size_t siz); +extern size_t strlcat(char *dst, const char *src, size_t siz); + +/****************************************************************************/ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/library/signal_headers.h b/library/signal_headers.h index c1478fb..8563764 100644 --- a/library/signal_headers.h +++ b/library/signal_headers.h @@ -1,5 +1,5 @@ /* - * $Id: signal_headers.h,v 1.1.1.1 2004-07-26 16:31:05 obarthel Exp $ + * $Id: signal_headers.h,v 1.2 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -68,20 +68,20 @@ typedef void (*signal_handler_t)(int sig); /****************************************************************************/ -extern signal_handler_t __signal_handler_table[NUM_SIGNALS]; +extern signal_handler_t NOCOMMON __signal_handler_table[NUM_SIGNALS]; /****************************************************************************/ -extern int __signals_blocked; +extern int NOCOMMON __signals_blocked; /****************************************************************************/ -extern BOOL __termination_message_printed; -extern BOOL __termination_message_disabled; +extern BOOL NOCOMMON __termination_message_printed; +extern BOOL NOCOMMON __termination_message_disabled; /****************************************************************************/ -extern const char __abnormal_program_termination[]; +extern const char NOCOMMON __abnormal_program_termination[]; /****************************************************************************/ diff --git a/library/smakefile b/library/smakefile index 6fe5667..174f0fe 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.10 2004-09-29 14:17:44 obarthel Exp $ +# $Id: smakefile,v 1.11 2004-11-14 11:06:27 obarthel Exp $ # # :ts=8 # @@ -88,6 +88,7 @@ AMIGA_OBJ = \ amiga_newlist.o \ amiga_rangerand.o \ amiga_remtof.o \ + amiga_rexxvars.o \ amiga_setsuperattrs.o \ amiga_timedelay.o \ amiga_waitbeam.o \ @@ -394,6 +395,10 @@ STDLIB_OBJ = \ stdlib_mkstemp.o \ stdlib_mktemp.o \ stdlib_never_free.o \ + stdlib_osliberror.o \ + stdlib_oslibversion.o \ + stdlib_priority.o \ + stdlib_process_name.o \ stdlib_putenv.o \ stdlib_qsort.o \ stdlib_rand.o \ @@ -419,7 +424,8 @@ STDLIB_OBJ = \ stdlib_swapstack.o \ stdlib_system.o \ stdlib_unsetenv.o \ - stdlib_wildcard_expand.o + stdlib_wildcard_expand.o \ + stdlib_stdio_window_spec.o STRING_OBJ = \ string_bcmp.o \ @@ -440,6 +446,8 @@ STRING_OBJ = \ string_strcspn.o \ string_strdup.o \ string_strerror.o \ + string_strlcat.o \ + string_strlcpy.o \ string_strlen.o \ string_strncat.o \ string_strncmp.o \ diff --git a/library/socket_data.c b/library/socket_data.c index 3ce2160..6866e2d 100644 --- a/library/socket_data.c +++ b/library/socket_data.c @@ -1,5 +1,5 @@ /* - * $Id: socket_data.c,v 1.2 2004-07-28 15:50:45 obarthel Exp $ + * $Id: socket_data.c,v 1.3 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -46,9 +46,7 @@ struct Library * __SocketBase; /****************************************************************************/ #if defined(__amigaos4__) - struct SocketIFace *__ISocket; - #endif /* __amigaos4__ */ /****************************************************************************/ diff --git a/library/socket_headers.h b/library/socket_headers.h index ba6c58f..2cbccda 100644 --- a/library/socket_headers.h +++ b/library/socket_headers.h @@ -1,5 +1,5 @@ /* - * $Id: socket_headers.h,v 1.2 2004-07-28 15:50:45 obarthel Exp $ + * $Id: socket_headers.h,v 1.3 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -48,19 +48,19 @@ /****************************************************************************/ -extern struct Library * __SocketBase; +extern struct Library * NOCOMMON __SocketBase; /****************************************************************************/ #if defined(__amigaos4__) -extern struct SocketIFace *__ISocket; +extern struct SocketIFace * NOCOMMON __ISocket; #endif /* __amigaos4__ */ /****************************************************************************/ -extern int h_errno; +extern int NOCOMMON h_errno; /****************************************************************************/ diff --git a/library/socket_init_exit.c b/library/socket_init_exit.c index 6c43552..2a389a4 100644 --- a/library/socket_init_exit.c +++ b/library/socket_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: socket_init_exit.c,v 1.4 2004-09-29 17:03:57 obarthel Exp $ + * $Id: socket_init_exit.c,v 1.5 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -39,16 +39,16 @@ #include "socket_headers.h" #endif /* _SOCKET_HEADERS_H */ +#ifndef _SIGNAL_HEADERS_H +#include "signal_headers.h" +#endif /* _SIGNAL_HEADERS_H */ + /****************************************************************************/ #include "stdlib_protos.h" /****************************************************************************/ -extern BOOL __detach; - -/****************************************************************************/ - /* Code value. */ #define SBTB_CODE 1 #define SBTS_CODE 0x3FFF @@ -78,16 +78,6 @@ struct DaemonMessage /****************************************************************************/ -extern BOOL __termination_message_disabled; -extern char * __program_name; -extern BOOL __is_daemon; - -/****************************************************************************/ - -extern void __socket_hook_entry(struct Hook * hook,struct fd * fd,struct file_hook_message * message); - -/****************************************************************************/ - CLIB_DESTRUCTOR(__socket_exit) { ENTER(); @@ -192,7 +182,7 @@ __socket_init(void) /* Wire the library's h_errno variable to our local h_errno. */ tags[3].ti_Tag = SBTM_SETVAL(SBTC_HERRNOLONGPTR); - tags[3].ti_Data = (ULONG)&errno; + tags[3].ti_Data = (ULONG)&h_errno; tags[4].ti_Tag = TAG_END; diff --git a/library/stat_headers.h b/library/stat_headers.h index 09a09be..4e63aab 100644 --- a/library/stat_headers.h +++ b/library/stat_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stat_headers.h,v 1.1.1.1 2004-07-26 16:31:22 obarthel Exp $ + * $Id: stat_headers.h,v 1.2 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -42,7 +42,7 @@ /****************************************************************************/ -extern mode_t __current_umask; +extern mode_t NOCOMMON __current_umask; /****************************************************************************/ diff --git a/library/stdio_headers.h b/library/stdio_headers.h index 756c536..f39120e 100644 --- a/library/stdio_headers.h +++ b/library/stdio_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stdio_headers.h,v 1.2 2004-08-07 09:15:32 obarthel Exp $ + * $Id: stdio_headers.h,v 1.3 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -347,22 +347,22 @@ struct file_hook_message /****************************************************************************/ /* The file handle table. */ -extern struct iob ** __iob; -extern int __num_iob; +extern struct iob ** NOCOMMON __iob; +extern int NOCOMMON __num_iob; /****************************************************************************/ /* The file descriptor table. */ -extern struct fd ** __fd; -extern int __num_fd; +extern struct fd ** NOCOMMON __fd; +extern int NOCOMMON __num_fd; /****************************************************************************/ -extern char * __file_lock_semaphore_name; +extern char * NOCOMMON __file_lock_semaphore_name; /****************************************************************************/ -extern BOOL __no_standard_io; +extern BOOL NOCOMMON __no_standard_io; /****************************************************************************/ diff --git a/library/stdlib_data.c b/library/stdlib_data.c index 8dd4d0e..99cea30 100644 --- a/library/stdlib_data.c +++ b/library/stdlib_data.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_data.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ + * $Id: stdlib_data.c,v 1.3 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -84,6 +84,14 @@ ULONG __stk_extensions; /****************************************************************************/ +#if defined(__SASC) + +UBYTE * __base; + +#endif /* __SASC */ + +/****************************************************************************/ + struct Library * __UtilityBase; /****************************************************************************/ @@ -91,11 +99,3 @@ struct Library * __UtilityBase; #if defined(__amigaos4__) struct UtilityIFace * __IUtility; #endif /* __amigaos4__ */ - -/****************************************************************************/ - -#if defined(__SASC) - -UBYTE * __base; - -#endif /* __SASC */ diff --git a/library/stdlib_exit.c b/library/stdlib_exit.c index 024c666..27f3df3 100644 --- a/library/stdlib_exit.c +++ b/library/stdlib_exit.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_exit.c,v 1.1.1.1 2004-07-26 16:31:54 obarthel Exp $ + * $Id: stdlib_exit.c,v 1.2 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -42,10 +42,6 @@ int __exit_value = RETURN_FAIL; /****************************************************************************/ -extern void __exit_trap_trigger(void); - -/****************************************************************************/ - void _exit(int return_code) { diff --git a/library/stdlib_headers.h b/library/stdlib_headers.h index 44beca0..d3210fa 100644 --- a/library/stdlib_headers.h +++ b/library/stdlib_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stdlib_headers.h,v 1.1.1.1 2004-07-26 16:31:56 obarthel Exp $ + * $Id: stdlib_headers.h,v 1.2 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -157,81 +157,79 @@ struct LocalVariable /****************************************************************************/ -extern struct LocalVariable * __lv_root; +extern struct LocalVariable * NOCOMMON __lv_root; /****************************************************************************/ -extern unsigned __random_seed; +extern unsigned NOCOMMON __random_seed; /****************************************************************************/ -extern struct MemoryTree __memory_tree; -extern struct MinList __memory_list; -extern APTR __memory_pool; +extern struct MemoryTree NOCOMMON __memory_tree; +extern struct MinList NOCOMMON __memory_list; +extern APTR NOCOMMON __memory_pool; /****************************************************************************/ -extern struct MinList __alloca_memory_list; +extern struct MinList NOCOMMON __alloca_memory_list; /****************************************************************************/ -extern unsigned long __maximum_memory_allocated; -extern unsigned long __current_memory_allocated; -extern unsigned long __maximum_num_memory_chunks_allocated; -extern unsigned long __current_num_memory_chunks_allocated; +extern unsigned long NOCOMMON __maximum_memory_allocated; +extern unsigned long NOCOMMON __current_memory_allocated; +extern unsigned long NOCOMMON __maximum_num_memory_chunks_allocated; +extern unsigned long NOCOMMON __current_num_memory_chunks_allocated; /****************************************************************************/ -extern jmp_buf __exit_jmp_buf; -extern int __exit_value; +extern jmp_buf NOCOMMON __exit_jmp_buf; +extern int NOCOMMON __exit_value; /****************************************************************************/ -extern unsigned int (* __get_default_stack_size)(void); +extern unsigned int NOCOMMON (* __get_default_stack_size)(void); /****************************************************************************/ -extern unsigned int __stack_size; -extern BOOL __stack_overflow; -extern UBYTE * __stk_limit; -/*extern UBYTE ** __stackborders;*/ -/*extern UBYTE * __SaveSP;*/ -extern UBYTE * __base; +extern unsigned int NOCOMMON __stack_size; +extern BOOL NOCOMMON __stack_overflow; +extern UBYTE * NOCOMMON __stk_limit; +extern UBYTE * NOCOMMON __base; /****************************************************************************/ -extern ULONG __stk_argbytes; -extern ULONG __stk_safezone; -extern ULONG __stk_maxsize; -extern ULONG __stk_size; -extern ULONG __stk_extensions; -extern ULONG __stk_minframe; +extern ULONG NOCOMMON __stk_argbytes; +extern ULONG NOCOMMON __stk_safezone; +extern ULONG NOCOMMON __stk_maxsize; +extern ULONG NOCOMMON __stk_size; +extern ULONG NOCOMMON __stk_extensions; +extern ULONG NOCOMMON __stk_minframe; /****************************************************************************/ -extern BOOL __is_resident; +extern BOOL NOCOMMON __is_resident; /****************************************************************************/ -extern BOOL __free_program_name; +extern BOOL NOCOMMON __free_program_name; /****************************************************************************/ -extern UBYTE __shell_escape_character; +extern UBYTE NOCOMMON __shell_escape_character; /****************************************************************************/ -extern char ** __argv; -extern int __argc; +extern char ** NOCOMMON __argv; +extern int NOCOMMON __argc; /****************************************************************************/ -extern UBYTE * __quote_vector; +extern UBYTE * NOCOMMON __quote_vector; /****************************************************************************/ -extern int __default_pool_size; -extern int __default_puddle_size; +extern int NOCOMMON __default_pool_size; +extern int NOCOMMON __default_puddle_size; /****************************************************************************/ diff --git a/library/stdlib_main.c b/library/stdlib_main.c index 1aae2e6..393c95a 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.5 2004-10-02 15:56:13 obarthel Exp $ + * $Id: stdlib_main.c,v 1.6 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -111,9 +111,8 @@ static int call_main(void) { /* Initialization functions; must be called exactly in this - * order because there are dependencies between the - * individual functions. - */ + order because there are dependencies between the + individual functions. */ static init_func_ptr init_functions[] = { __stdlib_init, @@ -129,10 +128,9 @@ call_main(void) }; /* Finalization functions; these may be called - * essentially in any order. But this one makes the - * most sense (roll-back of the corresponding - * initialization functions). - */ + essentially in any order. But this one makes the + most sense (roll-back of the corresponding + initialization functions). */ static exit_func_ptr exit_functions[] = { __stdlib_exit, @@ -189,20 +187,18 @@ call_main(void) #endif /* __USE_SAS_PROFILING_FOR_MONITORING */ /* If we end up here with the __stack_overflow variable - * set then the stack overflow handler dropped into - * longjmp() and _exit() did not get called. This - * means that we will have to show the error message - * and invoke _exit() all on our own. - */ + set then the stack overflow handler dropped into + longjmp() and _exit() did not get called. This + means that we will have to show the error message + and invoke _exit() all on our own. */ if(__stack_overflow) { SHOWMSG("we have a stack overflow"); /* Dump whatever is waiting to be written to the - * standard I/O streams, and make sure that no - * break signal is about to make things any more - * complicated than they already are. - */ + standard I/O streams, and make sure that no + break signal is about to make things any more + complicated than they already are. */ __check_abort_enabled = FALSE; if(stdout != NULL) @@ -230,10 +226,9 @@ call_main(void) SHOWMSG("calling the exit functions"); /* Any of the following cleanup routines may call - * _exit() by way of abort() or through a hook - * function. Which is why we redirect the exit - * return procedure. - */ + _exit() by way of abort() or through a hook + function. Which is why we redirect the exit + return procedure. */ for(i = 0 ; exit_functions[i] != NULL ; i++) { D(("calling exit function #%ld",i)); @@ -265,13 +260,12 @@ detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list if(((struct Library *)DOSBase)->lib_Version < 50) { /* Now for the slightly shady part. We need to unload the segment - * list this program was originally loaded with. We have to close - * dos.library, though, which means that either we can close the - * library or unload the code, but not both. But there's a loophole - * in that we can enter Forbid(), unload the code, close the library - * and exit and nobody will be able to allocate this program's - * memory until after the process has been terminated. - */ + list this program was originally loaded with. We have to close + dos.library, though, which means that either we can close the + library or unload the code, but not both. But there's a loophole + in that we can enter Forbid(), unload the code, close the library + and exit and nobody will be able to allocate this program's + memory until after the process has been terminated. */ Forbid(); UnLoadSeg(segment_list); @@ -316,6 +310,7 @@ _main(void) int return_code = RETURN_FAIL; ULONG current_stack_size; APTR old_window_pointer; + int os_version; SysBase = *(struct Library **)4; @@ -349,13 +344,26 @@ _main(void) __WBenchMsg = startup_message; + /* Check which minimum operating system version we actually require. */ + os_version = 37; + if(__minimum_os_lib_version > 37) + os_version = __minimum_os_lib_version; + /* We will need dos.library V37 and utility.library V37. */ - DOSBase = (struct Library *)OpenLibrary("dos.library",37); - __UtilityBase = OpenLibrary("utility.library",37); + DOSBase = (struct Library *)OpenLibrary("dos.library",os_version); + __UtilityBase = OpenLibrary("utility.library",os_version); if(DOSBase == NULL || __UtilityBase == NULL) { - __show_error("This program requires AmigaOS 2.04 or higher."); + char * error_message; + + /* If available, use the error message provided by the client. */ + if(__minimum_os_lib_error != NULL) + error_message = __minimum_os_lib_error; + else + error_message = "This program requires AmigaOS 2.04 or higher."; + + __show_error(error_message); goto out; } @@ -374,9 +382,8 @@ _main(void) #endif /* __amigaos4__ */ /* If a callback was provided which can fill us in on which - * minimum stack size should be used, invoke it now and - * store its result in the global __stack_size variable. - */ + minimum stack size should be used, invoke it now and + store its result in the global __stack_size variable. */ if(__get_default_stack_size != NULL) { unsigned int size; @@ -390,9 +397,8 @@ _main(void) current_stack_size = get_stack_size(&this_process->pr_Task); /* If this is a resident program, don't allow for the detach - * code to run. Same goes for launching the program from - * Workbench. - */ + code to run. Same goes for launching the program from + Workbench. */ if(__is_resident || startup_message != NULL) { __detach = FALSE; @@ -404,13 +410,17 @@ _main(void) } /* The following code will be executed if the program is to keep - * running in the shell or was launched from Workbench. - */ + running in the shell or was launched from Workbench. */ if(DO_NOT __detach) { + int old_priority = 256; + + /* Change the task priority, if requested. */ + if(-128 <= __priority && __priority <= 127) + old_priority = SetTaskPri((struct Task *)this_process,__priority); + /* Was a minimum stack size requested and do we - * need more stack space than was provided for? - */ + need more stack space than was provided for? */ if(__stack_size > 0 && current_stack_size < (ULONG)__stack_size) { struct StackSwapStruct * stk; @@ -452,19 +462,22 @@ _main(void) /* We have enough room to make the call or just don't care. */ return_code = call_main(); } + + /* Restore the task priority, if necessary. */ + if(-128 <= old_priority && old_priority <= 127) + SetTaskPri((struct Task *)this_process,old_priority); } else { struct CommandLineInterface * cli = Cli(); - struct TagItem tags[11]; + struct TagItem tags[12]; UBYTE program_name[256]; unsigned int stack_size; int i; /* Now for the interesting part: detach from the shell we're - * currently executing in. This works only if the program is - * not reentrant and has not been launched from Workbench. - */ + currently executing in. This works only if the program is + not reentrant and has not been launched from Workbench. */ stack_size = __stack_size; @@ -483,7 +496,7 @@ _main(void) tags[i]. ti_Tag = NP_StackSize; tags[i++]. ti_Data = stack_size; tags[i]. ti_Tag = NP_Name; - tags[i++]. ti_Data = (ULONG)program_name; + tags[i++]. ti_Data = (ULONG)(__process_name != NULL ? __process_name : program_name); tags[i]. ti_Tag = NP_CommandName; tags[i++]. ti_Data = (ULONG)program_name; tags[i]. ti_Tag = NP_Cli; @@ -495,6 +508,13 @@ _main(void) tags[i]. ti_Tag = NP_ExitData; tags[i++]. ti_Data = (ULONG)cli->cli_Module; + /* Use a predefined task priority, if requested. */ + if(-128 <= __priority && __priority <= 127) + { + tags[i]. ti_Tag = NP_Priority; + tags[i++]. ti_Data = (ULONG)__priority; + } + /* dos.library V50 will free the segment list upon exit. */ if(((struct Library *)DOSBase)->lib_Version >= 50) { @@ -581,11 +601,10 @@ _main(void) /****************************************************************************/ /* The following is automatically called by the main() function through code - * inserted by GCC. In theory, this could be removed by updating the machine - * definition, but for now we'll just keep this stub around. It is intended - * to call the constructor functions, but we do this in our own _main() - * anyway. - */ + inserted by GCC. In theory, this could be removed by updating the machine + definition, but for now we'll just keep this stub around. It is intended + to call the constructor functions, but we do this in our own _main() + anyway. */ #if defined(__GNUC__) diff --git a/library/stdlib_osliberror.c b/library/stdlib_osliberror.c new file mode 100644 index 0000000..a2d3302 --- /dev/null +++ b/library/stdlib_osliberror.c @@ -0,0 +1,34 @@ +/* + * $Id: stdlib_osliberror.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +char * __minimum_os_lib_error; diff --git a/library/stdlib_oslibversion.c b/library/stdlib_oslibversion.c new file mode 100644 index 0000000..aa715be --- /dev/null +++ b/library/stdlib_oslibversion.c @@ -0,0 +1,34 @@ +/* + * $Id: stdlib_oslibversion.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +int __minimum_os_lib_version; diff --git a/library/stdlib_priority.c b/library/stdlib_priority.c new file mode 100644 index 0000000..7110a3e --- /dev/null +++ b/library/stdlib_priority.c @@ -0,0 +1,36 @@ +/* + * $Id: stdlib_priority.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +/* We use an invalid priority value to indicate "do not change the program's + task priority". */ +int __priority = 256; diff --git a/library/stdlib_process_name.c b/library/stdlib_process_name.c new file mode 100644 index 0000000..0dec4c3 --- /dev/null +++ b/library/stdlib_process_name.c @@ -0,0 +1,34 @@ +/* + * $Id: stdlib_process_name.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +char * __process_name; diff --git a/library/stdlib_startup.c b/library/stdlib_startup.c index 77c1c53..b639ca7 100644 --- a/library/stdlib_startup.c +++ b/library/stdlib_startup.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_startup.c,v 1.3 2004-09-29 19:57:58 obarthel Exp $ + * $Id: stdlib_startup.c,v 1.4 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -347,7 +347,11 @@ __startup_init(void) __original_current_directory = CurrentDir(__WBenchMsg->sm_ArgList[0].wa_Lock); __current_directory_changed = TRUE; - if(__WBenchMsg->sm_ToolWindow != NULL) + if (__stdio_window_specification != NULL) + { + input = Open(__stdio_window_specification,MODE_NEWFILE); + } + else if (__WBenchMsg->sm_ToolWindow != NULL) { input = Open(__WBenchMsg->sm_ToolWindow,MODE_NEWFILE); } diff --git a/library/stdlib_stdio_window_spec.c b/library/stdlib_stdio_window_spec.c new file mode 100644 index 0000000..fb42e81 --- /dev/null +++ b/library/stdlib_stdio_window_spec.c @@ -0,0 +1,34 @@ +/* + * $Id: stdlib_stdio_window_spec.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +char * __stdio_window_specification; diff --git a/library/string_strlcat.c b/library/string_strlcat.c new file mode 100644 index 0000000..e624454 --- /dev/null +++ b/library/string_strlcat.c @@ -0,0 +1,140 @@ +/* + * $Id: string_strlcat.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +/****************************************************************************/ + +/* + * Copyright (c) 1998 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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 _STDLIB_NULL_POINTER_CHECK_H +#include "stdlib_null_pointer_check.h" +#endif /* _STDLIB_NULL_POINTER_CHECK_H */ + +/****************************************************************************/ + +#ifndef _STRING_HEADERS_H +#include "string_headers.h" +#endif /* _STRING_HEADERS_H */ + +/****************************************************************************/ + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +size_t +strlcat(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t result; + size_t dlen; + + assert( src != NULL && (siz == 0 || dst != NULL) ); + + #if defined(CHECK_FOR_NULL_POINTERS) + { + if(src == NULL || (siz != 0 && dst == NULL)) + { + errno = EFAULT; + + result = 0; + goto out; + } + } + #endif /* CHECK_FOR_NULL_POINTERS */ + + /* Find the end of dst and adjust bytes left but don't go past end */ + while(n-- != 0 && (*d) != '\0') + d++; + + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + { + result = dlen + strlen(s); + } + else + { + while((*s) != '\0') + { + if(n != 1) + { + (*d++) = (*s); + + n--; + } + + s++; + } + + (*d) = '\0'; + + result = dlen + (s - src); /* count does not include NUL */ + } + + out: + + return(result); +} diff --git a/library/string_strlcpy.c b/library/string_strlcpy.c new file mode 100644 index 0000000..7be4f76 --- /dev/null +++ b/library/string_strlcpy.c @@ -0,0 +1,130 @@ +/* + * $Id: string_strlcpy.c,v 1.1 2004-11-14 11:06:27 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2004 by Olaf Barthel + * 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. + */ + +/****************************************************************************/ + +/* + * Copyright (c) 1998 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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 _STDLIB_NULL_POINTER_CHECK_H +#include "stdlib_null_pointer_check.h" +#endif /* _STDLIB_NULL_POINTER_CHECK_H */ + +/****************************************************************************/ + +#ifndef _STRING_HEADERS_H +#include "string_headers.h" +#endif /* _STRING_HEADERS_H */ + +/****************************************************************************/ + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t result; + + assert( siz == 0 || (dst != NULL && src != NULL) ); + + #if defined(CHECK_FOR_NULL_POINTERS) + { + if(siz != 0 && (dst == NULL || src == NULL)) + { + errno = EFAULT; + + result = 0; + goto out; + } + } + #endif /* CHECK_FOR_NULL_POINTERS */ + + /* Copy as many bytes as will fit */ + if(n != 0 && --n != 0) + { + do + { + if(((*d++) = (*s++)) == '\0') + break; + } + while(--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if(n == 0) + { + if(siz != 0) + (*d) = '\0'; /* NUL-terminate dst */ + + while (*s++) + ; + } + + result = (s - src - 1); /* count does not include NUL */ + + out: + + return(result); +} diff --git a/library/time_headers.h b/library/time_headers.h index 78b0c67..6ba2d11 100644 --- a/library/time_headers.h +++ b/library/time_headers.h @@ -1,5 +1,5 @@ /* - * $Id: time_headers.h,v 1.2 2004-09-29 19:57:58 obarthel Exp $ + * $Id: time_headers.h,v 1.3 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -84,10 +84,10 @@ /****************************************************************************/ -extern const char * const __abbreviated_week_day_names[7]; -extern const char * const __week_day_names[7]; -extern const char * const __abbreviated_month_names[12]; -extern const char * const __month_names[12]; +extern const char * const NOCOMMON __abbreviated_week_day_names[7]; +extern const char * const NOCOMMON __week_day_names[7]; +extern const char * const NOCOMMON __abbreviated_month_names[12]; +extern const char * const NOCOMMON __month_names[12]; /****************************************************************************/ diff --git a/library/unistd_headers.h b/library/unistd_headers.h index 0926530..44131d0 100644 --- a/library/unistd_headers.h +++ b/library/unistd_headers.h @@ -1,5 +1,5 @@ /* - * $Id: unistd_headers.h,v 1.3 2004-09-29 19:57:58 obarthel Exp $ + * $Id: unistd_headers.h,v 1.4 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -42,7 +42,7 @@ /****************************************************************************/ -extern char __current_path_name[MAXPATHLEN]; +extern char NOCOMMON __current_path_name[MAXPATHLEN]; /****************************************************************************/ @@ -73,7 +73,7 @@ extern BOOL NOCOMMON __unlock_current_directory; /****************************************************************************/ -extern BOOL __unix_path_semantics; +extern BOOL NOCOMMON __unix_path_semantics; /****************************************************************************/ diff --git a/library/usergroup_headers.h b/library/usergroup_headers.h index 62b4d89..547a3ff 100644 --- a/library/usergroup_headers.h +++ b/library/usergroup_headers.h @@ -1,5 +1,5 @@ /* - * $Id: usergroup_headers.h,v 1.3 2004-09-29 19:57:58 obarthel Exp $ + * $Id: usergroup_headers.h,v 1.4 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -54,14 +54,14 @@ extern struct UserGroupIFace * NOCOMMON __IUserGroup; /****************************************************************************/ -extern BOOL __root_mode; +extern BOOL NOCOMMON __root_mode; /****************************************************************************/ -extern int __root_uid; -extern int __root_gid; -extern int __root_euid; -extern int __root_egid; +extern int NOCOMMON __root_uid; +extern int NOCOMMON __root_gid; +extern int NOCOMMON __root_euid; +extern int NOCOMMON __root_egid; /****************************************************************************/ diff --git a/library/usergroup_init_exit.c b/library/usergroup_init_exit.c index 536d642..4ddd2f9 100644 --- a/library/usergroup_init_exit.c +++ b/library/usergroup_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_init_exit.c,v 1.3 2004-09-29 19:57:58 obarthel Exp $ + * $Id: usergroup_init_exit.c,v 1.4 2004-11-14 11:06:27 obarthel Exp $ * * :ts=4 * @@ -45,15 +45,11 @@ /****************************************************************************/ -/* Pointer to errno, length == sizeof(errno) */ +/* Pointer to errno, length == sizeof(long) */ #define UGT_ERRNOLPTR 0x80000004 /****************************************************************************/ -extern char * __program_name; - -/****************************************************************************/ - struct Library * NOCOMMON __UserGroupBase; /****************************************************************************/