home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
DUP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
989b
|
47 lines
/* from Dale Schumacher's dLibs library */
/* these will have to be adjusted at some time ++jrb */
/* use these with caution, TOS 1.4 still has double re-direction bug! */
#include <stddef.h>
#include <fcntl.h>
#include <osbind.h>
#include <errno.h>
#include <mintbind.h>
#include <unistd.h>
extern int __mint;
int dup(handle)
int handle;
{
register int rv;
if (__mint)
rv = Fcntl(handle, (long)0, F_DUPFD);
else
rv = Fdup(handle);
if(rv < (__SMALLEST_VALID_HANDLE)) {
errno = -rv; rv = -1;
} else if (__OPEN_INDEX(rv) < __NHANDLES) {
__open_stat[__OPEN_INDEX(rv)] =
__open_stat[__OPEN_INDEX(handle)];
}
return(rv);
}
int dup2(handle1, handle2)
int handle1, handle2;
{
int rv;
close(handle2);
if ((rv = Fforce(handle2, handle1)) < 0)
errno = -rv;
else if (__OPEN_INDEX(handle2) < __NHANDLES)
__open_stat[__OPEN_INDEX(handle2)] =
__open_stat[__OPEN_INDEX(handle1)];
return (rv < 0) ? -1 : handle2;
}