00001
00007
00008
00009 #define EMPTY (-1)
00010 #define EOF (-2)
00011 #define TTY_IOC_NEXTC 0x0028
00012
00013 static int getch(int, int *);
00014 static int ungetch(int, int *);
00015 extern int _doscan(register char *, register int **, int (*)(), int (*)(), int, int);
00016
00024 int fscanf(int dev, char *fmt, int args)
00025 {
00026 int buf;
00027
00028 buf = EMPTY;
00029 return(_doscan(fmt, (int **)&args, getch, ungetch, dev,(int) (int)&buf));
00030 }
00031
00037 static int getch(int dev, int *buf)
00038 {
00039 if( *buf != EOF && *buf != EMPTY)
00040 { *buf = getc(dev); }
00041 if( *buf != EOF )
00042 { *buf = control(dev, TTY_IOC_NEXTC, 0, 0); }
00043 return(*buf);
00044 }
00045
00051 static int ungetch(int dev, int *buf)
00052 {
00053 *buf = EMPTY;
00054 return(*buf);
00055 }