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 6126 - (hide annotations) (download) (as text)
Fri Nov 13 14:36:37 2015 UTC (8 years, 4 months ago) by yutakapon
File MIME type: text/x-csrc
File size: 128664 byte(s)
チケット #35710 Cygwin設定の見直し

項番2に対応させた。

2. 設定ダイアログでの変更内容は、メモリに保存しておき、
 Save setup時に、変更があれば、メモリの内容をcygterm.cfgに書き出す。
 現実装で行っているテンポラリファイルからのリネームはやらない。

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