/[LeafOK_CVS]/lbbs/src/io.c
ViewVC logotype

Contents of /lbbs/src/io.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sat Oct 23 18:41:41 2004 UTC (21 years, 4 months ago) by sysadm
Branch: MAIN
Changes since 1.1: +27 -9 lines
Content type: text/x-csrc
*** empty log message ***

1 /***************************************************************************
2 io.c - description
3 -------------------
4 begin : Mon Oct 18 2004
5 copyright : (C) 2004 by Leaflet
6 email : leaflet@leafok.com
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "io.h"
19 #include "common.h"
20 #include <stdio.h>
21 #include <stdarg.h>
22
23 int
24 outc(char c)
25 {
26 int retval;
27
28 retval = printf("%c",c);
29
30 return retval;
31 }
32
33 int
34 prints(const char * format, ...)
35 {
36 va_list args;
37 int retval;
38
39 va_start (args, format);
40 retval = vfprintf (stdout, format, args);
41 va_end (args);
42
43 return retval;
44 }
45
46 int
47 iflush()
48 {
49 int retval;
50
51 retval = fflush (stdout);
52
53 return retval;
54 }
55
56 int
57 igetch ()
58 {
59 char c, tmp[256];
60 static char buf[256];
61 int out = 0, loop = 1, in_esc = 0, in_ascii = 0, i = 0, j;
62 static int len =0 , pos = 0;
63
64 if (pos >= len)
65 {
66 len = s_receive (socket_client, buf, 255, "");
67 pos = 0;
68
69 //For debug
70 //for (j = 0; j < len; j++)
71 // log_std ("[%d]\n", buf[j]);
72 }
73
74 while (pos < len)
75 {
76 c = buf[pos++];
77
78 if (c == '\0')
79 {
80 out = c;
81 break;
82 }
83
84 if (c == ESC_KEY)
85 {
86 if (in_esc == 0)
87 {
88 in_esc = 1;
89 in_ascii = 1;
90 i = 0;
91 continue;
92 }
93 else
94 {
95 out = ESC_KEY;
96 in_esc = 0;
97 break;
98 }
99 }
100
101 in_esc = 0;
102
103 if (in_ascii)
104 {
105 tmp[i++] = c;
106 if (c == 'm')
107 {
108 in_ascii = 0;
109 continue;
110 }
111 if (i == 2 && c >= 'A' && c <= 'D')
112 {
113 in_ascii = 0;
114 switch (c)
115 {
116 case 'A':
117 out = KEY_UP;
118 break;
119 case 'B':
120 out = KEY_DOWN;
121 break;
122 case 'C':
123 out = KEY_RIGHT;
124 break;
125 case 'D':
126 out = KEY_LEFT;
127 break;
128 }
129 break;
130 }
131 if (i == 3 && tmp[0] == 91 && tmp[2] == 126)
132 {
133 in_ascii = 0;
134 switch (tmp[1])
135 {
136 case 49:
137 out = KEY_HOME;
138 break;
139 case 52:
140 out = KEY_END;
141 break;
142 case 53:
143 out = KEY_PGUP;
144 break;
145 case 54:
146 out = KEY_PGDOWN;
147 break;
148 }
149 break;
150 }
151 continue;
152 }
153
154 out = ((int)c + 256) % 256;
155 break;
156 }
157
158 //for debug
159 //log_std ("[%d]\n", out);
160
161 return out;
162 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1