1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- 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.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14798 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-01-09 15:58:02 +00:00
parent 64c1175f7b
commit 5191ee5660
8 changed files with 241 additions and 154 deletions

View File

@ -31,6 +31,15 @@
- 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.
c.lib 1.185 (2.1.2005)

View File

@ -1,5 +1,5 @@
/*
* $Id: dirent_readdir.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $
* $Id: dirent_readdir.c,v 1.5 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -89,7 +89,6 @@ 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 );
@ -103,10 +102,12 @@ readdir(DIR * directory_pointer)
{
if(IsFileSystem(dh->dh_VolumeNode->ln_Name))
{
port = DeviceProc(dh->dh_VolumeNode->ln_Name);
if(port != NULL)
struct DevProc * dvp;
dvp = GetDeviceProc(dh->dh_VolumeNode->ln_Name,NULL);
if(dvp != NULL)
{
dir_lock = DoPkt(port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(name),SHARED_LOCK, 0,0);
dir_lock = DoPkt(dvp->dvp_Port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(name),SHARED_LOCK, 0,0);
if(dir_lock != ZERO)
{
if(Examine(dir_lock,fib))
@ -122,6 +123,8 @@ readdir(DIR * directory_pointer)
UnLock(dir_lock);
}
FreeDeviceProc(dvp);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: fcntl_open.c,v 1.5 2005-01-09 09:54:33 obarthel Exp $
* $Id: fcntl_open.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -53,6 +53,69 @@
/****************************************************************************/
/* This is used in place of ExamineFH() in order to work around a bug in
dos.library V40 and below: a "NIL:" file handle will crash the
ExamineFH() function. */
static LONG
safe_examine_file_handle(BPTR file_handle,struct FileInfoBlock *fib)
{
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);
PROFILE_ON();
out:
return(result);
}
/* Same thing as above, but for ChangeMode(), which suffers from
the same problem. */
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 */ )
{
@ -64,7 +127,6 @@ 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;
@ -294,20 +356,7 @@ 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)
if(safe_examine_file_handle(handle,fib) != DOSFALSE)
{
BOOL operation_permitted = TRUE;
@ -336,7 +385,6 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
goto out;
}
}
}
fd = __fd[fd_slot_number];
@ -365,7 +413,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ )
len = 0;
for(i = 0 ; i < (int)strlen(path_name) ; i++)
for(i = 0 ; path_name[i] != '\0' ; i++)
{
if(path_name[i] == ':')
{
@ -399,22 +447,12 @@ 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)
{
PROFILE_OFF();
ChangeMode(CHANGE_FH,handle,SHARED_LOCK);
PROFILE_ON();
}
}
safe_change_mode(CHANGE_FH,handle,SHARED_LOCK);
/* We should be able to seek in this file. */
SET_FLAG(fd->fd_Flags,FDF_CACHE_POSITION);

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_fdhookentry.c,v 1.5 2005-01-02 09:07:08 obarthel Exp $
* $Id: stdio_fdhookentry.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -59,16 +59,21 @@
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);
@ -85,14 +90,19 @@ safe_examine_file_handle(BPTR file_handle,struct FileInfoBlock *fib)
static BPTR
safe_parent_of_file_handle(BPTR file_handle)
{
struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle);
BPTR result = ZERO;
#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 = ParentOfFH(file_handle);
@ -243,6 +253,12 @@ 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)
{
@ -258,6 +274,8 @@ obtain_file_lock_semaphore(BOOL shared)
}
}
}
#endif /* __amigaos4__ */
}
else
{
ObtainSemaphore((struct SignalSemaphore *)FileLockSemaphore);
@ -1885,6 +1903,21 @@ __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");
@ -1930,6 +1963,8 @@ __fd_hook_entry(
__translate_io_error_to_errno(IoErr(),&error);
}
}
}
#endif /* __amigaos4__ */
CurrentDir(old_current_dir);

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_init_exit.c,v 1.10 2005-01-09 10:43:40 obarthel Exp $
* $Id: stdio_init_exit.c,v 1.11 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -242,12 +242,8 @@ __stdio_init(void)
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_NO_CLOSE);
}
else if (__fd[STDOUT_FILENO]->fd_DefaultFile != ZERO)
else
{
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);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_malloc.c,v 1.5 2005-01-02 09:07:18 obarthel Exp $
* $Id: stdlib_malloc.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -275,8 +275,16 @@ __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();
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_startup.c,v 1.5 2005-01-02 09:07:19 obarthel Exp $
* $Id: stdlib_startup.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
*
* :ts=4
*
@ -387,9 +387,6 @@ __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);
@ -398,7 +395,6 @@ __startup_init(void)
else
SetConsoleTask((struct MsgPort *)old_console_task);
}
}
if(output == ZERO)
output = Open("NIL:",MODE_NEWFILE);

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_chown.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
* $Id: unistd_chown.c,v 1.4 2005-01-09 15:58:02 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,6 +148,9 @@ 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)
{
@ -156,7 +159,6 @@ chown(const char * path_name, uid_t owner, gid_t group)
}
result = 0;
}
out: