ReactOS  0.4.13-dev-464-g6b95727
TMapLoader Class Reference

#include <tmapldr.h>

Collaboration diagram for TMapLoader:

Public Member Functions

 TMapLoader (KeyTranslator &RefKeyTrans, TCharmap &RefCharmap)
 
 ~TMapLoader ()
 
int Load (const char *filename, const char *szKeysetName)
 
void Display ()
 

Private Member Functions

int LookForPart (stringArray &sa, const char *partType, const char *partName)
 
charParseKeyDef (const char *buf, WORD &vk_code, DWORD &control)
 
int LoadGlobal (string &buf)
 
int LoadKeyMap (string buf)
 
int LoadCharMap (string buf)
 

Private Attributes

KeyTranslatorKeyTrans
 
TCharmapCharmap
 

Detailed Description

Definition at line 79 of file tmapldr.h.

Constructor & Destructor Documentation

◆ TMapLoader()

TMapLoader::TMapLoader ( KeyTranslator RefKeyTrans,
TCharmap RefCharmap 
)
inline

Definition at line 81 of file tmapldr.h.

81  :
82  KeyTrans(RefKeyTrans), Charmap(RefCharmap) {}
TCharmap & Charmap
Definition: tmapldr.h:93
KeyTranslator & KeyTrans
Definition: tmapldr.h:92

◆ ~TMapLoader()

TMapLoader::~TMapLoader ( )
inline

Definition at line 83 of file tmapldr.h.

83 {}

Member Function Documentation

◆ Display()

void TMapLoader::Display ( )

Definition at line 741 of file tmapldr.cpp.

741  {
742 
744  if (max == 0) {
746  return;
747  };
748  for ( int i = 0; i < max; i++ ) {
749  char buf[20];
750  itoa(i,buf,10);
751  printit("\t");
752  // Ioannou : we can show the current
753  if (KeyTrans.currentKeyMap == i)
754  printit("*");
755  else
756  printit(" ");
757  strcat(buf," ");
758  printit(buf);
759  char * msg = new char [KeyTrans.mapArray[i].orig.length()+1];
760  strcpy(msg,KeyTrans.mapArray[i].orig.c_str());
761  printit(msg);
762  delete[] msg;
763  printit("\n");
764  };
765 };
#define max(a, b)
Definition: svc.c:63
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MSG_KEYNOKEYMAPS
Definition: resource.h:47
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
int currentKeyMap
Definition: keytrans.h:92
int printit(const char *it)
Definition: tnerror.cpp:58
TArrayAsVector< KeyMap > mapArray
Definition: keytrans.h:84
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
size_type GetItemsInContainer()
Definition: stl_bids.h:88
#define msg(x)
Definition: auth_time.c:54
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by Telnet::DisplayKeyMap().

◆ Load()

int TMapLoader::Load ( const char filename,
const char szKeysetName 
)

Definition at line 466 of file tmapldr.cpp.

