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 9431 - (hide annotations) (download) (as text)
Sun Sep 19 15:14:16 2021 UTC (2 years, 6 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139560 byte(s)
plugin CopySerialList() を Unicode化

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