ReactOS  0.4.12-dev-18-gf469aca
tmapldr.cpp
Go to the documentation of this file.
1 //Telnet Win32 : an ANSI telnet client.
3 //Copyright (C) 1998-2000 Paul Brannan
4 //Copyright (C) 1998 I.Ioannou
5 //Copyright (C) 1997 Brad Johnson
6 //
7 //This program is free software; you can redistribute it and/or
8 //modify it under the terms of the GNU General Public License
9 //as published by the Free Software Foundation; either version 2
10 //of the License, or (at your option) any later version.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 //GNU General Public License for more details.
16 //
17 //You should have received a copy of the GNU General Public License
18 //along with this program; if not, write to the Free Software
19 //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 //I.Ioannou
22 //roryt@hol.gr
23 //
25 
27 // Class TMapLoader - Key/Character Mappings //
28 // - Loads from telnet.cfg //
29 // originally part of KeyTrans.cpp //
31 
32 #include "precomp.h"
33 
34 // It's probably a good idea to turn off the "identifier was truncated" warning
35 // in MSVC (Paul Brannan 5/25/98)
36 #ifdef _MSC_VER
37 #pragma warning(disable: 4786)
38 #endif
39 
40 // AVS
41 // skip inline comments, empty lines
42 static char * getline(istream& i, char* buf, int size){
43 
44  int len = 0;
45 
46  while (1) {
47  memset(buf,0,size);
48  if (i.eof()) break;
49  i.getline(buf,size,'\n');
50 
51  while (buf[len]) {
52  if ( /*(buf[len]>=0) &&*/ buf[len]< ' ' ) buf[len] = ' ';
53  len++;
54  };
55  len = 0;
56 
57  // not so fast, but work ;)
58  while ( buf[len] ) {
59  if ( (buf[len] == ' ') && (buf[len+1] == ' ')) {
60  memmove(buf+len, buf+len+1, strlen(buf+len));
61  } else len++;
62  };
63 
64  if (buf[0] == ' ') memmove(buf, buf+1, size-1);
65 
66  // empty or comment
67  if ((buf[0]==0)||(buf[0]==';')) continue;
68 
69  len = 0; // look for comment like this one
70  while (buf[len])
71  if ((buf[len] == '/') && (buf[len+1] == '/')) buf[len] = 0;
72  else len++;
73 
74  if (len && (buf[len-1] == ' ')) {
75  len--;
76  buf[len]=0;
77  };
78  // in case for comment like this one (in line just a comment)
79  if (buf[0]==0) continue;
80 
81  break;
82  };
83  return (buf);
84 };
85 
86 //AVS
87 // use string as FIFO queue for lines
88 static int getline(string&str, char* buf, size_t sz) {
89 
90  if ( !str.length() ) return 0;
91  const char * p = strchr(str.c_str(),'\n');
92  unsigned int len; // Changed to unsigned (Paul Brannan 6/23/98)
93  if ( p==NULL )
94  len = str.length();
95  else
96  len = p - str.c_str();
97 
98  len = len<sz?len:sz-1;
99 
100  strncpy(buf,str.c_str(), len);
101  buf[len]=0;
102  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
103 #ifndef __BORLANDC__
104  str.erase(0, len + 1);
105 #else
106  str.remove(0,len+1);
107 #endif
108  return 1;
109 };
110 
111 //AVS
112 // parse \nnn and \Xhh
113 static int getbyte(const char*str) {
114  unsigned char retval = 0;
115  int base = 10;
116  int readed = 0;
117 
118  if ( (*str == 'x') || (*str == 'X') ) {
119  base = 16;
120  readed++;
121  };
122 
123  while (readed != 3 && str[readed]) {
124  unsigned char ch = toupper(str[readed]);
125  if ( isdigit(ch) ) {
126  retval = retval*base + (ch -'0');
127  } else if (base == 16 && ch >= 'A' && ch <= 'F') {
128  retval = retval*base + (ch-'A'+10);
129  } else {
130  return -1;
131  };
132  readed++;
133  };
134  // Ioannou: If we discard the 0x00 we can't undefine a key !!!
135  // if ( retval == 0 ) {
136  // return -1;
137  // };
138  return retval;
139 };
140 
141 //AVS
142 // a little optimization
143 DWORD Fix_ControlKeyState(char * Next_Token) {
144  if (stricmp(Next_Token, "RIGHT_ALT" ) == 0) return RIGHT_ALT_PRESSED;
145  if (stricmp(Next_Token, "LEFT_ALT" ) == 0) return LEFT_ALT_PRESSED;
146  if (stricmp(Next_Token, "RIGHT_CTRL") == 0) return RIGHT_CTRL_PRESSED;
147  if (stricmp(Next_Token, "LEFT_CTRL" ) == 0) return LEFT_CTRL_PRESSED;
148  if (stricmp(Next_Token, "SHIFT" ) == 0) return SHIFT_PRESSED;
149  if (stricmp(Next_Token, "NUMLOCK" ) == 0) return NUMLOCK_ON;
150  if (stricmp(Next_Token, "SCROLLLOCK") == 0) return SCROLLLOCK_ON;
151  if (stricmp(Next_Token, "CAPSLOCK" ) == 0) return CAPSLOCK_ON;
152  if (stricmp(Next_Token, "ENHANCED" ) == 0) return ENHANCED_KEY;
153 
154  // Paul Brannan 5/27/98
155  if (stricmp(Next_Token, "APP_KEY" ) == 0) return APP_KEY;
156  // Paul Brannan 6/28/98
157  if (stricmp(Next_Token, "APP2_KEY" ) == 0) return APP2_KEY;
158  // Paul Brannan 8/28/98
159  if (stricmp(Next_Token, "APP3_KEY" ) == 0) return APP3_KEY;
160  // Paul Brannan 12/9/98
161  if (stricmp(Next_Token, "APP4_KEY" ) == 0) return APP4_KEY;
162 
163  return 0;
164 }
165 
166 
167 // AVS
168 // rewrited to suppert \xhh notation, a little optimized
169 char* Fix_Tok(char * tok) {
170  static char s[256];
171  int i,j,n;
172 
173  // setmem is nonstandard; memset is standard (Paul Brannan 5/25/98)
174  memset(s, 0, 256);
175  // setmem(s, 256, 0);
176  i = j = n = 0;
177  if ( tok != NULL ) {
178  for ( ; tok[i] != 0; ) {
179  switch ( tok[i] ) {
180  case '\\' :
181  switch ( tok[i+1] ) {
182  case '\\':
183  s[j++] = '\\';
184  i += 2;
185  break;
186  default:
187  n = getbyte(tok+i+1);
188  if ( n < 0 )
189  s[j++] = tok[i++];
190  else {
191  s[j++]=n;
192  i += 4;
193  } ;
194  break;
195  };
196  break;
197  case '^' :
198  if ( tok[i+1] >= '@' ) {
199  s[j++] = tok[i+1] - '@';
200  i += 2;
201  break;
202  }
203  default :
204  s[j++] = tok[i++];
205  }
206  }
207  }
208  return s;
209 };
210 
211 // AVS
212 // perform 'normalization' for lines like [some text], and some checks
213 // maybe it will be done faster - but no time for it
214 int normalizeSplitter(string& buf) {
215  if ( buf.length() <= 2 ) return 0;
216  if ( buf[0] == '[' && buf[buf.length()-1] == ']' ) {
217  while ( buf[1] == ' ' )
218  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
219 #ifndef __BORLANDC__
220  buf.erase(1, 1);
221 #else
222  buf.remove(1,1);
223 #endif
224  while ( buf[buf.length()-2] == ' ' )
225  // Paul Brannan 6/23/98
226 #ifndef __BORLANDC__
227  buf.erase(buf.length()-2,1);
228 #else
229  buf.remove(buf.length()-2,1);
230 #endif
231  return 1;
232  }
233  return 0;
234 };
235 
236 // AVS
237 // looking for part in string array, see Load(..) for more info
238 int TMapLoader::LookForPart(stringArray& sa, const char* partType, const char* partName) {
239  if ( !sa.IsEmpty() ) {
240  string cmpbuf("[");
241  cmpbuf += partType;
242  cmpbuf += " ";
243  cmpbuf += partName;
244  cmpbuf += "]";
245  normalizeSplitter(cmpbuf); // if no parttype, [global] for example
246  int max = sa.GetItemsInContainer();
247  for ( int i = 0; i<max; i++ )
248  // I found some strange behavior if strnicmp was used here
249  if (strnicmp(cmpbuf.c_str(),sa[i].c_str(),cmpbuf.length()) == 0)
250  return i;
251  };
252  return INT_MAX;
253 };
254 
255 // AVS
256 // load globals to 'globals'
257 // in buf must be a [global] part of input file
259 
260  char wbuf[128];
261  while ( buf.length() ) {
262  wbuf[0]=0;
263  if (!getline(buf,wbuf,sizeof(wbuf))) break;
264  if ( wbuf[0]==0 ) break;
265  char* Name = strtok(wbuf, TOKEN_DELIMITERS);
266  if ( stricmp(Name, "[global]")==0 ) continue;
267 
268  char* Value = strtok(NULL, TOKEN_DELIMITERS);
269  if ( Value == NULL ) {
270  // cerr << "[global] -> no value for " << Name << endl;
271  printm(0, FALSE, MSG_KEYNOVAL, Name);
272  continue;
273  };
274  int val = atoi(Value);
275  if ( val > 0 && val <= 0xff ) {
276  if ( !KeyTrans.AddGlobalDef(val, Name)) return 0;
277  }
278  else {
279  // cerr << "[global] -> bad value for " << Name << endl;
280  printm(0, FALSE, MSG_KEYBADVAL, Name);
281  continue;
282  };
283  };
284  return 1;
285 };
286 
287 // AVS
288 // perform parsing of strings like 'VK_CODE shifts text'
289 // returns text on success
290 char* TMapLoader::ParseKeyDef(const char* buf, WORD& vk_code, DWORD& control) {
291  char wbuf[256];
292  strcpy(wbuf,buf);
293  char* ptr = strtok(wbuf, TOKEN_DELIMITERS);
294  if ( ptr == NULL ) return NULL;
295 
296  int i = KeyTrans.LookOnGlobal(ptr);
297  if ( i == INT_MAX ) return NULL;
298 
299  vk_code = KeyTrans.GetGlobalCode(i);
300 
301  control = 0;
302  DWORD st;
303  while (1) {
304  ptr = strtok(NULL, TOKEN_DELIMITERS);
305  if ((ptr == NULL) || ((st = Fix_ControlKeyState(ptr)) == 0)) break;
306  control |= st;
307  };
308 
309  if ( ptr == NULL ) return NULL;
310 
311  return Fix_Tok(ptr);
312 };
313 
314 // AVS
315 // load keymap to current map
316 // be aware - buf must passed by value, its destroyed
318 
319  char wbuf[128];
320  WORD vk_code;
321  DWORD control;
322  int i;
323 
324  // Paul Brannan Feb. 22, 1999
325  strcpy(wbuf, "VK_");
326  wbuf[4] = 0;
327  wbuf[3] = ini.get_escape_key();
328  i = KeyTrans.LookOnGlobal(wbuf);
329  if (i != INT_MAX) {
332  }
333  wbuf[3] = ini.get_scrollback_key();
334  i = KeyTrans.LookOnGlobal(wbuf);
335  if (i != INT_MAX) {
338  }
339  wbuf[3] = ini.get_dial_key();
340  i = KeyTrans.LookOnGlobal(wbuf);
341  if (i != INT_MAX) {
344  }
346 
347  while ( buf.length() ) {
348  wbuf[0] = 0;
349  if (!getline(buf,wbuf,sizeof(wbuf))) break;
350  if ( wbuf[0]==0 ) break;
351  if ( strnicmp(wbuf,"[keymap",7)==0 ) continue;
352 
353  char * keydef = ParseKeyDef(wbuf,vk_code,control);
354 
355  if ( keydef != NULL ) {
356 
357  // Check to see if keydef is a "special" code (Paul Brannan 3/29/00)
358  if(!strnicmp(keydef, "\\tn_escape", strlen("\\tn_escape"))) {
359  if(!KeyTrans.AddKeyDef(vk_code, control, TN_ESCAPE)) return 0;
360  } else if(!strnicmp(keydef, "\\tn_scrollback", strlen("\\tn_scrollback"))) {
361  if(!KeyTrans.AddKeyDef(vk_code, control, TN_SCROLLBACK)) return 0;
362  } else if(!strnicmp(keydef, "\\tn_dial", strlen("\\tn_dial"))) {
363  if(!KeyTrans.AddKeyDef(vk_code, control, TN_DIAL)) return 0;
364  } else if(!strnicmp(keydef, "\\tn_paste", strlen("\\tn_paste"))) {
365  if(!KeyTrans.AddKeyDef(vk_code, control, TN_PASTE)) return 0;
366  } else if(!strnicmp(keydef, "\\tn_null", strlen("\\tn_null"))) {
367  if(!KeyTrans.AddKeyDef(vk_code, control, TN_NULL)) return 0;
368  } else if(!strnicmp(keydef, "\\tn_cr", strlen("\\tn_cr"))) {
369  if(!KeyTrans.AddKeyDef(vk_code, control, TN_CR)) return 0;
370  } else if(!strnicmp(keydef, "\\tn_crlf", strlen("\\tn_crlf"))) {
371  if(!KeyTrans.AddKeyDef(vk_code, control, TN_CRLF)) return 0;
372  } else
373  if(!KeyTrans.AddKeyDef(vk_code,control,keydef)) return 0;
374  // else DeleteKeyDef() ???? - I'm not sure...
375  }
376  };
377 
378  return 1;
379 };
380 
381 // AVS
382 // load [charmap ...] part to xlat
384  char wbuf[128];
385  char charmapname[128];
386  charmapname[0] = 0;
387 
388  // xlat.init(); now it done by KeyTranslator::Load()
389 
390  while ( buf.length() ) {
391  wbuf[0]=0;
392  if (!getline(buf,wbuf,sizeof(wbuf))) break;
393  if ( wbuf[0]==0 ) break;
394  if ( strnicmp(wbuf,"[charmap",8)==0 ) {
395  strcpy(charmapname,wbuf);
396  continue;
397  };
398  char * host = strtok(wbuf, " ");
399  char * console = strtok(NULL, " ");
400 
401  int bHost;
402  int bConsole;
403 
404  if ( host == NULL || console == NULL ) {
405  // cerr << charmapname << " -> Bad structure" << endl;
406  printm(0, FALSE, MSG_KEYBADSTRUCT, charmapname);
407  return 0;
408  };
409  if ( strlen(host) > 1 && host[0] == '\\' )
410  bHost = getbyte(host+1);
411  else
412  bHost = (unsigned char)host[0];
413 
414  if ( strlen(console) > 1 && console[0] == '\\' )
415  bConsole = getbyte(console+1);
416  else
417  bConsole = (unsigned char)console[0];
418 
419  if ( bHost <= 0 || bConsole <= 0 ) {
420  // cerr << charmapname << " -> Bad chars? "
421  // << host << " -> " << console << endl;
422  printm(0, FALSE, MSG_KEYBADCHARS, charmapname, host, console);
423  return 0;
424  };
425  // xlat.table[bHost] = bConsole;
426  Charmap.modmap(bHost, 'B', bConsole);
427  };
428  return (Charmap.enabled = 1);
429 };
430 
431 // AVS
432 // ignore long comment [comment] ... [end comment]
433 // recursive!
434 int getLongComment(istream& is, char* wbuf, size_t sz) {
435 
436  int bufLen;
437  while ( is ) {
438  wbuf[0] = 0;
439  getline(is, wbuf, sz);
440  if ( wbuf[0]==0 ) return 1;
441  bufLen = strlen(wbuf);
442  if ( wbuf[0] == '[' && wbuf[bufLen-1] == ']' ) {
443  string temps(wbuf);
444 
445  if (!normalizeSplitter(temps)) {
446  // cerr << "Unexpected line '" << temps << "'\n";
447  printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
448  return 0;
449  };
450  if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
451  // do recursive call
452  if ( !getLongComment(is, wbuf, sz) ) return 0;
453  continue;
454  };
455  if ( stricmp(temps.c_str(),"[end comment]") == 0 ) return 1;
456  };
457  };
458  // we get a warning if we don't put a return here (Paul Brannan 5/25/98)
459  return 0;
460 };
461 
462 // AVS
463 // completelly rewrited to support new conceptions
464 int TMapLoader::Load(const char * filename, const char * szActiveEmul) {
465  char buf[256];
466  int bufLen;
467 
468  ifstream inpfile(filename);
470  Charmap.init();
471 
472  // it is an array for store [...] ... [end ...] parts from file
473  stringArray SA(0,0,sizeof(string));
474  int AllOk = 0;
475 
476  while ( inpfile ) {
477 
478  getline(inpfile, buf, 255);
479  bufLen = strlen(buf);
480  if ( !bufLen ) continue;
481 
482  if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
483  // is a part splitter [...]
484  string temps(buf);
485 
486  if (!normalizeSplitter(temps)) {
487  printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
488  AllOk = 0;
489  break;
490  };
491  // if a comment
492  if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
493 #ifdef KEYDEBUG
494  printit(temps.c_str());
495 #endif
496  if ( !getLongComment(inpfile, buf, sizeof(buf)) ) {
498  break;
499  };
500 #ifdef KEYDEBUG
501  printit("\r \r");
502 #endif
503  continue;
504  };
505 
506 
507  string back = temps;
508  // prepare line for make it as [end ...]
509  // and check it
510  if ( strnicmp(back.c_str(), "[global]", 8) == 0 ) {} // do nothing
511  else if ( strnicmp(back.c_str(), "[keymap", 7) == 0 ) {
512  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
513 #ifndef __BORLANDC__
514  back.erase(7);
515 #else
516  back.remove(7);
517 #endif
518  back += "]";
519  }
520  else if ( strnicmp(back.c_str(), "[charmap", 8) == 0 ) {
521  // Paul Brannan 6/23/98
522 #ifndef __BORLANDC__
523  back.erase(8);
524 #else
525  back.remove(8);
526 #endif
527  back += "]";
528  }
529  else if ( strnicmp(back.c_str(), "[config", 7) == 0 ) {
530  // Paul Brannan 6/23/98
531 #ifndef __BORLANDC__
532  back.erase(7);
533 #else
534  back.remove(7);
535 #endif
536  back += "]";
537  }
538  else {
539  // cerr << "Unexpected token " << back << endl;
540  printm(0, FALSE, MSG_KEYUNEXPTOK, back.c_str());
541  break;
542  };
543 
544  back.insert(1,"END "); // now it looks like [END ...]
545 #ifdef KEYDEBUG
546  printit(temps.c_str());
547 #endif
548 
549  int ok = 0;
550  // fetch it to temps
551  while ( 1 ) {
552  getline(inpfile, buf, sizeof(buf));
553  bufLen = strlen(buf);
554  if ( !bufLen ) break;
555  if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
556  string t(buf);
557  if ( !normalizeSplitter(t) ) break;
558 
559  if ( stricmp(t.c_str(),back.c_str()) == 0 ) {
560  ok = 1;
561  break;
562  };
563 
564  // AVS 31.12.97 fix [comment] block inside another block
565  if ( stricmp(t.c_str(),"[comment]") == 0 &&
566  getLongComment(inpfile, buf, sizeof(buf)) ) continue;
567 
568  break;
569  };
570  temps += "\n";
571  temps += buf;
572  };
573  if ( !ok ) {
574  // cerr << "Unexpected end of file or token" << endl;
576  AllOk = 0;
577  break;
578  };
579 #ifdef KEYDEBUG
580  printit("\r \r");
581 #endif
582  AllOk = SA.Add(temps);
583  if ( !AllOk ) break;
584  } else {
585  // cerr << "Unexpected line '" << buf << "'\n";
586  printm(0, FALSE, MSG_KEYUNEXPLINE, buf);
587  AllOk = 0;
588  break;
589  };
590  };
591 
592  inpfile.close();
593 
594  if ( !AllOk ) return 0;
595 
596  // now all file are in SA, comments are stripped
597 
598  int i = LookForPart(SA, "global", "");
599  if ( i == INT_MAX ) {
600  // cerr << "No [GLOBAL] definition!" << endl;
602  return 0;
603  };
604  if ( !LoadGlobal(SA[i]) ) {
605  return 0;
606  };
607 
608  // look for need configuration
609  i = LookForPart(SA, "config", szActiveEmul);
610  if ( i == INT_MAX ) {
611  // cerr << "No [CONFIG " << szActiveEmul << "]\n";
612  printm(0, FALSE, MSG_KEYNOCONFIG, szActiveEmul);
613  return 0;
614  };
615  // cerr << "use configuration: " << szActiveEmul << endl;
616  printm(0, FALSE, MSG_KEYUSECONFIG, szActiveEmul);
617  BOOL hadKeys = FALSE;
618 
619  string config = SA[i];
620  // parse it
621  while ( config.length() ) {
622  buf[0] = 0;
623  getline(config,buf,sizeof(buf));
624  bufLen = strlen(buf);
625  if ( !bufLen || (buf[0] == '[' && buf[bufLen-1] == ']') ) continue;
626  if ( strnicmp(buf,"keymap",6) == 0 ) {
627  string orig(buf);
628  printit("\t"); printit(buf); printit("\n");
629  char * mapdef = strtok(buf,":");
630  char * switchKey = strtok(NULL,"\n");
631 
632  if ( !KeyTrans.mapArray.IsEmpty() && switchKey == NULL ) {
633  // cerr << "no switch Key for '" << mapdef
634  // << "'" << endl;
635  printm(0, FALSE, MSG_KEYNOSWKEY, mapdef);
636  break;
637  };
638  if ( KeyTrans.mapArray.IsEmpty() ) {
639  if ( switchKey != NULL ) { // create default keymap
640  // cerr << "You cannot define switch key for default keymap -> ignored"
641  // << endl;
643  };
644  TKeyDef empty;
645  KeyTrans.mapArray.Add(KeyMap(string(mapdef)));
646  KeyTrans.switchMap(empty); // set it as current keymap
648  }
649  else {
650  string keydef(switchKey);
651  keydef += " !*!*!*"; // just for check
652  WORD vk_code;
653  DWORD control;
654  switchKey = ParseKeyDef(keydef.c_str(),vk_code,control);
655  if ( switchKey != NULL ) {
656  TKeyDef swi(NULL,control,vk_code);
657  if ( KeyTrans.switchMap(swi) > 0 ) {
658  // cerr << "Duplicate switching key\n";
660  break;
661  };
662  KeyTrans.mapArray.Add(KeyMap(swi, orig));
663  KeyTrans.switchMap(swi); // set it as current keymap
664  }
665  };
666  mapdef+=7; // 'keymap '
667  // now load defined keymaps to current
668  while ((mapdef != NULL)&&
669  (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
670  i = LookForPart(SA,"keymap",mapdef);
671  if ( i == INT_MAX ) {
672  // cerr << "Unknown KEYMAP " << mapdef << endl;
673  printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
674  } else {
675  mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
676  // so - save pointer!
677  hadKeys = LoadKeyMap(SA[i]); // load it
678  };
679  };
680 
681  }
682  else if ( strnicmp(buf,"charmap",7) == 0 ) {
683  printit("\t"); printit(buf); printit("\n");
684  char * mapdef = buf + 8;// 'charmap '
685  int SuccesLoaded = 0;
686  // now load defined charmaps to current
687  while ((mapdef != NULL)&&
688  (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
689  i = LookForPart(SA,"charmap",mapdef);
690  if ( i == INT_MAX ) {
691  // cerr << "Unknown KEYMAP " << mapdef << endl;
692  printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
693  } else {
694  mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
695  // so - save pointer!
696  if (LoadCharMap(SA[i])) // load it
697  SuccesLoaded++;
698  };
699  };
700  if (!SuccesLoaded) {
701  // cerr << "No charmaps loaded\n";
703  Charmap.init();
704  };
705  /* strtok(buf," ");
706 
707  char* name = strtok(NULL," ");
708  if ( name == NULL ) {
709  cerr << "No name for CHARMAP" << endl;
710  } else {
711  i = LookForPart(SA,"charmap", name);
712  if ( i == INT_MAX ) {
713  cerr << "Unknown CHARMAP " << name << endl;
714  } else {
715  LoadCharMap(SA[i]);
716  };
717  };
718  */
719  }
720  else {
721  // cerr << "unexpected token in " << szActiveEmul << endl;
722  printm(0, FALSE, MSG_KEYUNEXPTOKIN, szActiveEmul);
723  }
724  }
725 
726  if ( hadKeys) {
727  TKeyDef empty;
728  KeyTrans.switchMap(empty); // switch to default
729  KeyTrans.mainKeyMap = KeyTrans.currentKeyMap; // save it's number
730  // cerr << "There are " << (KeyTrans.mapArray.GetItemsInContainer()) << " maps\n";
731  char s[12]; // good enough for a long int (32-bit)
733  printm(0, FALSE, MSG_KEYNUMMAPS, s);
734  return 1;
735  };
736  return 0;
737 }
738 
740 
742  if (max == 0) {
744  return;
745  };
746  for ( int i = 0; i < max; i++ ) {
747  char buf[20];
748  itoa(i,buf,10);
749  printit("\t");
750  // Ioannou : we can show the current
751  if (KeyTrans.currentKeyMap == i)
752  printit("*");
753  else
754  printit(" ");
755  strcat(buf," ");
756  printit(buf);
757  char * msg = new char [KeyTrans.mapArray[i].orig.length()+1];
758  strcpy(msg,KeyTrans.mapArray[i].orig.c_str());
759  printit(msg);
760  delete[] msg;
761  printit("\n");
762  };
763 };
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define SCROLLLOCK_ON
Definition: wincon.h:137
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define max(a, b)
Definition: svc.c:63
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
int normalizeSplitter(string &buf)
Definition: tmapldr.cpp:214
#define INT_MAX
Definition: limits.h:40
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int enabled
Definition: tcharmap.h:37
#define APP_KEY
Definition: keytrans.h:41
int LookForPart(stringArray &sa, const char *partType, const char *partName)
Definition: tmapldr.cpp:238
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define APP4_KEY
Definition: keytrans.h:38
DWORD Fix_ControlKeyState(char *Next_Token)
Definition: tmapldr.cpp:143
#define MSG_KEYBADCHARS
Definition: resource.h:33
_Check_return_ _CRTIMP int __cdecl strnicmp(_In_z_ const char *_Str1, _In_z_ const char *_Str, _In_ size_t _MaxCount)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define MSG_KEYNOKEYMAPS
Definition: resource.h:47
char * host
Definition: whois.c:55
#define MSG_KEYNUMMAPS
Definition: resource.h:48
void modmap(char pos, char mapchar, char c)
Definition: tcharmap.cpp:212
GLdouble GLdouble t
Definition: gl.h:2047
#define MSG_KEYUNEXPEOF
Definition: resource.h:35
#define VK_INSERT
Definition: winuser.h:2186
int LoadKeyMap(string buf)
Definition: tmapldr.cpp:317
#define SHIFT_PRESSED
Definition: wincon.h:135
#define MSG_KEYUNEXPTOK
Definition: resource.h:36
const char * filename
Definition: ioapi.h:135
int mainKeyMap
Definition: keytrans.h:92
static const WCHAR empty[]
Definition: task.c:29
GLuint n
Definition: s_context.h:57
int getLongComment(istream &is, char *wbuf, size_t sz)
Definition: tmapldr.cpp:434
char * Fix_Tok(char *tok)
Definition: tmapldr.cpp:169
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define MSG_KEYUNEXP
Definition: resource.h:38
void DeleteAllDefs(void)
Definition: keytrans.cpp:193
#define APP3_KEY
Definition: keytrans.h:39
#define MSG_KEYNOGLOBAL
Definition: resource.h:39
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
#define MSG_KEYCANNOTDEF
Definition: resource.h:43
TCharmap & Charmap
Definition: tmapldr.h:93
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:27
#define isdigit(c)
Definition: acclib.h:68
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define ok(value,...)
Definition: CComObject.cpp:34
#define LEFT_ALT_PRESSED
Definition: wincon.h:132
TConfig ini
Definition: tnconfig.cpp:45
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
int toupper(int c)
Definition: utclib.c:881
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define APP2_KEY
Definition: keytrans.h:40
int currentKeyMap
Definition: keytrans.h:92
#define ENHANCED_KEY
Definition: wincon.h:139
static int getbyte(const char *str)
Definition: tmapldr.cpp:113
#define MSG_KEYNOCONFIG
Definition: resource.h:40
unsigned short WORD
Definition: ntddk_ex.h:93
#define MSG_KEYNOVAL
Definition: resource.h:30
unsigned long DWORD
Definition: ntddk_ex.h:95
_Self & getline(char_type *__s, streamsize __n, char_type delim)
Definition: _istream.c:754
int printit(const char *it)
Definition: tnerror.cpp:58
int switchMap(TKeyDef &tk)
Definition: keytrans.cpp:67
char get_scrollback_key() const
Definition: tnconfig.h:83
int LoadCharMap(string buf)
Definition: tmapldr.cpp:383
#define MSG_KEYDUPSWKEY
Definition: resource.h:44
#define LEFT_CTRL_PRESSED
Definition: wincon.h:134
bool eof() const
Definition: _ios_base.h:173
TArrayAsVector< KeyMap > mapArray
Definition: keytrans.h:84
Definition: tkeydef.h:19
DWORD GetGlobalCode(int i)
Definition: keytrans.h:90
GLenum GLsizei len
Definition: glext.h:6722
#define MSG_KEYNOSWKEY
Definition: resource.h:42
GLdouble s
Definition: gl.h:2039
void Display()
Definition: tmapldr.cpp:739
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
int LookOnGlobal(char *vkey)
Definition: keytrans.cpp:150
void init()
Definition: tcharmap.h:14
void close()
Definition: _fstream.h:519
Definition: tkeymap.h:17
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
#define MSG_KEYBADVAL
Definition: resource.h:31
#define MSG_KEYUNEXPTOKIN
Definition: resource.h:37
int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, char *lpzKeyDef)
Definition: keytrans.cpp:119
#define MSG_KEYUNEXPLINE
Definition: resource.h:34
int Add(const T &item)
Definition: stl_bids.h:38
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char get_escape_key() const
Definition: tnconfig.h:82
size_type GetItemsInContainer()
Definition: stl_bids.h:88
char * strchr(const char *String, int ch)
Definition: utclib.c:501
int LoadGlobal(string &buf)
Definition: tmapldr.cpp:258
#define msg(x)
Definition: auth_time.c:54
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
char get_dial_key() const
Definition: tnconfig.h:84
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define MSG_KEYNOCHARMAPS
Definition: resource.h:46
#define MSG_KEYBADSTRUCT
Definition: resource.h:32
char * ParseKeyDef(const char *buf, WORD &vk_code, DWORD &control)
Definition: tmapldr.cpp:290
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:133
int AddGlobalDef(WORD wVirtualKeyCode, char *lpzKeyDef)
Definition: keytrans.cpp:160
int Load(const char *filename, const char *szKeysetName)
Definition: tmapldr.cpp:464
GLfloat GLfloat p
Definition: glext.h:8902
#define MSG_KEYUNKNOWNMAP
Definition: resource.h:45
#define memset(x, y, z)
Definition: compat.h:39
#define MSG_KEYUSECONFIG
Definition: resource.h:41
int IsEmpty()
Definition: stl_bids.h:104
#define NUMLOCK_ON
Definition: wincon.h:136
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
#define CAPSLOCK_ON
Definition: wincon.h:138
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42
#define TOKEN_DELIMITERS
Definition: keytrans.h:26