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

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

Use standard integer types.

  • 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 void *memcpy(void *vp1, void *vp2, int16_t n);
17extern int16_t readbuf(int16_t dev, int8_t *buf);
18extern void writeln(int16_t unit, int8_t *buf);
19
20int8_t _ConBuf[258]; /* console input buffer */
21int16_t _CBused;
22
23int16_t _conin(int8_t *buff, int16_t len)
24{
25 int16_t nbp;
26 register int16_t 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.