mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- The internal 'struct fd' file descriptor table entry data structure
now has a user data field entry. - Rearranged the contents of the 'struct fd' file descriptor table entry data structure in preparation for making it public. Also added a version field so that user code can handle changes to it gracefully. The default file is no longer a BCPL pointer to a file handle by default, but both a BPTR and a socket identifier, wrapped into a union. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15160 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
- The internal 'struct fd' file descriptor table entry data structure
|
||||||
|
now has a user data field entry.
|
||||||
|
|
||||||
|
- Rearranged the contents of the 'struct fd' file descriptor table entry
|
||||||
|
data structure in preparation for making it public. Also added a version
|
||||||
|
field so that user code can handle changes to it gracefully. The default
|
||||||
|
file is no longer a BCPL pointer to a file handle by default, but
|
||||||
|
both a BPTR and a socket identifier, wrapped into a union.
|
||||||
|
|
||||||
- Added experimental tilde expansion in Unix path names. This still needs
|
- Added experimental tilde expansion in Unix path names. This still needs
|
||||||
some more work.
|
some more work.
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio_duplicate_fd.c,v 1.5 2006-01-08 12:04:24 obarthel Exp $
|
* $Id: stdio_duplicate_fd.c,v 1.6 2006-10-10 13:39:26 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@ -55,8 +55,8 @@ __duplicate_fd(struct fd * duplicate_fd,struct fd * original_fd)
|
|||||||
duplicate_fd->fd_Original = original_fd;
|
duplicate_fd->fd_Original = original_fd;
|
||||||
|
|
||||||
/* Add the duplicate at the beginning of the list. */
|
/* Add the duplicate at the beginning of the list. */
|
||||||
duplicate_fd->fd_NextLink = duplicate_fd->fd_Original->fd_NextLink;
|
duplicate_fd->fd_NextAlias = duplicate_fd->fd_Original->fd_NextAlias;
|
||||||
duplicate_fd->fd_Original->fd_NextLink = duplicate_fd;
|
duplicate_fd->fd_Original->fd_NextAlias = duplicate_fd;
|
||||||
|
|
||||||
__fd_unlock(original_fd);
|
__fd_unlock(original_fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio_headers.h,v 1.27 2006-09-25 14:05:31 obarthel Exp $
|
* $Id: stdio_headers.h,v 1.28 2006-10-10 13:39:26 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@ -365,6 +365,7 @@ struct iob
|
|||||||
standard input/output/error streams. */
|
standard input/output/error streams. */
|
||||||
#define FDF_TERMIOS (1UL<<13) /* File is under termios control.
|
#define FDF_TERMIOS (1UL<<13) /* File is under termios control.
|
||||||
FDF_IS_INTERACTIVE should also be set. */
|
FDF_IS_INTERACTIVE should also be set. */
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
/* The file action function for unbuffered files. */
|
/* The file action function for unbuffered files. */
|
||||||
@ -379,25 +380,39 @@ typedef void (*fd_cleanup_t)(struct fd * fd);
|
|||||||
|
|
||||||
struct fd
|
struct fd
|
||||||
{
|
{
|
||||||
file_action_fd_t fd_Action; /* Function to invoke to perform actions */
|
int fd_Version; /* Version number of this definition
|
||||||
ULONG fd_Flags; /* File properties */
|
of the 'fd' data structure. */
|
||||||
struct fd * fd_Original; /* NULL if this is not a dup()ed file
|
file_action_fd_t fd_Action; /* Function to invoke to perform actions */
|
||||||
descriptor; points to original
|
void * fd_UserData; /* To be used by custom file action
|
||||||
descriptor if non-NULL */
|
functions */
|
||||||
struct fd * fd_NextLink; /* Points to next duplicate of this
|
ULONG fd_Flags; /* File properties */
|
||||||
file descriptor; NULL for none */
|
|
||||||
BPTR fd_DefaultFile; /* A dos.library file handle */
|
|
||||||
ULONG fd_Position; /* Cached file position (seek offset). */
|
|
||||||
fd_cleanup_t fd_Cleanup; /* Cleanup function, if any. */
|
|
||||||
|
|
||||||
struct SignalSemaphore * fd_Lock; /* For thread locking */
|
union
|
||||||
|
{
|
||||||
|
BPTR fdu_File; /* A dos.library file handle */
|
||||||
|
LONG fdu_Socket; /* A socket identifier */
|
||||||
|
} fdu_Default;
|
||||||
|
|
||||||
void * fd_Aux; /* Auxilliary data for "special" files,
|
struct SignalSemaphore * fd_Lock; /* For thread locking */
|
||||||
e.g. termios support. */
|
ULONG fd_Position; /* Cached file position (seek offset). */
|
||||||
|
fd_cleanup_t fd_Cleanup; /* Cleanup function, if any. */
|
||||||
|
|
||||||
|
struct fd * fd_Original; /* NULL if this is not a dup()ed file
|
||||||
|
descriptor; points to original
|
||||||
|
descriptor if non-NULL */
|
||||||
|
struct fd * fd_NextAlias; /* Points to next duplicate of this
|
||||||
|
file descriptor; NULL for none */
|
||||||
|
void * fd_Aux; /* Auxilliary data for "special" files,
|
||||||
|
e.g. termios support. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#define fd_DefaultFile fdu_Default.fdu_File
|
||||||
|
#define fd_Socket fdu_Default.fdu_Socket
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
/* Files and directories to be unlinked when the program exits. */
|
/* Files and directories to be unlinked when the program exits. */
|
||||||
struct UnlinkNode
|
struct UnlinkNode
|
||||||
{
|
{
|
||||||
@ -481,7 +496,7 @@ extern BOOL NOCOMMON __no_standard_io;
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#define __fd_is_aliased(fd) \
|
#define __fd_is_aliased(fd) \
|
||||||
((fd)->fd_Original != NULL || (fd)->fd_NextLink != NULL)
|
((fd)->fd_Original != NULL || (fd)->fd_NextAlias != NULL)
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio_initializefd.c,v 1.6 2006-01-08 12:04:24 obarthel Exp $
|
* $Id: stdio_initializefd.c,v 1.7 2006-10-10 13:39:26 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@ -49,6 +49,7 @@ __initialize_fd(
|
|||||||
|
|
||||||
memset(fd,0,sizeof(*fd));
|
memset(fd,0,sizeof(*fd));
|
||||||
|
|
||||||
|
fd->fd_Version = 1;
|
||||||
fd->fd_DefaultFile = default_file;
|
fd->fd_DefaultFile = default_file;
|
||||||
fd->fd_Flags = flags;
|
fd->fd_Flags = flags;
|
||||||
fd->fd_Action = action_function;
|
fd->fd_Action = action_function;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio_record_locking.c,v 1.17 2006-09-25 14:51:15 obarthel Exp $
|
* $Id: stdio_record_locking.c,v 1.18 2006-10-10 13:39:26 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@ -342,7 +342,7 @@ remove_locked_region_node(struct FileLockSemaphore * fls,struct fd * fd,LONG sta
|
|||||||
{
|
{
|
||||||
CLEAR_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
CLEAR_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
||||||
}
|
}
|
||||||
while((fd = fd->fd_NextLink) != NULL);
|
while((fd = fd->fd_NextAlias) != NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -725,7 +725,7 @@ cleanup_locked_records(struct fd * fd)
|
|||||||
{
|
{
|
||||||
CLEAR_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
CLEAR_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
||||||
}
|
}
|
||||||
while((fd = fd->fd_NextLink) != NULL);
|
while((fd = fd->fd_NextAlias) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
release_file_lock_semaphore(fls);
|
release_file_lock_semaphore(fls);
|
||||||
@ -1086,7 +1086,7 @@ __handle_record_locking(int cmd,struct flock * l,struct fd * fd,int * error_ptr)
|
|||||||
{
|
{
|
||||||
SET_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
SET_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
||||||
}
|
}
|
||||||
while((fd = fd->fd_NextLink) != NULL);
|
while((fd = fd->fd_NextAlias) != NULL);
|
||||||
}
|
}
|
||||||
else if (cmd == F_SETLK)
|
else if (cmd == F_SETLK)
|
||||||
{
|
{
|
||||||
@ -1164,7 +1164,7 @@ __handle_record_locking(int cmd,struct flock * l,struct fd * fd,int * error_ptr)
|
|||||||
{
|
{
|
||||||
SET_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
SET_FLAG(fd->fd_Flags,FDF_IS_LOCKED);
|
||||||
}
|
}
|
||||||
while((fd = fd->fd_NextLink) != NULL);
|
while((fd = fd->fd_NextAlias) != NULL);
|
||||||
}
|
}
|
||||||
else if (cmd == F_GETLK)
|
else if (cmd == F_GETLK)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio_remove_fd_alias.c,v 1.4 2006-01-08 12:04:25 obarthel Exp $
|
* $Id: stdio_remove_fd_alias.c,v 1.5 2006-10-10 13:39:26 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@ -54,36 +54,36 @@ __remove_fd_alias(struct fd * fd)
|
|||||||
/* Remove this alias from the list. */
|
/* Remove this alias from the list. */
|
||||||
for(list_fd = fd->fd_Original ;
|
for(list_fd = fd->fd_Original ;
|
||||||
list_fd != NULL ;
|
list_fd != NULL ;
|
||||||
list_fd = list_fd->fd_NextLink)
|
list_fd = list_fd->fd_NextAlias)
|
||||||
{
|
{
|
||||||
if(list_fd->fd_NextLink == fd)
|
if(list_fd->fd_NextAlias == fd)
|
||||||
{
|
{
|
||||||
list_fd->fd_NextLink = fd->fd_NextLink;
|
list_fd->fd_NextAlias = fd->fd_NextAlias;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fd->fd_NextLink != NULL) /* this one has aliases attached; it is the 'original' resource */
|
else if (fd->fd_NextAlias != NULL) /* this one has aliases attached; it is the 'original' resource */
|
||||||
{
|
{
|
||||||
struct fd * first_alias;
|
struct fd * first_alias;
|
||||||
struct fd * next_alias;
|
struct fd * next_alias;
|
||||||
struct fd * list_fd;
|
struct fd * list_fd;
|
||||||
|
|
||||||
/* The first link now becomes the original resource */
|
/* The first link now becomes the original resource */
|
||||||
first_alias = fd->fd_NextLink;
|
first_alias = fd->fd_NextAlias;
|
||||||
next_alias = first_alias->fd_NextLink;
|
next_alias = first_alias->fd_NextAlias;
|
||||||
|
|
||||||
/* Structure copy... */
|
/* Structure copy... */
|
||||||
(*first_alias) = (*fd);
|
(*first_alias) = (*fd);
|
||||||
|
|
||||||
/* Fix up the linkage. */
|
/* Fix up the linkage. */
|
||||||
first_alias->fd_NextLink = next_alias;
|
first_alias->fd_NextAlias = next_alias;
|
||||||
first_alias->fd_Original = NULL;
|
first_alias->fd_Original = NULL;
|
||||||
|
|
||||||
/* The resources are migrated to the first link. */
|
/* The resources are migrated to the first link. */
|
||||||
for(list_fd = next_alias ;
|
for(list_fd = next_alias ;
|
||||||
list_fd != NULL ;
|
list_fd != NULL ;
|
||||||
list_fd = list_fd->fd_NextLink)
|
list_fd = list_fd->fd_NextAlias)
|
||||||
{
|
{
|
||||||
list_fd->fd_Original = first_alias;
|
list_fd->fd_Original = first_alias;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user