ReactOS  0.4.15-dev-439-g292f67a
precomp.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <memory.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NLS_FILE_HEADER
 

Macros

#define LOBYTE(w)   ((uint8_t)((uint32_t)(w) & 0xff))
 
#define MAXIMUM_LEADBYTES   12
 

Functions

int nls_from_txt (const char *txt_file_path, const char *nls_file_path)
 
int txt_get_header (const char *file_path, NLS_FILE_HEADER *header)
 
uint16_ttxt_get_mb_table (const char *file_path, uint16_t uni_default_char)
 
uint16_ttxt_get_wc_table (const char *file_path, uint16_t default_char, int is_dbcs)
 
uint16_ttxt_get_glyph_table (const char *file_path, uint16_t uni_default_char)
 

Macro Definition Documentation

◆ LOBYTE

#define LOBYTE (   w)    ((uint8_t)((uint32_t)(w) & 0xff))

Definition at line 18 of file precomp.h.

◆ MAXIMUM_LEADBYTES

#define MAXIMUM_LEADBYTES   12

Definition at line 20 of file precomp.h.

Function Documentation

◆ nls_from_txt()

int nls_from_txt ( const char txt_file_path,
const char nls_file_path 
)

Definition at line 104 of file nls.c.

105 {
107  FILE *file = NULL;
108  uint16_t *mb_table = NULL;
109  uint16_t *wc_table = NULL;
110  uint16_t *glyph_table = NULL;
111  uint16_t number_of_lb_ranges;
112  uint16_t size;
113  int is_dbcs;
114  int res = 0;
115 
116  memset(&header, 0, sizeof(header));
117 
118  if (!txt_get_header(txt_file_path, &header))
119  goto Cleanup;
120 
121  is_dbcs = (header.MaximumCharacterSize == 2) ? 1 : 0;
122 
123  mb_table = txt_get_mb_table(txt_file_path, header.UniDefaultChar);
124  if (!mb_table)
125  goto Cleanup;
126 
127  wc_table = txt_get_wc_table(txt_file_path, header.DefaultChar, is_dbcs);
128  if (!wc_table)
129  goto Cleanup;
130 
131  /* GLYPHTABLE optionally. We do not leave if it is absent */
132  glyph_table = txt_get_glyph_table(txt_file_path, header.UniDefaultChar);
133 
134  if (is_dbcs)
135  {
136  /* DBCS codepage */
137  uint16_t *table = (uint16_t*)wc_table;
138  header.TransUniDefaultChar = table[header.UniDefaultChar];
139  /* TODO: TransDefaultChar for DBCS codepages */
140  }
141  else
142  {
143  /* SBCS codepage */
144  uint8_t *table = (uint8_t*)wc_table;
145  header.TransUniDefaultChar = table[header.UniDefaultChar];
146  header.TransDefaultChar = mb_table[LOBYTE(header.DefaultChar)];
147  }
148 
149 #ifdef _NLS_DEBUG_PRINT
151  nls_print_mb_table(mb_table, header.UniDefaultChar);
152  if (glyph_table)
153  nls_print_glyph_table(glyph_table, header.UniDefaultChar);
154  nls_print_wc_table(wc_table, header.DefaultChar, is_dbcs);
155 #endif /* _NLS_DEBUG_PRINT */
156 
157  /* Create binary file with write access */
158  file = fopen(nls_file_path, "wb");
159  if (!file)
160  {
161  printf("Unable to create NLS file.\n");
162  goto Cleanup;
163  }
164 
165  /* Write NLS file header */
166  if (fwrite(&header, 1, sizeof(header), file) != sizeof(header))
167  {
168  printf("Unable to write NLS file.\n");
169  goto Cleanup;
170  }
171 
172  size = (256 * sizeof(uint16_t)) + /* Primary CP to Unicode table */
173  sizeof(uint16_t) + /* optional OEM glyph table size in words */
174  (glyph_table ? (256 * sizeof(uint16_t)) : 0) + /* OEM glyph table size in words * sizeof(uint16_t) */
175  sizeof(uint16_t) + /* Number of DBCS LeadByte ranges */
176  0 + /* offsets of lead byte sub tables */
177  0 + /* LeadByte sub tables */
178  sizeof(uint16_t); /* Unknown flag */
179 
180  size /= sizeof(uint16_t);
181 
182  if (fwrite(&size, 1, sizeof(size), file) != sizeof(size))
183  {
184  printf("Unable to write NLS file.\n");
185  goto Cleanup;
186  }
187 
188  /* Write multibyte table */
189  if (fwrite(mb_table, 1, (256 * sizeof(uint16_t)), file) != (256 * sizeof(uint16_t)))
190  {
191  printf("Unable to write NLS file.\n");
192  goto Cleanup;
193  }
194 
195  /* OEM glyph table size in words */
196  size = (glyph_table ? 256 : 0);
197 
198  if (fwrite(&size, 1, sizeof(size), file) != sizeof(size))
199  {
200  printf("Unable to write NLS file.\n");
201  goto Cleanup;
202  }
203 
204  if (glyph_table)
205  {
206  /* Write OEM glyph table */
207  if (fwrite(glyph_table, 1, (256 * sizeof(uint16_t)), file) != (256 * sizeof(uint16_t)))
208  {
209  printf("Unable to write NLS file.\n");
210  goto Cleanup;
211  }
212  }
213 
214  /* Number of DBCS LeadByte ranges */
215  number_of_lb_ranges = 0;
216  if (fwrite(&number_of_lb_ranges, 1, sizeof(number_of_lb_ranges), file) != sizeof(number_of_lb_ranges))
217  {
218  printf("Unable to write NLS file.\n");
219  goto Cleanup;
220  }
221 
222  /* Unknown flag */
223  size = 0;
224  if (fwrite(&size, 1, sizeof(size), file) != sizeof(size))
225  {
226  printf("Unable to write NLS file.\n");
227  goto Cleanup;
228  }
229 
230  /* Write wide char table */
231  if (fwrite(wc_table, 1, (65536 * header.MaximumCharacterSize), file) != (65536 * header.MaximumCharacterSize))
232  {
233  printf("Unable to write NLS file.\n");
234  goto Cleanup;
235  }
236 
237  res = 1;
238 
239 Cleanup:
240  if (file) fclose(file);
241  free(mb_table);
242  free(wc_table);
243  free(glyph_table);
244 
245  return res;
246 }
#define LOBYTE(W)
Definition: jmemdos.c:487
#define free
Definition: debug_ros.c:5
uint16_t * txt_get_mb_table(const char *file_path, uint16_t uni_default_char)
Definition: txt.c:133
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
static void nls_print_header(NLS_FILE_HEADER *header)
Definition: nls.c:15
int txt_get_header(const char *file_path, NLS_FILE_HEADER *header)
Definition: txt.c:11
static void nls_print_wc_table(uint16_t *wc_table, uint16_t default_char, int is_dbcs)
Definition: nls.c:54
smooth NULL
Definition: ftsmooth.c:416
static void nls_print_glyph_table(uint16_t *glyph_table, uint16_t uni_default_char)
Definition: nls.c:84
GLsizeiptr size
Definition: glext.h:5919
uint16_t * txt_get_glyph_table(const char *file_path, uint16_t uni_default_char)
Definition: txt.c:386
const char file[]
Definition: icontest.c:11
uint16_t * txt_get_wc_table(const char *file_path, uint16_t default_char, int is_dbcs)
Definition: txt.c:247
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR Cleanup[]
Definition: register.c:80
BYTE uint8_t
Definition: msvideo1.c:66
GLuint res
Definition: glext.h:9613
static void nls_print_mb_table(uint16_t *mb_table, uint16_t uni_default_char)
Definition: nls.c:36
#define memset(x, y, z)
Definition: compat.h:39
struct CFHEADER header
Definition: fdi.c:101
#define printf
Definition: config.h:203
Definition: fci.c:126

