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