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 6467 - (hide annotations) (download) (as text)
Wed Aug 17 08:39:09 2016 UTC (7 years, 7 months ago) by doda
File MIME type: text/x-csrc
File size: 132424 byte(s)
MaxComPort のデフォルト値を 256 に増やした。

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