1 | /*---------------------------------*C*--------------------------------------* |
1 | /*---------------------------------*C*--------------------------------------* |
2 | * File: grkelot.c |
2 | * File: grkelot.c |
3 | *--------------------------------------------------------------------------* |
3 | *--------------------------------------------------------------------------* |
4 | * $Id: grkelot.C,v 1.2 2003/11/24 17:31:27 pcg Exp $ |
4 | * $Id: grkelot.C,v 1.3 2004/01/31 00:20:21 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1994,1995 Angelo Haritsis. All rights reserved. |
7 | * Copyright (c) 1994,1995 Angelo Haritsis. All rights reserved. |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1997,1998 Oezger Kesim <kesim@math.fu-berlin.de> |
9 | * Copyright (c) 1997,1998 Oezger Kesim <kesim@math.fu-berlin.de> |
… | |
… | |
162 | static void kstate_add_xlat(char *str); |
162 | static void kstate_add_xlat(char *str); |
163 | static void kstate_add_switcher(char *str); |
163 | static void kstate_add_switcher(char *str); |
164 | static void kstate_set_life(char *str); |
164 | static void kstate_set_life(char *str); |
165 | |
165 | |
166 | /* --- Functions ------------- */ |
166 | /* --- Functions ------------- */ |
167 | /* INTPROTO */ |
|
|
168 | void |
167 | void |
169 | kstate_setcurr(int stateno) |
168 | kstate_setcurr(int stateno) |
170 | { |
169 | { |
171 | u_char prev_state; |
170 | u_char prev_state; |
172 | |
171 | |
… | |
… | |
178 | prev_state = nStateNow; |
177 | prev_state = nStateNow; |
179 | pStateNow = &State[nStateNow = stateno]; |
178 | pStateNow = &State[nStateNow = stateno]; |
180 | pStateNow->prev_state = prev_state; |
179 | pStateNow->prev_state = prev_state; |
181 | } |
180 | } |
182 | |
181 | |
183 | /* INTPROTO */ |
|
|
184 | void |
182 | void |
185 | kstate_init(void) |
183 | kstate_init(void) |
186 | { |
184 | { |
187 | pStateNow->num_xlat = pStateNow->num_switcher = pStateNow->life = pStateNow->prev_state = 0; |
185 | pStateNow->num_xlat = pStateNow->num_switcher = pStateNow->life = pStateNow->prev_state = 0; |
188 | pStateNow->xlat = NULL; |
186 | pStateNow->xlat = NULL; |
189 | } |
187 | } |
190 | |
188 | |
191 | /* INTPROTO */ |
|
|
192 | void |
189 | void |
193 | kstate_end(void) |
190 | kstate_end(void) |
194 | { |
191 | { |
195 | int i; |
192 | int i; |
196 | |
193 | |
… | |
… | |
202 | |
199 | |
203 | /* |
200 | /* |
204 | * Hard coded ELOT-928 translations. Could read these from an rc-type file |
201 | * Hard coded ELOT-928 translations. Could read these from an rc-type file |
205 | * to support other remappers. |
202 | * to support other remappers. |
206 | */ |
203 | */ |
207 | /* INTPROTO */ |
|
|
208 | void |
204 | void |
209 | kstate_init_all(int greek_mode) |
205 | kstate_init_all(int greek_mode) |
210 | { |
206 | { |
211 | /* the translation tables for the 4 FSM states for ELOT-928 mappings */ |
207 | /* the translation tables for the 4 FSM states for ELOT-928 mappings */ |
212 | int i; |
208 | int i; |
… | |
… | |
238 | kstate_setcurr(3); |
234 | kstate_setcurr(3); |
239 | kstate_add_xlat(xlat_now->acc_uml); |
235 | kstate_add_xlat(xlat_now->acc_uml); |
240 | kstate_set_life("L1"); |
236 | kstate_set_life("L1"); |
241 | } |
237 | } |
242 | |
238 | |
243 | /* INTPROTO */ |
|
|
244 | void |
239 | void |
245 | kstate_end_all(void) |
240 | kstate_end_all(void) |
246 | { |
241 | { |
247 | int i; |
242 | int i; |
248 | |
243 | |
… | |
… | |
254 | } |
249 | } |
255 | |
250 | |
256 | /* |
251 | /* |
257 | * reset FSM |
252 | * reset FSM |
258 | */ |
253 | */ |
259 | /* INTPROTO */ |
|
|
260 | void |
254 | void |
261 | kstate_reset(void) |
255 | kstate_reset(void) |
262 | { |
256 | { |
263 | kstate_setcurr(0); |
257 | kstate_setcurr(0); |
264 | } |
258 | } |
265 | |
259 | |
266 | /* INTPROTO */ |
|
|
267 | void |
260 | void |
268 | kstate_add_xlat(char *str) |
261 | kstate_add_xlat(char *str) |
269 | { |
262 | { |
270 | K_XLAT *xlat; |
263 | K_XLAT *xlat; |
271 | u_int *pval_tmp; |
264 | u_int *pval_tmp; |
… | |
… | |
295 | } |
288 | } |
296 | |
289 | |
297 | /* |
290 | /* |
298 | * Ascii only for this implementation |
291 | * Ascii only for this implementation |
299 | */ |
292 | */ |
300 | /* INTPROTO */ |
|
|
301 | void |
293 | void |
302 | kstate_add_switcher(char *str) |
294 | kstate_add_switcher(char *str) |
303 | { |
295 | { |
304 | K_SWITCH *switcher; |
296 | K_SWITCH *switcher; |
305 | |
297 | |
… | |
… | |
317 | switcher->on = 0; |
309 | switcher->on = 0; |
318 | pStateNow->num_switcher++; |
310 | pStateNow->num_switcher++; |
319 | } |
311 | } |
320 | |
312 | |
321 | /* L1 or L0 */ |
313 | /* L1 or L0 */ |
322 | /* INTPROTO */ |
|
|
323 | void |
314 | void |
324 | kstate_set_life(char *str) |
315 | kstate_set_life(char *str) |
325 | { |
316 | { |
326 | pStateNow->life = atoi(&str[1]); |
317 | pStateNow->life = atoi(&str[1]); |
327 | } |
318 | } |
328 | |
319 | |
329 | /* INTPROTO */ |
|
|
330 | unsigned int |
320 | unsigned int |
331 | kstate_cxlat(unsigned int c) |
321 | kstate_cxlat(unsigned int c) |
332 | { |
322 | { |
333 | int i; |
323 | int i; |
334 | |
324 | |
… | |
… | |
351 | kstate_setcurr(pStateNow->prev_state); |
341 | kstate_setcurr(pStateNow->prev_state); |
352 | return (c); |
342 | return (c); |
353 | } |
343 | } |
354 | |
344 | |
355 | #ifdef RXVT |
345 | #ifdef RXVT |
356 | /* EXTPROTO */ |
|
|
357 | void |
346 | void |
358 | greek_init(void) |
347 | greek_init(void) |
359 | { |
348 | { |
360 | kstate_init_all(GreekMode); |
349 | kstate_init_all(GreekMode); |
361 | } |
350 | } |
362 | |
351 | |
363 | /* EXTPROTO */ |
|
|
364 | void |
352 | void |
365 | greek_end(void) |
353 | greek_end(void) |
366 | { |
354 | { |
367 | kstate_end_all(); |
355 | kstate_end_all(); |
368 | } |
356 | } |
369 | |
357 | |
370 | /* EXTPROTO */ |
|
|
371 | void |
358 | void |
372 | greek_reset(void) |
359 | greek_reset(void) |
373 | { |
360 | { |
374 | kstate_reset(); |
361 | kstate_reset(); |
375 | } |
362 | } |
376 | |
363 | |
377 | /* EXTPROTO */ |
|
|
378 | void |
364 | void |
379 | greek_setmode(int greek_mode) |
365 | greek_setmode(int greek_mode) |
380 | { |
366 | { |
381 | GreekMode = greek_mode; |
367 | GreekMode = greek_mode; |
382 | } |
368 | } |
383 | |
369 | |
384 | /* EXTPROTO */ |
|
|
385 | int |
370 | int |
386 | greek_getmode(void) |
371 | greek_getmode(void) |
387 | { |
372 | { |
388 | return (GreekMode); |
373 | return (GreekMode); |
389 | } |
374 | } |
390 | |
375 | |
391 | /* |
376 | /* |
392 | * xlate a given string in-place - return new string length |
377 | * xlate a given string in-place - return new string length |
393 | */ |
378 | */ |
394 | /* EXTPROTO */ |
|
|
395 | int |
379 | int |
396 | greek_xlat(char *s, int num_chars) |
380 | greek_xlat(char *s, int num_chars) |
397 | { |
381 | { |
398 | int i, count; |
382 | int i, count; |
399 | unsigned int c; |
383 | unsigned int c; |