Referenced by main().

◆ txt_get_glyph_table()

uint16_t* txt_get_glyph_table ( const char file_path,
uint16_t  uni_default_char 
)

Definition at line 386 of file txt.c.

387 {
388  uint16_t *table;
389  char buf[256];
390  char *p;
391  uint32_t count = 0;
392  uint32_t index;
393  uint32_t line = 0;
394  int found;
395  int res = 0;
396  FILE *file;
397 
398  table = malloc(256 * sizeof(uint16_t));
399  if (!table)
400  {
401  printf("Memory allocation failure\n");
402  return NULL;
403  }
404 
405  /* Set default value for all table items */
406  for (index = 0; index <= 255; index++)
407  table[index] = uni_default_char;
408 
409  file = fopen(file_path, "r");
410  if (!file)
411  {
412  printf("Unable to read TXT file.\n");
413  goto Cleanup;
414  }
415 
416  /* Find GLYPHTABLE entry */
417  found = 0;
418  while (fgets(buf, sizeof(buf), file))
419  {
420  ++line;
421 
422  p = strstr(buf, "GLYPHTABLE");
423  if (p)
424  {
425  p += 10;
426 
427  /* Skip spaces */
428  while (isspace(*p)) ++p;
429 
430  count = strtoul(p, &p, 10);
431  if (count == 0 || count > 256)
432  {
433  printf("Wrong GLYPHTABLE size: %u (line: %u)\n", count, line);
434  goto Cleanup;
435  }
436 
437  found = 1;
438  break;
439  }
440  }
441 
442  if (!found)
443  {
444  printf("GLYPHTABLE not found.\n");
445  goto Cleanup;
446  }
447 
448  /* Parse next line */
449  while (fgets(buf, sizeof(buf), file) && count)
450  {
452  uint32_t uni_char;
453 
454  ++line;
455 
456  p = buf;
457 
458  /* Skip spaces */
459  while (isspace(*p)) ++p;
460 
461  if (!*p || p[0] == ';')
462  continue;
463 
464  cp_char = strtoul(p, &p, 16);
465  if (cp_char > 0xFF)
466  {
467  printf("Wrong char value: %u (line: %u)\n", cp_char, line);
468  goto Cleanup;
469  }
470 
471  /* Skip spaces */
472  while (isspace(*p)) ++p;
473 
474  uni_char = strtoul(p, &p, 16);
475  if (uni_char > 0xFFFF)
476  {
477  printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line);
478  goto Cleanup;
479  }
480 
481  table[cp_char] = uni_char;
482  --count;
483  }
484 
485  res = 1;
486 
487 Cleanup:
488  if (!res)
489  {
490  free(table);
491  table = NULL;
492  }
493 
494  fclose(file);
495 
496  return table;
497 }
#define isspace(c)
Definition: acclib.h:69
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
unsigned short int uint16_t
Definition: acefiex.h:54
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
WCHAR cp_char
Definition: create_nls.c:53
GLuint index
Definition: glext.h:6031
const char file[]
Definition: icontest.c:11
char line[200]
Definition: main.c:97
#define index(s, c)
Definition: various.h:29
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR Cleanup[]
Definition: register.c:80
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
UINT32 uint32_t
Definition: types.h:75
GLuint res
Definition: glext.h:9613
#define malloc
Definition: debug_ros.c:4
GLfloat GLfloat p
Definition: glext.h:8902
#define printf
Definition: config.h:203
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
Definition: fci.c:126

