3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
5 * This product is part of the Amsterdam Compiler Kit.
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
19 /* Author: J.W. Stevenson */
24 extern struct file
**_extfl
;
26 extern struct file
*_curfil
;
29 extern char ***_penviron
;
42 static char namebuf
[] = "/usr/tmp/plf.xxxxx";
49 *q
++ = (i
& 07) + '0';
52 if ((i
= _creat(p
,0644)) < 0)
53 if ((i
= _creat(p
+= 4,0644)) < 0)
54 if ((i
= _creat(p
+= 5,0644)) < 0)
58 if ((i
= _open(p
,2)) < 0)
65 static int initfl(descr
,sz
,f
) int descr
; int sz
; struct file
*f
; {
73 for (i
=0; i
<_extflc
; i
++)
76 if (i
>= _extflc
) { /* local file */
78 if ((descr
& WRBIT
) == 0 && (f
->flags
& 0377) == MAGIC
) {
80 if (_lseek(f
->ufd
,(long)0,0) == -1)
86 } else { /* external file */
93 if ((descr
& WRBIT
) == 0) {
94 if ((f
->ufd
= _open(f
->fname
,0)) < 0)
97 if ((f
->ufd
= _creat(f
->fname
,0644)) < 0)
101 f
->buflen
= (sz
>PC_BUFLEN
? sz
: PC_BUFLEN
-PC_BUFLEN
%sz
);
108 _opn(sz
,f
) int sz
; struct file
*f
; {
110 if (initfl(MAGIC
,sz
,f
))
114 _cre(sz
,f
) int sz
; struct file
*f
; {
116 if (initfl(WRBIT
|EOFBIT
|ELNBIT
|MAGIC
,sz
,f
))
117 f
->count
= f
->buflen
;