cls.c

Go to the documentation of this file.
00001 /* $Header: /opt/proj/minix/cvsroot/src/lib/ack/libp/cls.c,v 1.1 2005/10/10 15:27:46 beng Exp $ */
00002 /*
00003  * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
00004  *
00005  *          This product is part of the Amsterdam Compiler Kit.
00006  *
00007  * Permission to use, sell, duplicate or disclose this software must be
00008  * obtained in writing. Requests for such permissions may be sent to
00009  *
00010  *      Dr. Andrew S. Tanenbaum
00011  *      Wiskundig Seminarium
00012  *      Vrije Universiteit
00013  *      Postbox 7161
00014  *      1007 MC Amsterdam
00015  *      The Netherlands
00016  *
00017  */
00018 
00019 /* Author: J.W. Stevenson */
00020 
00021 #include        <pc_file.h>
00022 #include        <pc_err.h>
00023 
00024 extern struct file      *_curfil;
00025 extern                  _trp();
00026 extern                  _flush();
00027 extern                  _outcpt();
00028 extern int              _close();
00029 
00030 _xcls(f) struct file *f; {
00031 
00032         if ((f->flags & WRBIT) == 0)
00033                 return;
00034         if ((f->flags & (TXTBIT|ELNBIT)) == TXTBIT) {
00035 #ifdef CPM
00036                 *f->ptr = '\r';
00037                 _outcpt(f);
00038 #endif
00039                 *f->ptr = '\n';
00040                 _outcpt(f);
00041         }
00042         _flush(f);
00043 }
00044 
00045 _cls(f) struct file *f; {
00046 #ifdef MAYBE
00047         char *p;
00048 #endif
00049 
00050         _curfil = f;
00051         if ((f->flags&0377) != MAGIC)
00052                 return;
00053 #ifdef MAYBE
00054         p = f->bufadr;
00055         if (f->ptr < p)
00056                 return;
00057         if (f->buflen <= 0)
00058                 return;
00059         p += f->buflen;
00060         if (f->ptr >= p)
00061                 return;
00062 #endif
00063         _xcls(f);
00064         if (_close(f->ufd) != 0)
00065                 _trp(ECLOSE);
00066         f->flags = 0;
00067 }

Generated on Fri Apr 14 22:57:25 2006 for minix by  doxygen 1.4.6