Referenced by nls_from_txt().

◆ txt_get_header()

int txt_get_header ( const char file_path,
NLS_FILE_HEADER header 
)

Definition at line 11 of file txt.c.

12 {
13  FILE *file;
14  char *p;
15  char buf[256];
16  uint32_t line = 0;
17  int res = 0;
18  int found;
19  uint32_t val;
20 
21  file = fopen(file_path, "r");
22  if (!file)
23  {
24  printf("Unable to read TXT file.\n");
25  return 0;
26  }
27 
28  /* Find CODEPAGE entry */
29  found = 0;
30  while (fgets(buf, sizeof(buf), file))
31  {
32  ++line;
33 
34  p = strstr(buf, "CODEPAGE");
35  if (p)
36  {
37  /* Length of CODEPAGE string is 8 chars */
38  p += 8;
39 
40  /* Skip all spaces after CODEPAGE */
41  while (isspace(*p)) ++p;
42 
43  /* Convert string to uint32_t */
44  val = strtoul(p, &p, 10);
45 
46  /* Validate codepage value */
47  if (val > 0xFFFF)
48  {
49  printf("Wrong codepage: %u (line: %u)\n", val, line);
50  goto Cleanup;
51  }
52 
53  header->CodePage = (uint16_t)val;
54 
55  found = 1;
56  break;
57  }
58  }
59 
60  if (!found)
61  {
62  printf("CODEPAGE not found.\n");
63  goto Cleanup;
64  }
65 
66  /* Find CPINFO entry */
67  found = 0;
68  while (fgets(buf, sizeof(buf), file))
69  {
70  ++line;
71 
72  p = strstr(buf, "CPINFO");
73  if (p)
74  {
75  /* Length of CPINFO string is 6 chars */
76  p += 6;
77 
78  /* Skip all spaces after CPINFO */
79  while (isspace(*p)) ++p;
80 
81  /* Convert string to uint32_t */
82  val = strtoul(p, &p, 10);
83 
84  /* Validate value */
85  if (val != 1 && val != 2)
86  {
87  printf("Wrong character size: %u (line: %u)\n", val, line);
88  goto Cleanup;
89  }
90 
91  header->MaximumCharacterSize = (uint16_t)val;
92 
93  /* Skip all spaces after character size */
94  while (isspace(*p)) ++p;
95 
96  /* Convert string to uint32_t */
97  val = strtoul(p, &p, 16);
98  header->DefaultChar = (uint16_t)val;
99  /* By default set value as DefaultChar */
100  header->TransDefaultChar = (uint16_t)val;
101 
102  /* Skip all spaces after default char */
103  while (isspace(*p)) ++p;
104 
105  /* Convert string to uint32_t */
106  val = strtoul(p, &p, 16);
107  header->UniDefaultChar = (uint16_t)val;
108  /* By default set value as UniDefaultChar */
109  header->TransUniDefaultChar = (uint16_t)val;
110 
111  found = 1;
112  break;
113  }
114  }
115 
116  if (!found)
117  {
118  printf("CPINFO not found.\n");
119  goto Cleanup;
120  }
121 
122  header->HeaderSize = sizeof(NLS_FILE_HEADER) / sizeof(uint16_t);
123 
124  res = 1;
125 
126 Cleanup:
127  fclose(file);
128 
129  return res;
130 }
#define isspace(c)
Definition: acclib.h:69
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
struct _NLS_FILE_HEADER NLS_FILE_HEADER
Definition: parser.c:48
GLuint GLfloat * val
Definition: glext.h:7180
const char file[]
Definition: icontest.c:11
char line[200]
Definition: main.c:97
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR Cleanup[]
Definition: register.c:80
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
UINT32 uint32_t
Definition: types.h:75
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902
#define printf
Definition: config.h:203
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
Definition: fci.c:126

