ReactOS  0.4.15-dev-439-g292f67a
tmapldr.cpp File Reference
#include "precomp.h"
Include dependency graph for tmapldr.cpp:

Go to the source code of this file.

Functions

static chargetline (istream &i, char *buf, int size)
 
static int getline (string &str, char *buf, size_t sz)
 
static int getbyte (const char *str)
 
DWORD Fix_ControlKeyState (char *Next_Token)
 
charFix_Tok (char *tok)
 
int normalizeSplitter (string &buf)
 
int getLongComment (istream &is, char *wbuf, size_t sz)
 

Function Documentation

◆ Fix_ControlKeyState()

DWORD Fix_ControlKeyState ( char Next_Token)

Definition at line 145 of file tmapldr.cpp.

145  {
146  if (stricmp(Next_Token, "RIGHT_ALT" ) == 0) return RIGHT_ALT_PRESSED;
147  if (stricmp(Next_Token, "LEFT_ALT" ) == 0) return LEFT_ALT_PRESSED;
148  if (stricmp(Next_Token, "RIGHT_CTRL") == 0) return RIGHT_CTRL_PRESSED;
149  if (stricmp(Next_Token, "LEFT_CTRL" ) == 0) return LEFT_CTRL_PRESSED;
150  if (stricmp(Next_Token, "SHIFT" ) == 0) return SHIFT_PRESSED;
151  if (stricmp(Next_Token, "NUMLOCK" ) == 0) return NUMLOCK_ON;
152  if (stricmp(Next_Token, "SCROLLLOCK") == 0) return SCROLLLOCK_ON;
153  if (stricmp(Next_Token, "CAPSLOCK" ) == 0) return CAPSLOCK_ON;
154  if (stricmp(Next_Token, "ENHANCED" ) == 0) return ENHANCED_KEY;
155 
156  // Paul Brannan 5/27/98
157  if (stricmp(Next_Token, "APP_KEY" ) == 0) return APP_KEY;
158  // Paul Brannan 6/28/98
159  if (stricmp(Next_Token, "APP2_KEY" ) == 0) return APP2_KEY;
160  // Paul Brannan 8/28/98
161  if (stricmp(Next_Token, "APP3_KEY" ) == 0) return APP3_KEY;
162  // Paul Brannan 12/9/98
163  if (stricmp(Next_Token, "APP4_KEY" ) == 0) return APP4_KEY;
164 
165  return 0;
166 }
#define SCROLLLOCK_ON
Definition: wincon.h:143
#define APP_KEY
Definition: keytrans.h:41
#define APP4_KEY
Definition: keytrans.h:38
#define SHIFT_PRESSED
Definition: wincon.h:141
#define APP3_KEY
Definition: keytrans.h:39
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define LEFT_ALT_PRESSED
Definition: wincon.h:138
#define APP2_KEY
Definition: keytrans.h:40
#define ENHANCED_KEY
Definition: wincon.h:145
#define LEFT_CTRL_PRESSED
Definition: wincon.h:140
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:139
#define NUMLOCK_ON
Definition: wincon.h:142
#define RIGHT_ALT_PRESSED
Definition: wincon.h:137
#define CAPSLOCK_ON
Definition: wincon.h:144

Referenced by TMapLoader::ParseKeyDef().

◆ Fix_Tok()

char* Fix_Tok ( char tok)

Definition at line 171 of file tmapldr.cpp.

171  {
172  static char s[256];
173  int i,j,n;
174 
175  // setmem is nonstandard; memset is standard (Paul Brannan 5/25/98)
176  memset(s, 0, 256);
177  // setmem(s, 256, 0);
178  i = j = n = 0;
179  if ( tok != NULL ) {
180  for ( ; tok[i] != 0; ) {
181  switch ( tok[i] ) {
182  case '\\' :
183  switch ( tok[i+1] ) {
184  case '\\':
185  s[j++] = '\\';
186  i += 2;
187  break;
188  default:
189  n = getbyte(tok+i+1);
190  if ( n < 0 )
191  s[j++] = tok[i++];
192  else {
193  s[j++]=n;
194  i += 4;
195  } ;
196  break;
197  };
198  break;
199  case '^' :
200  if ( tok[i+1] >= '@' ) {
201  s[j++] = tok[i+1] - '@';
202  i += 2;
203  break;
204  }
205  default :
206  s[j++] = tok[i++];
207  }
208  }
209  }
210  return s;
211 };
GLdouble n
Definition: glext.h:7729
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
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 GLint GLint j
Definition: glfuncs.h:250
static int getbyte(const char *str)
Definition: tmapldr.cpp:115
GLdouble s
Definition: gl.h:2039
#define memset(x, y, z)
Definition: compat.h:39

Referenced by TMapLoader::ParseKeyDef().

◆ getbyte()

static int getbyte ( const char str)
static

Definition at line 115 of file tmapldr.cpp.

