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

Contents of /lbbs/src/io.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Oct 22 15:21:28 2004 UTC (21 years, 4 months ago) by sysadm
Branch: MAIN
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 Ctrl (char c)
58 {
59 return (c - 'A' + 1);
60 }
61
62 int
63 igetch ()
64 {
65 char c, tmp[256];
66 static char buf[256];
67 int out = 0, loop = 1, in_esc = 0, in_ascii = 0, i = 0;
68 static int len =0 , pos = 0;
69
70 if (pos >= len)
71 {
72 len = s_receive (socket_client, buf, 255, "");
73 pos = 0;
74 }
75
76 while (pos < len)
77 {
78 c = buf[pos++];
79
80 if (c == '\0')
81 {
82 out = c;
83 break;
84 }
85
86 if (c == ESC_KEY)
87 {
88 if (in_esc == 0)
89 {
90 in_esc = 1;
91 in_ascii = 1;
92 i = 0;
93 continue;
94 }
95 else
96 {
97 out = ESC_KEY;
98 in_esc = 0;
99 break;
100 }
101 }
102
103 in_esc = 0;
104
105 if (in_ascii)
106 {
107 tmp[i++] = c;
108 if (c == 'm')
109 {
110 in_ascii = 0;
111 continue;
112 }
113 if (i == 2 && c >= 'A' && c <= 'D')
114 {
115 in_ascii = 0;
116 switch (c)
117 {
118 case 'A':
119 out = KEY_UP;
120 break;
121 case 'B':
122 out = KEY_DOWN;
123 break;
124 case 'C':
125 out = KEY_LEFT;
126 break;
127 case 'D':
128 out = KEY_RIGHT;
129 break;
130 }
131 break;
132 }
133 continue;
134 }
135
136 out = ((int)c + 256) % 256;
137 break;
138 }
139
140 //for debug
141 //log_std ("[%d]\n", out);
142
143 return out;
144 }

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