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 9913 - (hide annotations) (download) (as text)
Sun May 8 13:25:16 2022 UTC (23 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 136851 byte(s)
Eterm風 背景画像 が設定できなくなっていたので修正

- theme/以下の設定ファイル(テーマファイル)が保存できない場合があった
- 保存できるよう修正
  - 起動時に設定ファイルがないとき、
    個人設定フォルダへ設定ファイルをコピーするが、
    そのときにthemeフォルダのファイルもコピーするようにした
  - iniファイル保存時に theme フォルダを作成するようにした
- テーマファイルの書き込み時のファイルパスをUnicode化
- ETERM_SECTION を削除
  - BG_SECTION へ置き換え
- 書き換えを行わないデータに const を追加
- far キーワードを削除

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