source: trunk/minix/lib/ack/libp/incpt.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.4 KB
Line 
1/* $Header: /cvsup/minix/src/lib/ack/libp/incpt.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
2/*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 *
5 * This product is part of the Amsterdam Compiler Kit.
6 *
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
9 *
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
16 *
17 */
18
19/* Author: J.W. Stevenson */
20
21#include <pc_file.h>
22#include <pc_err.h>
23
24#define EINTR 4
25
26extern int errno;
27extern _trp();
28extern int _read();
29
30_incpt(f) struct file *f; {
31
32 if (f->flags & EOFBIT)
33 _trp(EEOF);
34 f->flags |= WINDOW;
35 f->flags &= ~ELNBIT;
36#ifdef CPM
37 do {
38#endif
39 f->ptr += f->size;
40 if (f->count == 0) {
41 f->ptr = f->bufadr;
42 for(;;) {
43 f->count=_read(f->ufd,f->bufadr,f->buflen);
44 if ( f->count<0 ) {
45 if (errno != EINTR) _trp(EREAD) ;
46 continue ;
47 }
48 break ;
49 }
50 if (f->count == 0) {
51 f->flags |= EOFBIT;
52 *f->ptr = '\0';
53 return;
54 }
55 }
56 if ((f->count -= f->size) < 0)
57 _trp(EFTRUNC);
58#ifdef CPM
59 } while ((f->flags&TXTBIT) && *f->ptr == '\r');
60#endif
61 if (f->flags & TXTBIT) {
62 if (*f->ptr & 0200)
63 _trp(EASCII);
64 if (*f->ptr == '\n') {
65 f->flags |= ELNBIT;
66 *f->ptr = ' ';
67 }
68#ifdef CPM
69 if (*f->ptr == 26) {
70 f->flags |= EOFBIT;
71 *f->ptr = 0;
72 }
73#endif
74 }
75}
Note: See TracBrowser for help on using the repository browser.