466  {
467  char buf[256];
468  int bufLen;
469 
470  ifstream inpfile(filename);
472  Charmap.init();
473 
474  // it is an array for store [...] ... [end ...] parts from file
475  stringArray SA(0,0,sizeof(string));
476  int AllOk = 0;
477 
478  while ( inpfile ) {
479 
480  getline(inpfile, buf, 255);
481  bufLen = strlen(buf);
482  if ( !bufLen ) continue;
483 
484  if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
485  // is a part splitter [...]
486  string temps(buf);
487 
488  if (!normalizeSplitter(temps)) {
489  printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
490  AllOk = 0;
491  break;
492  };
493  // if a comment
494  if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
495 #ifdef KEYDEBUG
496  printit(temps.c_str());
497 #endif
498  if ( !getLongComment(inpfile, buf, sizeof(buf)) ) {
500  break;
501  };
502 #ifdef KEYDEBUG
503  printit("\r \r");
504 #endif
505  continue;
506  };
507 
508 
509  string back = temps;
510  // prepare line for make it as [end ...]
511  // and check it
512  if ( strnicmp(back.c_str(), "[global]", 8) == 0 ) {} // do nothing
513  else if ( strnicmp(back.c_str(), "[keymap", 7) == 0 ) {
514  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
515 #ifndef __BORLANDC__
516  back.erase(7);
517 #else
518  back.remove(7);
519 #endif
520  back += "]";
521  }
522  else if ( strnicmp(back.c_str(), "[charmap", 8) == 0 ) {
523  // Paul Brannan 6/23/98
524 #ifndef __BORLANDC__
525  back.erase(8);
526 #else
527  back.remove(8);
528 #endif
529  back += "]";
530  }
531  else if ( strnicmp(back.c_str(), "[config", 7) == 0 ) {
532  // Paul Brannan 6/23/98
533 #ifndef __BORLANDC__
534  back.erase(7);
535 #else
536  back.remove(7);
537 #endif
538  back += "]";
539  }
540  else {
541  // cerr << "Unexpected token " << back << endl;
542  printm(0, FALSE, MSG_KEYUNEXPTOK, back.c_str());
543  break;
544  };
545 
546  back.insert(1,"END "); // now it looks like [END ...]
547 #ifdef KEYDEBUG
548  printit(temps.c_str());
549 #endif
550 
551  int ok = 0;
552  // fetch it to temps
553  while ( 1 ) {
554  getline(inpfile, buf, sizeof(buf));
555  bufLen = strlen(buf);
556  if ( !bufLen ) break;
557  if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
558  string t(buf);
559  if ( !normalizeSplitter(t) ) break;
560 
561  if ( stricmp(t.c_str(),back.c_str()) == 0 ) {
562  ok = 1;
563  break;
564  };
565 
566  // AVS 31.12.97 fix [comment] block inside another block
567  if ( stricmp(t.c_str(),"[comment]") == 0 &&
568  getLongComment(inpfile, buf, sizeof(buf)) ) continue;
569 
570  break;
571  };
572  temps += "\n";
573  temps += buf;
574  };
575  if ( !ok ) {
576  // cerr << "Unexpected end of file or token" << endl;
578  AllOk = 0;
579  break;
580  };
581 #ifdef KEYDEBUG
582  printit("\r \r");
583 #endif
584  AllOk = SA.Add(temps);
585  if ( !AllOk ) break;
586  } else {
587  // cerr << "Unexpected line '" << buf << "'\n";
589  AllOk = 0;
590  break;
591  };
592  };
593 
594  inpfile.close();
595 
596  if ( !AllOk ) return 0;
597 
598  // now all file are in SA, comments are stripped
599 
600  int i = LookForPart(SA, "global", "");
601  if ( i == INT_MAX ) {
602  // cerr << "No [GLOBAL] definition!" << endl;
604  return 0;
605  };
606  if ( !LoadGlobal(SA[i]) ) {
607  return 0;
608  };
609 
610  // look for need configuration
611  i = LookForPart(SA, "config", szActiveEmul);
612  if ( i == INT_MAX ) {
613  // cerr << "No [CONFIG " << szActiveEmul << "]\n";
614  printm(0, FALSE, MSG_KEYNOCONFIG, szActiveEmul);
615  return 0;
616  };
617  // cerr << "use configuration: " << szActiveEmul << endl;
618  printm(0, FALSE, MSG_KEYUSECONFIG, szActiveEmul);
619  BOOL hadKeys = FALSE;
620 
621  string config = SA[i];
622  // parse it
623  while ( config.length() ) {
624  buf[0] = 0;
625  getline(config,buf,sizeof(buf));
626  bufLen = strlen(buf);
627  if ( !bufLen || (buf[0] == '[' && buf[bufLen-1] == ']') ) continue;
628  if ( strnicmp(buf,"keymap",6) == 0 ) {
629  string orig(buf);
630  printit("\t"); printit(buf); printit("\n");
631  char * mapdef = strtok(buf,":");
632  char * switchKey = strtok(NULL,"\n");
633 
634  if ( !KeyTrans.mapArray.IsEmpty() && switchKey == NULL ) {
635  // cerr << "no switch Key for '" << mapdef
636  // << "'" << endl;
637  printm(0, FALSE, MSG_KEYNOSWKEY, mapdef);
638  break;
639  };
640  if ( KeyTrans.mapArray.IsEmpty() ) {
641  if ( switchKey != NULL ) { // create default keymap
642  // cerr << "You cannot define switch key for default keymap -> ignored"
643  // << endl;
645  };
646  TKeyDef empty;
647  KeyTrans.mapArray.Add(KeyMap(string(mapdef)));
648  KeyTrans.switchMap(empty); // set it as current keymap
650  }
651  else {
652  string keydef(switchKey);
653  keydef += " !*!*!*"; // just for check
654  WORD vk_code;
655  DWORD control;
656  switchKey = ParseKeyDef(keydef.c_str(),vk_code,control);
657  if ( switchKey != NULL ) {
658  TKeyDef swi(NULL,control,vk_code);
659  if ( KeyTrans.switchMap(swi) > 0 ) {
660  // cerr << "Duplicate switching key\n";
662  break;
663  };
664  KeyTrans.mapArray.Add(KeyMap(swi, orig));
665  KeyTrans.switchMap(swi); // set it as current keymap
666  }
667  };
668  mapdef+=7; // 'keymap '
669  // now load defined keymaps to current
670  while ((mapdef != NULL)&&
671  (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
672  i = LookForPart(SA,"keymap",mapdef);
673  if ( i == INT_MAX ) {
674  // cerr << "Unknown KEYMAP " << mapdef << endl;
675  printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
676  } else {
677  mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
678  // so - save pointer!
679  hadKeys = LoadKeyMap(SA[i]); // load it
680  };
681  };
682 
683  }
684  else if ( strnicmp(buf,"charmap",7) == 0 ) {
685  printit("\t"); printit(buf); printit("\n");
686  char * mapdef = buf + 8;// 'charmap '
687  int SuccesLoaded = 0;
688  // now load defined charmaps to current
689  while ((mapdef != NULL)&&
690  (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
691  i = LookForPart(SA,"charmap",mapdef);
692  if ( i == INT_MAX ) {
693  // cerr << "Unknown KEYMAP " << mapdef << endl;
694  printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
695  } else {
696  mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
697  // so - save pointer!
698  if (LoadCharMap(SA[i])) // load it
699  SuccesLoaded++;
700  };
701  };
702  if (!SuccesLoaded) {
703  // cerr << "No charmaps loaded\n";
705  Charmap.init();
706  };
707  /* strtok(buf," ");
708 
709  char* name = strtok(NULL," ");
710  if ( name == NULL ) {
711  cerr << "No name for CHARMAP" << endl;
712  } else {
713  i = LookForPart(SA,"charmap", name);
714  if ( i == INT_MAX ) {
715  cerr << "Unknown CHARMAP " << name << endl;
716  } else {
717  LoadCharMap(SA[i]);
718  };
719  };
720  */
721  }
722  else {
723  // cerr << "unexpected token in " << szActiveEmul << endl;
724  printm(0, FALSE, MSG_KEYUNEXPTOKIN, szActiveEmul);
725  }
726  }
727 
728  if ( hadKeys) {
729  TKeyDef empty;
730  KeyTrans.switchMap(empty); // switch to default
731  KeyTrans.mainKeyMap = KeyTrans.currentKeyMap; // save it's number
732  // cerr << "There are " << (KeyTrans.mapArray.GetItemsInContainer()) << " maps\n";
733  char s[12]; // good enough for a long int (32-bit)
736  return 1;
737  };
738  return 0;
739 }
int normalizeSplitter(string &buf)
Definition: tmapldr.cpp:216
#define INT_MAX
Definition: limits.h:40
int LookForPart(stringArray &sa, const char *partType, const char *partName)
Definition: tmapldr.cpp:240
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP int __cdecl strnicmp(_In_z_ const char *_Str1, _In_z_ const char *_Str, _In_ size_t _MaxCount)
static const WCHAR empty[]
Definition: main.c:49
#define MSG_KEYNUMMAPS
Definition: resource.h:48
GLdouble GLdouble t
Definition: gl.h:2047
#define MSG_KEYUNEXPEOF
Definition: resource.h:35
int LoadKeyMap(string buf)
Definition: tmapldr.cpp:319
#define MSG_KEYUNEXPTOK
Definition: resource.h:36
const char * filename
Definition: ioapi.h:135
int mainKeyMap
Definition: keytrans.h:92
int getLongComment(istream &is, char *wbuf, size_t sz)
Definition: tmapldr.cpp:436
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MSG_KEYUNEXP
Definition: resource.h:38
void DeleteAllDefs(void)
Definition: keytrans.cpp:193
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MSG_KEYNOGLOBAL
Definition: resource.h:39
#define ok(value,...)
#define MSG_KEYCANNOTDEF
Definition: resource.h:43
TCharmap & Charmap
Definition: tmapldr.h:93
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
int currentKeyMap
Definition: keytrans.h:92
#define MSG_KEYNOCONFIG
Definition: resource.h:40
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
int printit(const char *it)
Definition: tnerror.cpp:58
int switchMap(TKeyDef &tk)
Definition: keytrans.cpp:67
int LoadCharMap(string buf)
Definition: tmapldr.cpp:385
#define MSG_KEYDUPSWKEY
Definition: resource.h:44
TArrayAsVector< KeyMap > mapArray
Definition: keytrans.h:84
#define MSG_KEYNOSWKEY
Definition: resource.h:42
GLdouble s
Definition: gl.h:2039
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
void init()
Definition: tcharmap.h:14
Definition: tkeymap.h:17
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
#define MSG_KEYUNEXPTOKIN
Definition: resource.h:37
#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
size_type GetItemsInContainer()
Definition: stl_bids.h:88
int LoadGlobal(string &buf)
Definition: tmapldr.cpp:260
#define MSG_KEYNOCHARMAPS
Definition: resource.h:46
char * ParseKeyDef(const char *buf, WORD &vk_code, DWORD &control)
Definition: tmapldr.cpp:292
#define MSG_KEYUNKNOWNMAP
Definition: resource.h:45
#define MSG_KEYUSECONFIG
Definition: resource.h:41
int IsEmpty()
Definition: stl_bids.h:104
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42
#define TOKEN_DELIMITERS
Definition: keytrans.h:26

Referenced by Telnet::LoadKeyMap().

◆ LoadCharMap()

int TMapLoader::LoadCharMap ( string  buf)
private

Definition at line 385 of file tmapldr.cpp.

385  {
386  char wbuf[128];
387  char charmapname[128];
388  charmapname[0] = 0;
389 
390  // xlat.init(); now it done by KeyTranslator::Load()
391 
392  while ( buf.length() ) {
393  wbuf[0]=0;
394  if (!getline(buf,wbuf,sizeof(wbuf))) break;
395  if ( wbuf[0]==0 ) break;
396  if ( strnicmp(wbuf,"[charmap",8)==0 ) {
397  strcpy(charmapname,wbuf);
398  continue;
399  };
400  char * host = strtok(wbuf, " ");
401  char * console = strtok(NULL, " ");
402 
403  int bHost;
404  int bConsole;
405 
406  if ( host == NULL || console == NULL ) {
407  // cerr << charmapname << " -> Bad structure" << endl;
408  printm(0, FALSE, MSG_KEYBADSTRUCT, charmapname);
409  return 0;
410  };
411  if ( strlen(host) > 1 && host[0] == '\\' )
412  bHost = getbyte(host+1);
413  else
414  bHost = (unsigned char)host[0];
415 
416  if ( strlen(console) > 1 && console[0] == '\\' )
417  bConsole = getbyte(console+1);
418  else
419  bConsole = (unsigned char)console[0];
420 
421  if ( bHost <= 0 || bConsole <= 0 ) {
422  // cerr << charmapname << " -> Bad chars? "
423  // << host << " -> " << console << endl;
424  printm(0, FALSE, MSG_KEYBADCHARS, charmapname, host, console);
425  return 0;
426  };
427  // xlat.table[bHost] = bConsole;
428  Charmap.modmap(bHost, 'B', bConsole);
429  };
430  return (Charmap.enabled = 1);
431 };
int enabled
Definition: tcharmap.h:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#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 * host
Definition: whois.c:55
void modmap(char pos, char mapchar, char c)
Definition: tcharmap.cpp:212
TCharmap & Charmap
Definition: tmapldr.h:93
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
static int getbyte(const char *str)
Definition: tmapldr.cpp:115
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define MSG_KEYBADSTRUCT
Definition: resource.h:32
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42

Referenced by Load().

◆ LoadGlobal()

int TMapLoader::LoadGlobal ( string buf)
private

Definition at line 260 of file tmapldr.cpp.

260  {
261 
262  char wbuf[128];
263  while ( buf.length() ) {
264  wbuf[0]=0;
265  if (!getline(buf,wbuf,sizeof(wbuf))) break;
266  if ( wbuf[0]==0 ) break;
267  char* Name = strtok(wbuf, TOKEN_DELIMITERS);
268  if ( stricmp(Name, "[global]")==0 ) continue;
269 
270  char* Value = strtok(NULL, TOKEN_DELIMITERS);
271  if ( Value == NULL ) {
272  // cerr << "[global] -> no value for " << Name << endl;
274  continue;
275  };
276  int val = atoi(Value);
277  if ( val > 0 && val <= 0xff ) {
278  if ( !KeyTrans.AddGlobalDef(val, Name)) return 0;
279  }
280  else {
281  // cerr << "[global] -> bad value for " << Name << endl;
283  continue;
284  };
285  };
286  return 1;
287 };
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define MSG_KEYNOVAL
Definition: resource.h:30
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
#define MSG_KEYBADVAL
Definition: resource.h:31
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int AddGlobalDef(WORD wVirtualKeyCode, char *lpzKeyDef)
Definition: keytrans.cpp:160
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42
#define TOKEN_DELIMITERS
Definition: keytrans.h:26

Referenced by Load().

◆ LoadKeyMap()

int TMapLoader::LoadKeyMap ( string  buf)
private

Definition at line 319 of file tmapldr.cpp.

319  {
320 
321  char wbuf[128];
322  WORD vk_code;
323  DWORD control;
324  int i;
325 
326  // Paul Brannan Feb. 22, 1999
327  strcpy(wbuf, "VK_");
328  wbuf[4] = 0;
329  wbuf[3] = ini.get_escape_key();
330  i = KeyTrans.LookOnGlobal(wbuf);
331  if (i != INT_MAX) {
334  }
335  wbuf[3] = ini.get_scrollback_key();
336  i = KeyTrans.LookOnGlobal(wbuf);
337  if (i != INT_MAX) {
340  }
341  wbuf[3] = ini.get_dial_key();
342  i = KeyTrans.LookOnGlobal(wbuf);
343  if (i != INT_MAX) {
346  }
348 
349  while ( buf.length() ) {
350  wbuf[0] = 0;
351  if (!getline(buf,wbuf,sizeof(wbuf))) break;
352  if ( wbuf[0]==0 ) break;
353  if ( strnicmp(wbuf,"[keymap",7)==0 ) continue;
354 
355  char * keydef = ParseKeyDef(wbuf,vk_code,control);
356 
357  if ( keydef != NULL ) {
358 
359  // Check to see if keydef is a "special" code (Paul Brannan 3/29/00)
360  if(!strnicmp(keydef, "\\tn_escape", strlen("\\tn_escape"))) {
361  if(!KeyTrans.AddKeyDef(vk_code, control, TN_ESCAPE)) return 0;
362  } else if(!strnicmp(keydef, "\\tn_scrollback", strlen("\\tn_scrollback"))) {
363  if(!KeyTrans.AddKeyDef(vk_code, control, TN_SCROLLBACK)) return 0;
364  } else if(!strnicmp(keydef, "\\tn_dial", strlen("\\tn_dial"))) {
365  if(!KeyTrans.AddKeyDef(vk_code, control, TN_DIAL)) return 0;
366  } else if(!strnicmp(keydef, "\\tn_paste", strlen("\\tn_paste"))) {
367  if(!KeyTrans.AddKeyDef(vk_code, control, TN_PASTE)) return 0;
368  } else if(!strnicmp(keydef, "\\tn_null", strlen("\\tn_null"))) {
369  if(!KeyTrans.AddKeyDef(vk_code, control, TN_NULL)) return 0;
370  } else if(!strnicmp(keydef, "\\tn_cr", strlen("\\tn_cr"))) {
371  if(!KeyTrans.AddKeyDef(vk_code, control, TN_CR)) return 0;
372  } else if(!strnicmp(keydef, "\\tn_crlf", strlen("\\tn_crlf"))) {
373  if(!KeyTrans.AddKeyDef(vk_code, control, TN_CRLF)) return 0;
374  } else
375  if(!KeyTrans.AddKeyDef(vk_code,control,keydef)) return 0;
376  // else DeleteKeyDef() ???? - I'm not sure...
377  }
378  };
379 
380  return 1;
381 };
#define INT_MAX
Definition: limits.h:40
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP int __cdecl strnicmp(_In_z_ const char *_Str1, _In_z_ const char *_Str, _In_ size_t _MaxCount)
#define VK_INSERT
Definition: winuser.h:2186
#define SHIFT_PRESSED
Definition: wincon.h:135
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define LEFT_ALT_PRESSED
Definition: wincon.h:132
TConfig ini
Definition: tnconfig.cpp:45
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
char get_scrollback_key() const
Definition: tnconfig.h:83
Definition: tkeydef.h:19
DWORD GetGlobalCode(int i)
Definition: keytrans.h:90
int LookOnGlobal(char *vkey)
Definition: keytrans.cpp:150
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, char *lpzKeyDef)
Definition: keytrans.cpp:119
char get_escape_key() const
Definition: tnconfig.h:82
char get_dial_key() const
Definition: tnconfig.h:84
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * ParseKeyDef(const char *buf, WORD &vk_code, DWORD &control)
Definition: tmapldr.cpp:292
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42

