projects
/
unix-history
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Bell 32V development
[unix-history]
/
usr
/
src
/
libc
/
stdio
/
fdopen.c
/*
* Unix routine to do an "fopen" on file descriptor
* The mode has to be repeated because you can't query its
* status
*/
#include <stdio.h>
#include <errno.h>
FILE
*
fdopen
(
fd
,
mode
)
register
char
*
mode
;
{
extern
int
errno
;
register
FILE
*
iop
;
extern
FILE
*
_lastbuf
;
for
(
iop
=
_iob
;
iop
->
_flag
&(
_IOREAD
|
_IOWRT
);
iop
++)
if
(
iop
>=
_lastbuf
)
return
(
NULL
);
iop
->
_cnt
=
0
;
iop
->
_file
=
fd
;
if
(*
mode
!=
'r'
) {
iop
->
_flag
|=
_IOWRT
;
if
(*
mode
==
'a'
)
lseek
(
fd
,
0L
,
2
);
}
else
iop
->
_flag
|=
_IOREAD
;
return
(
iop
);
}