source: buchla-68k/libcio/conin.c@ 0580615

Last change on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 =============================================================================
3 conin.c -- read from the console
4 Version 6 -- 1987-06-30 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define _FS_DEF_ /* to avoid unnecessary externals */
9
10#include "biosdefs.h"
11#include "io.h"
12#include "errno.h"
13#include "fcntl.h"
14#include "stddefs.h"
15
16extern char *memcpy(char *s1, char *s2, int n);
17extern int readbuf(int dev, char *buf);
18extern void writeln(int unit, char *buf);
19
20char _ConBuf[258]; /* console input buffer */
21int _CBused;
22
23int _conin(char *buff, int len)
24{
25 int nbp;
26 register int l;
27
28 if (_ConBuf[1] EQ 0) {
29
30 _ConBuf[0] = 255;
31 _ConBuf[1] = _ConBuf[2] = 0;
32
33 readbuf(CON_DEV, _ConBuf);
34 writeln(CON_DEV, "\r\n");
35
36 if (_ConBuf[2] EQ 0x1a) {
37
38 _ConBuf[1] = 0;
39 return(0);
40 }
41
42 nbp = ++_ConBuf[1];
43 _ConBuf[nbp++ + 1] = '\r';
44 _ConBuf[nbp + 1] = '\n';
45 _CBused = 2;
46 }
47
48 if ((l = _ConBuf[1]) > len)
49 l = len;
50
51 memcpy(buff, (_ConBuf + _CBused), l);
52 _CBused += l;
53 _ConBuf[1] -= l;
54 return (l);
55}
Note: See TracBrowser for help on using the repository browser.