Referenced by nls_from_txt().

◆ txt_get_mb_table()

uint16_t* txt_get_mb_table ( const char file_path,
uint16_t  uni_default_char 
)

Definition at line 133 of file txt.c.

134 {
135  uint16_t *table;
136  char buf[256];
137  char *p;
138  uint32_t count = 0;
139  uint32_t index;
140  uint32_t line = 0;
141  int found;
142  int res = 0;
143  FILE *file;
144 
145  table = malloc(256 * sizeof(uint16_t));
146  if (!table)
147  {
148  printf("Memory allocation failure\n");
149  return NULL;
150  }
151 
152  /* Set default value for all table items */
153  for (index = 0; index <= 255; index++)
154  table[index] = uni_default_char;
155 
156  file = fopen(file_path, "r");
157  if (!file)
158  {
159  printf("Unable to read TXT file.\n");
160  goto Cleanup;
161  }
162 
163  /* Find MBTABLE entry */
164  found = 0;
165  while (fgets(buf, sizeof(buf), file))
166  {
167  ++line;
168 
169  p = strstr(buf, "MBTABLE");
170  if (p)
171  {
172  p += 7;
173 
174  /* Skip spaces */
175  while (isspace(*p)) ++p;
176 
177  count = strtoul(p, &p, 10);
178  if (count == 0 || count > 256)
179  {
180  printf("Wrong MBTABLE size: %u (line: %u)\n", count, line);
181  goto Cleanup;
182  }
183 
184  found = 1;
185  break;
186  }
187  }
188 
189  if (!found)
190  {
191  printf("MBTABLE not found.\n");
192  goto Cleanup;
193  }
194 
195  /* Parse next line */
196  while (fgets(buf, sizeof(buf), file) && count)
197  {
199  uint32_t uni_char;
200 
201  ++line;
202 
203  p = buf;
204 
205  /* Skip spaces */
206  while (isspace(*p)) ++p;
207 
208  if (!*p || p[0] == ';')
209  continue;
210 
211  cp_char = strtoul(p, &p, 16);
212  if (cp_char > 0xFF)
213  {
214  printf("Wrong char value: %u (line: %u)\n", cp_char, line);
215  goto Cleanup;
216  }
217 
218  /* Skip spaces */
219  while (isspace(*p)) ++p;
220 
221  uni_char = strtoul(p, &p, 16);
222  if (uni_char > 0xFFFF)
223  {
224  printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line);
225  goto Cleanup;
226  }
227 
228  table[cp_char] = uni_char;
229  --count;
230  }
231 
232  res = 1;
233 
234 Cleanup:
235  if (!res)
236  {
237  free(table);
238  table = NULL;
239  }
240 
241  fclose(file);
242 
243  return table;
244 }
#define isspace(c)
Definition: acclib.h:69
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
unsigned short int uint16_t
Definition: acefiex.h:54
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
WCHAR cp_char
Definition: create_nls.c:53
GLuint index
Definition: glext.h:6031
const char file[]
Definition: icontest.c:11
char line[200]
Definition: main.c:97
#define index(s, c)
Definition: various.h:29
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR Cleanup[]
Definition: register.c:80
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
UINT32 uint32_t
Definition: types.h:75
GLuint res
Definition: glext.h:9613
#define malloc
Definition: debug_ros.c:4
GLfloat GLfloat p
Definition: glext.h:8902
#define printf
Definition: config.h:203
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
Definition: fci.c:126

