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 2482 - (hide annotations) (download) (as text)
Tue Apr 22 02:49:02 2008 UTC (15 years, 11 months ago) by maya
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 82043 byte(s)
Terminal 設定の New-lin Transmit が空白になる問題を修正した。[Ttssh2-devel 930]
共有メモリの ts とやりとりする部分を #if 0 した。

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