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 6369 - (hide annotations) (download) (as text)
Mon Apr 11 13:42:54 2016 UTC (8 years ago) by maya
File MIME type: text/x-csrc
File size: 132001 byte(s)
送信改行コード LF を追加
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 yutakapon 6127 line[i++] = _strdup(buf);
344 yutakapon 6126 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 maya 3227
492     ts->Minimize = 0;
493     ts->HideWindow = 0;
494     ts->LogFlag = 0; // Log flags
495     ts->FTFlag = 0; // File transfer flags
496     ts->MenuFlag = 0; // Menu flags
497     ts->TermFlag = 0; // Terminal flag
498     ts->ColorFlag = 0; // ANSI/Attribute color flags
499 doda 3666 ts->FontFlag = 0; // Font flag
500 maya 3227 ts->PortFlag = 0; // Port flags
501 doda 3485 ts->WindowFlag = 0; // Window flags
502 doda 4700 ts->CtrlFlag = 0; // Control sequence flags
503 maya 3227 ts->TelPort = 23;
504    
505 doda 3388 ts->DisableTCPEchoCR = FALSE;
506    
507 maya 3227 /* Version number */
508     /* GetPrivateProfileString(Section,"Version","",
509     Temp,sizeof(Temp),FName); */
510    
511     /* Language */
512     GetPrivateProfileString(Section, "Language", "",
513     Temp, sizeof(Temp), FName);
514     if (_stricmp(Temp, "Japanese") == 0)
515     ts->Language = IdJapanese;
516     else if (_stricmp(Temp, "Russian") == 0)
517     ts->Language = IdRussian;
518     else if (_stricmp(Temp, "English") == 0)
519     ts->Language = IdEnglish;
520     else if (_stricmp(Temp,"Korean") == 0) // HKS
521     ts->Language = IdKorean;
522 maya 3401 else if (_stricmp(Temp,"UTF-8") == 0)
523     ts->Language = IdUtf8;
524 maya 3227 else {
525     switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
526     case LANG_JAPANESE:
527     ts->Language = IdJapanese;
528     break;
529     case LANG_RUSSIAN:
530     ts->Language = IdRussian;
531     break;
532 doda 3354 case LANG_KOREAN: // HKS
533 maya 3227 ts->Language = IdKorean;
534     break;
535     default:
536     ts->Language = IdEnglish;
537     }
538     }
539    
540     /* Port type */
541     GetPrivateProfileString(Section, "Port", "",
542     Temp, sizeof(Temp), FName);
543     if (_stricmp(Temp, "tcpip") == 0)
544     ts->PortType = IdTCPIP;
545     else if (_stricmp(Temp, "serial") == 0)
546     ts->PortType = IdSerial;
547 yutakapon 4857 else if (_stricmp(Temp, "namedpipe") == 0)
548     ts->PortType = IdNamedPipe;
549 maya 3227 else {
550     ts->PortType = IdTCPIP;
551     }
552    
553     /* VT win position */
554     GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
555     GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
556     GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
557    
558     /* TEK win position */
559     GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
560     GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
561     GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
562    
563     /* Save VT Window position */
564     ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
565    
566     /* VT terminal size */
567     GetPrivateProfileString(Section, "TerminalSize", "80,24",
568     Temp, sizeof(Temp), FName);
569     GetNthNum(Temp, 1, &ts->TerminalWidth);
570     GetNthNum(Temp, 2, &ts->TerminalHeight);
571     if (ts->TerminalWidth < 0)
572     ts->TerminalWidth = 1;
573     if (ts->TerminalHeight < 0)
574     ts->TerminalHeight = 1;
575    
576     /* Terminal size = Window size */
577     ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
578    
579     /* Auto window resize flag */
580     ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
581    
582     /* CR Receive */
583     GetPrivateProfileString(Section, "CRReceive", "",
584     Temp, sizeof(Temp), FName);
585     if (_stricmp(Temp, "CRLF") == 0) {
586     ts->CRReceive = IdCRLF;
587     }
588     else if (_stricmp(Temp, "LF") == 0) {
589     ts->CRReceive = IdLF;
590     }
591 maya 4893 else if (_stricmp(Temp, "AUTO") == 0) {
592     ts->CRReceive = IdAUTO;
593     }
594 maya 3227 else {
595     ts->CRReceive = IdCR;
596     }
597     /* CR Send */
598     GetPrivateProfileString(Section, "CRSend", "",
599     Temp, sizeof(Temp), FName);
600 maya 6369 if (_stricmp(Temp, "CRLF") == 0) {
601 maya 3227 ts->CRSend = IdCRLF;
602 maya 6369 }
603     else if (_stricmp(Temp, "LF") == 0) {
604     ts->CRSend = IdLF;
605     }
606     else {
607 maya 3227 ts->CRSend = IdCR;
608 maya 6369 }
609 maya 3227 ts->CRSend_ini = ts->CRSend;
610    
611     /* Local echo */
612     ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
613     ts->LocalEcho_ini = ts->LocalEcho;
614    
615     /* Answerback */
616     GetPrivateProfileString(Section, "Answerback", "", Temp,
617     sizeof(Temp), FName);
618     ts->AnswerbackLen =
619     Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
620    
621     /* Kanji Code (receive) */
622     GetPrivateProfileString(Section, "KanjiReceive", "",
623     Temp, sizeof(Temp), FName);
624     if (_stricmp(Temp, "EUC") == 0)
625     ts->KanjiCode = IdEUC;
626     else if (_stricmp(Temp, "JIS") == 0)
627     ts->KanjiCode = IdJIS;
628     else if (_stricmp(Temp, "UTF-8") == 0)
629     ts->KanjiCode = IdUTF8;
630     else if (_stricmp(Temp, "UTF-8m") == 0)
631     ts->KanjiCode = IdUTF8m;
632 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
633     ts->KanjiCode = IdSJIS;
634 maya 3227 else
635     ts->KanjiCode = IdSJIS;
636 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
637     {
638     WORD KanjiCode = ts->KanjiCode;
639     ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
640     }
641 maya 3227
642     /* Katakana (receive) */
643     GetPrivateProfileString(Section, "KatakanaReceive", "",
644     Temp, sizeof(Temp), FName);
645     if (_stricmp(Temp, "7") == 0)
646     ts->JIS7Katakana = 1;
647     else
648     ts->JIS7Katakana = 0;
649    
650     /* Kanji Code (transmit) */
651     GetPrivateProfileString(Section, "KanjiSend", "",
652     Temp, sizeof(Temp), FName);
653     if (_stricmp(Temp, "EUC") == 0)
654     ts->KanjiCodeSend = IdEUC;
655     else if (_stricmp(Temp, "JIS") == 0)
656     ts->KanjiCodeSend = IdJIS;
657     else if (_stricmp(Temp, "UTF-8") == 0)
658     ts->KanjiCodeSend = IdUTF8;
659 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
660     ts->KanjiCode = IdSJIS;
661 maya 3227 else
662     ts->KanjiCodeSend = IdSJIS;
663 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
664     {
665     WORD KanjiCodeSend = ts->KanjiCodeSend;
666     ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
667     }
668 maya 3227
669     /* Katakana (receive) */
670     GetPrivateProfileString(Section, "KatakanaSend", "",
671     Temp, sizeof(Temp), FName);
672     if (_stricmp(Temp, "7") == 0)
673     ts->JIS7KatakanaSend = 1;
674     else
675     ts->JIS7KatakanaSend = 0;
676    
677     /* KanjiIn */
678     GetPrivateProfileString(Section, "KanjiIn", "",
679     Temp, sizeof(Temp), FName);
680     if (_stricmp(Temp, "@") == 0)
681     ts->KanjiIn = IdKanjiInA;
682     else
683     ts->KanjiIn = IdKanjiInB;
684    
685     /* KanjiOut */
686     GetPrivateProfileString(Section, "KanjiOut", "",
687     Temp, sizeof(Temp), FName);
688     if (_stricmp(Temp, "B") == 0)
689     ts->KanjiOut = IdKanjiOutB;
690     else if (_stricmp(Temp, "H") == 0)
691     ts->KanjiOut = IdKanjiOutH;
692     else
693     ts->KanjiOut = IdKanjiOutJ;
694    
695     /* Auto Win Switch VT<->TEK */
696     ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
697    
698     /* Terminal ID */
699     GetPrivateProfileString(Section, "TerminalID", "",
700     Temp, sizeof(Temp), FName);
701     ts->TerminalID = str2id(TermList, Temp, IdVT100);
702    
703     /* Russian character set (host) */
704     GetPrivateProfileString(Section, "RussHost", "",
705     Temp, sizeof(Temp), FName);
706     ts->RussHost = str2id(RussList, Temp, IdKOI8);
707    
708     /* Russian character set (client) */
709     GetPrivateProfileString(Section, "RussClient", "",
710     Temp, sizeof(Temp), FName);
711     ts->RussClient = str2id(RussList, Temp, IdWindows);
712    
713     /* Title String */
714     GetPrivateProfileString(Section, "Title", "Tera Term",
715     ts->Title, sizeof(ts->Title), FName);
716    
717     /* Cursor shape */
718     GetPrivateProfileString(Section, "CursorShape", "",
719     Temp, sizeof(Temp), FName);
720     if (_stricmp(Temp, "vertical") == 0)
721     ts->CursorShape = IdVCur;
722     else if (_stricmp(Temp, "horizontal") == 0)
723     ts->CursorShape = IdHCur;
724     else
725     ts->CursorShape = IdBlkCur;
726    
727     /* Hide title */
728     ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
729    
730     /* Popup menu */
731     ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
732    
733     /* PC-Style bold color mapping */
734     if (GetOnOff(Section, "PcBoldColor", FName, FALSE))
735     ts->ColorFlag |= CF_PCBOLD16;
736    
737     /* aixterm style 16 colors mode */
738     if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))
739     ts->ColorFlag |= CF_AIXTERM16;
740    
741     /* xterm style 256 colors mode */
742     if (GetOnOff(Section, "Xterm256Color", FName, TRUE))
743     ts->ColorFlag |= CF_XTERM256;
744    
745     /* Enable scroll buffer */
746     ts->EnableScrollBuff =
747     GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
748    
749     /* Scroll buffer size */
750     ts->ScrollBuffSize =
751     GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
752    
753     /* VT Color */
754     GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
755     Temp, sizeof(Temp), FName);
756     for (i = 0; i <= 5; i++)
757     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
758     for (i = 0; i <= 1; i++)
759     ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
760     (BYTE) ts->TmpColor[0][i * 3 + 1],
761     (BYTE) ts->TmpColor[0][i * 3 + 2]);
762    
763     /* VT Bold Color */
764     GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
765     Temp, sizeof(Temp), FName);
766     for (i = 0; i <= 5; i++)
767     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
768     for (i = 0; i <= 1; i++)
769     ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
770     (BYTE) ts->TmpColor[0][i * 3 + 1],
771     (BYTE) ts->TmpColor[0][i * 3 + 2]);
772     if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))
773     ts->ColorFlag |= CF_BOLDCOLOR;
774    
775     /* VT Blink Color */
776     GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
777     Temp, sizeof(Temp), FName);
778     for (i = 0; i <= 5; i++)
779     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
780     for (i = 0; i <= 1; i++)
781     ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
782     (BYTE) ts->TmpColor[0][i * 3 + 1],
783     (BYTE) ts->TmpColor[0][i * 3 + 2]);
784     if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))
785     ts->ColorFlag |= CF_BLINKCOLOR;
786    
787     /* VT Reverse Color */
788     GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
789     Temp, sizeof(Temp), FName);
790     for (i = 0; i <= 5; i++)
791     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
792     for (i = 0; i <= 1; i++)
793     ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
794     (BYTE) ts->TmpColor[0][i * 3 + 1],
795     (BYTE) ts->TmpColor[0][i * 3 + 2]);
796     if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))
797     ts->ColorFlag |= CF_REVERSECOLOR;
798    
799     ts->EnableClickableUrl =
800     GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
801    
802     /* URL Color */
803     GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
804     Temp, sizeof(Temp), FName);
805     for (i = 0; i <= 5; i++)
806     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
807     for (i = 0; i <= 1; i++)
808     ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
809     (BYTE) ts->TmpColor[0][i * 3 + 1],
810     (BYTE) ts->TmpColor[0][i * 3 + 2]);
811     if (GetOnOff(Section, "EnableURLColor", FName, TRUE))
812     ts->ColorFlag |= CF_URLCOLOR;
813    
814 doda 3660 if (GetOnOff(Section, "URLUnderline", FName, TRUE))
815 doda 3666 ts->FontFlag |= FF_URLUNDERLINE;
816 doda 3660
817 maya 3227 /* TEK Color */
818     GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
819     Temp, sizeof(Temp), FName);
820     for (i = 0; i <= 5; i++)
821     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
822     for (i = 0; i <= 1; i++)
823     ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
824     (BYTE) ts->TmpColor[0][i * 3 + 1],
825     (BYTE) ts->TmpColor[0][i * 3 + 2]);
826    
827     /* ANSI color definition (in the case FullColor=on) -- special option
828     o UseTextColor should be off, or the background and foreground color of
829     VTColor are assigned to color-number 0 and 7 respectively, even if
830     they are specified in ANSIColor.
831     o ANSIColor is a set of 4 values that are color-number(0--15),
832     red-value(0--255), green-value(0--255) and blue-value(0--255). */
833     GetPrivateProfileString(Section, "ANSIColor",
834     " 0, 0, 0, 0,"
835     " 1,255, 0, 0,"
836     " 2, 0,255, 0,"
837     " 3,255,255, 0,"
838     " 4, 0, 0,255,"
839     " 5,255, 0,255,"
840     " 6, 0,255,255,"
841     " 7,255,255,255,"
842     " 8,128,128,128,"
843     " 9,128, 0, 0,"
844     "10, 0,128, 0,"
845     "11,128,128, 0,"
846     "12, 0, 0,128,"
847     "13,128, 0,128,"
848     "14, 0,128,128,"
849     "15,192,192,192", Temp, sizeof(Temp), FName);
850     {
851     char *t;
852     int n = 1;
853     for (t = Temp; *t; t++)
854     if (*t == ',')
855     n++;
856     n /= 4;
857 doda 4640 for (i = 0; i < n; i++) {
858 maya 3227 int colorid, r, g, b;
859     GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
860     GetNthNum(Temp, i * 4 + 2, (int far *) &r);
861     GetNthNum(Temp, i * 4 + 3, (int far *) &g);
862     GetNthNum(Temp, i * 4 + 4, (int far *) &b);
863     ts->ANSIColor[colorid & 15] =
864     RGB((BYTE) r, (BYTE) g, (BYTE) b);
865     }
866     }
867    
868     TmpDC = GetDC(0); /* Get screen device context */
869     for (i = 0; i <= 1; i++)
870     ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
871     for (i = 0; i <= 1; i++)
872     ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
873     for (i = 0; i <= 1; i++)
874     ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
875     for (i = 0; i <= 1; i++)
876     ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
877     /* begin - ishizaki */
878     for (i = 0; i <= 1; i++)
879     ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
880     /* end - ishizaki */
881     for (i = 0; i < 16; i++)
882     ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
883     ReleaseDC(0, TmpDC);
884     if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))
885     ts->ColorFlag |= CF_ANSICOLOR;
886    
887     /* TEK color emulation */
888     ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
889    
890     /* VT Font */
891     GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
892     Temp, sizeof(Temp), FName);
893     GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
894     GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
895     GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
896     GetNthNum(Temp, 4, &(ts->VTFontCharSet));
897    
898     /* Bold font flag */
899 doda 3666 if (GetOnOff(Section, "EnableBold", FName, TRUE))
900     ts->FontFlag |= FF_BOLD;
901 maya 3227
902     /* Russian character set (font) */
903     GetPrivateProfileString(Section, "RussFont", "",
904     Temp, sizeof(Temp), FName);
905     ts->RussFont = str2id(RussList, Temp, IdWindows);
906    
907     /* TEK Font */
908     GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
909     Temp, sizeof(Temp), FName);
910     GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
911     GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
912     GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
913     GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
914    
915     /* BS key */
916     GetPrivateProfileString(Section, "BSKey", "",
917     Temp, sizeof(Temp), FName);
918     if (_stricmp(Temp, "DEL") == 0)
919     ts->BSKey = IdDEL;
920     else
921     ts->BSKey = IdBS;
922     /* Delete key */
923     ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
924    
925     /* Meta Key */
926 doda 4414 GetPrivateProfileString(Section, "MetaKey", "off", Temp, sizeof(Temp), FName);
927     if (_stricmp(Temp, "on") == 0)
928     ts->MetaKey = IdMetaOn;
929     else if (_stricmp(Temp, "left") == 0)
930     ts->MetaKey = IdMetaLeft;
931     else if (_stricmp(Temp, "right") == 0)
932     ts->MetaKey = IdMetaRight;
933     else
934     ts->MetaKey = IdMetaOff;
935 maya 3227
936 doda 4414 // Windows95 �n�����E�� Alt ��������������
937 yutakapon 6286 if (!IsWindowsNTKernel() && ts->MetaKey != IdMetaOff) {
938 doda 4414 ts->MetaKey = IdMetaOn;
939     }
940    
941 maya 3227 /* Application Keypad */
942     ts->DisableAppKeypad =
943     GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
944    
945     /* Application Cursor */
946     ts->DisableAppCursor =
947     GetOnOff(Section, "DisableAppCursor", FName, FALSE);
948    
949     /* Russian keyboard type */
950     GetPrivateProfileString(Section, "RussKeyb", "",
951     Temp, sizeof(Temp), FName);
952     ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
953    
954     /* Serial port ID */
955     ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
956    
957     /* Baud rate */
958 maya 3874 ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
959 maya 3227
960     /* Parity */
961     GetPrivateProfileString(Section, "Parity", "",
962     Temp, sizeof(Temp), FName);
963     if (_stricmp(Temp, "even") == 0)
964     ts->Parity = IdParityEven;
965     else if (_stricmp(Temp, "odd") == 0)
966     ts->Parity = IdParityOdd;
967 doda 4849 else if (_stricmp(Temp, "mark") == 0)
968     ts->Parity = IdParityMark;
969     else if (_stricmp(Temp, "space") == 0)
970     ts->Parity = IdParitySpace;
971 maya 3227 else
972     ts->Parity = IdParityNone;
973    
974     /* Data bit */
975     GetPrivateProfileString(Section, "DataBit", "",
976     Temp, sizeof(Temp), FName);
977     if (_stricmp(Temp, "7") == 0)
978     ts->DataBit = IdDataBit7;
979     else
980     ts->DataBit = IdDataBit8;
981    
982     /* Stop bit */
983     GetPrivateProfileString(Section, "StopBit", "",
984     Temp, sizeof(Temp), FName);
985     if (_stricmp(Temp, "2") == 0)
986     ts->StopBit = IdStopBit2;
987 doda 4849 else if (_stricmp(Temp, "1.5") == 0)
988     ts->StopBit = IdStopBit15;
989 maya 3227 else
990     ts->StopBit = IdStopBit1;
991    
992     /* Flow control */
993     GetPrivateProfileString(Section, "FlowCtrl", "",
994     Temp, sizeof(Temp), FName);
995     if (_stricmp(Temp, "x") == 0)
996     ts->Flow = IdFlowX;
997     else if (_stricmp(Temp, "hard") == 0)
998     ts->Flow = IdFlowHard;
999     else
1000     ts->Flow = IdFlowNone;
1001    
1002     /* Delay per character */
1003     ts->DelayPerChar =
1004     GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1005    
1006     /* Delay per line */
1007     ts->DelayPerLine =
1008     GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1009    
1010     /* Telnet flag */
1011     ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1012    
1013     /* Telnet terminal type */
1014     GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1015     sizeof(ts->TermType), FName);
1016    
1017     /* TCP port num */
1018     ts->TCPPort =
1019     GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1020    
1021     /* Auto window close flag */
1022     ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1023    
1024     /* History list */
1025     ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1026    
1027     /* File transfer binary flag */
1028     ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1029    
1030 doda 3887 /* Log binary flag */
1031     ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1032    
1033 maya 3227 /* Log append */
1034     ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1035    
1036     /* Log plain text (2005.5.7 yutaka) */
1037     ts->LogTypePlainText =
1038     GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1039    
1040     /* Log with timestamp (2006.7.23 maya) */
1041     ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1042    
1043     /* Log without transfer dialog */
1044     ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1045    
1046 yutakapon 5444 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1047 yutakapon 5392
1048 doda 5312 /* File Transfer dialog visibility */
1049     ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1050    
1051 maya 3227 /* Default Log file name (2006.8.28 maya) */
1052     GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1053     ts->LogDefaultName, sizeof(ts->LogDefaultName),
1054     FName);
1055    
1056     /* Default Log file path (2007.5.30 maya) */
1057     GetPrivateProfileString(Section, "LogDefaultPath", "",
1058     ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
1059     FName);
1060    
1061     /* Auto start logging (2007.5.31 maya) */
1062     ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1063    
1064 yutakapon 5171 /* Log Rotate (2013.3.24 yutaka) */
1065     ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1066     ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1067     ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1068     ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1069    
1070 yutakapon 5206 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1071     ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1072 yutakapon 5171
1073 yutakapon 5206
1074 maya 3227 /* XMODEM option */
1075     GetPrivateProfileString(Section, "XmodemOpt", "",
1076     Temp, sizeof(Temp), FName);
1077     if (_stricmp(Temp, "crc") == 0)
1078     ts->XmodemOpt = XoptCRC;
1079     else if (_stricmp(Temp, "1k") == 0)
1080 doda 6219 ts->XmodemOpt = Xopt1kCRC;
1081 doda 6328 else if (_stricmp(Temp, "1ksum") == 0)
1082     ts->XmodemOpt = Xopt1kCksum;
1083 maya 3227 else
1084     ts->XmodemOpt = XoptCheck;
1085    
1086     /* XMODEM binary file */
1087     ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1088    
1089     /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1090     GetPrivateProfileString(Section, "XModemRcvCommand", "",
1091     ts->XModemRcvCommand,
1092     sizeof(ts->XModemRcvCommand), FName);
1093    
1094     /* Default directory for file transfer */
1095     GetPrivateProfileString(Section, "FileDir", "",
1096     ts->FileDir, sizeof(ts->FileDir), FName);
1097     if (strlen(ts->FileDir) == 0)
1098     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
1099     else {
1100     _getcwd(Temp, sizeof(Temp));
1101     if (_chdir(ts->FileDir) != 0)
1102     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
1103     _chdir(Temp);
1104     }
1105    
1106     /* filter on file send (2007.6.5 maya) */
1107     GetPrivateProfileString(Section, "FileSendFilter", "",
1108     ts->FileSendFilter, sizeof(ts->FileSendFilter),
1109     FName);
1110    
1111 yutakapon 4880 /* SCP���M���p�X (2012.4.6 yutaka) */
1112 maya 4888 GetPrivateProfileString(Section, "ScpSendDir", "~/",
1113 yutakapon 4880 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1114    
1115    
1116 maya 3227 /*--------------------------------------------------*/
1117     /* 8 bit control code flag -- special option */
1118     if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1119     ts->TermFlag |= TF_ACCEPT8BITCTRL;
1120    
1121     /* Wrong sequence flag -- special option */
1122     if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1123     ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1124    
1125     if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1126     (ts->KanjiOut == IdKanjiOutH))
1127     ts->KanjiOut = IdKanjiOutJ;
1128    
1129 maya 6083 // Detect disconnect/reconnect of serial port --- special option
1130 maya 6115 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1131 maya 6083
1132 maya 3227 // Auto file renaming --- special option
1133     if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1134     ts->FTFlag |= FT_RENAME;
1135    
1136     // Auto invoking (character set->G0->GL) --- special option
1137     if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1138     ts->TermFlag |= TF_AUTOINVOKE;
1139    
1140     // Auto text copy --- special option
1141     ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1142    
1143     /* Back wrap -- special option */
1144     if (GetOnOff(Section, "BackWrap", FName, FALSE))
1145     ts->TermFlag |= TF_BACKWRAP;
1146    
1147     /* Beep type -- special option */
1148 doda 4082 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1149 maya 3227 if (_stricmp(Temp, "off") == 0)
1150     ts->Beep = IdBeepOff;
1151     else if (_stricmp(Temp, "visual") == 0)
1152     ts->Beep = IdBeepVisual;
1153     else
1154     ts->Beep = IdBeepOn;
1155    
1156     /* Beep on connection & disconnection -- special option */
1157     if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1158     ts->PortFlag |= PF_BEEPONCONNECT;
1159    
1160     /* Auto B-Plus activation -- special option */
1161     if (GetOnOff(Section, "BPAuto", FName, FALSE))
1162     ts->FTFlag |= FT_BPAUTO;
1163     if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1164     strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1165     _TRUNCATE);
1166     ts->AnswerbackLen = 5;
1167     }
1168    
1169     /* B-Plus ESCCTL flag -- special option */
1170     if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1171     ts->FTFlag |= FT_BPESCCTL;
1172    
1173     /* B-Plus log -- special option */
1174     if (GetOnOff(Section, "BPLog", FName, FALSE))
1175     ts->LogFlag |= LOG_BP;
1176    
1177     /* Clear serial port buffer when port opening -- special option */
1178     ts->ClearComBuffOnOpen =
1179     GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1180    
1181 salarm 6349 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1182     ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1183    
1184 maya 3227 /* Confirm disconnection -- special option */
1185     if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1186     ts->PortFlag |= PF_CONFIRMDISCONN;
1187    
1188     /* Ctrl code in Kanji -- special option */
1189     if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1190     ts->TermFlag |= TF_CTRLINKANJI;
1191    
1192     /* Debug flag -- special option */
1193     ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1194    
1195     /* Delimiter list -- special option */
1196     GetPrivateProfileString(Section, "DelimList",
1197     "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1198     Temp, sizeof(Temp), FName);
1199     Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1200    
1201     /* regard DBCS characters as delimiters -- special option */
1202     ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1203    
1204     // Enable popup menu -- special option
1205     if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1206     ts->MenuFlag |= MF_NOPOPUP;
1207    
1208     // Enable "Show menu" -- special option
1209     if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1210     ts->MenuFlag |= MF_NOSHOWMENU;
1211    
1212     // Enable the status line -- special option
1213     if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1214     ts->TermFlag |= TF_ENABLESLINE;
1215    
1216 maya 6079 // Enable multiple bytes send -- special option
1217 maya 6115 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1218 maya 6079
1219 maya 3227 // fixed JIS --- special
1220     if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1221     ts->TermFlag |= TF_FIXEDJIS;
1222    
1223     /* IME Flag -- special option */
1224     ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1225    
1226     /* IME-inline Flag -- special option */
1227     ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1228    
1229     /* Kermit log -- special option */
1230     if (GetOnOff(Section, "KmtLog", FName, FALSE))
1231     ts->LogFlag |= LOG_KMT;
1232 yutakapon 4810 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1233     ts->KermitOpt |= KmtOptLongPacket;
1234     if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1235     ts->KermitOpt |= KmtOptFileAttr;
1236 maya 3227
1237     // Enable language selection -- special option
1238     if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1239     ts->MenuFlag |= MF_NOLANGUAGE;
1240    
1241     /* Maximum scroll buffer size -- special option */
1242     ts->ScrollBuffMax =
1243     GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1244     if (ts->ScrollBuffMax < 24)
1245     ts->ScrollBuffMax = 10000;
1246    
1247     /* Max com port number -- special option */
1248     ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 4, FName);
1249     if (ts->MaxComPort < 4)
1250     ts->MaxComPort = 4;
1251     // COM16����99���g�� (2005.11.30 yutaka)
1252     // 99����200���g�� (2007.7.23 maya)
1253     if (ts->MaxComPort > MAXCOMPORT)
1254     ts->MaxComPort = MAXCOMPORT;
1255     if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1256     ts->ComPort = 1;
1257    
1258     /* Non-blinking cursor -- special option */
1259     ts->NonblinkingCursor =
1260     GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1261    
1262     // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1263     ts->KillFocusCursor =
1264     GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1265    
1266     /* Delay for pass-thru printing activation */
1267     /* -- special option */
1268     ts->PassThruDelay =
1269     GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1270    
1271     /* Printer port for pass-thru printing */
1272     /* -- special option */
1273     GetPrivateProfileString(Section, "PassThruPort", "",
1274     ts->PrnDev, sizeof(ts->PrnDev), FName);
1275    
1276 doda 4397 /* �v�����^�p�����R�[�h�������t������ */
1277     if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1278     ts->TermFlag |= TF_PRINTERCTRL;
1279 yutakapon 4393
1280 maya 3227 /* Printer Font --- special option */
1281     GetPrivateProfileString(Section, "PrnFont", "",
1282     Temp, sizeof(Temp), FName);
1283     if (strlen(Temp) == 0) {
1284     ts->PrnFont[0] = 0;
1285     ts->PrnFontSize.x = 0;
1286     ts->PrnFontSize.y = 0;
1287     ts->PrnFontCharSet = 0;
1288     }
1289     else {
1290     GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
1291     GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
1292     GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
1293     GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
1294     }
1295    
1296     // Page margins (left, right, top, bottom) for printing
1297     // -- special option
1298     GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1299     Temp, sizeof(Temp), FName);
1300     for (i = 0; i <= 3; i++)
1301     GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1302    
1303     /* Quick-VAN log -- special option */
1304     if (GetOnOff(Section, "QVLog", FName, FALSE))
1305     ts->LogFlag |= LOG_QV;
1306    
1307     /* Quick-VAN window size -- special */
1308     ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1309    
1310     /* Russian character set (print) -- special option */
1311     GetPrivateProfileString(Section, "RussPrint", "",
1312     Temp, sizeof(Temp), FName);
1313     ts->RussPrint = str2id(RussList, Temp, IdWindows);
1314    
1315     /* Scroll threshold -- special option */
1316     ts->ScrollThreshold =
1317     GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1318    
1319     ts->MouseWheelScrollLine =
1320     GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1321    
1322     // Select on activate -- special option
1323     ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1324    
1325     /* Send 8bit control sequence -- special option */
1326     ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1327    
1328 maya 5694 /* SendBreak time (in msec) -- special option */
1329     ts->SendBreakTime =
1330     GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1331    
1332 maya 3227 /* Startup macro -- special option */
1333     GetPrivateProfileString(Section, "StartupMacro", "",
1334     ts->MacroFN, sizeof(ts->MacroFN), FName);
1335    
1336     /* TEK GIN Mouse keycode -- special option */
1337     ts->GINMouseCode =
1338     GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1339    
1340     /* Telnet Auto Detect -- special option */
1341     ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1342    
1343     /* Telnet binary flag -- special option */
1344     ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1345    
1346     /* Telnet Echo flag -- special option */
1347     ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1348    
1349     /* Telnet log -- special option */
1350     if (GetOnOff(Section, "TelLog", FName, FALSE))
1351     ts->LogFlag |= LOG_TEL;
1352    
1353     /* TCP port num for telnet -- special option */
1354     ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1355    
1356     /* Telnet keep-alive packet(NOP command) interval -- special option */
1357     ts->TelKeepAliveInterval =
1358     GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1359    
1360     /* Max number of broadcast commad history */
1361     ts->MaxBroadcatHistory =
1362     GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1363    
1364     /* Local echo for non-telnet */
1365     ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1366    
1367     /* "new-line (transmit)" option for non-telnet -- special option */
1368     GetPrivateProfileString(Section, "TCPCRSend", "",
1369     Temp, sizeof(Temp), FName);
1370     if (_stricmp(Temp, "CR") == 0)
1371     ts->TCPCRSend = IdCR;
1372     else if (_stricmp(Temp, "CRLF") == 0)
1373     ts->TCPCRSend = IdCRLF;
1374     else
1375     ts->TCPCRSend = 0; // disabled
1376    
1377     /* Use text (background) color for "white (black)" --- special option */
1378     if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1379     ts->ColorFlag |= CF_USETEXTCOLOR;
1380    
1381     /* Title format -- special option */
1382     ts->TitleFormat =
1383 maya 6170 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1384 maya 3227
1385     /* VT Compatible Tab -- special option */
1386     ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1387    
1388     /* VT Font space --- special option */
1389     GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1390     Temp, sizeof(Temp), FName);
1391     GetNthNum(Temp, 1, &ts->FontDX);
1392     GetNthNum(Temp, 2, &ts->FontDW);
1393     GetNthNum(Temp, 3, &ts->FontDY);
1394     GetNthNum(Temp, 4, &ts->FontDH);
1395     if (ts->FontDX < 0)
1396     ts->FontDX = 0;
1397     if (ts->FontDW < 0)
1398     ts->FontDW = 0;
1399     ts->FontDW = ts->FontDW + ts->FontDX;
1400     if (ts->FontDY < 0)
1401     ts->FontDY = 0;
1402     if (ts->FontDH < 0)
1403     ts->FontDH = 0;
1404     ts->FontDH = ts->FontDH + ts->FontDY;
1405    
1406     // VT-print scaling factors (pixels per inch) --- special option
1407     GetPrivateProfileString(Section, "VTPPI", "0,0",
1408     Temp, sizeof(Temp), FName);
1409     GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1410     GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1411    
1412     // TEK-print scaling factors (pixels per inch) --- special option
1413     GetPrivateProfileString(Section, "TEKPPI", "0,0",
1414     Temp, sizeof(Temp), FName);
1415     GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1416     GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1417    
1418     // Show "Window" menu -- special option
1419     if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1420     ts->MenuFlag |= MF_SHOWWINMENU;
1421    
1422     /* XMODEM log -- special option */
1423     if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1424     ts->LogFlag |= LOG_X;
1425    
1426     /* YMODEM log -- special option */
1427     if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1428     ts->LogFlag |= LOG_Y;
1429    
1430 yutakapon 3815 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1431     GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1432     ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1433    
1434 maya 3227 /* Auto ZMODEM activation -- special option */
1435     if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1436     ts->FTFlag |= FT_ZAUTO;
1437    
1438     /* ZMODEM data subpacket length for sending -- special */
1439     ts->ZmodemDataLen =
1440     GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1441     /* ZMODEM window size for sending -- special */
1442     ts->ZmodemWinSize =
1443     GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1444    
1445     /* ZMODEM ESCCTL flag -- special option */
1446     if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1447     ts->FTFlag |= FT_ZESCCTL;
1448    
1449     /* ZMODEM log -- special option */
1450     if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1451     ts->LogFlag |= LOG_Z;
1452    
1453     /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1454     GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1455     ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1456    
1457     #ifndef NO_COPYLINE_FIX
1458    
1459     /* Enable continued-line copy -- special option */
1460     ts->EnableContinuedLineCopy =
1461     GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1462     #endif /* NO_COPYLINE_FIX */
1463    
1464     ts->DisablePasteMouseRButton =
1465     GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE);
1466    
1467     // added DisablePasteMouseMButton (2008.3.2 maya)
1468     ts->DisablePasteMouseMButton =
1469     GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE);
1470    
1471     // added ConfirmPasteMouseRButton (2007.3.17 maya)
1472     ts->ConfirmPasteMouseRButton =
1473     GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE);
1474    
1475     // added ConfirmChangePaste (2008.2.3 yutaka)
1476     ts->ConfirmChangePaste =
1477     GetOnOff(Section, "ConfirmChangePaste", FName, TRUE);
1478 yutakapon 3535 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1479     Temp, sizeof(Temp), FName);
1480     strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1481     _TRUNCATE);
1482 maya 3227
1483     // added ScrollWindowClearScreen (2008.5.3 yutaka)
1484     ts->ScrollWindowClearScreen =
1485     GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1486    
1487     // added SelectOnlyByLButton (2007.11.20 maya)
1488     ts->SelectOnlyByLButton =
1489     GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1490    
1491     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1492     ts->DisableAcceleratorSendBreak =
1493     GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1494    
1495     // WinSock connecting timeout value (2007.1.11 yutaka)
1496     ts->ConnectingTimeout =
1497     GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1498    
1499     // mouse cursor
1500     GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1501     Temp, sizeof(Temp), FName);
1502     strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1503     _TRUNCATE);
1504    
1505     // Translucent window
1506     ts->AlphaBlend =
1507     GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1508     ts->AlphaBlend = max(0, ts->AlphaBlend);
1509     ts->AlphaBlend = min(255, ts->AlphaBlend);
1510    
1511     // Cygwin install path
1512     GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1513     Temp, sizeof(Temp), FName);
1514     strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1515     _TRUNCATE);
1516    
1517     // Viewlog Editor path
1518 doda 4198 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1519     strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1520     }
1521     else {
1522     Temp[0] = '\0';
1523     }
1524     GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1525     ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1526 maya 3227
1527     // Locale for UTF-8
1528     GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1529     Temp, sizeof(Temp), FName);
1530     strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1531    
1532     // CodePage
1533     ts->CodePage =
1534     GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1535     FName);
1536    
1537     // UI language message file
1538     GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1539     Temp, sizeof(Temp), FName);
1540     {
1541     char CurDir[MAX_PATH];
1542    
1543     // �t���p�X�������O������������������������������
1544     strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1545    
1546     GetCurrentDirectory(sizeof(CurDir), CurDir);
1547     SetCurrentDirectory(ts->HomeDir);
1548     _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1549     SetCurrentDirectory(CurDir);
1550     }
1551    
1552     // Broadcast Command History (2007.3.3 maya)
1553     ts->BroadcastCommandHistory =
1554     GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1555    
1556     // 337: 2007/03/20 Accept Broadcast
1557     ts->AcceptBroadcast =
1558     GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1559    
1560     // Confirm send a file when drag and drop (2007.12.28 maya)
1561     ts->ConfirmFileDragAndDrop =
1562     GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1563    
1564     // Translate mouse wheel to cursor key when application cursor mode
1565     ts->TranslateWheelToCursor =
1566     GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1567    
1568     // Display "New Connection" dialog on startup (2008.1.18 maya)
1569     ts->HostDialogOnStartup =
1570     GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1571    
1572     // Mouse event tracking
1573     ts->MouseEventTracking =
1574     GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1575    
1576     // Maximized bug tweak
1577     ts->MaximizedBugTweak =
1578     GetOnOff(Section, "MaximizedBugTweak", FName, TRUE);
1579    
1580     // Convert Unicode symbol characters to DEC Special characters
1581     ts->UnicodeDecSpMapping =
1582     GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1583    
1584     // VT Window Icon
1585     GetPrivateProfileString(Section, "VTIcon", "Default",
1586     Temp, sizeof(Temp), FName);
1587     ts->VTIcon = IconName2IconId(Temp);
1588    
1589     // Tek Window Icon
1590     GetPrivateProfileString(Section, "TEKIcon", "Default",
1591     Temp, sizeof(Temp), FName);
1592     ts->TEKIcon = IconName2IconId(Temp);
1593    
1594     // Unknown Unicode Character
1595     ts->UnknownUnicodeCharaAsWide =
1596     GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1597    
1598     #ifdef USE_NORMAL_BGCOLOR
1599     // UseNormalBGColor
1600     ts->UseNormalBGColor =
1601     GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1602     // 2006/03/11 by 337
1603     if (ts->UseNormalBGColor) {
1604     ts->VTBoldColor[1] =
1605     ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1606     }
1607     #endif
1608    
1609     // AutoScrollOnlyInBottomLine
1610     ts->AutoScrollOnlyInBottomLine =
1611     GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1612    
1613     // Accept remote-controlled window title changing
1614     GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1615     Temp, sizeof(Temp), FName);
1616     if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1617     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1618     else if (_stricmp(Temp, "ahead") == 0)
1619     ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1620     else if (_stricmp(Temp, "last") == 0)
1621     ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1622     else
1623     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1624    
1625     // Size of paste confirm dialog
1626     GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1627     Temp, sizeof(Temp), FName);
1628     GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1629     GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1630     if (ts->PasteDialogSize.cx < 0)
1631     ts->PasteDialogSize.cx = 330;
1632     if (ts->PasteDialogSize.cy < 0)
1633     ts->PasteDialogSize.cy = 220;
1634    
1635     // Disable mouse event tracking when Control-Key is pressed.
1636     ts->DisableMouseTrackingByCtrl =
1637     GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1638    
1639     // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1640     ts->DisableWheelToCursorByCtrl =
1641     GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1642    
1643     // Strict Key Mapping.
1644     ts->StrictKeyMapping =
1645     GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1646    
1647     // added Wait4allMacroCommand (2009.3.23 yutaka)
1648     ts->Wait4allMacroCommand =
1649     GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1650 maya 3279
1651 maya 3283 // added DisableMenuSendBreak (2009.4.6 maya)
1652     ts->DisableMenuSendBreak =
1653     GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1654 maya 3282
1655 maya 3283 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1656     ts->ClearScreenOnCloseConnection =
1657     GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1658    
1659     // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1660 maya 3282 ts->DisableAcceleratorDuplicateSession =
1661     GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1662 maya 3306
1663 maya 5684 ts->AcceleratorNewConnection =
1664     GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1665    
1666     ts->AcceleratorCygwinConnection =
1667     GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1668    
1669 maya 3964 // added DisableMenuDuplicateSession (2010.8.3 maya)
1670     ts->DisableMenuDuplicateSession =
1671     GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1672    
1673 maya 3965 // added DisableMenuNewConnection (2010.8.4 maya)
1674     ts->DisableMenuNewConnection =
1675     GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1676    
1677 maya 3306 // added PasteDelayPerLine (2009.4.12 maya)
1678     ts->PasteDelayPerLine =
1679     GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1680 maya 3315 {
1681     int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1682     ts->PasteDelayPerLine = tmp;
1683     }
1684 doda 3395
1685     // Font scaling -- test
1686     ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1687 doda 3441
1688     // Meta sets MSB
1689 doda 3507 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1690     if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1691     ts->Meta8Bit = IdMeta8BitRaw;
1692     else if (_stricmp(Temp, "text") == 0)
1693     ts->Meta8Bit = IdMeta8BitText;
1694     else
1695     ts->Meta8Bit = IdMeta8BitOff;
1696    
1697 maya 3479 // Window control sequence
1698 doda 3485 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1699     ts->WindowFlag |= WF_WINDOWCHANGE;
1700 maya 3479
1701     // Cursor control sequence
1702 doda 3485 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1703     ts->WindowFlag |= WF_CURSORCHANGE;
1704    
1705     // Window report sequence
1706     if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1707     ts->WindowFlag |= WF_WINDOWREPORT;
1708    
1709 doda 3749 // Title report sequence
1710 doda 3747 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1711 doda 3774 if (_stricmp(Temp, "accept") == 0)
1712     ts->WindowFlag |= IdTitleReportAccept;
1713     else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1714 doda 3747 ts->WindowFlag &= ~WF_TITLEREPORT;
1715     else // empty
1716     ts->WindowFlag |= IdTitleReportEmpty;
1717 doda 3501
1718     // Line at a time mode
1719     ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1720 doda 3721
1721     // Clear window on resize
1722     if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1723     ts->TermFlag |= TF_CLEARONRESIZE;
1724 doda 3743
1725     // Alternate Screen Buffer
1726     if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1727     ts->TermFlag |= TF_ALTSCR;
1728 doda 3969
1729     // IME status related cursor style
1730     if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1731     ts->WindowFlag |= WF_IMECURSORCHANGE;
1732 doda 4217
1733     // Terminal Unique ID
1734     GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1735     if (strlen(Temp) == 8) {
1736 doda 4228 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1737 doda 4217 if (islower(Temp[i])) {
1738     ts->TerminalUID[i] = toupper(Temp[i]);
1739     }
1740     else {
1741     ts->TerminalUID[i] = Temp[i];
1742     }
1743     }
1744     if (i == 8) {
1745     ts->TerminalUID[i] = 0;
1746     }
1747     else {
1748     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1749     }
1750     }
1751     else {
1752     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1753     }
1754 doda 4225
1755     // Lock Terminal UID
1756     if (GetOnOff(Section, "LockTUID", FName, TRUE))
1757     ts->TermFlag |= TF_LOCKTUID;
1758 doda 4261
1759 doda 4273 // Confirm PasteCR
1760     ts->ConfirmChangePasteCR = GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE);
1761 doda 4281
1762 doda 4480 // Jump List
1763     ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1764    
1765 doda 4699 // TabStopModifySequence
1766 doda 4687 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1767     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1768     ts->TabStopFlag = TABF_ALL;
1769     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1770     ts->TabStopFlag = TABF_NONE;
1771     else {
1772     ts->TabStopFlag = TABF_NONE;
1773     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1774     if (_stricmp(Temp2, "HTS") == 0)
1775     ts->TabStopFlag |= TABF_HTS;
1776     else if (_stricmp(Temp2, "HTS7") == 0)
1777     ts->TabStopFlag |= TABF_HTS7;
1778     else if (_stricmp(Temp2, "HTS8") == 0)
1779     ts->TabStopFlag |= TABF_HTS8;
1780     else if (_stricmp(Temp2, "TBC") == 0)
1781     ts->TabStopFlag |= TABF_TBC;
1782     else if (_stricmp(Temp2, "TBC0") == 0)
1783     ts->TabStopFlag |= TABF_TBC0;
1784     else if (_stricmp(Temp2, "TBC3") == 0)
1785     ts->TabStopFlag |= TABF_TBC3;
1786     }
1787     }
1788    
1789 doda 4700 // Clipboard Access from Remote
1790     GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1791     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1792     ts->CtrlFlag |= CSF_CBRW;
1793     else if (_stricmp(Temp, "read") == 0)
1794     ts->CtrlFlag |= CSF_CBREAD;
1795     else if (_stricmp(Temp, "write") == 0)
1796     ts->CtrlFlag |= CSF_CBWRITE;
1797    
1798 doda 4281 // Use invalid DECRPSS (for testing)
1799     if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1800     ts->TermFlag |= TF_INVALIDDECRPSS;
1801 maya 4704
1802     // ClickableUrlBrowser
1803     GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1804     ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1805     GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1806     ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1807 maya 4786
1808     // Exclusive Lock when open the log file
1809     ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1810 maya 4874
1811     // Font quality
1812     GetPrivateProfileString(Section, "FontQuality", "default",
1813     Temp, sizeof(Temp), FName);
1814     if (_stricmp(Temp, "nonantialiased") == 0)
1815     ts->FontQuality = NONANTIALIASED_QUALITY;
1816     else if (_stricmp(Temp, "antialiased") == 0)
1817     ts->FontQuality = ANTIALIASED_QUALITY;
1818     else if (_stricmp(Temp, "cleartype") == 0)
1819     ts->FontQuality = CLEARTYPE_QUALITY;
1820     else
1821     ts->FontQuality = DEFAULT_QUALITY;
1822 doda 5316
1823     // Beep Over Used
1824     ts->BeepOverUsedCount =
1825     GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1826     ts->BeepOverUsedTime =
1827     GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1828     ts->BeepSuppressTime =
1829     GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1830 doda 5410
1831     // Max OSC string buffer size
1832     ts->MaxOSCBufferSize =
1833     GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1834 doda 5428
1835 doda 5438 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1836 doda 5428
1837 doda 5438 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1838     ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1839 doda 5590
1840     // Debug modes.
1841     GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1842     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1843     ts->DebugModes = DBGF_ALL;
1844     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1845     ts->DebugModes = DBGF_NONE;
1846     ts->Debug = FALSE;
1847     }
1848     else {
1849     ts->DebugModes = DBGF_NONE;
1850     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1851     if (_stricmp(Temp2, "normal") == 0)
1852     ts->DebugModes |= DBGF_NORM;
1853     else if (_stricmp(Temp2, "hex") == 0)
1854     ts->DebugModes |= DBGF_HEXD;
1855     else if (_stricmp(Temp2, "noout") == 0)
1856     ts->DebugModes |= DBGF_NOUT;
1857     }
1858     if (ts->DebugModes == DBGF_NONE)
1859     ts->Debug = FALSE;
1860     }
1861 yutakapon 6119
1862 doda 6318 // Xmodem Timeout
1863     GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1864     ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1865     if (ts->XmodemTimeOutInit < 1)
1866     ts->XmodemTimeOutInit = 1;
1867     ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1868     if (ts->XmodemTimeOutInitCRC < 1)
1869     ts->XmodemTimeOutInitCRC = 1;
1870     ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1871     if (ts->XmodemTimeOutShort < 1)
1872     ts->XmodemTimeOutShort = 1;
1873     ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1874     if (ts->XmodemTimeOutLong < 1)
1875     ts->XmodemTimeOutLong = 1;
1876     ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1877     if (ts->XmodemTimeOutVLong < 1)
1878     ts->XmodemTimeOutVLong = 1;
1879    
1880 maya 6319 // Ymodem Timeout
1881     GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1882     ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1883     if (ts->YmodemTimeOutInit < 1)
1884     ts->YmodemTimeOutInit = 1;
1885     ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1886     if (ts->YmodemTimeOutInitCRC < 1)
1887     ts->YmodemTimeOutInitCRC = 1;
1888     ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1889     if (ts->YmodemTimeOutShort < 1)
1890     ts->YmodemTimeOutShort = 1;
1891     ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1892     if (ts->YmodemTimeOutLong < 1)
1893     ts->YmodemTimeOutLong = 1;
1894     ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1895     if (ts->YmodemTimeOutVLong < 1)
1896     ts->YmodemTimeOutVLong = 1;
1897    
1898     // Zmodem Timeout
1899     GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1900     ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1901     if (ts->ZmodemTimeOutNormal < 1)
1902     ts->ZmodemTimeOutNormal = 1;
1903     ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1904     if (ts->ZmodemTimeOutTCPIP < 0)
1905     ts->ZmodemTimeOutTCPIP = 0;
1906     ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1907     if (ts->ZmodemTimeOutInit < 1)
1908     ts->ZmodemTimeOutInit = 1;
1909     ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1910     if (ts->ZmodemTimeOutFin < 1)
1911     ts->ZmodemTimeOutFin = 1;
1912    
1913 yutakapon 6119 // CygTerm Configuration File
1914     ReadCygtermConfFile(ts);
1915 maya 3227 }
1916    
1917     void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
1918     {
1919     int i;
1920 maya 4031 char Temp[MAX_PATH];
1921 maya 3227 char buf[20];
1922 yutakapon 5052 int ret;
1923     char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
1924 maya 3227
1925     /* version */
1926 yutakapon 5052 ret = WritePrivateProfileString(Section, "Version", "2.3", FName);
1927     if (ret == 0) {
1928     // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
1929     ret = GetLastError();
1930     get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
1931     _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
1932 maya 3227
1933 yutakapon 5052 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
1934    
1935     MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
1936     }
1937    
1938 maya 3227 /* Language */
1939 doda 3359 switch (ts->Language) {
1940     case IdJapanese:
1941 maya 3227 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
1942 doda 3359 break;
1943     case IdKorean:
1944     strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
1945     break;
1946     case IdRussian:
1947     strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
1948     break;
1949 maya 3401 case IdUtf8:
1950     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1951     break;
1952 doda 3359 default:
1953     strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
1954     }
1955    
1956 maya 3227 WritePrivateProfileString(Section, "Language", Temp, FName);
1957    
1958     /* Port type */
1959     if (ts->PortType == IdSerial)
1960     strncpy_s(Temp, sizeof(Temp), "serial", _TRUNCATE);
1961 yutakapon 4966 else if (ts->PortType == IdNamedPipe)
1962 yutakapon 4857 strncpy_s(Temp, sizeof(Temp), "namedpipe", _TRUNCATE);
1963 maya 3227 else /* IdFile -> IdTCPIP */
1964     strncpy_s(Temp, sizeof(Temp), "tcpip", _TRUNCATE);
1965    
1966     WritePrivateProfileString(Section, "Port", Temp, FName);
1967    
1968     /* Save win position */
1969     if (ts->SaveVTWinPos) {
1970     /* VT win position */
1971     WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
1972     }
1973    
1974     /* VT terminal size */
1975     WriteInt2(Section, "TerminalSize", FName,
1976     ts->TerminalWidth, ts->TerminalHeight);
1977    
1978     /* Terminal size = Window size */
1979     WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
1980    
1981     /* Auto window resize flag */
1982     WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
1983    
1984     /* CR Receive */
1985     if (ts->CRReceive == IdCRLF) {
1986     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1987     }
1988     else if (ts->CRReceive == IdLF) {
1989     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
1990     }
1991 maya 4893 else if (ts->CRReceive == IdAUTO) {
1992     strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
1993     }
1994 maya 3227 else {
1995     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1996     }
1997     WritePrivateProfileString(Section, "CRReceive", Temp, FName);
1998    
1999     /* CR Send */
2000 maya 6369 if (ts->CRSend == IdCRLF) {
2001 maya 3227 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2002 maya 6369 }
2003     else if (ts->CRSend == IdLF) {
2004     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2005     }
2006     else {
2007 maya 3227 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2008 maya 6369 }
2009 maya 3227 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2010    
2011     /* Local echo */
2012     WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2013    
2014     /* Answerback */
2015     if ((ts->FTFlag & FT_BPAUTO) == 0) {
2016     Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2017     sizeof(Temp) - 1, TRUE);
2018     WritePrivateProfileString(Section, "Answerback", Temp, FName);
2019     }
2020    
2021     /* Kanji Code (receive) */
2022     switch (ts->KanjiCode) {
2023     case IdEUC:
2024     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2025     break;
2026     case IdJIS:
2027     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2028     break;
2029     case IdUTF8:
2030     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2031     break;
2032     case IdUTF8m:
2033     strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2034     break;
2035     default:
2036 doda 3420 switch (ts->Language) {
2037     case IdJapanese:
2038     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2039     break;
2040     case IdKorean:
2041     strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2042     break;
2043     default:
2044     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2045     }
2046 maya 3227 }
2047     WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2048    
2049     /* Katakana (receive) */
2050     if (ts->JIS7Katakana == 1)
2051     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2052     else
2053     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2054    
2055     WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2056    
2057     /* Kanji Code (transmit) */
2058     switch (ts->KanjiCodeSend) {
2059     case IdEUC:
2060     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2061     break;
2062     case IdJIS:
2063     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2064     break;
2065     case IdUTF8:
2066     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2067     break;
2068     default:
2069 doda 3420 switch (ts->Language) {
2070     case IdJapanese:
2071     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2072     break;
2073     case IdKorean:
2074     strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2075     break;
2076     default:
2077     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2078     }
2079 maya 3227 }
2080     WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2081    
2082     /* Katakana (transmit) */
2083     if (ts->JIS7KatakanaSend == 1)
2084     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2085     else
2086     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2087    
2088     WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2089    
2090     /* KanjiIn */
2091     if (ts->KanjiIn == IdKanjiInA)
2092     strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2093     else
2094     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2095    
2096     WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2097    
2098     /* KanjiOut */
2099     switch (ts->KanjiOut) {
2100     case IdKanjiOutB:
2101     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2102     break;
2103     case IdKanjiOutH:
2104     strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2105     break;
2106     default:
2107     strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2108     }
2109     WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2110    
2111     // new configuration
2112     WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2113    
2114     WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2115     ts->DisablePasteMouseRButton);
2116    
2117     // added DisablePasteMouseMButton (2008.3.2 maya)
2118     WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2119     ts->DisablePasteMouseMButton);
2120    
2121     // added ConfirmPasteMouseRButton (2007.3.17 maya)
2122     WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2123     ts->ConfirmPasteMouseRButton);
2124    
2125     // added ConfirmChangePaste
2126     WriteOnOff(Section, "ConfirmChangePaste", FName,
2127     ts->ConfirmChangePaste);
2128 yutakapon 3535 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2129     ts->ConfirmChangePasteStringFile, FName);
2130 maya 3227
2131     // added ScrollWindowClearScreen
2132     WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2133     ts->ScrollWindowClearScreen);
2134    
2135     // added SelectOnlyByLButton (2007.11.20 maya)
2136     WriteOnOff(Section, "SelectOnlyByLButton", FName,
2137     ts->SelectOnlyByLButton);
2138     // added DisableAcceleratorSendBreak (2007.3.17 maya)
2139     WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2140     ts->DisableAcceleratorSendBreak);
2141     WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2142     ts->EnableContinuedLineCopy);
2143     WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2144     FName);
2145     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
2146     WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2147     WritePrivateProfileString(Section, "CygwinDirectory",
2148     ts->CygwinDirectory, FName);
2149     WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2150     FName);
2151     WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
2152     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
2153     WritePrivateProfileString(Section, "CodePage", Temp, FName);
2154    
2155     // ANSI color(2004.9.5 yutaka)
2156     Temp[0] = '\0';
2157     for (i = 0; i < 15; i++) {
2158     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2159     i,
2160     GetRValue(ts->ANSIColor[i]),
2161     GetGValue(ts->ANSIColor[i]),
2162     GetBValue(ts->ANSIColor[i])
2163     );
2164     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2165     }
2166     i = 15;
2167     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2168     i,
2169     GetRValue(ts->ANSIColor[i]),
2170     GetGValue(ts->ANSIColor[i]),
2171     GetBValue(ts->ANSIColor[i])
2172     );
2173     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2174     WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2175    
2176     /* AutoWinChange VT<->TEK */
2177     WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2178    
2179     /* Terminal ID */
2180     id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2181     WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2182    
2183     /* Russian character set (host) */
2184     id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
2185     WritePrivateProfileString(Section, "RussHost", Temp, FName);
2186    
2187     /* Russian character set (client) */
2188     id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
2189     WritePrivateProfileString(Section, "RussClient", Temp, FName);
2190    
2191     /* Title text */
2192     WritePrivateProfileString(Section, "Title", ts->Title, FName);
2193    
2194     /* Cursor shape */
2195     switch (ts->CursorShape) {
2196     case IdVCur