modify upstream makefile to allow hardening build flags to apply
[debian/yforth] / udio.c
1 /* yForth? - A Forth interpreter written in ANSI C
2  * Copyright (C) 2012 Luca Padovani
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  * ------------------------------------------------------------------------
17  * Module name: udio.c
18  * Abstract:    User Device Input/Output functions. Here are enclosed all
19  *              non-portable functions.
20  */
21
22 #include "yforth.h"
23 #if HAVE_CONIO
24 #       include <conio.h>
25 #endif
26 #include "udio.h"
27
28 /* d_clrscr: clear the screen */
29 void d_clrscr() {
30 #if HAVE_CONIO
31         clrscr();
32 #endif
33 }
34
35 /* d_clreol: clear to end of line */
36 void d_clreol() {
37 #if HAVE_CONIO
38         clreol();
39 #endif
40 }
41
42 /* d_setattr: set default attributes */
43 void d_setaddr(Cell attr) {
44 #if HAVE_CONIO
45         textattr(attr);
46 #endif
47 }
48
49 /* d_getattr: get default attributes */
50 Cell d_getattr() {
51 #if HAVE_CONIO
52         struct text_info ti;
53         gettextinfo(&ti);
54         return (ti.attribute);
55 #endif
56 }
57
58 /* d_gotoxy: move the cursor to the location (x, y) of the screen */
59 void d_gotoxy(Cell x, Cell y) {
60 #if HAVE_CONIO
61         gotoxy(x, y);
62 #endif
63 }
64
65 /* d_wherex: current column position of the cursor */
66 Cell d_wherex() {
67 #if HAVE_CONIO
68         return (wherex());
69 #endif
70 }
71
72 /* d_wherey: current row position of the cursor */
73 Cell d_wherey() {
74 #if HAVE_CONIO
75         return (wherey());
76 #endif
77 }
78
79 /* d_getch: read a characted from the input device without displaying it and
80  * return as soon as the character is enteres (i.e. no wait for Carriage 
81  * Return
82  */
83 Char d_getch() {
84 #if HAVE_CONIO
85         return (getch());
86 #endif 
87 }
88
89 /* d_kbhit: return True if a character is available */
90 Cell d_kbhit() {
91 #if HAVE_CONIO
92         return (kbhit());
93 #endif
94 }
95
96 /* d_open: Initialize the Input/Output device */
97 void d_open() {
98 }
99
100 /* d_close: make some work when program finish to restore Input/Output device */
101 void d_close() {
102 }
103
104
105
106
107
108
109
110
111