-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocKit.cpp
More file actions
107 lines (102 loc) · 2.08 KB
/
locKit.cpp
File metadata and controls
107 lines (102 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "locKit.h"
#include "systemInterface.h"
#include <stdio.h>
#include <string.h>
unsigned char LocKit::CountLangFile()
{
char buff[11];
strcpy(buff,"lang1.loc");
FILE *f; unsigned char i;
for(i=0;i<10;i++)
{
buff[4]='0'+i;
f=fopen(buff,"rb");
if(f==0) break;
fclose(f);
}
return i;
}
void LocKit::GetLangName(unsigned char i,wchar_t *dest,unsigned long len)
{
char buff[11];
if(i>10)
{
message("LocKit::GetLangName","The maxium number of language is 10");
i=0;
}
strcpy(buff,"lang1.loc");
buff[4]='0'+i;
FILE *f=fopen(buff,"rb");
if(f==0)
{
message("LocKit::GetLangName","file %s don't found",buff);
return;
}
unsigned short bom;
fread(&bom,2,1,f);
if(bom!=0x0FEFF)
{
message("LocKit::GetLangName","file %s is not unicode little-endian",buff);
fclose(f);
return;
}
while(1)
{
fgetws(dest,len,f);
if(feof(f)) break;
if(dest[0]==13) continue;
if(dest[0]==10) continue;
if(dest[0]==L'/') continue;
break;
}
fclose(f);
}
void LocKit::Init(unsigned char lang)
{
unsigned char nSet=0,i;
for(i=0;i<LK_TOTAL;i++)
string[i][0][0]=string[i][1][0]=0;
char buff[11];
if(lang>10)
{
message("LocKit::Init","The maxium number of language is 10");
i=0;
}
strcpy(buff,"lang1.loc");
buff[4]='0'+lang;
FILE *f=fopen(buff,"rb");
if(f==0)
{
message("LocKit::Init","file %s don't found",buff);
return;
}
unsigned short bom;
fread(&bom,2,1,f);
if(bom!=0x0FEFF)
{
message("LocKit::Init","file %s is not unicode little-endian",buff);
fclose(f);
return;
}
wchar_t *u;
while(1)
{
fgetws(string[nSet][0],MAX_LEN,f);
if(feof(f)) break;
if(string[nSet][0][0]==13) continue;
if(string[nSet][0][0]==10) continue;
if(string[nSet][0][0]==L'/') continue;
u=wcschr(string[nSet][0],L'\\');
if(u)
{
wcscpy(string[nSet][1],(u+1));
*u=0;
}
nSet++;
if(nSet==LK_TOTAL) break;
}
//hard codes name! don't change!!!!
wcscat(string[LK_AUTHOR][0],L"Antonino Perricone");
wcscat(string[LK_AUTHOR+1][0],L"Kevin MacLeod");
fclose(f);
}