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 2478 - (hide annotations) (download) (as text)
Thu Apr 17 16:16:26 2008 UTC (15 years, 11 months ago) by yutakapon
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 81979 byte(s)
XModemRcvCommandのデフォルトを空にした。

1 maya 2476 /* 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     #include "ttlib.h"
17    
18     #define Section "Tera Term"
19    
20     static PCHAR far TermList[] =
21     { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
22     "VT320", "VT382", NULL };
23     // expansion (2005.11.30 yutaka)
24     static PCHAR BaudList[] =
25     { "110", "300", "600", "1200", "2400", "4800", "9600",
26     "14400", "19200", "38400", "57600", "115200",
27     "230400", "460800", "921600", NULL
28     };
29    
30     static PCHAR far RussList[] =
31     { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
32     static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
33    
34     WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
35     {
36     WORD i;
37     i = 0;
38     while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))
39     i++;
40     if (List[i] == NULL)
41     i = DefId;
42     else
43     i++;
44    
45     return i;
46     }
47    
48     void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
49     {
50     int i;
51    
52     if (Id == 0)
53     i = DefId - 1;
54     else {
55     i = 0;
56     while ((List[i] != NULL) && (i < Id - 1))
57     i++;
58     if (List[i] == NULL)
59     i = DefId - 1;
60     }
61     strncpy_s(str, destlen, List[i], _TRUNCATE);
62     }
63    
64     WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)
65     {
66     char Temp[4];
67     GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
68     if (Default) {
69     if (_stricmp(Temp, "off") == 0)
70     return 0;
71     else
72     return 1;
73     }
74     else {
75     if (_stricmp(Temp, "on") == 0)
76     return 1;
77     else
78     return 0;
79     }
80     }
81    
82     void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)
83     {
84     char Temp[4];
85    
86     if (Flag != 0)
87     strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
88     else
89     strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
90     WritePrivateProfileString(Sect, Key, Temp, FName);
91     }
92    
93     void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)
94     {
95     char Temp[15];
96     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
97     WritePrivateProfileString(Sect, Key, Temp, FName);
98     }
99    
100     void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)
101     {
102     char Temp[15];
103     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
104     WritePrivateProfileString(Sect, Key, Temp, FName);
105     }
106    
107     void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)
108     {
109     char Temp[32];
110     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
111     WritePrivateProfileString(Sect, Key, Temp, FName);
112     }
113    
114     void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,
115     int i1, int i2, int i3, int i4)
116     {
117     char Temp[64];
118     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
119     i1, i2, i3, i4);
120     WritePrivateProfileString(Sect, Key, Temp, FName);
121     }
122    
123     void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,
124     int i1, int i2, int i3, int i4, int i5, int i6)
125     {
126     char Temp[96];
127     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",
128     i1, i2,i3, i4, i5, i6);
129     WritePrivateProfileString(Sect, Key, Temp, FName);
130     }
131    
132     void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
133     PCHAR Name, int x, int y, int charset)
134     {
135     char Temp[80];
136     if (Name[0] != 0)
137     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",
138     Name, x, y, charset);
139     else
140     Temp[0] = 0;
141     WritePrivateProfileString(Sect, Key, Temp, FName);
142     }
143    
144     void FAR PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
145     {
146     int i;
147     HDC TmpDC;
148     char Temp[MAXPATHLEN];
149    
150     ts->Minimize = 0;
151     ts->HideWindow = 0;
152     ts->LogFlag = 0; // Log flags
153     ts->FTFlag = 0; // File transfer flags
154     ts->MenuFlag = 0; // Menu flags
155     ts->TermFlag = 0; // Terminal flag
156     ts->ColorFlag = 0; // ANSI color flags
157     ts->PortFlag = 0; // Port flags
158     ts->TelPort = 23;
159    
160     /* Version number */
161     /* GetPrivateProfileString(Section,"Version","",
162     Temp,sizeof(Temp),FName); */
163    
164     /* Language */
165     GetPrivateProfileString(Section, "Language", "",
166     Temp, sizeof(Temp), FName);
167     if (_stricmp(Temp, "Japanese") == 0)
168     ts->Language = IdJapanese;
169     else if (_stricmp(Temp, "Russian") == 0)
170     ts->Language = IdRussian;
171     else if (_stricmp(Temp, "English") == 0)
172     ts->Language = IdEnglish;
173     else {
174     switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
175     case LANG_JAPANESE:
176     ts->Language = IdJapanese;
177     break;
178     case LANG_RUSSIAN:
179     ts->Language = IdRussian;
180     break;
181     default:
182     ts->Language = IdEnglish;
183     }
184     }
185    
186     /* Port type */
187     GetPrivateProfileString(Section, "Port", "",
188     Temp, sizeof(Temp), FName);
189     if (_stricmp(Temp, "tcpip") == 0)
190     ts->PortType = IdTCPIP;
191     else if (_stricmp(Temp, "serial") == 0)
192     ts->PortType = IdSerial;
193     else {
194     ts->PortType = IdTCPIP;
195     }
196    
197     /* VT win position */
198     GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
199     GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
200     GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
201    
202     /* TEK win position */
203     GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
204     GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
205     GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
206    
207     /* Save VT Window position */
208     ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
209    
210     /* VT terminal size */
211     GetPrivateProfileString(Section, "TerminalSize", "80,24",
212     Temp, sizeof(Temp), FName);
213     GetNthNum(Temp, 1, &ts->TerminalWidth);
214     GetNthNum(Temp, 2, &ts->TerminalHeight);
215     if (ts->TerminalWidth < 0)
216     ts->TerminalWidth = 1;
217     if (ts->TerminalHeight < 0)
218     ts->TerminalHeight = 1;
219    
220     /* Terminal size = Window size */
221     ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
222    
223     /* Auto window resize flag */
224     ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
225    
226     /* CR Receive */
227     GetPrivateProfileString(Section, "CRReceive", "",
228     Temp, sizeof(Temp), FName);
229     if (_stricmp(Temp, "CRLF") == 0) {
230     ts->CRReceive = IdCRLF;
231     }
232     else if (_stricmp(Temp, "LF") == 0) {
233     ts->CRReceive = IdLF;
234     }
235     else {
236     ts->CRReceive = IdCR;
237     }
238     /* CR Send */
239     GetPrivateProfileString(Section, "CRSend", "",
240     Temp, sizeof(Temp), FName);
241     if (_stricmp(Temp, "CRLF") == 0)
242     ts->CRSend = IdCRLF;
243     else
244     ts->CRSend = IdCR;
245    
246     /* Local echo */
247     ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
248    
249     /* Answerback */
250     GetPrivateProfileString(Section, "Answerback", "", Temp,
251     sizeof(Temp), FName);
252     ts->AnswerbackLen =
253     Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
254    
255     /* Kanji Code (receive) */
256     GetPrivateProfileString(Section, "KanjiReceive", "",
257     Temp, sizeof(Temp), FName);
258     if (_stricmp(Temp, "EUC") == 0)
259     ts->KanjiCode = IdEUC;
260     else if (_stricmp(Temp, "JIS") == 0)
261     ts->KanjiCode = IdJIS;
262     else if (_stricmp(Temp, "UTF-8") == 0)
263     ts->KanjiCode = IdUTF8;
264     else if (_stricmp(Temp, "UTF-8m") == 0)
265     ts->KanjiCode = IdUTF8m;
266     else
267     ts->KanjiCode = IdSJIS;
268    
269     /* Katakana (receive) */
270     GetPrivateProfileString(Section, "KatakanaReceive", "",
271     Temp, sizeof(Temp), FName);
272     if (_stricmp(Temp, "7") == 0)
273     ts->JIS7Katakana = 1;
274     else
275     ts->JIS7Katakana = 0;
276    
277     /* Kanji Code (transmit) */
278     GetPrivateProfileString(Section, "KanjiSend", "",
279     Temp, sizeof(Temp), FName);
280     if (_stricmp(Temp, "EUC") == 0)
281     ts->KanjiCodeSend = IdEUC;
282     else if (_stricmp(Temp, "JIS") == 0)
283     ts->KanjiCodeSend = IdJIS;
284     else if (_stricmp(Temp, "UTF-8") == 0)
285     ts->KanjiCodeSend = IdUTF8;
286     else
287     ts->KanjiCodeSend = IdSJIS;
288    
289     /* Katakana (receive) */
290     GetPrivateProfileString(Section, "KatakanaSend", "",
291     Temp, sizeof(Temp), FName);
292     if (_stricmp(Temp, "7") == 0)
293     ts->JIS7KatakanaSend = 1;
294     else
295     ts->JIS7KatakanaSend = 0;
296    
297     /* KanjiIn */
298     GetPrivateProfileString(Section, "KanjiIn", "",
299     Temp, sizeof(Temp), FName);
300     if (_stricmp(Temp, "@") == 0)
301     ts->KanjiIn = IdKanjiInA;
302     else
303     ts->KanjiIn = IdKanjiInB;
304    
305     /* KanjiOut */
306     GetPrivateProfileString(Section, "KanjiOut", "",
307     Temp, sizeof(Temp), FName);
308     if (_stricmp(Temp, "B") == 0)
309     ts->KanjiOut = IdKanjiOutB;
310     else if (_stricmp(Temp, "H") == 0)
311     ts->KanjiOut = IdKanjiOutH;
312     else
313     ts->KanjiOut = IdKanjiOutJ;
314    
315     /* Auto Win Switch VT<->TEK */
316     ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
317    
318     /* Terminal ID */
319     GetPrivateProfileString(Section, "TerminalID", "",
320     Temp, sizeof(Temp), FName);
321     ts->TerminalID = str2id(TermList, Temp, IdVT100);
322    
323     /* Russian character set (host) */
324     GetPrivateProfileString(Section, "RussHost", "",
325     Temp, sizeof(Temp), FName);
326     ts->RussHost = str2id(RussList, Temp, IdKOI8);
327    
328     /* Russian character set (client) */
329     GetPrivateProfileString(Section, "RussClient", "",
330     Temp, sizeof(Temp), FName);
331     ts->RussClient = str2id(RussList, Temp, IdWindows);
332    
333     /* Title String */
334     GetPrivateProfileString(Section, "Title", "Tera Term",
335     ts->Title, sizeof(ts->Title), FName);
336    
337     /* Cursor shape */
338     GetPrivateProfileString(Section, "CursorShape", "",
339     Temp, sizeof(Temp), FName);
340     if (_stricmp(Temp, "vertical") == 0)
341     ts->CursorShape = IdVCur;
342     else if (_stricmp(Temp, "horizontal") == 0)
343     ts->CursorShape = IdHCur;
344     else
345     ts->CursorShape = IdBlkCur;
346    
347     /* Hide title */
348     ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
349    
350     /* Popup menu */
351     ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
352    
353     /* PC-Style bold color mapping */
354     ts->ColorFlag |=
355     CF_PCBOLD16 * GetOnOff(Section, "PcBoldColor", FName, FALSE);
356    
357     /* aixterm style 16 colors mode */
358     ts->ColorFlag |=
359     CF_AIXTERM16 * GetOnOff(Section, "Aixterm16Color", FName, FALSE);
360    
361     /* xterm style 256 colors mode */
362     ts->ColorFlag |=
363     CF_XTERM256 * GetOnOff(Section, "Xterm256Color", FName, TRUE);
364    
365     /* Enable scroll buffer */
366     ts->EnableScrollBuff =
367     GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
368    
369     /* Scroll buffer size */
370     ts->ScrollBuffSize =
371     GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
372    
373     /* VT Color */
374     GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
375     Temp, sizeof(Temp), FName);
376     for (i = 0; i <= 5; i++)
377     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
378     for (i = 0; i <= 1; i++)
379     ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
380     (BYTE) ts->TmpColor[0][i * 3 + 1],
381     (BYTE) ts->TmpColor[0][i * 3 + 2]);
382    
383     /* VT Bold Color */
384     GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
385     Temp, sizeof(Temp), FName);
386     for (i = 0; i <= 5; i++)
387     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
388     for (i = 0; i <= 1; i++)
389     ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
390     (BYTE) ts->TmpColor[0][i * 3 + 1],
391     (BYTE) ts->TmpColor[0][i * 3 + 2]);
392    
393     /* VT Blink Color */
394     GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
395     Temp, sizeof(Temp), FName);
396     for (i = 0; i <= 5; i++)
397     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
398     for (i = 0; i <= 1; i++)
399     ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
400     (BYTE) ts->TmpColor[0][i * 3 + 1],
401     (BYTE) ts->TmpColor[0][i * 3 + 2]);
402    
403     /* begin - ishizaki */
404     ts->EnableClickableUrl =
405     GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
406    
407     /* URL Color */
408     GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
409     Temp, sizeof(Temp), FName);
410     for (i = 0; i <= 5; i++)
411     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
412     for (i = 0; i <= 1; i++)
413     ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
414     (BYTE) ts->TmpColor[0][i * 3 + 1],
415     (BYTE) ts->TmpColor[0][i * 3 + 2]);
416     /* end - ishizaki */
417    
418     /* TEK Color */
419     GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
420     Temp, sizeof(Temp), FName);
421     for (i = 0; i <= 5; i++)
422     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
423     for (i = 0; i <= 1; i++)
424     ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
425     (BYTE) ts->TmpColor[0][i * 3 + 1],
426     (BYTE) ts->TmpColor[0][i * 3 + 2]);
427    
428     #ifndef NO_ANSI_COLOR_EXTENSION
429     /* ANSI color definition (in the case FullColor=on) -- special option
430     o UseTextColor should be off, or the background and foreground color of
431     VTColor are assigned to color-number 0 and 7 respectively, even if
432     they are specified in ANSIColor.
433     o ANSIColor is a set of 4 values that are color-number(0--15),
434     red-value(0--255), green-value(0--255) and blue-value(0--255). */
435     GetPrivateProfileString(Section, "ANSIColor",
436     " 0, 0, 0, 0,"
437     " 1,255, 0, 0,"
438     " 2, 0,255, 0,"
439     " 3,255,255, 0,"
440     " 4, 0, 0,255,"
441     " 5,255, 0,255,"
442     " 6, 0,255,255,"
443     " 7,255,255,255,"
444     " 8,128,128,128,"
445     " 9,128, 0, 0,"
446     "10, 0,128, 0,"
447     "11,128,128, 0,"
448     "12, 0, 0,128,"
449     "13,128, 0,128,"
450     "14, 0,128,128,"
451     "15,192,192,192", Temp, sizeof(Temp), FName);
452     {
453     char *t;
454     int n = 1;
455     for (t = Temp; *t; t++)
456     if (*t == ',')
457     n++;
458     n /= 4;
459     for (i = 0; i <= n; i++) {
460     int colorid, r, g, b;
461     GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
462     GetNthNum(Temp, i * 4 + 2, (int far *) &r);
463     GetNthNum(Temp, i * 4 + 3, (int far *) &g);
464     GetNthNum(Temp, i * 4 + 4, (int far *) &b);
465     ts->ANSIColor[colorid & 15] =
466     RGB((BYTE) r, (BYTE) g, (BYTE) b);
467     }
468     }
469     #endif /* NO_ANSI_COLOR_EXTENSION */
470    
471     TmpDC = GetDC(0); /* Get screen device context */
472     for (i = 0; i <= 1; i++)
473     ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
474     for (i = 0; i <= 1; i++)
475     ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
476     for (i = 0; i <= 1; i++)
477     ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
478     for (i = 0; i <= 1; i++)
479     ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
480     /* begin - ishizaki */
481     for (i = 0; i <= 1; i++)
482     ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
483     /* end - ishizaki */
484     #ifndef NO_ANSI_COLOR_EXTENSION
485     for (i = 0; i < 16; i++)
486     ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
487     #endif /* NO_ANSI_COLOR_EXTENSION */
488     ReleaseDC(0, TmpDC);
489    
490     /* TEK color emulation */
491     ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
492    
493     /* VT Font */
494     GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
495     Temp, sizeof(Temp), FName);
496     GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
497     GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
498     GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
499     GetNthNum(Temp, 4, &(ts->VTFontCharSet));
500    
501     /* Bold font flag */
502     ts->EnableBold = GetOnOff(Section, "EnableBold", FName, TRUE);
503    
504     /* Russian character set (font) */
505     GetPrivateProfileString(Section, "RussFont", "",
506     Temp, sizeof(Temp), FName);
507     ts->RussFont = str2id(RussList, Temp, IdWindows);
508    
509     /* TEK Font */
510     GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
511     Temp, sizeof(Temp), FName);
512     GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
513     GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
514     GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
515     GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
516    
517     /* BS key */
518     GetPrivateProfileString(Section, "BSKey", "",
519     Temp, sizeof(Temp), FName);
520     if (_stricmp(Temp, "DEL") == 0)
521     ts->BSKey = IdDEL;
522     else
523     ts->BSKey = IdBS;
524     /* Delete key */
525     ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
526    
527     /* Meta Key */
528     ts->MetaKey = GetOnOff(Section, "MetaKey", FName, FALSE);
529    
530     /* Application Keypad */
531     ts->DisableAppKeypad = GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
532    
533     /* Application Cursor */
534     ts->DisableAppCursor = GetOnOff(Section, "DisableAppCursor", FName, FALSE);
535    
536     /* Russian keyboard type */
537     GetPrivateProfileString(Section, "RussKeyb", "",
538     Temp, sizeof(Temp), FName);
539     ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
540    
541     /* Serial port ID */
542     ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
543    
544     /* Baud rate */
545     GetPrivateProfileString(Section, "BaudRate", "9600",
546     Temp, sizeof(Temp), FName);
547     ts->Baud = str2id(BaudList, Temp, IdBaud9600);
548    
549     /* Parity */
550     GetPrivateProfileString(Section, "Parity", "",
551     Temp, sizeof(Temp), FName);
552     if (_stricmp(Temp, "even") == 0)
553     ts->Parity = IdParityEven;
554     else if (_stricmp(Temp, "odd") == 0)
555     ts->Parity = IdParityOdd;
556     else
557     ts->Parity = IdParityNone;
558    
559     /* Data bit */
560     GetPrivateProfileString(Section, "DataBit", "",
561     Temp, sizeof(Temp), FName);
562     if (_stricmp(Temp, "7") == 0)
563     ts->DataBit = IdDataBit7;
564     else
565     ts->DataBit = IdDataBit8;
566    
567     /* Stop bit */
568     GetPrivateProfileString(Section, "StopBit", "",
569     Temp, sizeof(Temp), FName);
570     if (_stricmp(Temp, "2") == 0)
571     ts->StopBit = IdStopBit2;
572     else
573     ts->StopBit = IdStopBit1;
574    
575     /* Flow control */
576     GetPrivateProfileString(Section, "FlowCtrl", "",
577     Temp, sizeof(Temp), FName);
578     if (_stricmp(Temp, "x") == 0)
579     ts->Flow = IdFlowX;
580     else if (_stricmp(Temp, "hard") == 0)
581     ts->Flow = IdFlowHard;
582     else
583     ts->Flow = IdFlowNone;
584    
585     /* Delay per character */
586     ts->DelayPerChar =
587     GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
588    
589     /* Delay per line */
590     ts->DelayPerLine =
591     GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
592    
593     /* Telnet flag */
594     ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
595    
596     /* Telnet terminal type */
597     GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
598     sizeof(ts->TermType), FName);
599    
600     /* TCP port num */
601     ts->TCPPort =
602     GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
603    
604     /* Auto window close flag */
605     ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
606    
607     /* History list */
608     ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
609    
610     /* File transfer binary flag */
611     ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
612    
613     /* Log append */
614     ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
615    
616     /* Log plain text (2005.5.7 yutaka) */
617     ts->LogTypePlainText =
618     GetOnOff(Section, "LogTypePlainText", FName, FALSE);
619    
620     /* Log with timestamp (2006.7.23 maya) */
621     ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
622    
623     /* Log without transfer dialog */
624     ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
625    
626     /* Default Log file name (2006.8.28 maya) */
627     GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
628     ts->LogDefaultName, sizeof(ts->LogDefaultName),
629     FName);
630    
631     /* Default Log file path (2007.5.30 maya) */
632     GetPrivateProfileString(Section, "LogDefaultPath", "",
633     ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
634     FName);
635    
636     /* Auto start logging (2007.5.31 maya) */
637     ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
638    
639     /* XMODEM option */
640     GetPrivateProfileString(Section, "XmodemOpt", "",
641     Temp, sizeof(Temp), FName);
642     if (_stricmp(Temp, "crc") == 0)
643     ts->XmodemOpt = XoptCRC;
644     else if (_stricmp(Temp, "1k") == 0)
645     ts->XmodemOpt = Xopt1K;
646     else
647     ts->XmodemOpt = XoptCheck;
648    
649     /* XMODEM binary file */
650     ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
651    
652     /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
653 yutakapon 2478 GetPrivateProfileString(Section, "XModemRcvCommand", "",
654 maya 2476 ts->XModemRcvCommand, sizeof(ts->XModemRcvCommand), FName);
655    
656     /* Default directory for file transfer */
657     GetPrivateProfileString(Section, "FileDir", "",
658     ts->FileDir, sizeof(ts->FileDir), FName);
659     if (strlen(ts->FileDir) == 0)
660     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
661     else {
662     _getcwd(Temp, sizeof(Temp));
663     if (_chdir(ts->FileDir) != 0)
664     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
665     _chdir(Temp);
666     }
667    
668     /* filter on file send (2007.6.5 maya) */
669     GetPrivateProfileString(Section, "FileSendFilter", "",
670     ts->FileSendFilter, sizeof(ts->FileSendFilter),
671     FName);
672    
673     /*--------------------------------------------------*/
674     /* 8 bit control code flag -- special option */
675     ts->TermFlag |=
676     TF_ACCEPT8BITCTRL *
677     GetOnOff(Section, "Accept8BitCtrl", FName, TRUE);
678    
679     /* Wrong sequence flag -- special option */
680     ts->TermFlag |=
681     TF_ALLOWWRONGSEQUENCE *
682     GetOnOff(Section, "AllowWrongSequence", FName, FALSE);
683    
684     if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
685     (ts->KanjiOut == IdKanjiOutH))
686     ts->KanjiOut = IdKanjiOutJ;
687    
688     // Auto file renaming --- special option
689     ts->FTFlag |=
690     FT_RENAME * GetOnOff(Section, "AutoFileRename", FName, FALSE);
691    
692     // Auto invoking (character set->G0->GL) --- special option
693     ts->TermFlag |=
694     TF_AUTOINVOKE * GetOnOff(Section, "AutoInvoke", FName, FALSE);
695    
696     // Auto text copy --- special option
697     ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
698    
699     /* Back wrap -- special option */
700     ts->TermFlag |=
701     TF_BACKWRAP * GetOnOff(Section, "BackWrap", FName, FALSE);
702    
703     /* Beep type -- special option */
704     ts->Beep = GetOnOff(Section, "Beep", FName, TRUE);
705    
706     /* Beep on connection & disconnection -- special option */
707     ts->PortFlag |=
708     PF_BEEPONCONNECT * GetOnOff(Section, "BeepOnConnect", FName,
709     FALSE);
710    
711     /* Auto B-Plus activation -- special option */
712     ts->FTFlag |= FT_BPAUTO * GetOnOff(Section, "BPAuto", FName, FALSE);
713     if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
714     strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
715     _TRUNCATE);
716     ts->AnswerbackLen = 5;
717     }
718    
719     /* B-Plus ESCCTL flag -- special option */
720     ts->FTFlag |=
721     FT_BPESCCTL * GetOnOff(Section, "BPEscCtl", FName, FALSE);
722    
723     /* B-Plus log -- special option */
724     ts->LogFlag |= LOG_BP * GetOnOff(Section, "BPLog", FName, FALSE);
725    
726     /* Clear serial port buffer when port opening -- special option */
727     ts->ClearComBuffOnOpen = GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
728    
729     /* Confirm disconnection -- special option */
730     ts->PortFlag |=
731     PF_CONFIRMDISCONN * GetOnOff(Section, "ConfirmDisconnect", FName,
732     TRUE);
733    
734     /* Ctrl code in Kanji -- special option */
735     ts->TermFlag |=
736     TF_CTRLINKANJI * GetOnOff(Section, "CtrlInKanji", FName, TRUE);
737    
738     /* Debug flag -- special option */
739     ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
740    
741     /* Delimiter list -- special option */
742     GetPrivateProfileString(Section, "DelimList",
743     "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
744     Temp, sizeof(Temp), FName);
745     Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
746    
747     /* regard DBCS characters as delimiters -- special option */
748     ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
749    
750     // Enable popup menu -- special option
751     if (GetOnOff(Section, "EnablePopupMenu", FName, TRUE) == 0)
752     ts->MenuFlag |= MF_NOPOPUP;
753    
754     // Enable "Show menu" -- special option
755     if (GetOnOff(Section, "EnableShowMenu", FName, TRUE) == 0)
756     ts->MenuFlag |= MF_NOSHOWMENU;
757    
758     // Enable the status line -- special option
759     ts->TermFlag |=
760     TF_ENABLESLINE * GetOnOff(Section, "EnableStatusLine", FName, TRUE);
761    
762     // fixed JIS --- special
763     ts->TermFlag |=
764     TF_FIXEDJIS * GetOnOff(Section, "FixedJIS", FName, FALSE);
765    
766     /* IME Flag -- special option */
767     ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
768    
769     /* IME-inline Flag -- special option */
770     ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
771    
772     /* Kermit log -- special option */
773     ts->LogFlag |= LOG_KMT * GetOnOff(Section, "KmtLog", FName, FALSE);
774    
775     // Enable language selection -- special option
776     if (GetOnOff(Section, "LanguageSelection", FName, TRUE) == 0)
777     ts->MenuFlag |= MF_NOLANGUAGE;
778    
779     /* Maximum scroll buffer size -- special option */
780     ts->ScrollBuffMax =
781     GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
782     if (ts->ScrollBuffMax < 24)
783     ts->ScrollBuffMax = 10000;
784    
785     /* Max com port number -- special option */
786     ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 4, FName);
787     if (ts->MaxComPort < 4)
788     ts->MaxComPort = 4;
789     // COM16����99���g�� (2005.11.30 yutaka)
790     // 99����200���g�� (2007.7.23 maya)
791     if (ts->MaxComPort > MAXCOMPORT)
792     ts->MaxComPort = MAXCOMPORT;
793     if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
794     ts->ComPort = 1;
795    
796     /* Non-blinking cursor -- special option */
797     ts->NonblinkingCursor =
798     GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
799    
800     // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
801     ts->KillFocusCursor =
802     GetOnOff(Section, "KillFocusCursor", FName, TRUE);
803    
804     /* Delay for pass-thru printing activation */
805     /* -- special option */
806     ts->PassThruDelay =
807     GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
808    
809     /* Printer port for pass-thru printing */
810     /* -- special option */
811     GetPrivateProfileString(Section, "PassThruPort", "",
812     ts->PrnDev, sizeof(ts->PrnDev), FName);
813    
814     /* Printer Font --- special option */
815     GetPrivateProfileString(Section, "PrnFont", "",
816     Temp, sizeof(Temp), FName);
817     if (strlen(Temp) == 0) {
818     ts->PrnFont[0] = 0;
819     ts->PrnFontSize.x = 0;
820     ts->PrnFontSize.y = 0;
821     ts->PrnFontCharSet = 0;
822     }
823     else {
824     GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
825     GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
826     GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
827     GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
828     }
829    
830     // Page margins (left, right, top, bottom) for printing
831     // -- special option
832     GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
833     Temp, sizeof(Temp), FName);
834     for (i = 0; i <= 3; i++)
835     GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
836    
837     /* Quick-VAN log -- special option */
838     ts->LogFlag |= LOG_QV * GetOnOff(Section, "QVLog", FName, FALSE);
839    
840     /* Quick-VAN window size -- special */
841     ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
842    
843     /* Russian character set (print) -- special option */
844     GetPrivateProfileString(Section, "RussPrint", "",
845     Temp, sizeof(Temp), FName);
846     ts->RussPrint = str2id(RussList, Temp, IdWindows);
847    
848     /* Scroll threshold -- special option */
849     ts->ScrollThreshold =
850     GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
851    
852     ts->MouseWheelScrollLine =
853     GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
854    
855     // Select on activate -- special option
856     ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
857    
858     /* Send 8bit control sequence -- special option */
859     ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
860    
861     /* Startup macro -- special option */
862     GetPrivateProfileString(Section, "StartupMacro", "",
863     ts->MacroFN, sizeof(ts->MacroFN), FName);
864    
865     /* TEK GIN Mouse keycode -- special option */
866     ts->GINMouseCode =
867     GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
868    
869     /* Telnet Auto Detect -- special option */
870     ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
871    
872     /* Telnet binary flag -- special option */
873     ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
874    
875     /* Telnet Echo flag -- special option */
876     ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
877    
878     /* Telnet log -- special option */
879     ts->LogFlag |= LOG_TEL * GetOnOff(Section, "TelLog", FName, FALSE);
880    
881     /* TCP port num for telnet -- special option */
882     ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
883    
884     /* Telnet keep-alive packet(NOP command) interval -- special option */
885     ts->TelKeepAliveInterval =
886     GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
887    
888     /* Max number of broadcast commad history */
889     ts->MaxBroadcatHistory =
890     GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
891    
892     /* Local echo for non-telnet */
893     ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
894    
895     /* "new-line (transmit)" option for non-telnet -- special option */
896     GetPrivateProfileString(Section, "TCPCRSend", "",
897     Temp, sizeof(Temp), FName);
898     if (_stricmp(Temp, "CR") == 0)
899     ts->TCPCRSend = IdCR;
900     else if (_stricmp(Temp, "CRLF") == 0)
901     ts->TCPCRSend = IdCRLF;
902     else
903     ts->TCPCRSend = 0; // disabled
904    
905     /* Use text (background) color for "white (black)"
906     --- special option */
907     ts->ColorFlag |=
908     CF_USETEXTCOLOR * GetOnOff(Section, "UseTextColor", FName, FALSE);
909    
910     /* Title format -- special option */
911     ts->TitleFormat =
912     GetPrivateProfileInt(Section, "TitleFormat", 5, FName);
913    
914     /* VT Compatible Tab -- special option */
915     ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
916    
917     /* VT Font space --- special option */
918     GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
919     Temp, sizeof(Temp), FName);
920     GetNthNum(Temp, 1, &ts->FontDX);
921     GetNthNum(Temp, 2, &ts->FontDW);
922     GetNthNum(Temp, 3, &ts->FontDY);
923     GetNthNum(Temp, 4, &ts->FontDH);
924     if (ts->FontDX < 0)
925     ts->FontDX = 0;
926     if (ts->FontDW < 0)
927     ts->FontDW = 0;
928     ts->FontDW = ts->FontDW + ts->FontDX;
929     if (ts->FontDY < 0)
930     ts->FontDY = 0;
931     if (ts->FontDH < 0)
932     ts->FontDH = 0;
933     ts->FontDH = ts->FontDH + ts->FontDY;
934    
935     // VT-print scaling factors (pixels per inch) --- special option
936     GetPrivateProfileString(Section, "VTPPI", "0,0",
937     Temp, sizeof(Temp), FName);
938     GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
939     GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
940    
941     // TEK-print scaling factors (pixels per inch) --- special option
942     GetPrivateProfileString(Section, "TEKPPI", "0,0",
943     Temp, sizeof(Temp), FName);
944     GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
945     GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
946    
947     // Show "Window" menu -- special option
948     ts->MenuFlag |=
949     MF_SHOWWINMENU * GetOnOff(Section, "WindowMenu", FName, TRUE);
950    
951     /* XMODEM log -- special option */
952     ts->LogFlag |= LOG_X * GetOnOff(Section, "XmodemLog", FName, FALSE);
953    
954     /* Auto ZMODEM activation -- special option */
955     ts->FTFlag |= FT_ZAUTO * GetOnOff(Section, "ZmodemAuto", FName, FALSE);
956    
957     /* ZMODEM data subpacket length for sending -- special */
958     ts->ZmodemDataLen =
959     GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
960     /* ZMODEM window size for sending -- special */
961     ts->ZmodemWinSize =
962     GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
963    
964     /* ZMODEM ESCCTL flag -- special option */
965     ts->FTFlag |=
966     FT_ZESCCTL * GetOnOff(Section, "ZmodemEscCtl", FName, FALSE);
967    
968     /* ZMODEM log -- special option */
969     ts->LogFlag |= LOG_Z * GetOnOff(Section, "ZmodemLog", FName, FALSE);
970    
971     /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
972     GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
973     ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
974    
975     #ifndef NO_COPYLINE_FIX
976    
977     /* Enable continued-line copy -- special option */
978     ts->EnableContinuedLineCopy =
979     GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
980     #endif /* NO_COPYLINE_FIX */
981    
982     ts->DisablePasteMouseRButton =
983     GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE);
984    
985     // added DisablePasteMouseMButton (2008.3.2 maya)
986     ts->DisablePasteMouseMButton =
987     GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE);
988    
989     // added ConfirmPasteMouseRButton (2007.3.17 maya)
990     ts->ConfirmPasteMouseRButton =
991     GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE);
992    
993     // added ConfirmChangePaste (2008.2.3 yutaka)
994     ts->ConfirmChangePaste =
995     GetOnOff(Section, "ConfirmChangePaste", FName, FALSE);
996    
997     // added SelectOnlyByLButton (2007.11.20 maya)
998     ts->SelectOnlyByLButton =
999     GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1000    
1001     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1002     ts->DisableAcceleratorSendBreak =
1003     GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1004    
1005     // WinSock connecting timeout value (2007.1.11 yutaka)
1006     ts->ConnectingTimeout =
1007     GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1008    
1009     // mouse cursor
1010     GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1011     Temp, sizeof(Temp), FName);
1012     strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1013     _TRUNCATE);
1014    
1015     // Translucent window
1016     ts->AlphaBlend =
1017     GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1018     ts->AlphaBlend = max(0, ts->AlphaBlend);
1019     ts->AlphaBlend = min(255, ts->AlphaBlend);
1020    
1021     // Cygwin install path
1022     GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1023     Temp, sizeof(Temp), FName);
1024     strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1025     _TRUNCATE);
1026    
1027     // Viewlog Editor path
1028     GetPrivateProfileString(Section, "ViewlogEditor ", "notepad.exe",
1029     Temp, sizeof(Temp), FName);
1030     strncpy_s(ts->ViewlogEditor, sizeof(ts->ViewlogEditor), Temp,
1031     _TRUNCATE);
1032    
1033     // Locale for UTF-8
1034     GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1035     Temp, sizeof(Temp), FName);
1036     strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1037    
1038     // CodePage
1039     ts->CodePage =
1040     GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1041     FName);
1042    
1043     // UI language message file
1044     GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1045     Temp, sizeof(Temp), FName);
1046     {
1047     char CurDir[MAX_PATH];
1048    
1049     // �t���p�X�������O������������������������������
1050     strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1051    
1052     GetCurrentDirectory(sizeof(CurDir), CurDir);
1053     SetCurrentDirectory(ts->HomeDir);
1054     _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1055     SetCurrentDirectory(CurDir);
1056     }
1057    
1058     // Broadcast Command History (2007.3.3 maya)
1059     ts->BroadcastCommandHistory =
1060     GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1061    
1062     // 337: 2007/03/20 Accept Broadcast
1063     ts->AcceptBroadcast =
1064     GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1065    
1066     // Confirm send a file when drag and drop (2007.12.28 maya)
1067     ts->ConfirmFileDragAndDrop =
1068     GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1069    
1070     // Translate mouse wheel to cursor key when application cursor mode
1071     ts->TranslateWheelToCursor =
1072     GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1073    
1074     // Display "New Connection" dialog on startup (2008.1.18 maya)
1075     ts->HostDialogOnStartup =
1076     GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1077    
1078     // Mouse event tracking
1079     ts->MouseEventTracking =
1080     GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1081    
1082     // Maximized bug tweak
1083     ts->MaximizedBugTweak =
1084     GetOnOff(Section, "MaximizedBugTweak", FName, TRUE);
1085    
1086     #ifdef USE_NORMAL_BGCOLOR
1087     // UseNormalBGColor
1088     ts->UseNormalBGColor =
1089     GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1090     // 2006/03/11 by 337
1091     if (ts->UseNormalBGColor) {
1092     ts->VTBoldColor[1] =
1093     ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1094     }
1095     #endif
1096     }
1097    
1098     void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
1099     {
1100     int i;
1101     char Temp[MAXPATHLEN];
1102     char buf[20];
1103    
1104     /* version */
1105     WritePrivateProfileString(Section, "Version", "2.3", FName);
1106    
1107     /* Language */
1108     if (ts->Language == IdJapanese)
1109     strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
1110     else if (ts->Language == IdRussian)
1111     strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
1112     else
1113     strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
1114     WritePrivateProfileString(Section, "Language", Temp, FName);
1115    
1116     /* Port type */
1117     if (ts->PortType == IdSerial)
1118     strncpy_s(Temp, sizeof(Temp), "serial", _TRUNCATE);
1119     else /* IdFile -> IdTCPIP */
1120     strncpy_s(Temp, sizeof(Temp), "tcpip", _TRUNCATE);
1121    
1122     WritePrivateProfileString(Section, "Port", Temp, FName);
1123    
1124     /* Save win position */
1125     if (ts->SaveVTWinPos) {
1126     /* VT win position */
1127     WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
1128     }
1129    
1130     /* VT terminal size */
1131     WriteInt2(Section, "TerminalSize", FName,
1132     ts->TerminalWidth, ts->TerminalHeight);
1133    
1134     /* Terminal size = Window size */
1135     WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
1136    
1137     /* Auto window resize flag */
1138     WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
1139    
1140     /* CR Receive */
1141     if (ts->CRReceive == IdCRLF) {
1142     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1143     }
1144     else if (ts->CRReceive == IdLF) {
1145     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
1146     }
1147     else {
1148     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1149     }
1150     WritePrivateProfileString(Section, "CRReceive", Temp, FName);
1151    
1152     /* CR Send */
1153     if (ts->CRSend == IdCRLF)
1154     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1155     else
1156     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1157     WritePrivateProfileString(Section, "CRSend", Temp, FName);
1158    
1159     /* Local echo */
1160     WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
1161    
1162     /* Answerback */
1163     if ((ts->FTFlag & FT_BPAUTO) == 0) {
1164     Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
1165     sizeof(Temp) - 1, TRUE);
1166     WritePrivateProfileString(Section, "Answerback", Temp, FName);
1167     }
1168    
1169     /* Kanji Code (receive) */
1170     switch (ts->KanjiCode) {
1171     case IdEUC:
1172     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1173     break;
1174     case IdJIS:
1175     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1176     break;
1177     case IdUTF8:
1178     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1179     break;
1180     case IdUTF8m:
1181     strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
1182     break;
1183     default:
1184     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1185     }
1186     WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
1187    
1188     /* Katakana (receive) */
1189     if (ts->JIS7Katakana == 1)
1190     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1191     else
1192     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1193    
1194     WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
1195    
1196     /* Kanji Code (transmit) */
1197     switch (ts->KanjiCodeSend) {
1198     case IdEUC:
1199     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1200     break;
1201     case IdJIS:
1202     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1203     break;
1204     case IdUTF8:
1205     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1206     break;
1207     default:
1208     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1209     }
1210     WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
1211    
1212     /* Katakana (transmit) */
1213     if (ts->JIS7KatakanaSend == 1)
1214     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1215     else
1216     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1217    
1218     WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
1219    
1220     /* KanjiIn */
1221     if (ts->KanjiIn == IdKanjiInA)
1222     strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
1223     else
1224     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1225    
1226     WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
1227    
1228     /* KanjiOut */
1229     switch (ts->KanjiOut) {
1230     case IdKanjiOutB:
1231     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1232     break;
1233     case IdKanjiOutH:
1234     strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
1235     break;
1236     default:
1237     strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
1238     }
1239     WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
1240    
1241     // new configuration
1242     WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
1243    
1244     WriteOnOff(Section, "DisablePasteMouseRButton", FName,
1245     ts->DisablePasteMouseRButton);
1246    
1247     // added DisablePasteMouseMButton (2008.3.2 maya)
1248     WriteOnOff(Section, "DisablePasteMouseMButton", FName,
1249     ts->DisablePasteMouseMButton);
1250    
1251     // added ConfirmPasteMouseRButton (2007.3.17 maya)
1252     WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
1253     ts->ConfirmPasteMouseRButton);
1254    
1255     // added ConfirmChangePaste
1256     WriteOnOff(Section, "ConfirmChangePaste", FName,
1257     ts->ConfirmChangePaste);
1258    
1259     // added SelectOnlyByLButton (2007.11.20 maya)
1260     WriteOnOff(Section, "SelectOnlyByLButton", FName,
1261     ts->SelectOnlyByLButton);
1262     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1263     WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
1264     ts->DisableAcceleratorSendBreak);
1265     WriteOnOff(Section, "EnableContinuedLineCopy", FName,
1266     ts->EnableContinuedLineCopy);
1267     WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
1268     FName);
1269     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
1270     WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
1271     WritePrivateProfileString(Section, "CygwinDirectory",
1272     ts->CygwinDirectory, FName);
1273     WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
1274     FName);
1275     WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
1276     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
1277     WritePrivateProfileString(Section, "CodePage", Temp, FName);
1278    
1279     // ANSI color(2004.9.5 yutaka)
1280     Temp[0] = '\0';
1281     for (i = 0; i < 15; i++) {
1282     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
1283     i,
1284     GetRValue(ts->ANSIColor[i]),
1285     GetGValue(ts->ANSIColor[i]),
1286     GetBValue(ts->ANSIColor[i])
1287     );
1288     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1289     }
1290     i = 15;
1291     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
1292     i,
1293     GetRValue(ts->ANSIColor[i]),
1294     GetGValue(ts->ANSIColor[i]),
1295     GetBValue(ts->ANSIColor[i])
1296     );
1297     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1298     WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
1299    
1300     /* AutoWinChange VT<->TEK */
1301     WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
1302    
1303     /* Terminal ID */
1304     id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
1305     WritePrivateProfileString(Section, "TerminalID", Temp, FName);
1306    
1307     /* Russian character set (host) */
1308     id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
1309     WritePrivateProfileString(Section, "RussHost", Temp, FName);
1310    
1311     /* Russian character set (client) */
1312     id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
1313     WritePrivateProfileString(Section, "RussClient", Temp, FName);
1314    
1315     /* Title text */
1316     WritePrivateProfileString(Section, "Title", ts->Title, FName);
1317    
1318     /* Cursor shape */
1319     switch (ts->CursorShape) {
1320     case IdVCur:
1321     strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
1322     break;
1323     case IdHCur:
1324     strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
1325     break;
1326     default:
1327     strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
1328     }
1329     WritePrivateProfileString(Section, "CursorShape", Temp, FName);
1330    
1331     /* Hide title */
1332     WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
1333    
1334     /* Popup menu */
1335     WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
1336    
1337     /* PC-Style bold color mapping */
1338     WriteOnOff(Section, "PcBoldColor", FName,
1339     (WORD) (ts->ColorFlag & CF_PCBOLD16));
1340    
1341     /* aixterm 16 colors mode */
1342     WriteOnOff(Section, "Aixterm16Color", FName,
1343     (WORD) (ts->ColorFlag & CF_AIXTERM16));
1344    
1345     /* xterm 256 colors mode */
1346     WriteOnOff(Section, "Xterm256Color", FName,
1347     (WORD) (ts->ColorFlag & CF_XTERM256));
1348    
1349     /* Enable scroll buffer */
1350     WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
1351    
1352     /* Scroll buffer size */
1353     WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
1354    
1355     /* VT Color */
1356     for (i = 0; i <= 1; i++) {
1357     ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
1358     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
1359     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
1360     }
1361     WriteInt6(Section, "VTColor", FName,
1362     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1363     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1364    
1365     /* VT bold color */
1366     for (i = 0; i <= 1; i++) {
1367     ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
1368     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
1369     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
1370     }
1371     WriteInt6(Section, "VTBoldColor", FName,
1372     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1373     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1374    
1375     /* VT blink color */
1376     for (i = 0; i <= 1; i++) {
1377     ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
1378     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
1379     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
1380     }
1381     WriteInt6(Section, "VTBlinkColor", FName,
1382     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1383     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1384    
1385     /* start - ishizaki */
1386     WriteOnOff(Section, "EnableClickableUrl", FName,
1387     ts->EnableClickableUrl);
1388    
1389     /* URL color */
1390     for (i = 0; i <= 1; i++) {
1391     ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
1392     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
1393     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
1394     }
1395     WriteInt6(Section, "URLColor", FName,
1396     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1397     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1398     /* end - ishizaki */
1399    
1400     /* TEK Color */
1401     for (i = 0; i <= 1; i++) {
1402     ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
1403     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
1404     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
1405     }
1406     WriteInt6(Section, "TEKColor", FName,
1407     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1408     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1409    
1410     /* TEK color emulation */
1411     WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
1412    
1413     /* VT Font */
1414     WriteFont(Section, "VTFont", FName,
1415     ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
1416     ts->VTFontCharSet);
1417    
1418     /* Enable bold font flag */
1419     WriteOnOff(Section, "EnableBold", FName, ts->EnableBold);
1420    
1421     /* Russian character set (font) */
1422     id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
1423     WritePrivateProfileString(Section, "RussFont", Temp, FName);
1424    
1425     /* TEK Font */
1426     WriteFont(Section, "TEKFont", FName,
1427     ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
1428     ts->TEKFontCharSet);
1429    
1430     /* BS key */
1431     if (ts->BSKey == IdDEL)
1432     strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
1433     else
1434     strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
1435     WritePrivateProfileString(Section, "BSKey", Temp, FName);
1436    
1437     /* Delete key */
1438     WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
1439    
1440     /* Meta key */
1441     WriteOnOff(Section, "MetaKey", FName, ts->MetaKey);
1442    
1443     /* Application Keypad */
1444     WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
1445    
1446     /* Application Cursor */
1447     WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
1448    
1449     /* Russian keyboard type */
1450     id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
1451     WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
1452    
1453     /* Serial port ID */
1454     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
1455     WritePrivateProfileString(Section, "ComPort", Temp, FName);
1456    
1457     /* Baud rate */
1458     id2str(BaudList, ts->Baud, IdBaud9600, Temp, sizeof(Temp));
1459     WritePrivateProfileString(Section, "BaudRate", Temp, FName);
1460    
1461     /* Parity */
1462     switch (ts->Parity) {
1463     case IdParityEven:
1464     strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
1465     break;
1466     case IdParityOdd:
1467     strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
1468     break;
1469     default:
1470     strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1471     }
1472     WritePrivateProfileString(Section, "Parity", Temp, FName);
1473    
1474     /* Data bit */
1475     if (ts->DataBit == IdDataBit7)
1476     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1477     else
1478     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1479    
1480     WritePrivateProfileString(Section, "DataBit", Temp, FName);
1481    
1482     /* Stop bit */
1483     if (ts->StopBit == IdStopBit2)
1484     strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
1485     else
1486     strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
1487    
1488     WritePrivateProfileString(Section, "StopBit", Temp, FName);
1489    
1490     /* Flow control */
1491     switch (ts->Flow) {
1492     case IdFlowX:
1493     strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
1494     break;
1495     case IdFlowHard:
1496     strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
1497     break;
1498     default:
1499     strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1500     }
1501     WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
1502    
1503     /* Delay per character */
1504     WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
1505    
1506     /* Delay per line */
1507     WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
1508    
1509     /* Telnet flag */
1510     WriteOnOff(Section, "Telnet", FName, ts->Telnet);
1511    
1512     /* Telnet terminal type */
1513     WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
1514    
1515     /* TCP port num for non-telnet */
1516     WriteUint(Section, "TCPPort", FName, ts->TCPPort);
1517    
1518     /* Auto close flag */
1519     WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
1520    
1521     /* History list */
1522     WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
1523    
1524     /* File transfer binary flag */
1525     WriteOnOff(Section, "TransBin", FName, ts->TransBin);
1526    
1527     /* Log append */
1528     WriteOnOff(Section, "LogAppend", FName, ts->Append);
1529    
1530     /* File transfer binary flag */
1531     WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
1532    
1533     /* Log with timestamp (2006.7.23 maya) */
1534     WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
1535    
1536     /* Log without transfer dialog */
1537     WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
1538    
1539     /* Default Log file name (2006.8.28 maya) */
1540     WritePrivateProfileString(Section, "LogDefaultName",
1541     ts->LogDefaultName, FName);
1542    
1543     /* Default Log file path (2007.5.30 maya) */
1544     WritePrivateProfileString(Section, "LogDefaultPath",
1545     ts->LogDefaultPath, FName);
1546    
1547     /* Auto start logging (2007.5.31 maya) */
1548     WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
1549    
1550     /* XMODEM option */
1551     switch (ts->XmodemOpt) {
1552     case XoptCRC:
1553     strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
1554     break;
1555     case Xopt1K:
1556     strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
1557     break;
1558     default:
1559     strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);
1560     }
1561     WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);
1562    
1563     /* XMODEM binary flag */
1564     WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);
1565    
1566     /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1567     WritePrivateProfileString(Section, "XmodemRcvCommand", ts->XModemRcvCommand, FName);
1568    
1569     /* Default directory for file transfer */
1570     WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);
1571    
1572     /* filter on file send (2007.6.5 maya) */
1573     WritePrivateProfileString(Section, "FileSendFilter",
1574     ts->FileSendFilter, FName);
1575    
1576     /*------------------------------------------------------------------*/
1577     /* 8 bit control code flag -- special option */
1578     WriteOnOff(Section, "Accept8BitCtrl", FName,
1579     (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));
1580    
1581     /* Wrong sequence flag -- special option */
1582     WriteOnOff(Section, "AllowWrongSequence", FName,
1583     (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));
1584    
1585     /* Auto file renaming --- special option */
1586     WriteOnOff(Section, "AutoFileRename", FName,
1587     (WORD) (ts->FTFlag & FT_RENAME));
1588    
1589     /* Auto text copy --- special option */
1590     WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);
1591    
1592     /* Back wrap -- special option */
1593     WriteOnOff(Section, "BackWrap", FName,
1594     (WORD) (ts->TermFlag & TF_BACKWRAP));
1595    
1596     /* Beep type -- special option */
1597     WriteOnOff(Section, "Beep", FName, ts->Beep);
1598    
1599     /* Beep on connection & disconnection -- special option */
1600     WriteOnOff(Section, "BeepOnConnect", FName,
1601     (WORD) (ts->PortFlag & PF_BEEPONCONNECT));
1602    
1603     /* Auto B-Plus activation -- special option */
1604     WriteOnOff(Section, "BPAuto", FName, (WORD) (ts->FTFlag & FT_BPAUTO));
1605    
1606     /* B-Plus ESCCTL flag -- special option */
1607     WriteOnOff(Section, "BPEscCtl", FName,
1608     (WORD) (ts->FTFlag & FT_BPESCCTL));
1609    
1610     /* B-Plus log -- special option */
1611     WriteOnOff(Section, "BPLog", FName, (WORD) (ts->LogFlag & LOG_BP));
1612    
1613     /* Clear serial port buffer when port opening -- special option */
1614     WriteOnOff(Section, "ClearComBuffOnOpen", FName, ts->ClearComBuffOnOpen);
1615    
1616     /* Confirm disconnection -- special option */
1617     WriteOnOff(Section, "ConfirmDisconnect", FName,
1618     (WORD) (ts->PortFlag & PF_CONFIRMDISCONN));
1619    
1620     /* Ctrl code in Kanji -- special option */
1621     WriteOnOff(Section, "CtrlInKanji", FName,
1622     (WORD) (ts->TermFlag & TF_CTRLINKANJI));
1623    
1624     /* Debug flag -- special option */
1625     WriteOnOff(Section, "Debug", FName, ts->Debug);
1626    
1627     /* Delimiter list -- special option */
1628     Str2Hex(ts->DelimList, Temp, strlen(ts->DelimList),
1629     sizeof(Temp) - 1, TRUE);
1630     WritePrivateProfileString(Section, "DelimList", Temp, FName);
1631    
1632     /* regard DBCS characters as delimiters -- special option */
1633     WriteOnOff(Section, "DelimDBCS", FName, ts->DelimDBCS);
1634    
1635     // Enable popup menu -- special option
1636     if ((ts->MenuFlag & MF_NOPOPUP) == 0)
1637     WriteOnOff(Section, "EnablePopupMenu", FName, 1);
1638     else
1639     WriteOnOff(Section, "EnablePopupMenu", FName, 0);
1640    
1641     // Enable "Show menu" -- special option
1642     if ((ts->MenuFlag & MF_NOSHOWMENU) == 0)
1643     WriteOnOff(Section, "EnableShowMenu", FName, 1);
1644     else
1645     WriteOnOff(Section, "EnableShowMenu", FName, 0);
1646    
1647     /* Enable the status line -- special option */
1648     WriteOnOff(Section, "EnableStatusLine", FName,
1649     (WORD) (ts->TermFlag & TF_ENABLESLINE));
1650    
1651     /* IME Flag -- special option */
1652     WriteOnOff(Section, "IME", FName, ts->UseIME);
1653    
1654     /* IME-inline Flag -- special option */
1655     WriteOnOff(Section, "IMEInline", FName, ts->IMEInline);
1656    
1657     /* Kermit log -- special option */
1658     WriteOnOff(Section, "KmtLog", FName, (WORD) (ts->LogFlag & LOG_KMT));
1659    
1660     // Enable language selection -- special option
1661     if ((ts->MenuFlag & MF_NOLANGUAGE) == 0)
1662     WriteOnOff(Section, "LanguageSelection", FName, 1);
1663     else
1664     WriteOnOff(Section, "LanguageSelection", FName, 0);
1665    
1666     /* Maximum scroll buffer size -- special option */
1667     WriteInt(Section, "MaxBuffSize", FName, ts->ScrollBuffMax);
1668    
1669     /* Max com port number -- special option */
1670     WriteInt(Section, "MaxComPort", FName, ts->MaxComPort);
1671    
1672     /* Non-blinking cursor -- special option */
1673     WriteOnOff(Section, "NonblinkingCursor", FName, ts->NonblinkingCursor);
1674    
1675     WriteOnOff(Section, "KillFocusCursor", FName, ts->KillFocusCursor);
1676    
1677     /* Delay for pass-thru printing activation */
1678     /* -- special option */
1679     WriteUint(Section, "PassThruDelay", FName, ts->PassThruDelay);
1680    
1681     /* Printer port for pass-thru printing */
1682     /* -- special option */
1683     WritePrivateProfileString(Section, "PassThruPort", ts->PrnDev, FName);
1684    
1685     /* Printer Font --- special option */
1686     WriteFont(Section, "PrnFont", FName,
1687     ts->PrnFont, ts->PrnFontSize.x, ts->PrnFontSize.y,
1688     ts->PrnFontCharSet);
1689    
1690     // Page margins (left, right, top, bottom) for printing
1691     // -- special option
1692     WriteInt4(Section, "PrnMargin", FName,
1693     ts->PrnMargin[0], ts->PrnMargin[1],
1694     ts->PrnMargin[2], ts->PrnMargin[3]);
1695    
1696     /* Quick-VAN log -- special option */
1697     WriteOnOff(Section, "QVLog", FName, (WORD) (ts->LogFlag & LOG_QV));
1698    
1699     /* Quick-VAN window size -- special */
1700     WriteInt(Section, "QVWinSize", FName, ts->QVWinSize);
1701    
1702     /* Russian character set (print) -- special option */
1703     id2str(RussList, ts->RussPrint, IdWindows, Temp, sizeof(Temp));
1704     WritePrivateProfileString(Section, "RussPrint", Temp, FName);
1705    
1706     /* Scroll threshold -- special option */
1707     WriteInt(Section, "ScrollThreshold", FName, ts->ScrollThreshold);
1708    
1709     WriteInt(Section, "MouseWheelScrollLine", FName, ts->MouseWheelScrollLine);
1710    
1711     // Select on activate -- special option
1712     WriteOnOff(Section, "SelectOnActivate", FName, ts->SelOnActive);
1713    
1714     /* Send 8bit control sequence -- special option */
1715     WriteOnOff(Section, "Send8BitCtrl", FName, ts->Send8BitCtrl);
1716    
1717     /* Startup macro -- special option */
1718     WritePrivateProfileString(Section, "StartupMacro", ts->MacroFN, FName);
1719    
1720     /* TEK GIN Mouse keycode -- special option */
1721     WriteInt(Section, "TEKGINMouseCode", FName, ts->GINMouseCode);
1722    
1723     /* Telnet Auto Detect -- special option */
1724     WriteOnOff(Section, "TelAutoDetect", FName, ts->TelAutoDetect);
1725    
1726     /* Telnet binary flag -- special option */
1727     WriteOnOff(Section, "TelBin", FName, ts->TelBin);
1728    
1729     /* Telnet Echo flag -- special option */
1730     WriteOnOff(Section, "TelEcho", FName, ts->TelEcho);
1731    
1732     /* Telnet log -- special option */
1733     WriteOnOff(Section, "TelLog", FName, (WORD) (ts->LogFlag & LOG_TEL));
1734    
1735     /* TCP port num for telnet -- special option */
1736     WriteUint(Section, "TelPort", FName, ts->TelPort);
1737    
1738     /* Telnet keep-alive packet(NOP command) interval -- special option */
1739     WriteUint(Section, "TelKeepAliveInterval", FName,
1740     ts->TelKeepAliveInterval);
1741    
1742     /* Max number of broadcast commad history */
1743     WriteUint(Section, "MaxBroadcatHistory", FName,
1744     ts->MaxBroadcatHistory);
1745    
1746     /* Local echo for non-telnet */
1747     WriteOnOff(Section, "TCPLocalEcho", FName, ts->TCPLocalEcho);
1748    
1749     /* "new-line (transmit)" option for non-telnet -- special option */
1750     if (ts->TCPCRSend == IdCRLF)
1751     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1752     else if (ts->TCPCRSend == IdCR)
1753     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1754     else
1755     Temp[0] = 0;
1756     WritePrivateProfileString(Section, "TCPCRSend", Temp, FName);
1757    
1758     /* Use text (background) color for "white (black)"
1759     --- special option */
1760     WriteOnOff(Section, "UseTextColor", FName,
1761     (WORD) (ts->ColorFlag & CF_USETEXTCOLOR));
1762    
1763     /* Title format -- special option */
1764     WriteUint(Section, "TitleFormat", FName, ts->TitleFormat);
1765    
1766     /* VT Compatible Tab -- special option */
1767     WriteOnOff(Section, "VTCompatTab", FName, ts->VTCompatTab);
1768    
1769     /* VT Font space --- special option */
1770     WriteInt4(Section, "VTFontSpace", FName,
1771     ts->FontDX, ts->FontDW - ts->FontDX,
1772     ts->FontDY, ts->FontDH - ts->FontDY);
1773    
1774     // VT-print scaling factors (pixels per inch) --- special option
1775     WriteInt2(Section, "VTPPI", FName, ts->VTPPI.x, ts->VTPPI.y);
1776    
1777     // TEK-print scaling factors (pixels per inch) --- special option
1778     WriteInt2(Section, "TEKPPI", FName, ts->TEKPPI.x, ts->TEKPPI.y);
1779    
1780     // Show "Window" menu -- special option
1781     WriteOnOff(Section, "WindowMenu", FName,
1782     (WORD) (ts->MenuFlag & MF_SHOWWINMENU));
1783    
1784     /* XMODEM log -- special option */
1785     WriteOnOff(Section, "XmodemLog", FName, (WORD) (ts->LogFlag & LOG_X));
1786    
1787     /* Auto ZMODEM activation -- special option */
1788     WriteOnOff(Section, "ZmodemAuto", FName,
1789     (WORD) (ts->FTFlag & FT_ZAUTO));
1790    
1791     /* ZMODEM data subpacket length for sending -- special */
1792     WriteInt(Section, "ZmodemDataLen", FName, ts->ZmodemDataLen);
1793     /* ZMODEM window size for sending -- special */
1794     WriteInt(Section, "ZmodemWinSize", FName, ts->ZmodemWinSize);
1795    
1796     /* ZMODEM ESCCTL flag -- special option */
1797     WriteOnOff(Section, "ZmodemEscCtl", FName,
1798     (WORD) (ts->FTFlag & FT_ZESCCTL));
1799    
1800     /* ZMODEM log -- special option */
1801     WriteOnOff(Section, "ZmodemLog", FName, (WORD) (ts->LogFlag & LOG_Z));
1802    
1803     /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1804     WritePrivateProfileString(Section, "ZmodemRcvCommand", ts->ZModemRcvCommand, FName);
1805    
1806     /* update file */
1807     WritePrivateProfileString(NULL, NULL, NULL, FName);
1808    
1809     // Eterm lookfeel alphablend (2005.4.24 yutaka)
1810     #define ETERM_SECTION "BG"
1811     WriteOnOff(ETERM_SECTION, "BGEnable", FName,
1812     ts->EtermLookfeel.BGEnable);
1813     WriteOnOff(ETERM_SECTION, "BGUseAlphaBlendAPI", FName,
1814     ts->EtermLookfeel.BGUseAlphaBlendAPI);
1815     WritePrivateProfileString(ETERM_SECTION, "BGSPIPath",
1816     ts->EtermLookfeel.BGSPIPath, FName);
1817     WriteOnOff(ETERM_SECTION, "BGFastSizeMove", FName,
1818     ts->EtermLookfeel.BGFastSizeMove);
1819     WriteOnOff(ETERM_SECTION, "BGFlickerlessMove", FName,
1820     ts->EtermLookfeel.BGNoCopyBits);
1821     WriteOnOff(ETERM_SECTION, "BGNoFrame", FName,
1822     ts->EtermLookfeel.BGNoFrame);
1823     WritePrivateProfileString(ETERM_SECTION, "BGThemeFile",
1824     ts->EtermLookfeel.BGThemeFile, FName);
1825    
1826     #ifdef USE_NORMAL_BGCOLOR
1827     // UseNormalBGColor
1828     WriteOnOff(Section, "UseNormalBGColor", FName, ts->UseNormalBGColor);
1829     #endif
1830    
1831     // UI language message file
1832     WritePrivateProfileString(Section, "UILanguageFile",
1833     ts->UILanguageFile_ini, FName);
1834    
1835     // Broadcast Command History (2007.3.3 maya)
1836     WriteOnOff(Section, "BroadcastCommandHistory", FName,
1837     ts->BroadcastCommandHistory);
1838    
1839     // 337: 2007/03/20 Accept Broadcast
1840     WriteOnOff(Section, "AcceptBroadcast", FName, ts->AcceptBroadcast);
1841    
1842     // Confirm send a file when drag and drop (2007.12.28 maya)
1843     WriteOnOff(Section, "ConfirmFileDragAndDrop", FName,
1844     ts->ConfirmFileDragAndDrop);
1845    
1846     // Translate mouse wheel to cursor key when application cursor mode
1847     WriteOnOff(Section, "TranslateWheelToCursor", FName,
1848     ts->TranslateWheelToCursor);
1849    
1850     // Display "New Connection" dialog on startup (2008.1.18 maya)
1851     WriteOnOff(Section, "HostDialogOnStartup", FName,
1852     ts->HostDialogOnStartup);
1853    
1854     // Mouse event tracking
1855     WriteOnOff(Section, "MouseEventTracking", FName,
1856     ts->MouseEventTracking);
1857    
1858     // Maximized bug tweak
1859     WriteOnOff(Section, "MaximizedBugTweak", FName,
1860     ts->MaximizedBugTweak);
1861     }
1862    
1863     #define VTEditor "VT editor keypad"
1864     #define VTNumeric "VT numeric keypad"
1865     #define VTFunction "VT function keys"
1866     #define XFunction "X function keys"
1867     #define ShortCut "Shortcut keys"
1868    
1869     void GetInt(PKeyMap KeyMap, int KeyId, PCHAR Sect, PCHAR Key, PCHAR FName)
1870     {
1871     char Temp[11];
1872     WORD Num;
1873    
1874     GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
1875     if (Temp[0] == 0)
1876     Num = 0xFFFF;
1877     else if (_stricmp(Temp, "off") == 0)
1878     Num = 0xFFFF;
1879     else if (sscanf(Temp, "%d", &Num) != 1)
1880     Num = 0xFFFF;
1881    
1882     KeyMap->Map[KeyId - 1] = Num;
1883     }
1884    
1885     void FAR PASCAL ReadKeyboardCnf
1886     (PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning) {
1887     int i, j, Ptr;
1888     char EntName[7];
1889     char TempStr[221];
1890     char KStr[201];
1891    
1892     // clear key map
1893     for (i = 0; i <= IdKeyMax - 1; i++)
1894     KeyMap->Map[i] = 0xFFFF;
1895     for (i = 0; i <= NumOfUserKey - 1; i++) {
1896     KeyMap->UserKeyPtr[i] = 0;
1897     KeyMap->UserKeyLen[i] = 0;
1898     }
1899    
1900     // VT editor keypad
1901     GetInt(KeyMap, IdUp, VTEditor, "Up", FName);
1902    
1903     GetInt(KeyMap, IdDown, VTEditor, "Down", FName);
1904    
1905     GetInt(KeyMap, IdRight, VTEditor, "Right", FName);
1906    
1907     GetInt(KeyMap, IdLeft, VTEditor, "Left", FName);
1908    
1909     GetInt(KeyMap, IdFind, VTEditor, "Find", FName);
1910    
1911     GetInt(KeyMap, IdInsert, VTEditor, "Insert", FName);
1912    
1913     GetInt(KeyMap, IdRemove, VTEditor, "Remove", FName);
1914    
1915     GetInt(KeyMap, IdSelect, VTEditor, "Select", FName);
1916    
1917     GetInt(KeyMap, IdPrev, VTEditor, "Prev", FName);
1918    
1919     GetInt(KeyMap, IdNext, VTEditor, "Next", FName);
1920    
1921     // VT numeric keypad
1922     GetInt(KeyMap, Id0, VTNumeric, "Num0", FName);
1923    
1924     GetInt(KeyMap, Id1, VTNumeric, "Num1", FName);
1925    
1926     GetInt(KeyMap, Id2, VTNumeric, "Num2", FName);
1927    
1928     GetInt(KeyMap, Id3, VTNumeric, "Num3", FName);
1929    
1930     GetInt(KeyMap, Id4, VTNumeric, "Num4", FName);
1931    
1932     GetInt(KeyMap, Id5, VTNumeric, "Num5", FName);
1933    
1934     GetInt(KeyMap, Id6, VTNumeric, "Num6", FName);
1935    
1936     GetInt(KeyMap, Id7, VTNumeric, "Num7", FName);
1937    
1938     GetInt(KeyMap, Id8, VTNumeric, "Num8", FName);
1939    
1940     GetInt(KeyMap, Id9, VTNumeric, "Num9", FName);
1941    
1942     GetInt(KeyMap, IdMinus, VTNumeric, "NumMinus", FName);
1943    
1944     GetInt(KeyMap, IdComma, VTNumeric, "NumComma", FName);
1945    
1946     GetInt(KeyMap, IdPeriod, VTNumeric, "NumPeriod", FName);
1947    
1948     GetInt(KeyMap, IdEnter, VTNumeric, "NumEnter", FName);
1949    
1950     GetInt(KeyMap, IdSlash, VTNumeric, "NumSlash", FName);
1951    
1952     GetInt(KeyMap, IdAsterisk, VTNumeric, "NumAsterisk", FName);
1953    
1954     GetInt(KeyMap, IdPlus, VTNumeric, "NumPlus", FName);
1955    
1956     GetInt(KeyMap, IdPF1, VTNumeric, "PF1", FName);
1957    
1958     GetInt(KeyMap, IdPF2, VTNumeric, "PF2", FName);
1959    
1960     GetInt(KeyMap, IdPF3, VTNumeric, "PF3", FName);
1961    
1962     GetInt(KeyMap, IdPF4, VTNumeric, "PF4", FName);
1963    
1964     // VT function keys
1965     GetInt(KeyMap, IdScrollLock, VTFunction, "ScrollLock", FName);
1966    
1967     GetInt(KeyMap, IdHold, VTFunction, "Hold", FName);
1968    
1969     GetInt(KeyMap, IdPrint, VTFunction, "Print", FName);
1970    
1971     GetInt(KeyMap, IdBreak, VTFunction, "Break", FName);
1972    
1973     GetInt(KeyMap, IdF6, VTFunction, "F6", FName);
1974    
1975     GetInt(KeyMap, IdF7, VTFunction, "F7", FName);
1976    
1977     GetInt(KeyMap, IdF8, VTFunction, "F8", FName);
1978    
1979     GetInt(KeyMap, IdF9, VTFunction, "F9", FName);
1980    
1981     GetInt(KeyMap, IdF10, VTFunction, "F10", FName);
1982    
1983     GetInt(KeyMap, IdF11, VTFunction, "F11", FName);
1984    
1985     GetInt(KeyMap, IdF12, VTFunction, "F12", FName);
1986    
1987     GetInt(KeyMap, IdF13, VTFunction, "F13", FName);
1988    
1989     GetInt(KeyMap, IdF14, VTFunction, "F14", FName);
1990    
1991     GetInt(KeyMap, IdHelp, VTFunction, "Help", FName);
1992    
1993     GetInt(KeyMap, IdDo, VTFunction, "Do", FName);
1994    
1995     GetInt(KeyMap, IdF17, VTFunction, "F17", FName);
1996    
1997     GetInt(KeyMap, IdF18, VTFunction, "F18", FName);
1998    
1999     GetInt(KeyMap, IdF19, VTFunction, "F19", FName);
2000    
2001     GetInt(KeyMap, IdF20, VTFunction, "F20", FName);
2002    
2003     // UDK
2004     GetInt(KeyMap, IdUDK6, VTFunction, "UDK6", FName);
2005    
2006     GetInt(KeyMap, IdUDK7, VTFunction, "UDK7", FName);
2007    
2008     GetInt(KeyMap, IdUDK8, VTFunction, "UDK8", FName);
2009    
2010     GetInt(KeyMap, IdUDK9, VTFunction, "UDK9", FName);
2011    
2012     GetInt(KeyMap, IdUDK10, VTFunction, "UDK10", FName);
2013    
2014     GetInt(KeyMap, IdUDK11, VTFunction, "UDK11", FName);
2015    
2016     GetInt(KeyMap, IdUDK12, VTFunction, "UDK12", FName);
2017    
2018     GetInt(KeyMap, IdUDK13, VTFunction, "UDK13", FName);
2019    
2020     GetInt(KeyMap, IdUDK14, VTFunction, "UDK14", FName);
2021    
2022     GetInt(KeyMap, IdUDK15, VTFunction, "UDK15", FName);
2023    
2024     GetInt(KeyMap, IdUDK16, VTFunction, "UDK16", FName);
2025    
2026     GetInt(KeyMap, IdUDK17, VTFunction, "UDK17", FName);
2027    
2028     GetInt(KeyMap, IdUDK18, VTFunction, "UDK18", FName);
2029    
2030     GetInt(KeyMap, IdUDK19, VTFunction, "UDK19", FName);
2031    
2032     GetInt(KeyMap, IdUDK20, VTFunction, "UDK20", FName);
2033    
2034     // XTERM function keys
2035     GetInt(KeyMap, IdXF1, XFunction, "XF1", FName);
2036    
2037     GetInt(KeyMap, IdXF2, XFunction, "XF2", FName);
2038    
2039     GetInt(KeyMap, IdXF3, XFunction, "XF3", FName);
2040    
2041     GetInt(KeyMap, IdXF4, XFunction, "XF4", FName);
2042    
2043     GetInt(KeyMap, IdXF5, XFunction, "XF5", FName);
2044    
2045     // accelerator keys
2046     GetInt(KeyMap, IdCmdEditCopy, ShortCut, "EditCopy", FName);
2047    
2048     GetInt(KeyMap, IdCmdEditPaste, ShortCut, "EditPaste", FName);
2049    
2050     GetInt(KeyMap, IdCmdEditPasteCR, ShortCut, "EditPasteCR", FName);
2051    
2052     GetInt(KeyMap, IdCmdEditCLS, ShortCut, "EditCLS", FName);
2053    
2054     GetInt(KeyMap, IdCmdEditCLB, ShortCut, "EditCLB", FName);
2055    
2056     GetInt(KeyMap, IdCmdCtrlOpenTEK, ShortCut, "ControlOpenTEK", FName);
2057    
2058     GetInt(KeyMap, IdCmdCtrlCloseTEK, ShortCut, "ControlCloseTEK", FName);
2059    
2060     GetInt(KeyMap, IdCmdLineUp, ShortCut, "LineUp", FName);
2061    
2062     GetInt(KeyMap, IdCmdLineDown, ShortCut, "LineDown", FName);
2063    
2064     GetInt(KeyMap, IdCmdPageUp, ShortCut, "PageUp", FName);
2065    
2066     GetInt(KeyMap, IdCmdPageDown, ShortCut, "PageDown", FName);
2067    
2068     GetInt(KeyMap, IdCmdBuffTop, ShortCut, "BuffTop", FName);
2069    
2070     GetInt(KeyMap, IdCmdBuffBottom, ShortCut, "BuffBottom", FName);
2071    
2072     GetInt(KeyMap, IdCmdNextWin, ShortCut, "NextWin", FName);
2073    
2074     GetInt(KeyMap, IdCmdPrevWin, ShortCut, "PrevWin", FName);
2075    
2076     GetInt(KeyMap, IdCmdLocalEcho, ShortCut, "LocalEcho", FName);
2077    
2078     /* user keys */
2079    
2080     Ptr = 0;
2081    
2082     strncpy_s(EntName, sizeof(EntName), "User", _TRUNCATE);
2083     i = IdUser1;
2084     do {
2085     uint2str(i - IdUser1 + 1, &EntName[4], sizeof(EntName) - 4, 2);
2086     GetPrivateProfileString("User keys", EntName, "",
2087     TempStr, sizeof(TempStr), FName);
2088     if (strlen(TempStr) > 0) {
2089     /* scan code */
2090     GetNthString(TempStr, 1, sizeof(KStr), KStr);
2091     if (_stricmp(KStr, "off") == 0)
2092     KeyMap->Map[i - 1] = 0xFFFF;
2093     else {
2094     GetNthNum(TempStr, 1, &j);
2095     KeyMap->Map[i - 1] = (WORD) j;
2096     }
2097     /* conversion flag */
2098     GetNthNum(TempStr, 2, &j);
2099     KeyMap->UserKeyType[i - IdUser1] = (BYTE) j;
2100     /* key string */
2101     /* GetNthString(TempStr,3,sizeof(KStr),KStr); */
2102     KeyMap->UserKeyPtr[i - IdUser1] = Ptr;
2103     /* KeyMap->UserKeyLen[i-IdUser1] =
2104     Hex2Str(KStr,&(KeyMap->UserKeyStr[Ptr]),KeyStrMax-Ptr+1);
2105     */
2106     GetNthString(TempStr, 3, KeyStrMax - Ptr + 1,
2107     &(KeyMap->UserKeyStr[Ptr]));
2108     KeyMap->UserKeyLen[i - IdUser1] =
2109     strlen(&(KeyMap->UserKeyStr[Ptr]));
2110     Ptr = Ptr + KeyMap->UserKeyLen[i - IdUser1];
2111     }
2112    
2113     i++;
2114     }
2115     while ((i <= IdKeyMax) && (strlen(TempStr) > 0) && (Ptr <= KeyStrMax));
2116    
2117     for (j = 1; j <= IdKeyMax - 1; j++)
2118     if (KeyMap->Map[j] != 0xFFFF)
2119     for (i = 0; i <= j - 1; i++)
2120     if (KeyMap->Map[i] == KeyMap->Map[j]) {
2121     if (ShowWarning) {
2122     _snprintf_s(TempStr, sizeof(TempStr), _TRUNCATE,
2123     "Keycode %d is used more than once",
2124     KeyMap->Map[j]);
2125     MessageBox(0, TempStr,
2126     "Tera Term: Error in keyboard setup file",
2127     MB_ICONEXCLAMATION);
2128     }
2129     KeyMap->Map[i] = 0xFFFF;
2130     }
2131     }
2132    
2133     void FAR PASCAL CopySerialList(PCHAR IniSrc, PCHAR IniDest, PCHAR section,
2134     PCHAR key)
2135     {
2136     int i;
2137     char EntName[10];
2138     char TempHost[HostNameMaxLength + 1];
2139    
2140     if (_stricmp(IniSrc, IniDest) == 0)
2141     return;
2142    
2143     WritePrivateProfileString(section, NULL, NULL, IniDest);
2144     strncpy_s(EntName, sizeof(EntName) - 2, key, _TRUNCATE);
2145    
2146     i = 1;
2147     do {
2148     uint2str(i, &EntName[strlen(key)],
2149     sizeof(EntName) - strlen(key), 2);
2150    
2151     /* Get one hostname from file IniSrc */
2152     GetPrivateProfileString(section, EntName, "",
2153     TempHost, sizeof(TempHost), IniSrc);
2154     /* Copy it to the file IniDest */
2155     if (strlen(TempHost) > 0)
2156     WritePrivateProfileString(section, EntName, TempHost, IniDest);
2157     i++;
2158     }
2159     while ((i <= 99) && (strlen(TempHost) > 0));
2160    
2161     /* update file */
2162     WritePrivateProfileString(NULL, NULL, NULL, IniDest);
2163     }
2164    
2165     void FAR PASCAL AddValueToList(PCHAR FName, PCHAR Host, PCHAR section,
2166     PCHAR key)
2167     {
2168     HANDLE MemH;
2169     PCHAR MemP;
2170     char EntName[10];
2171     int i, j, Len;
2172     BOOL Update;
2173    
2174     if ((FName[0] == 0) || (Host[0] == 0))
2175     return;
2176     MemH = GlobalAlloc(GHND, (HostNameMaxLength + 1) * 99);
2177     if (MemH == NULL)
2178     return;
2179     MemP = GlobalLock(MemH);
2180     if (MemP != NULL) {
2181     strncpy_s(MemP, (HostNameMaxLength + 1) * 99, Host, _TRUNCATE);
2182     j = strlen(Host) + 1;
2183     strncpy_s(EntName, sizeof(EntName), key, _TRUNCATE);
2184     i = 1;
2185     Update = TRUE;
2186     do {
2187     uint2str(i, &EntName[strlen(key)],
2188     sizeof(EntName) - strlen(key), 2);
2189    
2190     /* Get a hostname */
2191     GetPrivateProfileString(section, EntName, "",
2192     &MemP[j], HostNameMaxLength + 1,
2193     FName);
2194     Len = strlen(&MemP[j]);
2195     if (_stricmp(&MemP[j], Host) == 0) {
2196     if (i == 1)
2197     Update = FALSE;
2198     }
2199     else
2200     j = j + Len + 1;
2201     i++;
2202     } while ((i <= 99) && (Len != 0) && Update);
2203    
2204     if (Update) {
2205     WritePrivateProfileString(section, NULL, NULL, FName);
2206    
2207     j = 0;
2208     i = 1;
2209     do {
2210     uint2str(i, &EntName[strlen(key)],
2211     sizeof(EntName) - strlen(key), 2);
2212    
2213     if (MemP[j] != 0)
2214     WritePrivateProfileString(section, EntName, &MemP[j],
2215     FName);
2216     j = j + strlen(&MemP[j]) + 1;
2217     i++;
2218     } while ((i <= 99) && (MemP[j] != 0));
2219     /* update file */
2220     WritePrivateProfileString(NULL, NULL, NULL, FName);
2221     }
2222     GlobalUnlock(MemH);
2223     }
2224     GlobalFree(MemH);
2225     }
2226    
2227     /* copy hostlist from source IniFile to dest IniFile */
2228     void FAR PASCAL CopyHostList(PCHAR IniSrc, PCHAR IniDest)
2229     {
2230     CopySerialList(IniSrc, IniDest, "Hosts", "Host");
2231     }
2232    
2233     void FAR PASCAL AddHostToList(PCHAR FName, PCHAR Host)
2234     {
2235     AddValueToList(FName, Host, "Hosts", "Host");
2236     }
2237    
2238     BOOL NextParam(PCHAR Param, int *i, PCHAR Temp, int Size)
2239     {
2240     int j;
2241     char c;
2242     BOOL Quoted;
2243    
2244     if ((unsigned int) (*i) >= strlen(Param))
2245     return FALSE;
2246     j = 0;
2247    
2248     while (Param[*i] == ' ')
2249     (*i)++;
2250    
2251     Quoted = FALSE;
2252     c = Param[*i];
2253     (*i)++;
2254     while ((c != 0) && (Quoted || (c != ' ')) &&
2255     (Quoted || (c != ';')) && (j < Size - 1)) {
2256     if (c == '"')
2257     Quoted = !Quoted;
2258     Temp[j] = c;
2259     j++;
2260     c = Param[*i];
2261     (*i)++;
2262     }
2263     if (!Quoted && (c == ';'))
2264     (*i)--;
2265    
2266     Temp[j] = 0;
2267     return (strlen(Temp) > 0);
2268     }
2269    
2270     void Dequote(PCHAR Source, PCHAR Dest)
2271     {
2272     int i, j;
2273     char q, c;
2274    
2275     Dest[0] = 0;
2276     if (Source[0] == 0)
2277     return;
2278     i = 0;
2279     /* quoting char */
2280     q = Source[i];
2281     /* only '"' is used as quoting char */
2282     if (q != '"')
2283     q = 0;
2284     else
2285     i++;
2286    
2287     c = Source[i];
2288     i++;
2289     j = 0;
2290     while ((c != 0) && (c != q)) {
2291     Dest[j] = c;
2292     j++;
2293     c = Source[i];
2294     i++;
2295     }
2296    
2297     Dest[j] = 0;
2298     }
2299    
2300    
2301     #ifndef NO_INET6
2302     static void ParseHostName(char *HostStr, WORD * port)
2303     {
2304     /*
2305     * hostname.domain.com
2306     * hostname.domain.com:23
2307     * [3ffe:1234:1234::1] IPv6 raw address
2308     * [3ffe:1234:1234::1]:23 IPv6 raw address and port#
2309     * telnet://hostname.domain.com/
2310     * telnet://hostname.domain.com:23/
2311     * telnet://[3ffe:1234:1234::1]/
2312     * telnet://[3ffe:1234:1234::1]:23/
2313     * tn3270:// .... /
2314