mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- ttyname() now calls ttyname_r(). Also, the libunix.a version of ttyname_r()
will produce "/CONSOLE" rather than "CONSOLE:". git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15147 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: amiga_argarraydone.c,v 1.3 2006-01-08 12:04:22 obarthel Exp $
|
||||
* $Id: amiga_argarraydone.c,v 1.4 2006-09-25 14:05:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -48,7 +48,7 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern char **CXLIB_argarray;
|
||||
extern const unsigned char **CXLIB_argarray;
|
||||
|
||||
extern struct DiskObject * CXLIB_disko;
|
||||
|
||||
|
||||
@ -5,6 +5,10 @@
|
||||
- asctime_r() now returns NULL if the buffer is too short to hold even a single
|
||||
byte of data.
|
||||
|
||||
- ttyname() now calls ttyname_r(). Also, the libunix.a version of ttyname_r()
|
||||
will produce "/CONSOLE" rather than "CONSOLE:".
|
||||
|
||||
|
||||
c.lib 1.201 (21.9.2006)
|
||||
|
||||
- If defined, the local environment variable "DISABLE_COMMANDLINE_WILDCARD_EXPANSION"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.26 2006-09-20 19:46:57 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.27 2006-09-25 14:05:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -433,7 +433,7 @@ extern int NOCOMMON __num_fd;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern char * NOCOMMON __file_lock_semaphore_name;
|
||||
extern const char * NOCOMMON __file_lock_semaphore_name;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_locksemaphorename.c,v 1.5 2006-09-22 09:02:51 obarthel Exp $
|
||||
* $Id: stdio_locksemaphorename.c,v 1.6 2006-09-25 14:05:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -37,4 +37,4 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
char * NOCOMMON __file_lock_semaphore_name = (char *)"Advisory File Locking";
|
||||
const char * NOCOMMON __file_lock_semaphore_name = "Advisory File Locking";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_ttyname.c,v 1.4 2006-09-22 09:02:51 obarthel Exp $
|
||||
* $Id: unistd_ttyname.c,v 1.5 2006-09-25 14:05:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -44,106 +44,18 @@
|
||||
char *
|
||||
ttyname(int file_descriptor)
|
||||
{
|
||||
static char tty_file_name[_POSIX_TTY_NAME_MAX];
|
||||
char * result = NULL;
|
||||
BOOL is_tty = FALSE;
|
||||
struct fd *fd;
|
||||
|
||||
ENTER();
|
||||
|
||||
SHOWVALUE(file_descriptor);
|
||||
|
||||
__stdio_lock();
|
||||
|
||||
fd = __get_file_descriptor(file_descriptor);
|
||||
if(fd == NULL)
|
||||
{
|
||||
__set_errno(EBADF);
|
||||
if(ttyname_r(file_descriptor,tty_file_name,sizeof(tty_file_name)) != 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
__fd_lock(fd);
|
||||
|
||||
#if defined(__THREAD_SAFE)
|
||||
{
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_STDIO))
|
||||
{
|
||||
BPTR file;
|
||||
|
||||
switch(fd->fd_DefaultFile)
|
||||
{
|
||||
case STDIN_FILENO:
|
||||
|
||||
file = Input();
|
||||
break;
|
||||
|
||||
case STDOUT_FILENO:
|
||||
|
||||
file = Output();
|
||||
break;
|
||||
|
||||
case STDERR_FILENO:
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
file = ErrorOutput();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct Process * this_process = (struct Process *)FindTask(NULL);
|
||||
|
||||
file = this_process->pr_CES;
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
/* The following is rather controversial; if the standard error stream
|
||||
is unavailable, we default to reuse the standard output stream. This
|
||||
is problematic if the standard output stream was redirected and should
|
||||
not be the same as the standard error output stream. */
|
||||
if(file == ZERO)
|
||||
file = Output();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
file = ZERO;
|
||||
break;
|
||||
}
|
||||
|
||||
__fd_lock(fd);
|
||||
|
||||
if(file != ZERO && IsInteractive(file))
|
||||
is_tty = TRUE;
|
||||
|
||||
__fd_unlock(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
is_tty = TRUE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
is_tty = TRUE;
|
||||
}
|
||||
#endif /* __THREAD_SAFE */
|
||||
|
||||
if(NOT is_tty)
|
||||
{
|
||||
__set_errno(ENOTTY);
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = (char *)"CONSOLE:";
|
||||
result = tty_file_name;
|
||||
|
||||
out:
|
||||
|
||||
__fd_unlock(fd);
|
||||
|
||||
__stdio_unlock();
|
||||
|
||||
RETURN(result);
|
||||
return(result);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_ttyname_r.c,v 1.3 2006-01-08 12:04:27 obarthel Exp $
|
||||
* $Id: unistd_ttyname_r.c,v 1.4 2006-09-25 14:05:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -44,6 +44,7 @@
|
||||
int
|
||||
ttyname_r(int file_descriptor,char *name,size_t buflen)
|
||||
{
|
||||
const char *tty_file_name;
|
||||
BOOL is_tty = FALSE;
|
||||
struct fd *fd;
|
||||
int result;
|
||||
@ -136,13 +137,23 @@ ttyname_r(int file_descriptor,char *name,size_t buflen)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(buflen < _POSIX_TTY_NAME_MAX) /* XXX Should this be _POSIX_PATH_MAX? */
|
||||
#if defined(UNIX_PATH_SEMANTICS)
|
||||
{
|
||||
tty_file_name = "/CONSOLE";
|
||||
}
|
||||
#else
|
||||
{
|
||||
tty_file_name = "CONSOLE:";
|
||||
}
|
||||
#endif /* UNIX_PATH_SEMANTICS */
|
||||
|
||||
if(buflen < strlen(tty_file_name)+1) /* XXX Should this be _POSIX_PATH_MAX? */
|
||||
{
|
||||
result = ERANGE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
strcpy(name,"CONSOLE:"); /* The buffer is at least 9 bytes, so this is ok. */
|
||||
strcpy(name,tty_file_name);
|
||||
|
||||
result = OK;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user