Referenced by Load().

◆ LookForPart()

int TMapLoader::LookForPart ( stringArray sa,
const char partType,
const char partName 
)
private

Definition at line 240 of file tmapldr.cpp.

240  {
241  if ( !sa.IsEmpty() ) {
242  string cmpbuf("[");
243  cmpbuf += partType;
244  cmpbuf += " ";
245  cmpbuf += partName;
246  cmpbuf += "]";
247  normalizeSplitter(cmpbuf); // if no parttype, [global] for example
248  int max = sa.GetItemsInContainer();
249  for ( int i = 0; i<max; i++ )
250  // I found some strange behavior if strnicmp was used here
251  if (strnicmp(cmpbuf.c_str(),sa[i].c_str(),cmpbuf.length()) == 0)
252  return i;
253  };
254  return INT_MAX;
255 };
#define max(a, b)
Definition: svc.c:63
int normalizeSplitter(string &buf)
Definition: tmapldr.cpp:216
#define INT_MAX
Definition: limits.h:40
_Check_return_ _CRTIMP int __cdecl strnicmp(_In_z_ const char *_Str1, _In_z_ const char *_Str, _In_ size_t _MaxCount)
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct sockaddr_in sa
Definition: adnsresfilter.c:69

Referenced by Load().

◆ ParseKeyDef()

