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