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 5270 - (hide annotations) (download) (as text)
Mon May 20 03:54:08 2013 UTC (10 years, 10 months ago) by doda
File MIME type: text/x-csrc
File size: 114401 byte(s)
/NOLOG コマンドラインオプションを追加

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