. service tells you which device it couldn't stat
[minix3.git] / lib / ack / libp / cls.c
blobf891a3658ac4f2fc202679b3221d2b92289181e8
1 /* $Header$ */
2 /*
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
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
19 /* Author: J.W. Stevenson */
21 #include <pc_file.h>
22 #include <pc_err.h>
24 extern struct file *_curfil;
25 extern _trp();
26 extern _flush();
27 extern _outcpt();
28 extern int _close();
30 _xcls(f) struct file *f; {
32 if ((f->flags & WRBIT) == 0)
33 return;
34 if ((f->flags & (TXTBIT|ELNBIT)) == TXTBIT) {
35 #ifdef CPM
36 *f->ptr = '\r';
37 _outcpt(f);
38 #endif
39 *f->ptr = '\n';
40 _outcpt(f);
42 _flush(f);
45 _cls(f) struct file *f; {
46 #ifdef MAYBE
47 char *p;
48 #endif
50 _curfil = f;
51 if ((f->flags&0377) != MAGIC)
52 return;
53 #ifdef MAYBE
54 p = f->bufadr;
55 if (f->ptr < p)
56 return;
57 if (f->buflen <= 0)
58 return;
59 p += f->buflen;
60 if (f->ptr >= p)
61 return;
62 #endif
63 _xcls(f);
64 if (_close(f->ufd) != 0)
65 _trp(ECLOSE);
66 f->flags = 0;