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

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

Added include files for global functions and variables.

  • Property mode set to 100644
File size: 1.0 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 "all.h"
11
12extern void *memcpy(void *vp1, void *vp2, int16_t n);
13extern int16_t readbuf(int16_t dev, int8_t *buf);
14extern void writeln(int16_t unit, int8_t *buf);
15
16int8_t _ConBuf[258]; /* console input buffer */
17int16_t _CBused;
18
19int16_t _conin(int8_t *buff, int16_t len)
20{
21 int16_t nbp;
22 register int16_t l;
23
24 if (_ConBuf[1] EQ 0) {
25
26 _ConBuf[0] = 255;
27 _ConBuf[1] = _ConBuf[2] = 0;
28
29 readbuf(CON_DEV, _ConBuf);
30 writeln(CON_DEV, "\r\n");
31
32 if (_ConBuf[2] EQ 0x1a) {
33
34 _ConBuf[1] = 0;
35 return(0);
36 }
37
38 nbp = ++_ConBuf[1];
39 _ConBuf[nbp++ + 1] = '\r';
40 _ConBuf[nbp + 1] = '\n';
41 _CBused = 2;
42 }
43
44 if ((l = _ConBuf[1]) > len)
45 l = len;
46
47 memcpy(buff, (_ConBuf + _CBused), l);
48 _CBused += l;
49 _ConBuf[1] -= l;
50 return (l);
51}
52
Note: See TracBrowser for help on using the repository browser.