Last change
on this file since bc11fc1 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 16 | extern void *memcpy(void *vp1, void *vp2, int16_t n);
|
---|
| 17 | extern int16_t readbuf(int16_t dev, int8_t *buf);
|
---|
| 18 | extern void writeln(int16_t unit, int8_t *buf);
|
---|
[f40a309] | 19 |
|
---|
[7258c6a] | 20 | int8_t _ConBuf[258]; /* console input buffer */
|
---|
| 21 | int16_t _CBused;
|
---|
[f40a309] | 22 |
|
---|
[7258c6a] | 23 | int16_t _conin(int8_t *buff, int16_t len)
|
---|
[f40a309] | 24 | {
|
---|
[7258c6a] | 25 | int16_t nbp;
|
---|
| 26 | register int16_t l;
|
---|
[f40a309] | 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.