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