Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/ttpset/ttset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6803 - (hide annotations) (download) (as text)
Tue Jun 13 10:42:58 2017 UTC (6 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 133146 byte(s)
NO_COPYLINE_FIX マクロを廃止。常に有効。
1 maya 3227 /* Tera Term
2     Copyright(C) 1994-1998 T. Teranishi
3     All rights reserved. */
4     /* IPv6 modification is Copyright(C) 2000 Jun-ya kato <kato@win6.jp> */
5    
6     /* TTSET.DLL, setup file routines*/
7     #include <winsock2.h>
8     #include <ws2tcpip.h>
9     #include "teraterm.h"
10     #include "tttypes.h"
11     #include <stdio.h>
12     #include <string.h>
13     #include <direct.h>
14 doda 4217 #include <ctype.h>
15 maya 6121 #include <errno.h>
16 maya 3227 #include "ttlib.h"
17     #include "tt_res.h"
18    
19     #include "compat_w95.h"
20    
21 maya 4874 #ifndef CLEARTYPE_QUALITY
22     #define CLEARTYPE_QUALITY 5
23     #endif
24    
25 maya 3227 #define Section "Tera Term"
26    
27 atsue 5126 #define MaxStrLen (LONG)512
28    
29 maya 3227 static PCHAR far TermList[] =
30     { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
31 doda 4084 "VT320", "VT382", "VT420", "VT520", "VT525", NULL };
32 maya 3227
33     static PCHAR far RussList[] =
34     { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
35     static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
36    
37     WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
38     {
39     WORD i;
40     i = 0;
41     while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))
42     i++;
43     if (List[i] == NULL)
44     i = DefId;
45     else
46     i++;
47    
48     return i;
49     }
50    
51     void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
52     {
53     int i;
54    
55     if (Id == 0)
56     i = DefId - 1;
57     else {
58     i = 0;
59     while ((List[i] != NULL) && (i < Id - 1))
60     i++;
61     if (List[i] == NULL)
62     i = DefId - 1;
63     }
64     strncpy_s(str, destlen, List[i], _TRUNCATE);
65     }
66    
67     int IconName2IconId(const char *name) {
68     int id;
69    
70     if (_stricmp(name, "tterm") == 0) {
71     id = IDI_TTERM;
72     }
73     else if (_stricmp(name, "vt") == 0) {
74     id = IDI_VT;
75     }
76     else if (_stricmp(name, "tek") == 0) {
77     id = IDI_TEK;
78     }
79     else if (_stricmp(name, "tterm_classic") == 0) {
80     id = IDI_TTERM_CLASSIC;
81     }
82     else if (_stricmp(name, "vt_classic") == 0) {
83     id = IDI_VT_CLASSIC;
84     }
85 maya 6386 else if (_stricmp(name, "tterm_3d") == 0) {
86     id = IDI_TTERM_3D;
87     }
88     else if (_stricmp(name, "vt_3d") == 0) {
89     id = IDI_VT_3D;
90     }
91 maya 3227 else if (_stricmp(name, "cygterm") == 0) {
92     id = IDI_CYGTERM;
93     }
94     else {
95     id = IdIconDefault;
96     }
97     return id;
98     }
99    
100     void IconId2IconName(char *name, int len, int id) {
101     char *icon;
102     switch (id) {
103     case IDI_TTERM:
104     icon = "tterm";
105     break;
106     case IDI_VT:
107     icon = "vt";
108     break;
109     case IDI_TEK:
110     icon = "tek";
111     break;
112     case IDI_TTERM_CLASSIC:
113     icon = "tterm_classic";
114     break;
115     case IDI_VT_CLASSIC:
116     icon = "vt_classic";
117     break;
118 maya 6386 case IDI_TTERM_3D:
119     icon = "tterm_3d";
120     break;
121     case IDI_VT_3D:
122     icon = "vt_3d";
123     break;
124 maya 3227 case IDI_CYGTERM:
125     icon = "cygterm";
126     break;
127     default:
128     icon = "Default";
129     }
130     strncpy_s(name, len, icon, _TRUNCATE);
131     }
132    
133     WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)
134     {
135     char Temp[4];
136     GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
137     if (Default) {
138     if (_stricmp(Temp, "off") == 0)
139     return 0;
140     else
141     return 1;
142     }
143     else {
144     if (_stricmp(Temp, "on") == 0)
145     return 1;
146     else
147     return 0;
148     }
149     }
150    
151     void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)
152     {
153     char Temp[4];
154    
155     if (Flag != 0)
156     strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
157     else
158     strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
159     WritePrivateProfileString(Sect, Key, Temp, FName);
160     }
161    
162     void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)
163     {
164     char Temp[15];
165     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
166     WritePrivateProfileString(Sect, Key, Temp, FName);
167     }
168    
169     void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)
170     {
171     char Temp[15];
172     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
173     WritePrivateProfileString(Sect, Key, Temp, FName);
174     }
175    
176     void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)
177     {
178     char Temp[32];
179     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
180     WritePrivateProfileString(Sect, Key, Temp, FName);
181     }
182    
183     void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,
184     int i1, int i2, int i3, int i4)
185     {
186     char Temp[64];
187     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
188     i1, i2, i3, i4);
189     WritePrivateProfileString(Sect, Key, Temp, FName);
190     }
191    
192     void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,
193     int i1, int i2, int i3, int i4, int i5, int i6)
194     {
195     char Temp[96];
196     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",
197     i1, i2,i3, i4, i5, i6);
198     WritePrivateProfileString(Sect, Key, Temp, FName);
199     }
200    
201     void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
202     PCHAR Name, int x, int y, int charset)
203     {
204     char Temp[80];
205     if (Name[0] != 0)
206     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",
207     Name, x, y, charset);
208     else
209     Temp[0] = 0;
210     WritePrivateProfileString(Sect, Key, Temp, FName);
211     }
212    
213 yutakapon 6119
214    
215     #define CYGTERM_FILE "cygterm.cfg" // CygTerm configuration file
216 yutakapon 6126 #define CYGTERM_FILE_MAXLINE 100
217 yutakapon 6119
218     static void ReadCygtermConfFile(PTTSet ts)
219     {
220     char *cfgfile = CYGTERM_FILE; // CygTerm configuration file
221     char cfg[MAX_PATH];
222     FILE *fp;
223     char buf[256], *head, *body;
224     cygterm_t settings;
225    
226     // try to read CygTerm config file
227     memset(&settings, 0, sizeof(settings));
228     _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "ttermpro.exe %%s %%d /E /KR=SJIS /KT=SJIS /VTICON=CygTerm /nossh");
229     _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "vt100");
230     _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "20000");
231     _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "40");
232     _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "auto");
233     _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "MAKE_MODE=unix");
234     _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "");
235     settings.login_shell = FALSE;
236     settings.home_chdir = FALSE;
237     settings.agent_proxy = FALSE;
238    
239     strncpy_s(cfg, sizeof(cfg), ts->HomeDir, _TRUNCATE);
240     AppendSlash(cfg, sizeof(cfg));
241     strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
242    
243     fp = fopen(cfg, "r");
244     if (fp != NULL) {
245     while (fgets(buf, sizeof(buf), fp) != NULL) {
246     int len = strlen(buf);
247    
248     if (buf[len - 1] == '\n')
249     buf[len - 1] = '\0';
250    
251     split_buffer(buf, '=', &head, &body);
252     if (head == NULL || body == NULL)
253     continue;
254    
255     if (_stricmp(head, "TERM") == 0) {
256     _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "%s", body);
257    
258     }
259     else if (_stricmp(head, "TERM_TYPE") == 0) {
260     _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "%s", body);
261    
262     }
263     else if (_stricmp(head, "PORT_START") == 0) {
264     _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "%s", body);
265    
266     }
267     else if (_stricmp(head, "PORT_RANGE") == 0) {
268     _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "%s", body);
269    
270     }
271     else if (_stricmp(head, "SHELL") == 0) {
272     _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "%s", body);
273    
274     }
275     else if (_stricmp(head, "ENV_1") == 0) {
276     _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "%s", body);
277    
278     }
279     else if (_stricmp(head, "ENV_2") == 0) {
280     _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "%s", body);
281    
282     }
283     else if (_stricmp(head, "LOGIN_SHELL") == 0) {
284     if (strchr("YyTt", *body)) {
285     settings.login_shell = TRUE;
286     }
287    
288     }
289     else if (_stricmp(head, "HOME_CHDIR") == 0) {
290     if (strchr("YyTt", *body)) {
291     settings.home_chdir = TRUE;
292     }
293    
294     }
295     else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
296     if (strchr("YyTt", *body)) {
297     settings.agent_proxy = TRUE;
298     }
299    
300     }
301     else {
302     // TODO: error check
303    
304     }
305     }
306     fclose(fp);
307     }
308    
309     memcpy(&ts->CygtermSettings, &settings, sizeof(cygterm_t));
310     }
311    
312     static void WriteCygtermConfFile(PTTSet ts)
313     {
314     char *cfgfile = CYGTERM_FILE; // CygTerm configuration file
315     char *tmpfile = "cygterm.tmp";
316     char cfg[MAX_PATH];
317     char tmp[MAX_PATH];
318     FILE *fp;
319     FILE *tmp_fp;
320     char buf[256], *head, *body;
321     char uimsg[MAX_UIMSG];
322     cygterm_t settings;
323 yutakapon 6126 char *line[CYGTERM_FILE_MAXLINE];
324     int i, linenum, len;
325 yutakapon 6119
326     // Cygwin���������X�������������������A�t�@�C�����������������B
327     if (ts->CygtermSettings.update_flag == FALSE)
328     return;
329     // �t���O���������ASave setup�����x�����x�������������������������B
330     ts->CygtermSettings.update_flag = FALSE;
331    
332     memcpy(&settings, &ts->CygtermSettings, sizeof(cygterm_t));
333    
334     strncpy_s(cfg, sizeof(cfg), ts->HomeDir, _TRUNCATE);
335     AppendSlash(cfg, sizeof(cfg));
336     strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
337    
338     strncpy_s(tmp, sizeof(tmp), ts->HomeDir, _TRUNCATE);
339     AppendSlash(tmp, sizeof(tmp));
340     strncat_s(tmp, sizeof(tmp), tmpfile, _TRUNCATE);
341    
342 yutakapon 6126 // cygterm.cfg �������������A�������������������������������B
343     memset(line, 0, sizeof(line));
344     linenum = 0;
345 yutakapon 6119 fp = fopen(cfg, "r");
346 yutakapon 6126 if (fp) {
347     i = 0;
348     while (fgets(buf, sizeof(buf), fp) != NULL) {
349     len = strlen(buf);
350     if (buf[len - 1] == '\n')
351     buf[len - 1] = '\0';
352     if (i < CYGTERM_FILE_MAXLINE)
353 yutakapon 6127 line[i++] = _strdup(buf);
354 yutakapon 6126 else
355     break;
356     }
357     linenum = i;
358     fclose(fp);
359     }
360    
361     tmp_fp = fopen(cfg, "w");
362 yutakapon 6119 if (tmp_fp == NULL) {
363     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
364     get_lang_msg("MSG_CYGTERM_CONF_WRITEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
365     "Can't write CygTerm configuration file (%d).", ts->UILanguageFile);
366     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
367     MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
368     }
369     else {
370 yutakapon 6126 if (linenum > 0) {
371     for (i = 0; i < linenum; i++) {
372     split_buffer(line[i], '=', &head, &body);
373 yutakapon 6119 if (head == NULL || body == NULL) {
374 yutakapon 6126 fprintf(tmp_fp, "%s\n", line[i]);
375 yutakapon 6119 }
376     else if (_stricmp(head, "TERM") == 0) {
377     fprintf(tmp_fp, "TERM = %s\n", settings.term);
378     settings.term[0] = '\0';
379     }
380     else if (_stricmp(head, "TERM_TYPE") == 0) {
381     fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
382     settings.term_type[0] = '\0';
383     }
384     else if (_stricmp(head, "PORT_START") == 0) {
385     fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
386     settings.port_start[0] = '\0';
387     }
388     else if (_stricmp(head, "PORT_RANGE") == 0) {
389     fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
390     settings.port_range[0] = '\0';
391     }
392     else if (_stricmp(head, "SHELL") == 0) {
393     fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
394     settings.shell[0] = '\0';
395     }
396     else if (_stricmp(head, "ENV_1") == 0) {
397     fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
398     settings.env1[0] = '\0';
399     }
400     else if (_stricmp(head, "ENV_2") == 0) {
401     fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
402     settings.env2[0] = '\0';
403     }
404     else if (_stricmp(head, "LOGIN_SHELL") == 0) {
405     fprintf(tmp_fp, "LOGIN_SHELL = %s\n", (settings.login_shell == TRUE) ? "yes" : "no");
406     settings.login_shell = FALSE;
407     }
408     else if (_stricmp(head, "HOME_CHDIR") == 0) {
409     fprintf(tmp_fp, "HOME_CHDIR = %s\n", (settings.home_chdir == TRUE) ? "yes" : "no");
410     settings.home_chdir = FALSE;
411     }
412     else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
413     fprintf(tmp_fp, "SSH_AGENT_PROXY = %s\n", (settings.agent_proxy == TRUE) ? "yes" : "no");
414     settings.agent_proxy = FALSE;
415     }
416     else {
417     fprintf(tmp_fp, "%s = %s\n", head, body);
418     }
419     }
420     }
421     else {
422     fputs("# CygTerm setting\n", tmp_fp);
423     fputs("\n", tmp_fp);
424     }
425     if (settings.term[0] != '\0') {
426     fprintf(tmp_fp, "TERM = %s\n", settings.term);
427     }
428     if (settings.term_type[0] != '\0') {
429     fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
430     }
431     if (settings.port_start[0] != '\0') {
432     fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
433     }
434     if (settings.port_range[0] != '\0') {
435     fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
436     }
437     if (settings.shell[0] != '\0') {
438     fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
439     }
440     if (settings.env1[0] != '\0') {
441     fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
442     }
443     if (settings.env2[0] != '\0') {
444     fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
445     }
446     if (settings.login_shell) {
447     fprintf(tmp_fp, "LOGIN_SHELL = yes\n");
448     }
449     if (settings.home_chdir) {
450     fprintf(tmp_fp, "HOME_CHDIR = yes\n");
451     }
452     if (settings.agent_proxy) {
453     fprintf(tmp_fp, "SSH_AGENT_PROXY = yes\n");
454     }
455     fclose(tmp_fp);
456    
457 yutakapon 6126 // �_�C���N�g���t�@�C���������������������������A���L�������s�v�B
458     #if 0
459 yutakapon 6119 if (remove(cfg) != 0 && errno != ENOENT) {
460     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
461     get_lang_msg("MSG_CYGTERM_CONF_REMOVEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
462     "Can't remove old CygTerm configuration file (%d).", ts->UILanguageFile);
463     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
464     MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
465     }
466     else if (rename(tmp, cfg) != 0) {
467     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
468     get_lang_msg("MSG_CYGTERM_CONF_RENAMEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
469     "Can't rename CygTerm configuration file (%d).", ts->UILanguageFile);
470     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
471     MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
472     }
473     else {
474     // cygterm.cfg �t�@�C�����������������������A���b�Z�[�W�_�C�A���O���\�������B
475     // �������ASave setup�����s�����K�v�������������������N�����B
476     // (2012.5.1 yutaka)
477     // Save setup ���s�����ACygTerm�������������������������������������A
478     // �_�C�A���O�\�����s�v�����������A���������B
479     // (2015.11.12 yutaka)
480     get_lang_msg("MSG_TT_NOTICE", uimsg, sizeof(uimsg), "MSG_TT_NOTICE", ts->UILanguageFile);
481     get_lang_msg("MSG_CYGTERM_CONF_SAVED_NOTICE", ts->UIMsg, sizeof(ts->UIMsg),
482     "%s has been saved. Do not do save setup.", ts->UILanguageFile);
483     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, CYGTERM_FILE);
484     MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONINFORMATION);
485 yutakapon 6126 }
486 yutakapon 6119 #endif
487     }
488 yutakapon 6126
489     // �Y�������������t���[���������B
490     for (i = 0; i < linenum; i++) {
491     free(line[i]);
492     }
493    
494 yutakapon 6119 }
495    
496 doda 6801 void PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
497 maya 3227 {
498     int i;
499     HDC TmpDC;
500 doda 4687 char Temp[MAX_PATH], Temp2[MAX_PATH];
501 maya 3227
502     ts->Minimize = 0;
503     ts->HideWindow = 0;
504     ts->LogFlag = 0; // Log flags
505     ts->FTFlag = 0; // File transfer flags
506     ts->MenuFlag = 0; // Menu flags
507     ts->TermFlag = 0; // Terminal flag
508     ts->ColorFlag = 0; // ANSI/Attribute color flags
509 doda 3666 ts->FontFlag = 0; // Font flag
510 maya 3227 ts->PortFlag = 0; // Port flags
511 doda 3485 ts->WindowFlag = 0; // Window flags
512 doda 4700 ts->CtrlFlag = 0; // Control sequence flags
513 doda 6594 ts->PasteFlag = 0; // Clipboard Paste flags
514 maya 3227 ts->TelPort = 23;
515    
516 doda 3388 ts->DisableTCPEchoCR = FALSE;
517    
518 maya 3227 /* Version number */
519     /* GetPrivateProfileString(Section,"Version","",
520     Temp,sizeof(Temp),FName); */
521    
522     /* Language */
523     GetPrivateProfileString(Section, "Language", "",
524     Temp, sizeof(Temp), FName);
525     if (_stricmp(Temp, "Japanese") == 0)
526     ts->Language = IdJapanese;
527     else if (_stricmp(Temp, "Russian") == 0)
528     ts->Language = IdRussian;
529     else if (_stricmp(Temp, "English") == 0)
530     ts->Language = IdEnglish;
531     else if (_stricmp(Temp,"Korean") == 0) // HKS
532     ts->Language = IdKorean;
533 maya 3401 else if (_stricmp(Temp,"UTF-8") == 0)
534     ts->Language = IdUtf8;
535 maya 3227 else {
536     switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
537     case LANG_JAPANESE:
538     ts->Language = IdJapanese;
539     break;
540     case LANG_RUSSIAN:
541     ts->Language = IdRussian;
542     break;
543 doda 3354 case LANG_KOREAN: // HKS
544 doda 6435 ts->Language = IdKorean;
545     break;
546 maya 3227 default:
547     ts->Language = IdEnglish;
548     }
549     }
550    
551     /* Port type */
552     GetPrivateProfileString(Section, "Port", "",
553     Temp, sizeof(Temp), FName);
554 doda 6696 if (_stricmp(Temp, "serial") == 0)
555 maya 3227 ts->PortType = IdSerial;
556     else {
557     ts->PortType = IdTCPIP;
558     }
559    
560     /* VT win position */
561     GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
562     GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
563     GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
564    
565     /* TEK win position */
566     GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
567     GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
568     GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
569    
570     /* Save VT Window position */
571     ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
572    
573     /* VT terminal size */
574     GetPrivateProfileString(Section, "TerminalSize", "80,24",
575     Temp, sizeof(Temp), FName);
576     GetNthNum(Temp, 1, &ts->TerminalWidth);
577     GetNthNum(Temp, 2, &ts->TerminalHeight);
578 doda 6784 if (ts->TerminalWidth <= 0)
579     ts->TerminalWidth = 80;
580     else if (ts->TerminalWidth > TermWidthMax)
581     ts->TerminalWidth = TermWidthMax;
582     if (ts->TerminalHeight <= 0)
583     ts->TerminalHeight = 24;
584     else if (ts->TerminalHeight > TermHeightMax)
585     ts->TerminalHeight = TermHeightMax;
586 maya 3227
587     /* Terminal size = Window size */
588     ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
589    
590     /* Auto window resize flag */
591     ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
592    
593     /* CR Receive */
594     GetPrivateProfileString(Section, "CRReceive", "",
595     Temp, sizeof(Temp), FName);
596     if (_stricmp(Temp, "CRLF") == 0) {
597     ts->CRReceive = IdCRLF;
598     }
599     else if (_stricmp(Temp, "LF") == 0) {
600     ts->CRReceive = IdLF;
601     }
602 maya 4893 else if (_stricmp(Temp, "AUTO") == 0) {
603     ts->CRReceive = IdAUTO;
604     }
605 maya 3227 else {
606     ts->CRReceive = IdCR;
607     }
608     /* CR Send */
609     GetPrivateProfileString(Section, "CRSend", "",
610     Temp, sizeof(Temp), FName);
611 maya 6369 if (_stricmp(Temp, "CRLF") == 0) {
612 maya 3227 ts->CRSend = IdCRLF;
613 maya 6369 }
614     else if (_stricmp(Temp, "LF") == 0) {
615     ts->CRSend = IdLF;
616     }
617     else {
618 maya 3227 ts->CRSend = IdCR;
619 maya 6369 }
620 maya 3227 ts->CRSend_ini = ts->CRSend;
621    
622     /* Local echo */
623     ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
624     ts->LocalEcho_ini = ts->LocalEcho;
625    
626     /* Answerback */
627     GetPrivateProfileString(Section, "Answerback", "", Temp,
628     sizeof(Temp), FName);
629     ts->AnswerbackLen =
630     Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
631    
632     /* Kanji Code (receive) */
633     GetPrivateProfileString(Section, "KanjiReceive", "",
634     Temp, sizeof(Temp), FName);
635     if (_stricmp(Temp, "EUC") == 0)
636     ts->KanjiCode = IdEUC;
637     else if (_stricmp(Temp, "JIS") == 0)
638     ts->KanjiCode = IdJIS;
639     else if (_stricmp(Temp, "UTF-8") == 0)
640     ts->KanjiCode = IdUTF8;
641     else if (_stricmp(Temp, "UTF-8m") == 0)
642     ts->KanjiCode = IdUTF8m;
643 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
644     ts->KanjiCode = IdSJIS;
645 maya 3227 else
646     ts->KanjiCode = IdSJIS;
647 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
648     {
649     WORD KanjiCode = ts->KanjiCode;
650     ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
651     }
652 maya 3227
653     /* Katakana (receive) */
654     GetPrivateProfileString(Section, "KatakanaReceive", "",
655     Temp, sizeof(Temp), FName);
656     if (_stricmp(Temp, "7") == 0)
657     ts->JIS7Katakana = 1;
658     else
659     ts->JIS7Katakana = 0;
660    
661     /* Kanji Code (transmit) */
662     GetPrivateProfileString(Section, "KanjiSend", "",
663     Temp, sizeof(Temp), FName);
664     if (_stricmp(Temp, "EUC") == 0)
665     ts->KanjiCodeSend = IdEUC;
666     else if (_stricmp(Temp, "JIS") == 0)
667     ts->KanjiCodeSend = IdJIS;
668     else if (_stricmp(Temp, "UTF-8") == 0)
669     ts->KanjiCodeSend = IdUTF8;
670 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
671     ts->KanjiCode = IdSJIS;
672 maya 3227 else
673     ts->KanjiCodeSend = IdSJIS;
674 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
675     {
676     WORD KanjiCodeSend = ts->KanjiCodeSend;
677     ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
678     }
679 maya 3227
680     /* Katakana (receive) */
681     GetPrivateProfileString(Section, "KatakanaSend", "",
682     Temp, sizeof(Temp), FName);
683     if (_stricmp(Temp, "7") == 0)
684     ts->JIS7KatakanaSend = 1;
685     else
686     ts->JIS7KatakanaSend = 0;
687    
688     /* KanjiIn */
689     GetPrivateProfileString(Section, "KanjiIn", "",
690     Temp, sizeof(Temp), FName);
691     if (_stricmp(Temp, "@") == 0)
692     ts->KanjiIn = IdKanjiInA;
693     else
694     ts->KanjiIn = IdKanjiInB;
695    
696     /* KanjiOut */
697     GetPrivateProfileString(Section, "KanjiOut", "",
698     Temp, sizeof(Temp), FName);
699     if (_stricmp(Temp, "B") == 0)
700     ts->KanjiOut = IdKanjiOutB;
701     else if (_stricmp(Temp, "H") == 0)
702     ts->KanjiOut = IdKanjiOutH;
703     else
704     ts->KanjiOut = IdKanjiOutJ;
705    
706     /* Auto Win Switch VT<->TEK */
707     ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
708    
709     /* Terminal ID */
710     GetPrivateProfileString(Section, "TerminalID", "",
711     Temp, sizeof(Temp), FName);
712     ts->TerminalID = str2id(TermList, Temp, IdVT100);
713    
714     /* Russian character set (host) */
715     GetPrivateProfileString(Section, "RussHost", "",
716     Temp, sizeof(Temp), FName);
717     ts->RussHost = str2id(RussList, Temp, IdKOI8);
718    
719     /* Russian character set (client) */
720     GetPrivateProfileString(Section, "RussClient", "",
721     Temp, sizeof(Temp), FName);
722     ts->RussClient = str2id(RussList, Temp, IdWindows);
723    
724     /* Title String */
725     GetPrivateProfileString(Section, "Title", "Tera Term",
726     ts->Title, sizeof(ts->Title), FName);
727    
728     /* Cursor shape */
729     GetPrivateProfileString(Section, "CursorShape", "",
730     Temp, sizeof(Temp), FName);
731     if (_stricmp(Temp, "vertical") == 0)
732     ts->CursorShape = IdVCur;
733     else if (_stricmp(Temp, "horizontal") == 0)
734     ts->CursorShape = IdHCur;
735     else
736     ts->CursorShape = IdBlkCur;
737    
738     /* Hide title */
739     ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
740    
741     /* Popup menu */
742     ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
743    
744     /* PC-Style bold color mapping */
745     if (GetOnOff(Section, "PcBoldColor", FName, FALSE))
746     ts->ColorFlag |= CF_PCBOLD16;
747    
748     /* aixterm style 16 colors mode */
749     if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))
750     ts->ColorFlag |= CF_AIXTERM16;
751    
752     /* xterm style 256 colors mode */
753     if (GetOnOff(Section, "Xterm256Color", FName, TRUE))
754     ts->ColorFlag |= CF_XTERM256;
755    
756     /* Enable scroll buffer */
757     ts->EnableScrollBuff =
758     GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
759    
760     /* Scroll buffer size */
761     ts->ScrollBuffSize =
762     GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
763    
764     /* VT Color */
765     GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
766     Temp, sizeof(Temp), FName);
767     for (i = 0; i <= 5; i++)
768     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
769     for (i = 0; i <= 1; i++)
770     ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
771     (BYTE) ts->TmpColor[0][i * 3 + 1],
772     (BYTE) ts->TmpColor[0][i * 3 + 2]);
773    
774     /* VT Bold Color */
775     GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
776     Temp, sizeof(Temp), FName);
777     for (i = 0; i <= 5; i++)
778     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
779     for (i = 0; i <= 1; i++)
780     ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
781     (BYTE) ts->TmpColor[0][i * 3 + 1],
782     (BYTE) ts->TmpColor[0][i * 3 + 2]);
783     if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))
784     ts->ColorFlag |= CF_BOLDCOLOR;
785    
786     /* VT Blink Color */
787     GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
788     Temp, sizeof(Temp), FName);
789     for (i = 0; i <= 5; i++)
790     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
791     for (i = 0; i <= 1; i++)
792     ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
793     (BYTE) ts->TmpColor[0][i * 3 + 1],
794     (BYTE) ts->TmpColor[0][i * 3 + 2]);
795     if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))
796     ts->ColorFlag |= CF_BLINKCOLOR;
797    
798     /* VT Reverse Color */
799     GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
800     Temp, sizeof(Temp), FName);
801     for (i = 0; i <= 5; i++)
802     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
803     for (i = 0; i <= 1; i++)
804     ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
805     (BYTE) ts->TmpColor[0][i * 3 + 1],
806     (BYTE) ts->TmpColor[0][i * 3 + 2]);
807     if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))
808     ts->ColorFlag |= CF_REVERSECOLOR;
809    
810     ts->EnableClickableUrl =
811     GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
812    
813     /* URL Color */
814     GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
815     Temp, sizeof(Temp), FName);
816     for (i = 0; i <= 5; i++)
817     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
818     for (i = 0; i <= 1; i++)
819     ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
820     (BYTE) ts->TmpColor[0][i * 3 + 1],
821     (BYTE) ts->TmpColor[0][i * 3 + 2]);
822     if (GetOnOff(Section, "EnableURLColor", FName, TRUE))
823     ts->ColorFlag |= CF_URLCOLOR;
824    
825 doda 3660 if (GetOnOff(Section, "URLUnderline", FName, TRUE))
826 doda 3666 ts->FontFlag |= FF_URLUNDERLINE;
827 doda 3660
828 maya 3227 /* TEK Color */
829     GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
830     Temp, sizeof(Temp), FName);
831     for (i = 0; i <= 5; i++)
832     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
833     for (i = 0; i <= 1; i++)
834     ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
835     (BYTE) ts->TmpColor[0][i * 3 + 1],
836     (BYTE) ts->TmpColor[0][i * 3 + 2]);
837    
838     /* ANSI color definition (in the case FullColor=on) -- special option
839     o UseTextColor should be off, or the background and foreground color of
840     VTColor are assigned to color-number 0 and 7 respectively, even if
841     they are specified in ANSIColor.
842     o ANSIColor is a set of 4 values that are color-number(0--15),
843     red-value(0--255), green-value(0--255) and blue-value(0--255). */
844     GetPrivateProfileString(Section, "ANSIColor",
845     " 0, 0, 0, 0,"
846     " 1,255, 0, 0,"
847     " 2, 0,255, 0,"
848     " 3,255,255, 0,"
849     " 4, 0, 0,255,"
850     " 5,255, 0,255,"
851     " 6, 0,255,255,"
852     " 7,255,255,255,"
853     " 8,128,128,128,"
854     " 9,128, 0, 0,"
855     "10, 0,128, 0,"
856     "11,128,128, 0,"
857     "12, 0, 0,128,"
858     "13,128, 0,128,"
859     "14, 0,128,128,"
860     "15,192,192,192", Temp, sizeof(Temp), FName);
861     {
862     char *t;
863     int n = 1;
864     for (t = Temp; *t; t++)
865     if (*t == ',')
866     n++;
867     n /= 4;
868 doda 4640 for (i = 0; i < n; i++) {
869 maya 3227 int colorid, r, g, b;
870     GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
871     GetNthNum(Temp, i * 4 + 2, (int far *) &r);
872     GetNthNum(Temp, i * 4 + 3, (int far *) &g);
873     GetNthNum(Temp, i * 4 + 4, (int far *) &b);
874     ts->ANSIColor[colorid & 15] =
875     RGB((BYTE) r, (BYTE) g, (BYTE) b);
876     }
877     }
878    
879     TmpDC = GetDC(0); /* Get screen device context */
880     for (i = 0; i <= 1; i++)
881     ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
882     for (i = 0; i <= 1; i++)
883     ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
884     for (i = 0; i <= 1; i++)
885     ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
886     for (i = 0; i <= 1; i++)
887     ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
888     /* begin - ishizaki */
889     for (i = 0; i <= 1; i++)
890     ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
891     /* end - ishizaki */
892     for (i = 0; i < 16; i++)
893     ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
894     ReleaseDC(0, TmpDC);
895     if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))
896     ts->ColorFlag |= CF_ANSICOLOR;
897    
898     /* TEK color emulation */
899     ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
900    
901     /* VT Font */
902     GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
903     Temp, sizeof(Temp), FName);
904     GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
905     GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
906     GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
907     GetNthNum(Temp, 4, &(ts->VTFontCharSet));
908    
909     /* Bold font flag */
910 doda 3666 if (GetOnOff(Section, "EnableBold", FName, TRUE))
911     ts->FontFlag |= FF_BOLD;
912 maya 3227
913     /* Russian character set (font) */
914     GetPrivateProfileString(Section, "RussFont", "",
915     Temp, sizeof(Temp), FName);
916     ts->RussFont = str2id(RussList, Temp, IdWindows);
917    
918     /* TEK Font */
919     GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
920     Temp, sizeof(Temp), FName);
921     GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
922     GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
923     GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
924     GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
925    
926     /* BS key */
927     GetPrivateProfileString(Section, "BSKey", "",
928     Temp, sizeof(Temp), FName);
929     if (_stricmp(Temp, "DEL") == 0)
930     ts->BSKey = IdDEL;
931     else
932     ts->BSKey = IdBS;
933     /* Delete key */
934     ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
935    
936     /* Meta Key */
937 doda 4414 GetPrivateProfileString(Section, "MetaKey", "off", Temp, sizeof(Temp), FName);
938     if (_stricmp(Temp, "on") == 0)
939     ts->MetaKey = IdMetaOn;
940     else if (_stricmp(Temp, "left") == 0)
941     ts->MetaKey = IdMetaLeft;
942     else if (_stricmp(Temp, "right") == 0)
943     ts->MetaKey = IdMetaRight;
944     else
945     ts->MetaKey = IdMetaOff;
946 maya 3227
947 doda 4414 // Windows95 �n�����E�� Alt ��������������
948 yutakapon 6286 if (!IsWindowsNTKernel() && ts->MetaKey != IdMetaOff) {
949 doda 4414 ts->MetaKey = IdMetaOn;
950     }
951    
952 maya 3227 /* Application Keypad */
953     ts->DisableAppKeypad =
954     GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
955    
956     /* Application Cursor */
957     ts->DisableAppCursor =
958     GetOnOff(Section, "DisableAppCursor", FName, FALSE);
959    
960     /* Russian keyboard type */
961     GetPrivateProfileString(Section, "RussKeyb", "",
962     Temp, sizeof(Temp), FName);
963     ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
964    
965     /* Serial port ID */
966     ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
967    
968     /* Baud rate */
969 maya 3874 ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
970 maya 3227
971     /* Parity */
972     GetPrivateProfileString(Section, "Parity", "",
973     Temp, sizeof(Temp), FName);
974     if (_stricmp(Temp, "even") == 0)
975     ts->Parity = IdParityEven;
976     else if (_stricmp(Temp, "odd") == 0)
977     ts->Parity = IdParityOdd;
978 doda 4849 else if (_stricmp(Temp, "mark") == 0)
979     ts->Parity = IdParityMark;
980     else if (_stricmp(Temp, "space") == 0)
981     ts->Parity = IdParitySpace;
982 maya 3227 else
983     ts->Parity = IdParityNone;
984    
985     /* Data bit */
986     GetPrivateProfileString(Section, "DataBit", "",
987     Temp, sizeof(Temp), FName);
988     if (_stricmp(Temp, "7") == 0)
989     ts->DataBit = IdDataBit7;
990     else
991     ts->DataBit = IdDataBit8;
992    
993     /* Stop bit */
994     GetPrivateProfileString(Section, "StopBit", "",
995     Temp, sizeof(Temp), FName);
996     if (_stricmp(Temp, "2") == 0)
997     ts->StopBit = IdStopBit2;
998 doda 4849 else if (_stricmp(Temp, "1.5") == 0)
999     ts->StopBit = IdStopBit15;
1000 maya 3227 else
1001     ts->StopBit = IdStopBit1;
1002    
1003     /* Flow control */
1004     GetPrivateProfileString(Section, "FlowCtrl", "",
1005     Temp, sizeof(Temp), FName);
1006     if (_stricmp(Temp, "x") == 0)
1007     ts->Flow = IdFlowX;
1008     else if (_stricmp(Temp, "hard") == 0)
1009     ts->Flow = IdFlowHard;
1010     else
1011     ts->Flow = IdFlowNone;
1012    
1013     /* Delay per character */
1014     ts->DelayPerChar =
1015     GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1016    
1017     /* Delay per line */
1018     ts->DelayPerLine =
1019     GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1020    
1021     /* Telnet flag */
1022     ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1023    
1024     /* Telnet terminal type */
1025     GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1026     sizeof(ts->TermType), FName);
1027    
1028     /* TCP port num */
1029     ts->TCPPort =
1030     GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1031    
1032     /* Auto window close flag */
1033     ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1034    
1035     /* History list */
1036     ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1037    
1038     /* File transfer binary flag */
1039     ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1040    
1041 doda 3887 /* Log binary flag */
1042     ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1043    
1044 maya 3227 /* Log append */
1045     ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1046    
1047     /* Log plain text (2005.5.7 yutaka) */
1048     ts->LogTypePlainText =
1049     GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1050    
1051     /* Log with timestamp (2006.7.23 maya) */
1052     ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1053    
1054     /* Log without transfer dialog */
1055     ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1056    
1057 yutakapon 5444 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1058 yutakapon 5392
1059 maya 6767 /* Timestamp format of Log each line */
1060 maya 6795 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1061 maya 6767 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1062     FName);
1063    
1064 maya 6768 /* Use UTC/GMT time for Log each line timestamp */
1065     ts->LogTimestampUTC = GetOnOff(Section, "LogTimestampUTC", FName, FALSE);
1066    
1067 doda 5312 /* File Transfer dialog visibility */
1068     ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1069    
1070 maya 3227 /* Default Log file name (2006.8.28 maya) */
1071     GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1072     ts->LogDefaultName, sizeof(ts->LogDefaultName),
1073     FName);
1074    
1075     /* Default Log file path (2007.5.30 maya) */
1076     GetPrivateProfileString(Section, "LogDefaultPath", "",
1077     ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
1078     FName);
1079    
1080     /* Auto start logging (2007.5.31 maya) */
1081     ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1082    
1083 yutakapon 5171 /* Log Rotate (2013.3.24 yutaka) */
1084     ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1085     ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1086     ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1087     ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1088    
1089 yutakapon 5206 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1090     ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1091 yutakapon 5171
1092 yutakapon 5206
1093 maya 3227 /* XMODEM option */
1094     GetPrivateProfileString(Section, "XmodemOpt", "",
1095     Temp, sizeof(Temp), FName);
1096     if (_stricmp(Temp, "crc") == 0)
1097     ts->XmodemOpt = XoptCRC;
1098     else if (_stricmp(Temp, "1k") == 0)
1099 doda 6219 ts->XmodemOpt = Xopt1kCRC;
1100 doda 6328 else if (_stricmp(Temp, "1ksum") == 0)
1101     ts->XmodemOpt = Xopt1kCksum;
1102 maya 3227 else
1103     ts->XmodemOpt = XoptCheck;
1104    
1105     /* XMODEM binary file */
1106     ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1107    
1108     /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1109     GetPrivateProfileString(Section, "XModemRcvCommand", "",
1110     ts->XModemRcvCommand,
1111     sizeof(ts->XModemRcvCommand), FName);
1112    
1113     /* Default directory for file transfer */
1114     GetPrivateProfileString(Section, "FileDir", "",
1115     ts->FileDir, sizeof(ts->FileDir), FName);
1116     if (strlen(ts->FileDir) == 0)
1117 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1118 maya 3227 else {
1119     _getcwd(Temp, sizeof(Temp));
1120     if (_chdir(ts->FileDir) != 0)
1121 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1122 maya 3227 _chdir(Temp);
1123     }
1124    
1125     /* filter on file send (2007.6.5 maya) */
1126     GetPrivateProfileString(Section, "FileSendFilter", "",
1127     ts->FileSendFilter, sizeof(ts->FileSendFilter),
1128     FName);
1129    
1130 yutakapon 4880 /* SCP���M���p�X (2012.4.6 yutaka) */
1131 doda 6457 GetPrivateProfileString(Section, "ScpSendDir", "",
1132 yutakapon 4880 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1133    
1134    
1135 maya 3227 /*--------------------------------------------------*/
1136     /* 8 bit control code flag -- special option */
1137     if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1138     ts->TermFlag |= TF_ACCEPT8BITCTRL;
1139    
1140     /* Wrong sequence flag -- special option */
1141     if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1142     ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1143    
1144     if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1145     (ts->KanjiOut == IdKanjiOutH))
1146     ts->KanjiOut = IdKanjiOutJ;
1147    
1148 maya 6083 // Detect disconnect/reconnect of serial port --- special option
1149 maya 6115 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1150 maya 6083
1151 maya 3227 // Auto file renaming --- special option
1152     if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1153     ts->FTFlag |= FT_RENAME;
1154    
1155     // Auto invoking (character set->G0->GL) --- special option
1156     if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1157     ts->TermFlag |= TF_AUTOINVOKE;
1158    
1159     // Auto text copy --- special option
1160     ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1161    
1162     /* Back wrap -- special option */
1163     if (GetOnOff(Section, "BackWrap", FName, FALSE))
1164     ts->TermFlag |= TF_BACKWRAP;
1165    
1166     /* Beep type -- special option */
1167 doda 4082 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1168 maya 3227 if (_stricmp(Temp, "off") == 0)
1169     ts->Beep = IdBeepOff;
1170     else if (_stricmp(Temp, "visual") == 0)
1171     ts->Beep = IdBeepVisual;
1172     else
1173     ts->Beep = IdBeepOn;
1174    
1175     /* Beep on connection & disconnection -- special option */
1176     if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1177     ts->PortFlag |= PF_BEEPONCONNECT;
1178    
1179     /* Auto B-Plus activation -- special option */
1180     if (GetOnOff(Section, "BPAuto", FName, FALSE))
1181     ts->FTFlag |= FT_BPAUTO;
1182     if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1183     strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1184     _TRUNCATE);
1185     ts->AnswerbackLen = 5;
1186     }
1187    
1188     /* B-Plus ESCCTL flag -- special option */
1189     if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1190     ts->FTFlag |= FT_BPESCCTL;
1191    
1192     /* B-Plus log -- special option */
1193     if (GetOnOff(Section, "BPLog", FName, FALSE))
1194     ts->LogFlag |= LOG_BP;
1195    
1196     /* Clear serial port buffer when port opening -- special option */
1197     ts->ClearComBuffOnOpen =
1198     GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1199    
1200 salarm 6349 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1201     ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1202    
1203 maya 3227 /* Confirm disconnection -- special option */
1204     if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1205     ts->PortFlag |= PF_CONFIRMDISCONN;
1206    
1207     /* Ctrl code in Kanji -- special option */
1208     if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1209     ts->TermFlag |= TF_CTRLINKANJI;
1210    
1211     /* Debug flag -- special option */
1212     ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1213    
1214     /* Delimiter list -- special option */
1215     GetPrivateProfileString(Section, "DelimList",
1216     "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1217     Temp, sizeof(Temp), FName);
1218     Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1219    
1220     /* regard DBCS characters as delimiters -- special option */
1221     ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1222    
1223     // Enable popup menu -- special option
1224     if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1225     ts->MenuFlag |= MF_NOPOPUP;
1226    
1227     // Enable "Show menu" -- special option
1228     if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1229     ts->MenuFlag |= MF_NOSHOWMENU;
1230    
1231     // Enable the status line -- special option
1232     if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1233     ts->TermFlag |= TF_ENABLESLINE;
1234    
1235 maya 6079 // Enable multiple bytes send -- special option
1236 maya 6115 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1237 maya 6079
1238 maya 3227 // fixed JIS --- special
1239     if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1240     ts->TermFlag |= TF_FIXEDJIS;
1241    
1242     /* IME Flag -- special option */
1243     ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1244    
1245     /* IME-inline Flag -- special option */
1246     ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1247    
1248     /* Kermit log -- special option */
1249     if (GetOnOff(Section, "KmtLog", FName, FALSE))
1250     ts->LogFlag |= LOG_KMT;
1251 yutakapon 4810 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1252     ts->KermitOpt |= KmtOptLongPacket;
1253     if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1254     ts->KermitOpt |= KmtOptFileAttr;
1255 maya 3227
1256     // Enable language selection -- special option
1257     if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1258     ts->MenuFlag |= MF_NOLANGUAGE;
1259    
1260     /* Maximum scroll buffer size -- special option */
1261     ts->ScrollBuffMax =
1262     GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1263     if (ts->ScrollBuffMax < 24)
1264     ts->ScrollBuffMax = 10000;
1265    
1266     /* Max com port number -- special option */
1267 doda 6467 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1268 maya 3227 if (ts->MaxComPort < 4)
1269     ts->MaxComPort = 4;
1270     if (ts->MaxComPort > MAXCOMPORT)
1271     ts->MaxComPort = MAXCOMPORT;
1272     if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1273     ts->ComPort = 1;
1274    
1275     /* Non-blinking cursor -- special option */
1276     ts->NonblinkingCursor =
1277     GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1278    
1279     // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1280     ts->KillFocusCursor =
1281     GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1282    
1283     /* Delay for pass-thru printing activation */
1284     /* -- special option */
1285     ts->PassThruDelay =
1286     GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1287    
1288     /* Printer port for pass-thru printing */
1289     /* -- special option */
1290     GetPrivateProfileString(Section, "PassThruPort", "",
1291     ts->PrnDev, sizeof(ts->PrnDev), FName);
1292    
1293 doda 4397 /* �v�����^�p�����R�[�h�������t������ */
1294     if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1295     ts->TermFlag |= TF_PRINTERCTRL;
1296 yutakapon 4393
1297 maya 3227 /* Printer Font --- special option */
1298     GetPrivateProfileString(Section, "PrnFont", "",
1299     Temp, sizeof(Temp), FName);
1300     if (strlen(Temp) == 0) {
1301     ts->PrnFont[0] = 0;
1302     ts->PrnFontSize.x = 0;
1303     ts->PrnFontSize.y = 0;
1304     ts->PrnFontCharSet = 0;
1305     }
1306     else {
1307     GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
1308     GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
1309     GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
1310     GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
1311     }
1312    
1313     // Page margins (left, right, top, bottom) for printing
1314     // -- special option
1315     GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1316     Temp, sizeof(Temp), FName);
1317     for (i = 0; i <= 3; i++)
1318     GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1319    
1320     /* Quick-VAN log -- special option */
1321     if (GetOnOff(Section, "QVLog", FName, FALSE))
1322     ts->LogFlag |= LOG_QV;
1323    
1324     /* Quick-VAN window size -- special */
1325     ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1326    
1327     /* Russian character set (print) -- special option */
1328     GetPrivateProfileString(Section, "RussPrint", "",
1329     Temp, sizeof(Temp), FName);
1330     ts->RussPrint = str2id(RussList, Temp, IdWindows);
1331    
1332     /* Scroll threshold -- special option */
1333     ts->ScrollThreshold =
1334     GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1335    
1336     ts->MouseWheelScrollLine =
1337     GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1338    
1339     // Select on activate -- special option
1340     ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1341    
1342     /* Send 8bit control sequence -- special option */
1343     ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1344    
1345 maya 5694 /* SendBreak time (in msec) -- special option */
1346     ts->SendBreakTime =
1347     GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1348    
1349 maya 3227 /* Startup macro -- special option */
1350     GetPrivateProfileString(Section, "StartupMacro", "",
1351     ts->MacroFN, sizeof(ts->MacroFN), FName);
1352    
1353     /* TEK GIN Mouse keycode -- special option */
1354     ts->GINMouseCode =
1355     GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1356    
1357     /* Telnet Auto Detect -- special option */
1358     ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1359    
1360     /* Telnet binary flag -- special option */
1361     ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1362    
1363     /* Telnet Echo flag -- special option */
1364     ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1365    
1366     /* Telnet log -- special option */
1367     if (GetOnOff(Section, "TelLog", FName, FALSE))
1368     ts->LogFlag |= LOG_TEL;
1369    
1370     /* TCP port num for telnet -- special option */
1371     ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1372    
1373     /* Telnet keep-alive packet(NOP command) interval -- special option */
1374     ts->TelKeepAliveInterval =
1375     GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1376    
1377     /* Max number of broadcast commad history */
1378     ts->MaxBroadcatHistory =
1379     GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1380    
1381     /* Local echo for non-telnet */
1382     ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1383    
1384     /* "new-line (transmit)" option for non-telnet -- special option */
1385     GetPrivateProfileString(Section, "TCPCRSend", "",
1386     Temp, sizeof(Temp), FName);
1387     if (_stricmp(Temp, "CR") == 0)
1388     ts->TCPCRSend = IdCR;
1389     else if (_stricmp(Temp, "CRLF") == 0)
1390     ts->TCPCRSend = IdCRLF;
1391     else
1392     ts->TCPCRSend = 0; // disabled
1393    
1394     /* Use text (background) color for "white (black)" --- special option */
1395     if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1396     ts->ColorFlag |= CF_USETEXTCOLOR;
1397    
1398     /* Title format -- special option */
1399     ts->TitleFormat =
1400 maya 6170 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1401 maya 3227
1402     /* VT Compatible Tab -- special option */
1403     ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1404    
1405     /* VT Font space --- special option */
1406     GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1407     Temp, sizeof(Temp), FName);
1408     GetNthNum(Temp, 1, &ts->FontDX);
1409     GetNthNum(Temp, 2, &ts->FontDW);
1410     GetNthNum(Temp, 3, &ts->FontDY);
1411     GetNthNum(Temp, 4, &ts->FontDH);
1412     if (ts->FontDX < 0)
1413     ts->FontDX = 0;
1414     if (ts->FontDW < 0)
1415     ts->FontDW = 0;
1416     ts->FontDW = ts->FontDW + ts->FontDX;
1417     if (ts->FontDY < 0)
1418     ts->FontDY = 0;
1419     if (ts->FontDH < 0)
1420     ts->FontDH = 0;
1421     ts->FontDH = ts->FontDH + ts->FontDY;
1422    
1423     // VT-print scaling factors (pixels per inch) --- special option
1424     GetPrivateProfileString(Section, "VTPPI", "0,0",
1425     Temp, sizeof(Temp), FName);
1426     GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1427     GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1428    
1429     // TEK-print scaling factors (pixels per inch) --- special option
1430     GetPrivateProfileString(Section, "TEKPPI", "0,0",
1431     Temp, sizeof(Temp), FName);
1432     GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1433     GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1434    
1435     // Show "Window" menu -- special option
1436     if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1437     ts->MenuFlag |= MF_SHOWWINMENU;
1438    
1439     /* XMODEM log -- special option */
1440     if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1441     ts->LogFlag |= LOG_X;
1442    
1443     /* YMODEM log -- special option */
1444     if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1445     ts->LogFlag |= LOG_Y;
1446    
1447 yutakapon 3815 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1448     GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1449     ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1450    
1451 maya 3227 /* Auto ZMODEM activation -- special option */
1452     if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1453     ts->FTFlag |= FT_ZAUTO;
1454    
1455     /* ZMODEM data subpacket length for sending -- special */
1456     ts->ZmodemDataLen =
1457     GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1458     /* ZMODEM window size for sending -- special */
1459     ts->ZmodemWinSize =
1460     GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1461    
1462     /* ZMODEM ESCCTL flag -- special option */
1463     if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1464     ts->FTFlag |= FT_ZESCCTL;
1465    
1466     /* ZMODEM log -- special option */
1467     if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1468     ts->LogFlag |= LOG_Z;
1469    
1470     /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1471     GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1472     ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1473    
1474     /* Enable continued-line copy -- special option */
1475     ts->EnableContinuedLineCopy =
1476     GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1477    
1478 doda 6594 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1479     ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1480 maya 3227
1481 doda 6594 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1482     ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1483 maya 3227
1484 doda 6594 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1485     ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1486 maya 3227
1487 doda 6594 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1488     ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1489    
1490     if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1491     ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1492    
1493 yutakapon 3535 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1494     Temp, sizeof(Temp), FName);
1495 doda 6594
1496 yutakapon 3535 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1497     _TRUNCATE);
1498 maya 3227
1499     // added ScrollWindowClearScreen (2008.5.3 yutaka)
1500     ts->ScrollWindowClearScreen =
1501     GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1502    
1503     // added SelectOnlyByLButton (2007.11.20 maya)
1504     ts->SelectOnlyByLButton =
1505     GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1506    
1507     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1508     ts->DisableAcceleratorSendBreak =
1509     GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1510    
1511     // WinSock connecting timeout value (2007.1.11 yutaka)
1512     ts->ConnectingTimeout =
1513     GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1514    
1515 doda 6435 // mouse cursor
1516 maya 3227 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1517     Temp, sizeof(Temp), FName);
1518     strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1519     _TRUNCATE);
1520    
1521     // Translucent window
1522     ts->AlphaBlend =
1523     GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1524     ts->AlphaBlend = max(0, ts->AlphaBlend);
1525     ts->AlphaBlend = min(255, ts->AlphaBlend);
1526    
1527     // Cygwin install path
1528     GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1529     Temp, sizeof(Temp), FName);
1530     strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1531     _TRUNCATE);
1532    
1533     // Viewlog Editor path
1534 doda 4198 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1535     strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1536     }
1537     else {
1538     Temp[0] = '\0';
1539     }
1540     GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1541     ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1542 maya 3227
1543     // Locale for UTF-8
1544     GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1545     Temp, sizeof(Temp), FName);
1546     strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1547    
1548     // CodePage
1549     ts->CodePage =
1550     GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1551     FName);
1552    
1553     // UI language message file
1554     GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1555     Temp, sizeof(Temp), FName);
1556     {
1557     char CurDir[MAX_PATH];
1558    
1559     // �t���p�X�������O������������������������������
1560     strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1561    
1562     GetCurrentDirectory(sizeof(CurDir), CurDir);
1563     SetCurrentDirectory(ts->HomeDir);
1564     _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1565     SetCurrentDirectory(CurDir);
1566     }
1567    
1568     // Broadcast Command History (2007.3.3 maya)
1569     ts->BroadcastCommandHistory =
1570     GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1571    
1572     // 337: 2007/03/20 Accept Broadcast
1573     ts->AcceptBroadcast =
1574     GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1575    
1576     // Confirm send a file when drag and drop (2007.12.28 maya)
1577     ts->ConfirmFileDragAndDrop =
1578     GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1579    
1580     // Translate mouse wheel to cursor key when application cursor mode
1581     ts->TranslateWheelToCursor =
1582     GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1583    
1584     // Display "New Connection" dialog on startup (2008.1.18 maya)
1585     ts->HostDialogOnStartup =
1586     GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1587    
1588     // Mouse event tracking
1589     ts->MouseEventTracking =
1590     GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1591    
1592     // Maximized bug tweak
1593 doda 6730 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1594 doda 6671 sizeof(Temp), FName);
1595     if (_stricmp(Temp, "on") == 0) {
1596 doda 6730 ts->MaximizedBugTweak = 2;
1597 doda 6671 }
1598     else {
1599     ts->MaximizedBugTweak = atoi(Temp);
1600     }
1601 maya 3227
1602     // Convert Unicode symbol characters to DEC Special characters
1603     ts->UnicodeDecSpMapping =
1604     GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1605    
1606     // VT Window Icon
1607     GetPrivateProfileString(Section, "VTIcon", "Default",
1608     Temp, sizeof(Temp), FName);
1609     ts->VTIcon = IconName2IconId(Temp);
1610    
1611     // Tek Window Icon
1612     GetPrivateProfileString(Section, "TEKIcon", "Default",
1613     Temp, sizeof(Temp), FName);
1614     ts->TEKIcon = IconName2IconId(Temp);
1615    
1616     // Unknown Unicode Character
1617     ts->UnknownUnicodeCharaAsWide =
1618     GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1619    
1620     #ifdef USE_NORMAL_BGCOLOR
1621     // UseNormalBGColor
1622     ts->UseNormalBGColor =
1623     GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1624     // 2006/03/11 by 337
1625     if (ts->UseNormalBGColor) {
1626     ts->VTBoldColor[1] =
1627     ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1628     }
1629     #endif
1630    
1631     // AutoScrollOnlyInBottomLine
1632     ts->AutoScrollOnlyInBottomLine =
1633     GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1634    
1635     // Accept remote-controlled window title changing
1636     GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1637     Temp, sizeof(Temp), FName);
1638     if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1639     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1640     else if (_stricmp(Temp, "ahead") == 0)
1641     ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1642     else if (_stricmp(Temp, "last") == 0)
1643     ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1644     else
1645     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1646    
1647     // Size of paste confirm dialog
1648     GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1649     Temp, sizeof(Temp), FName);
1650     GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1651     GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1652     if (ts->PasteDialogSize.cx < 0)
1653     ts->PasteDialogSize.cx = 330;
1654     if (ts->PasteDialogSize.cy < 0)
1655     ts->PasteDialogSize.cy = 220;
1656    
1657     // Disable mouse event tracking when Control-Key is pressed.
1658     ts->DisableMouseTrackingByCtrl =
1659     GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1660    
1661     // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1662     ts->DisableWheelToCursorByCtrl =
1663     GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1664    
1665     // Strict Key Mapping.
1666     ts->StrictKeyMapping =
1667     GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1668    
1669     // added Wait4allMacroCommand (2009.3.23 yutaka)
1670     ts->Wait4allMacroCommand =
1671     GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1672 maya 3279
1673 maya 3283 // added DisableMenuSendBreak (2009.4.6 maya)
1674     ts->DisableMenuSendBreak =
1675     GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1676 maya 3282
1677 maya 3283 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1678     ts->ClearScreenOnCloseConnection =
1679     GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1680    
1681     // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1682 maya 3282 ts->DisableAcceleratorDuplicateSession =
1683     GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1684 maya 3306
1685 maya 5684 ts->AcceleratorNewConnection =
1686     GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1687    
1688     ts->AcceleratorCygwinConnection =
1689     GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1690    
1691 maya 3964 // added DisableMenuDuplicateSession (2010.8.3 maya)
1692     ts->DisableMenuDuplicateSession =
1693     GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1694    
1695 maya 3965 // added DisableMenuNewConnection (2010.8.4 maya)
1696     ts->DisableMenuNewConnection =
1697     GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1698    
1699 maya 3306 // added PasteDelayPerLine (2009.4.12 maya)
1700     ts->PasteDelayPerLine =
1701     GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1702 maya 3315 {
1703     int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1704     ts->PasteDelayPerLine = tmp;
1705     }
1706 doda 3395
1707     // Font scaling -- test
1708     ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1709 doda 3441
1710     // Meta sets MSB
1711 doda 3507 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1712     if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1713     ts->Meta8Bit = IdMeta8BitRaw;
1714     else if (_stricmp(Temp, "text") == 0)
1715     ts->Meta8Bit = IdMeta8BitText;
1716     else
1717     ts->Meta8Bit = IdMeta8BitOff;
1718    
1719 maya 3479 // Window control sequence
1720 doda 3485 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1721     ts->WindowFlag |= WF_WINDOWCHANGE;
1722 maya 3479
1723     // Cursor control sequence
1724 doda 3485 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1725     ts->WindowFlag |= WF_CURSORCHANGE;
1726    
1727     // Window report sequence
1728     if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1729     ts->WindowFlag |= WF_WINDOWREPORT;
1730    
1731 doda 3749 // Title report sequence
1732 doda 3747 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1733 doda 3774 if (_stricmp(Temp, "accept") == 0)
1734     ts->WindowFlag |= IdTitleReportAccept;
1735     else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1736 doda 3747 ts->WindowFlag &= ~WF_TITLEREPORT;
1737     else // empty
1738     ts->WindowFlag |= IdTitleReportEmpty;
1739 doda 3501
1740     // Line at a time mode
1741     ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1742 doda 3721
1743     // Clear window on resize
1744     if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1745     ts->TermFlag |= TF_CLEARONRESIZE;
1746 doda 3743
1747     // Alternate Screen Buffer
1748     if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1749     ts->TermFlag |= TF_ALTSCR;
1750 doda 3969
1751     // IME status related cursor style
1752     if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1753     ts->WindowFlag |= WF_IMECURSORCHANGE;
1754 doda 4217
1755     // Terminal Unique ID
1756     GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1757     if (strlen(Temp) == 8) {
1758 doda 4228 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1759 doda 4217 if (islower(Temp[i])) {
1760     ts->TerminalUID[i] = toupper(Temp[i]);
1761     }
1762     else {
1763     ts->TerminalUID[i] = Temp[i];
1764     }
1765     }
1766     if (i == 8) {
1767     ts->TerminalUID[i] = 0;
1768     }
1769     else {
1770     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1771     }
1772     }
1773     else {
1774     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1775     }
1776 doda 4225
1777     // Lock Terminal UID
1778     if (GetOnOff(Section, "LockTUID", FName, TRUE))
1779     ts->TermFlag |= TF_LOCKTUID;
1780 doda 6435
1781 doda 4480 // Jump List
1782     ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1783    
1784 doda 4699 // TabStopModifySequence
1785 doda 4687 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1786     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1787     ts->TabStopFlag = TABF_ALL;
1788     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1789     ts->TabStopFlag = TABF_NONE;
1790     else {
1791     ts->TabStopFlag = TABF_NONE;
1792     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1793     if (_stricmp(Temp2, "HTS") == 0)
1794     ts->TabStopFlag |= TABF_HTS;
1795     else if (_stricmp(Temp2, "HTS7") == 0)
1796     ts->TabStopFlag |= TABF_HTS7;
1797     else if (_stricmp(Temp2, "HTS8") == 0)
1798     ts->TabStopFlag |= TABF_HTS8;
1799     else if (_stricmp(Temp2, "TBC") == 0)
1800     ts->TabStopFlag |= TABF_TBC;
1801     else if (_stricmp(Temp2, "TBC0") == 0)
1802     ts->TabStopFlag |= TABF_TBC0;
1803     else if (_stricmp(Temp2, "TBC3") == 0)
1804     ts->TabStopFlag |= TABF_TBC3;
1805     }
1806     }
1807    
1808 doda 4700 // Clipboard Access from Remote
1809     GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1810     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1811     ts->CtrlFlag |= CSF_CBRW;
1812     else if (_stricmp(Temp, "read") == 0)
1813     ts->CtrlFlag |= CSF_CBREAD;
1814     else if (_stricmp(Temp, "write") == 0)
1815     ts->CtrlFlag |= CSF_CBWRITE;
1816    
1817 doda 6666 // Notify Clipboard Access from Remote
1818     ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
1819    
1820 doda 4281 // Use invalid DECRPSS (for testing)
1821     if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1822     ts->TermFlag |= TF_INVALIDDECRPSS;
1823 maya 4704
1824     // ClickableUrlBrowser
1825     GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1826     ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1827     GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1828     ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1829 maya 4786
1830     // Exclusive Lock when open the log file
1831     ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1832 maya 4874
1833     // Font quality
1834     GetPrivateProfileString(Section, "FontQuality", "default",
1835     Temp, sizeof(Temp), FName);
1836     if (_stricmp(Temp, "nonantialiased") == 0)
1837     ts->FontQuality = NONANTIALIASED_QUALITY;
1838     else if (_stricmp(Temp, "antialiased") == 0)
1839     ts->FontQuality = ANTIALIASED_QUALITY;
1840     else if (_stricmp(Temp, "cleartype") == 0)
1841     ts->FontQuality = CLEARTYPE_QUALITY;
1842     else
1843     ts->FontQuality = DEFAULT_QUALITY;
1844 doda 5316
1845     // Beep Over Used
1846     ts->BeepOverUsedCount =
1847     GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1848     ts->BeepOverUsedTime =
1849     GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1850     ts->BeepSuppressTime =
1851     GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1852 doda 5410
1853     // Max OSC string buffer size
1854     ts->MaxOSCBufferSize =
1855     GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1856 doda 5428
1857 doda 5438 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1858 doda 5428
1859 doda 5438 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1860     ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1861 doda 5590
1862     // Debug modes.
1863     GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1864     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1865     ts->DebugModes = DBGF_ALL;
1866     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1867     ts->DebugModes = DBGF_NONE;
1868     ts->Debug = FALSE;
1869     }
1870     else {
1871     ts->DebugModes = DBGF_NONE;
1872     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1873     if (_stricmp(Temp2, "normal") == 0)
1874     ts->DebugModes |= DBGF_NORM;
1875     else if (_stricmp(Temp2, "hex") == 0)
1876     ts->DebugModes |= DBGF_HEXD;
1877     else if (_stricmp(Temp2, "noout") == 0)
1878     ts->DebugModes |= DBGF_NOUT;
1879     }
1880     if (ts->DebugModes == DBGF_NONE)
1881     ts->Debug = FALSE;
1882     }
1883 yutakapon 6119
1884 doda 6318 // Xmodem Timeout
1885     GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1886     ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1887     if (ts->XmodemTimeOutInit < 1)
1888     ts->XmodemTimeOutInit = 1;
1889     ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1890     if (ts->XmodemTimeOutInitCRC < 1)
1891     ts->XmodemTimeOutInitCRC = 1;
1892     ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1893     if (ts->XmodemTimeOutShort < 1)
1894     ts->XmodemTimeOutShort = 1;
1895     ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1896     if (ts->XmodemTimeOutLong < 1)
1897     ts->XmodemTimeOutLong = 1;
1898     ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1899     if (ts->XmodemTimeOutVLong < 1)
1900     ts->XmodemTimeOutVLong = 1;
1901    
1902 maya 6319 // Ymodem Timeout
1903     GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1904     ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1905     if (ts->YmodemTimeOutInit < 1)
1906     ts->YmodemTimeOutInit = 1;
1907     ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1908     if (ts->YmodemTimeOutInitCRC < 1)
1909     ts->YmodemTimeOutInitCRC = 1;
1910     ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1911     if (ts->YmodemTimeOutShort < 1)
1912     ts->YmodemTimeOutShort = 1;
1913     ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1914     if (ts->YmodemTimeOutLong < 1)
1915     ts->YmodemTimeOutLong = 1;
1916     ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1917     if (ts->YmodemTimeOutVLong < 1)
1918     ts->YmodemTimeOutVLong = 1;
1919    
1920     // Zmodem Timeout
1921     GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1922     ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1923     if (ts->ZmodemTimeOutNormal < 1)
1924     ts->ZmodemTimeOutNormal = 1;
1925     ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1926     if (ts->ZmodemTimeOutTCPIP < 0)
1927     ts->ZmodemTimeOutTCPIP = 0;
1928     ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1929     if (ts->ZmodemTimeOutInit < 1)
1930     ts->ZmodemTimeOutInit = 1;
1931     ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1932     if (ts->ZmodemTimeOutFin < 1)
1933     ts->ZmodemTimeOutFin = 1;
1934    
1935 doda 6418 // Trim trailing new line character when pasting
1936 doda 6594 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
1937     ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
1938 doda 6418
1939 doda 6595 // Normalize line break when pasting
1940     if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
1941     ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
1942    
1943 doda 6603
1944     // Fallback to CP932 (Experimental)
1945     ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
1946    
1947 yutakapon 6119 // CygTerm Configuration File
1948     ReadCygtermConfFile(ts);
1949 maya 3227 }
1950    
1951 doda 6801 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
1952 maya 3227 {
1953     int i;
1954 maya 4031 char Temp[MAX_PATH];
1955 maya 3227 char buf[20];
1956 yutakapon 5052 int ret;
1957     char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
1958 maya 3227
1959     /* version */
1960 yutakapon 5052 ret = WritePrivateProfileString(Section, "Version", "2.3", FName);
1961     if (ret == 0) {
1962     // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
1963     ret = GetLastError();
1964     get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
1965     _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
1966 maya 3227
1967 yutakapon 5052 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
1968    
1969     MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
1970     }
1971    
1972 maya 3227 /* Language */
1973 doda 3359 switch (ts->Language) {
1974     case IdJapanese:
1975 maya 3227 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
1976 doda 3359 break;
1977     case IdKorean:
1978 doda 6435 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
1979 doda 3359 break;
1980     case IdRussian:
1981 doda 6435 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
1982 doda 3359 break;
1983 maya 3401 case IdUtf8:
1984 doda 6435 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1985 maya 3401 break;
1986 doda 3359 default:
1987 doda 6435 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
1988 doda 3359 }
1989    
1990 maya 3227 WritePrivateProfileString(Section, "Language", Temp, FName);
1991    
1992     /* Port type */
1993 doda 6696 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
1994 maya 3227
1995     /* Save win position */
1996     if (ts->SaveVTWinPos) {
1997     /* VT win position */
1998     WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
1999     }
2000    
2001     /* VT terminal size */
2002     WriteInt2(Section, "TerminalSize", FName,
2003     ts->TerminalWidth, ts->TerminalHeight);
2004    
2005     /* Terminal size = Window size */
2006     WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2007    
2008     /* Auto window resize flag */
2009     WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2010    
2011     /* CR Receive */
2012     if (ts->CRReceive == IdCRLF) {
2013     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2014     }
2015     else if (ts->CRReceive == IdLF) {
2016     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2017     }
2018 maya 4893 else if (ts->CRReceive == IdAUTO) {
2019     strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2020     }
2021 maya 3227 else {
2022     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2023     }
2024     WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2025    
2026     /* CR Send */
2027 maya 6369 if (ts->CRSend == IdCRLF) {
2028 maya 3227 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2029 maya 6369 }
2030     else if (ts->CRSend == IdLF) {
2031     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2032     }
2033     else {
2034 maya 3227 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2035 maya 6369 }
2036 maya 3227 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2037    
2038     /* Local echo */
2039     WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2040    
2041     /* Answerback */
2042     if ((ts->FTFlag & FT_BPAUTO) == 0) {
2043     Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2044     sizeof(Temp) - 1, TRUE);
2045     WritePrivateProfileString(Section, "Answerback", Temp, FName);
2046     }
2047    
2048     /* Kanji Code (receive) */
2049     switch (ts->KanjiCode) {
2050     case IdEUC:
2051     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2052     break;
2053     case IdJIS:
2054     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2055     break;
2056     case IdUTF8:
2057     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2058     break;
2059     case IdUTF8m:
2060     strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2061     break;
2062     default:
2063 doda 3420 switch (ts->Language) {
2064     case IdJapanese:
2065     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2066     break;
2067     case IdKorean:
2068     strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2069     break;
2070     default:
2071     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2072     }
2073 maya 3227 }
2074     WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2075    
2076     /* Katakana (receive) */
2077     if (ts->JIS7Katakana == 1)
2078     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2079     else
2080     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2081    
2082     WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2083    
2084     /* Kanji Code (transmit) */
2085     switch (ts->KanjiCodeSend) {
2086     case IdEUC:
2087     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2088     break;
2089     case IdJIS:
2090     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2091     break;
2092     case IdUTF8:
2093     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2094     break;
2095     default:
2096 doda 3420 switch (ts->Language) {
2097     case IdJapanese:
2098     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2099     break;
2100     case IdKorean:
2101     strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2102     break;
2103     default:
2104     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2105     }
2106 maya 3227 }
2107     WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2108    
2109     /* Katakana (transmit) */
2110     if (ts->JIS7KatakanaSend == 1)
2111     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2112     else
2113     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2114    
2115     WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2116    
2117     /* KanjiIn */
2118     if (ts->KanjiIn == IdKanjiInA)
2119     strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2120     else
2121     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2122    
2123     WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2124    
2125     /* KanjiOut */
2126     switch (ts->KanjiOut) {
2127     case IdKanjiOutB:
2128     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2129     break;
2130     case IdKanjiOutH:
2131     strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2132     break;
2133     default:
2134     strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2135     }
2136     WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2137    
2138     // new configuration
2139     WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2140    
2141     WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2142 doda 6594 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2143 maya 3227
2144     WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2145 doda 6594 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2146 maya 3227
2147     WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2148 doda 6594 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2149 maya 3227
2150     // added ConfirmChangePaste
2151     WriteOnOff(Section, "ConfirmChangePaste", FName,
2152 doda 6594 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2153    
2154     WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2155     (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2156    
2157 yutakapon 3535 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2158     ts->ConfirmChangePasteStringFile, FName);
2159 maya 3227
2160     // added ScrollWindowClearScreen
2161     WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2162     ts->ScrollWindowClearScreen);
2163    
2164     // added SelectOnlyByLButton (2007.11.20 maya)
2165     WriteOnOff(Section, "SelectOnlyByLButton", FName,
2166     ts->SelectOnlyByLButton);
2167     // added DisableAcceleratorSendBreak (2007.3.17 maya)
2168     WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2169     ts->DisableAcceleratorSendBreak);
2170     WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2171     ts->EnableContinuedLineCopy);
2172     WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2173     FName);
2174     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
2175     WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2176     WritePrivateProfileString(Section, "CygwinDirectory",
2177     ts->CygwinDirectory, FName);
2178     WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2179     FName);
2180     WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
2181     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
2182     WritePrivateProfileString(Section, "CodePage", Temp, FName);
2183    
2184     // ANSI color(2004.9.5 yutaka)
2185     Temp[0] = '\0'