115  {
116  unsigned char retval = 0;
117  int base = 10;
118  int readed = 0;
119 
120  if ( (*str == 'x') || (*str == 'X') ) {
121  base = 16;
122  readed++;
123  };
124 
125  while (readed != 3 && str[readed]) {
126  unsigned char ch = toupper(str[readed]);
127  if ( isdigit(ch) ) {
128  retval = retval*base + (ch -'0');
129  } else if (base == 16 && ch >= 'A' && ch <= 'F') {
130  retval = retval*base + (ch-'A'+10);
131  } else {
132  return -1;
133  };
134  readed++;
135  };
136  // Ioannou: If we discard the 0x00 we can't undefine a key !!!
137  // if ( retval == 0 ) {
138  // return -1;
139  // };
140  return retval;
141 };
const WCHAR * str
#define isdigit(c)
Definition: acclib.h:68
int toupper(int c)
Definition: utclib.c:881

Referenced by Fix_Tok(), and TMapLoader::LoadCharMap().

◆ getline() [1/2]

static char* getline ( istream i,
char buf,
int  size 
)
static

Definition at line 42 of file tmapldr.cpp.

42  {
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] == ' ')) {
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  {
72  if ((buf[len] == '/') && (buf[len + 1] == '/')) buf[len] = 0;
73  else len++;
74 
75  if (len && (buf[len - 1] == ' ')) {
76  len--;
77  buf[len] = 0;
78  };
79  }
80  // in case for comment like this one (in line just a comment)
81  if (buf[0] == 0) continue;
82 
83  break;
84  };
85  return (buf);
86 };
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
#define memset(x, y, z)
Definition: compat.h:39

Referenced by getLongComment(), TMapLoader::Load(), TMapLoader::LoadCharMap(), TMapLoader::LoadGlobal(), and TMapLoader::LoadKeyMap().

◆ getline() [2/2]

static int getline ( string str,
char buf,
size_t  sz 
)
static

Definition at line 90 of file tmapldr.cpp.

90  {
91 
92  if ( !str.length() ) return 0;
93  const char * p = strchr(str.c_str(),'\n');
94  unsigned int len; // Changed to unsigned (Paul Brannan 6/23/98)
95  if ( p==NULL )
96  len = str.length();
97  else
98  len = p - str.c_str();
99 
100  len = len<sz?len:sz-1;
101 
102  strncpy(buf,str.c_str(), len);
103  buf[len]=0;
104  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
105 #ifndef __BORLANDC__
106  str.erase(0, len + 1);
107 #else
108  str.remove(0,len+1);
109 #endif
110  return 1;
111 };
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
char * strchr(const char *String, int ch)
Definition: utclib.c:501
GLfloat GLfloat p
Definition: glext.h:8902

◆ getLongComment()

int getLongComment ( istream is,
char wbuf,
size_t  sz 
)

Definition at line 436 of file tmapldr.cpp.

436  {
437 
438  int bufLen;
439  while ( is ) {
440  wbuf[0] = 0;
441  getline(is, wbuf, sz);
442  if ( wbuf[0]==0 ) return 1;
443  bufLen = strlen(wbuf);
444  if ( wbuf[0] == '[' && wbuf[bufLen-1] == ']' ) {
445  string temps(wbuf);
446 
447  if (!normalizeSplitter(temps)) {
448  // cerr << "Unexpected line '" << temps << "'\n";
449  printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
450  return 0;
451  };
452  if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
453  // do recursive call
454  if ( !getLongComment(is, wbuf, sz) ) return 0;
455  continue;
456  };
457  if ( stricmp(temps.c_str(),"[end comment]") == 0 ) return 1;
458  };
459  };
460  // we get a warning if we don't put a return here (Paul Brannan 5/25/98)
461  return 0;
462 };
int normalizeSplitter(string &buf)
Definition: tmapldr.cpp:216
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int getLongComment(istream &is, char *wbuf, size_t sz)
Definition: tmapldr.cpp:436
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
Definition: tnerror.cpp:84
#define MSG_KEYUNEXPLINE
Definition: resource.h:34
static char * getline(istream &i, char *buf, int size)
Definition: tmapldr.cpp:42

Referenced by TMapLoader::Load().

◆ normalizeSplitter()

int normalizeSplitter ( string buf)

Definition at line 216 of file tmapldr.cpp.

216  {
217  if ( buf.length() <= 2 ) return 0;
218  if ( buf[0] == '[' && buf[buf.length()-1] == ']' ) {
219  while ( buf[1] == ' ' )
220  // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
221 #ifndef __BORLANDC__
222  buf.erase(1, 1);
223 #else
224  buf.remove(1,1);
225 #endif
226  while ( buf[buf.length()-2] == ' ' )
227  // Paul Brannan 6/23/98
228 #ifndef __BORLANDC__
229  buf.erase(buf.length()-2,1);
230 #else
231  buf.remove(buf.length()-2,1);
232 #endif
233  return 1;
234  }
235  return 0;
236 };
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by getLongComment(), TMapLoader::Load(), and TMapLoader::LookForPart().