. service tells you which device it couldn't stat
[minix3.git] / lib / ack / libp / rdi.c
blobfa1909b81d07e7f406969dcf74acfa6a598ce687
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 _trp();
25 extern _rf();
26 extern _incpt();
28 _skipsp(f) struct file *f; {
29 while ((*f->ptr == ' ') || (*f->ptr == '\t'))
30 _incpt(f);
33 int _getsig(f) struct file *f; {
34 int sign;
36 if ((sign = (*f->ptr == '-')) || *f->ptr == '+')
37 _incpt(f);
38 return(sign);
41 int _fstdig(f) struct file *f; {
42 int ch;
44 ch = *f->ptr - '0';
45 if ((unsigned) ch > 9) {
46 _trp(EDIGIT);
47 ch = 0;
49 return(ch);
52 int _nxtdig(f) struct file *f; {
53 int ch;
55 _incpt(f);
56 ch = *f->ptr - '0';
57 if ((unsigned) ch > 9)
58 return(-1);
59 return(ch);
62 int _getint(f) struct file *f; {
63 int is_signed,i,ch;
65 is_signed = _getsig(f);
66 ch = _fstdig(f);
67 i = 0;
69 i = i*10 - ch;
70 while ((ch = _nxtdig(f)) >= 0);
71 return(is_signed ? i : -i);
74 int _rdi(f) struct file *f; {
75 _rf(f);
76 _skipsp(f);
77 return(_getint(f));