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 6349 - (hide annotations) (download) (as text)
Sat Mar 19 13:55:49 2016 UTC (8 years ago) by salarm
File MIME type: text/x-csrc
File size: 131823 byte(s)
r6347の改善
起動時にシリアルポートの接続を待つ/WAITCOM コマンドラインオプションを追加した。

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