Referenced by nls_from_txt().

◆ txt_get_wc_table()

uint16_t* txt_get_wc_table ( const char file_path,
uint16_t  default_char,
int  is_dbcs 
)

Definition at line 247 of file txt.c.

248 {
249  char buf[256];
250  char *p;
251  uint16_t *table;
252  uint32_t index;
253  uint32_t count = 0;
254  uint32_t line = 0;
255  int res = 0;
256  int found;
257  FILE *file;
258 
259  table = malloc(65536 * (is_dbcs ? sizeof(uint16_t) : sizeof(uint8_t)));
260  if (!table)
261  {
262  printf("Memory allocation failure\n");
263  return NULL;
264  }
265 
266  /* Set default value for all table items */
267  for (index = 0; index <= 65535; index++)
268  {
269  /* DBCS code page */
270  if (is_dbcs)
271  {
272  uint16_t *tmp = (uint16_t*)table;
273  tmp[index] = default_char;
274  }
275  /* SBCS code page */
276  else
277  {
278  uint8_t *tmp = (uint8_t*)table;
279  tmp[index] = default_char;
280  }
281  }
282 
283  file = fopen(file_path, "r");
284  if (!file)
285  {
286  printf("Unable to read TXT file.\n");
287  goto Cleanup;
288  }
289 
290  /* Find WCTABLE entry */
291  found = 0;
292  while (fgets(buf, sizeof(buf), file))
293  {
294  ++line;
295 
296  p = strstr(buf, "WCTABLE");
297  if (p)
298  {
299  p += 7;
300 
301  /* Skip spaces */
302  while (isspace(*p)) ++p;
303 
304  count = strtoul(p, &p, 10);
305  if (count == 0 || count > 65536)
306  {
307  printf("Wrong WCTABLE size: %u (line: %u)\n", count, line);
308  goto Cleanup;
309  }
310 
311  found = 1;
312  break;
313  }
314  }
315 
316  if (!found)
317  {
318  printf("WCTABLE not found.\n");
319  goto Cleanup;
320  }
321 
322  /* Parse next line */
323  while (fgets(buf, sizeof(buf), file) && count)
324  {
326  uint32_t uni_char;
327 
328  ++line;
329 
330  p = buf;
331 
332  /* Skip spaces */
333  while (isspace(*p)) ++p;
334 
335  if (!*p || p[0] == ';')
336  continue;
337 
338  uni_char = strtoul(p, &p, 16);
339  if (uni_char > 0xFFFF)
340  {
341  printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line);
342  goto Cleanup;
343  }
344 
345  /* Skip spaces */
346  while (isspace(*p)) ++p;
347 
348  cp_char = strtoul(p, &p, 16);
349  if ((is_dbcs && cp_char > 0xFFFF) || (!is_dbcs && cp_char > 0xFF))
350  {
351  printf("Wrong char value: %u (line: %u)\n", cp_char, line);
352  goto Cleanup;
353  }
354 
355  /* DBCS code page */
356  if (is_dbcs)
357  {
358  uint16_t *tmp = (uint16_t*)table;
359  tmp[uni_char] = cp_char;
360  }
361  /* SBCS code page */
362  else
363  {
364  uint8_t *tmp = (uint8_t*)table;
365  tmp[uni_char] = cp_char;
366  }
367 
368  --count;
369  }
370 
371  res = 1;
372 
373 Cleanup:
374  if (!res)
375  {
376  free(table);
377  table = NULL;
378  }
379 
380  fclose(file);
381 
382  return table;
383 }
#define isspace(c)
Definition: acclib.h:69
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
unsigned short int uint16_t
Definition: acefiex.h:54
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
WCHAR cp_char
Definition: create_nls.c:53
GLuint index
Definition: glext.h:6031
const char file[]
Definition: icontest.c:11
char line[200]
Definition: main.c:97
#define index(s, c)
Definition: various.h:29
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR Cleanup[]
Definition: register.c:80
BYTE uint8_t
Definition: msvideo1.c:66
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
UINT32 uint32_t
Definition: types.h:75
GLuint res
Definition: glext.h:9613
#define malloc
Definition: debug_ros.c:4
GLfloat GLfloat p
Definition: glext.h:8902
#define printf
Definition: config.h:203
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
Definition: fci.c:126

Referenced by nls_from_txt().