ReactOS  0.4.12-dev-57-g7050ac4
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 143 of file tmapldr.cpp.

Referenced by TMapLoader::ParseKeyDef().

143  {
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 }
#define SCROLLLOCK_ON
Definition: wincon.h:137
#define APP_KEY
Definition: keytrans.h:41
#define APP4_KEY
Definition: keytrans.h:38
#define SHIFT_PRESSED
Definition: wincon.h:135
#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:132
#define APP2_KEY
Definition: keytrans.h:40
#define ENHANCED_KEY
Definition: wincon.h:139
#define LEFT_CTRL_PRESSED
Definition: wincon.h:134
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:133
#define NUMLOCK_ON
Definition: wincon.h:136
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
#define CAPSLOCK_ON
Definition: wincon.h:138

◆ Fix_Tok()

char* Fix_Tok ( char tok)

Definition at line 169 of file tmapldr.cpp.

Referenced by TMapLoader::ParseKeyDef().

169  {
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 };
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
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
static int getbyte(const char *str)
Definition: tmapldr.cpp:113
GLdouble s
Definition: gl.h:2039
#define memset(x, y, z)
Definition: compat.h:39

◆ getbyte()

static int getbyte ( const char str)
static

Definition at line 113 of file tmapldr.cpp.

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

113  {
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 };
const WCHAR * str
#define isdigit(c)
Definition: acclib.h:68
int toupper(int c)
Definition: utclib.c:881

◆ getline() [1/2]

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

Definition at line 42 of file tmapldr.cpp.

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

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] == ' ')) {
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 };
#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
GLsizeiptr size
Definition: glext.h:5919
_Self & getline(char_type *__s, streamsize __n, char_type delim)
Definition: _istream.c:754
bool eof() const
Definition: _ios_base.h:173
GLenum GLsizei len
Definition: glext.h:6722
#define memset(x, y, z)
Definition: compat.h:39

◆ getline() [2/2]

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

Definition at line 88 of file tmapldr.cpp.

88  {
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 };
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
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 434 of file tmapldr.cpp.

Referenced by TMapLoader::Load().

434  {
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 };
int normalizeSplitter(string &buf)
Definition: tmapldr.cpp:214
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int getLongComment(istream &is, char *wbuf, size_t sz)
Definition: tmapldr.cpp:434
_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

◆ normalizeSplitter()

int normalizeSplitter ( string buf)

Definition at line 214 of file tmapldr.cpp.

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

214  {
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 };