char * TMapLoader::ParseKeyDef ( const char buf,
WORD vk_code,
DWORD control 
)
private

Definition at line 292 of file tmapldr.cpp.

292  {
293  char wbuf[256];
294  strcpy(wbuf,buf);
295  char* ptr = strtok(wbuf, TOKEN_DELIMITERS);
296  if ( ptr == NULL ) return NULL;
297 
298  int i = KeyTrans.LookOnGlobal(ptr);
299  if ( i == INT_MAX ) return NULL;
300 
301  vk_code = KeyTrans.GetGlobalCode(i);
302 
303  control = 0;
304  DWORD st;
305  while (1) {
307  if ((ptr == NULL) || ((st = Fix_ControlKeyState(ptr)) == 0)) break;
308  control |= st;
309  };
310 
311  if ( ptr == NULL ) return NULL;
312 
313  return Fix_Tok(ptr);
314 };
#define INT_MAX
Definition: limits.h:40
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD Fix_ControlKeyState(char *Next_Token)
Definition: tmapldr.cpp:145
char * Fix_Tok(char *tok)
Definition: tmapldr.cpp:171
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD GetGlobalCode(int i)
Definition: keytrans.h:90
int LookOnGlobal(char *vkey)
Definition: keytrans.cpp:150
KeyTranslator & KeyTrans
Definition: tmapldr.h:92
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define TOKEN_DELIMITERS
Definition: keytrans.h:26

Referenced by Load(), and LoadKeyMap().

Member Data Documentation

◆ Charmap

TCharmap& TMapLoader::Charmap
private

Definition at line 93 of file tmapldr.h.

Referenced by Load(), and LoadCharMap().

◆ KeyTrans

KeyTranslator& TMapLoader::KeyTrans
private

Definition at line 92 of file tmapldr.h.

Referenced by Display(), Load(), LoadGlobal(), LoadKeyMap(), and ParseKeyDef().


The documentation for this class was generated from the following files: