OSDN Git Service

Add UTF-8 to UTF-16 API bridge.
[ffftp/ffftp.git] / hostman.c
1 /*=============================================================================\r
2 *\r
3 *                                                               \83z\83X\83g\88ê\97\97\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define STRICT\r
31 #include <windows.h>\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 #include <string.h>\r
35 #include <commctrl.h>\r
36 #include <windowsx.h>\r
37 \r
38 #include "common.h"\r
39 #include "resource.h"\r
40 \r
41 #include <htmlhelp.h>\r
42 #include "helpid.h"\r
43 \r
44 \r
45 /*===== \83v\83\8d\83g\83^\83C\83v =====*/\r
46 \r
47 static BOOL CALLBACK SelectHostProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
48 static LRESULT CALLBACK HostListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
49 static HOSTLISTDATA *GetNextNode(HOSTLISTDATA *Pos);\r
50 static int GetNodeLevel(int Num);\r
51 static int GetNodeLevelByData(HOSTLISTDATA *Data);\r
52 static int GetNodeNumByData(HOSTLISTDATA *Data);\r
53 static HOSTLISTDATA *GetNodeByNum(int Num);\r
54 static int SetNodeLevelAll(void);\r
55 static int UpdateHostToList(int Num, HOSTDATA *Set);\r
56 static int DelHostFromList(int Num);\r
57 static int DeleteChildAndNext(HOSTLISTDATA *Pos);\r
58 static void SendAllHostNames(HWND hWnd, int Cur);\r
59 static int IsNodeGroup(int Num);\r
60 static int DispHostSetDlg(HWND hDlg);\r
61 static BOOL CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
62 static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
63 static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
64 static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
65 static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
66 \r
67 /*===== \8aO\95\94\8eQ\8fÆ =====*/\r
68 \r
69 extern HWND hHelpWin;\r
70 \r
71 /* \90Ý\92è\92l */\r
72 extern char UserMailAdrs[USER_MAIL_LEN+1];\r
73 extern HFONT ListFont;\r
74 extern char DefaultLocalPath[FMAX_PATH+1];\r
75 extern int ConnectAndSet;\r
76 extern SIZE HostDlgSize;\r
77 \r
78 /*===== \83\8d\81[\83J\83\8b\82È\83\8f\81[\83N =====*/\r
79 \r
80 static int Hosts = 0;                                           /* \83z\83X\83g\90\94 */\r
81 static int ConnectingHost;                                      /* \90Ú\91±\92\86\82Ì\83z\83X\83g */\r
82 static int CurrentHost;                                         /* \83J\81[\83\\83\8b\88Ê\92u\82Ì\83z\83X\83g */\r
83 static HOSTLISTDATA *HostListTop = NULL;        /* \83z\83X\83g\88ê\97\97\83f\81[\83^ */\r
84 static HOSTDATA TmpHost;                                        /* \83z\83X\83g\8fî\95ñ\83R\83s\81[\97p */\r
85 static int Apply;                                                       /* \83v\83\8d\83p\83e\83B\83V\81[\83g\82ÅOK\82ð\89\9f\82µ\82½\83t\83\89\83O */\r
86 static WNDPROC HostListProcPtr;\r
87 \r
88 \r
89 \r
90 /*----- \83z\83X\83g\88ê\97\97\83E\83C\83\93\83h\83E --------------------------------------------------\r
91 *\r
92 *       Parameter\r
93 *               int Type : \83_\83C\83A\83\8d\83O\82Ì\83^\83C\83v (DLG_TYPE_xxx)\r
94 *\r
95 *       Return Value\r
96 *               \83X\83e\81[\83^\83X (YES=\8eÀ\8ds/NO=\8eæ\8fÁ)\r
97 *----------------------------------------------------------------------------*/\r
98 \r
99 int SelectHost(int Type)\r
100 {\r
101         int Sts;\r
102         int Dlg;\r
103 \r
104         Dlg = hostconnect_dlg;\r
105         if((ConnectAndSet == YES) || (Type == DLG_TYPE_SET))\r
106                 Dlg = hostlist_dlg;\r
107 \r
108         Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(Dlg), GetMainHwnd(), SelectHostProc);\r
109 \r
110         /* \83z\83X\83g\90Ý\92è\82ð\95Û\91¶ */\r
111         SetNodeLevelAll();\r
112         SaveRegistory();\r
113 \r
114         return(Sts);\r
115 }\r
116 \r
117 \r
118 /*----- \83z\83X\83g\88ê\97\97\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N ------------------------------------\r
119 *\r
120 *       Parameter\r
121 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
122 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
123 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
124 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
125 *\r
126 *       Return Value\r
127 *               BOOL TRUE/FALSE\r
128 *----------------------------------------------------------------------------*/\r
129 \r
130 static BOOL CALLBACK SelectHostProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
131 {\r
132         static DIALOGSIZE DlgSize = {\r
133                 { HOST_NEW, HOST_FOLDER, HOST_SET, HOST_COPY, HOST_DEL, HOST_DOWN, HOST_UP, IDHELP, HOST_SIZEGRIP, -1 },\r
134                 { IDOK, IDCANCEL, HOST_SIZEGRIP, -1 },\r
135                 { HOST_LIST, -1 },\r
136                 { 0, 0 },\r
137                 { 0, 0 }\r
138         };\r
139         static HIMAGELIST hImage;\r
140         HTREEITEM hItem;\r
141         TV_ITEM Item;\r
142         int Level1;\r
143         int Level2;\r
144         HOSTLISTDATA *Data1;\r
145         HOSTLISTDATA *Data2;\r
146         NM_TREEVIEW *tView;\r
147         HTREEITEM tViewPos;\r
148         TV_HITTESTINFO HitInfo;\r
149 \r
150         switch (message)\r
151         {\r
152                 case WM_INITDIALOG :\r
153                         /* TreeView\82Å\82Ì\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\82Â\82©\82Ü\82¦\82é\82½\82ß */\r
154                         HostListProcPtr = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, HOST_LIST), GWL_WNDPROC, (LONG)HostListWndProc);\r
155 \r
156 \r
157 //              SetClassLong(hDlg, GCL_HICON, (LONG)LoadIcon(GetFtpInst(), MAKEINTRESOURCE(ffftp)));\r
158 \r
159                         if(AskConnecting() == YES)\r
160                         {\r
161                                 /* \90Ú\91±\92\86\82Í\81u\95Ï\8dX\81v\82Ì\82Ý\8b\96\89 */\r
162                                 EnableWindow(GetDlgItem(hDlg, HOST_NEW), FALSE);\r
163                                 EnableWindow(GetDlgItem(hDlg, HOST_FOLDER), FALSE);\r
164                                 EnableWindow(GetDlgItem(hDlg, HOST_COPY), FALSE);\r
165                                 EnableWindow(GetDlgItem(hDlg, HOST_DEL), FALSE);\r
166                                 EnableWindow(GetDlgItem(hDlg, HOST_DOWN), FALSE);\r
167                                 EnableWindow(GetDlgItem(hDlg, HOST_UP), FALSE);\r
168                         }\r
169                         if(ListFont != NULL)\r
170                                 SendDlgItemMessage(hDlg, HOST_LIST, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
171                         hImage = ImageList_LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(hlist_bmp), 16, 8, RGB(255,0,0));\r
172                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)hImage);\r
173                         CurrentHost = 0;\r
174                         if(ConnectingHost >= 0)\r
175                                 CurrentHost = ConnectingHost;\r
176                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
177                         DlgSizeInit(hDlg, &DlgSize, &HostDlgSize);\r
178                     return(TRUE);\r
179 \r
180                 case WM_COMMAND :\r
181                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
182                         {\r
183                                 case IDOK :\r
184                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
185                                         {\r
186                                                 Item.hItem = hItem;\r
187                                                 Item.mask = TVIF_PARAM;\r
188                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
189                                                 CurrentHost = Item.lParam;\r
190                                                 ConnectingHost = CurrentHost;\r
191                                                 AskDlgSize(hDlg, &DlgSize, &HostDlgSize);\r
192                                                 ImageList_Destroy(hImage);\r
193                                                 EndDialog(hDlg, YES);\r
194                                                 break;\r
195                                         }\r
196                                         /* \82±\82±\82Ébreak\82Í\82È\82¢ */\r
197 \r
198                                 case IDCANCEL :\r
199                                         AskDlgSize(hDlg, &DlgSize, &HostDlgSize);\r
200                                         ImageList_Destroy(hImage);\r
201                                         EndDialog(hDlg, NO);\r
202                                         break;\r
203 \r
204                                 case HOST_NEW :\r
205                                         CopyDefaultHost(&TmpHost);\r
206                                         if(DispHostSetDlg(hDlg) == YES)\r
207                                         {\r
208                                                 if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
209                                                 {\r
210                                                         Item.hItem = hItem;\r
211                                                         Item.mask = TVIF_PARAM;\r
212                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
213 \r
214                                                         TmpHost.Level = GetNodeLevel(Item.lParam);\r
215                                                         Level1 = Item.lParam + 1;\r
216                                                         CurrentHost = Level1;\r
217                                                 }\r
218                                                 else\r
219                                                 {\r
220                                                         TmpHost.Level = 0;\r
221                                                         Level1 = -1;\r
222                                                         CurrentHost = Hosts;\r
223                                                 }\r
224                                                 AddHostToList(&TmpHost, Level1, SET_LEVEL_SAME);\r
225                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
226                                         }\r
227                                         break;\r
228 \r
229                                 case HOST_FOLDER :\r
230                                         CopyDefaultHost(&TmpHost);\r
231                                         if(InputDialogBox(group_dlg, hDlg, NULL, TmpHost.HostName, HOST_NAME_LEN+1, &Level1, IDH_HELP_TOPIC_0000001) == YES)\r
232                                         {\r
233                                                 if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
234                                                 {\r
235                                                         Item.hItem = hItem;\r
236                                                         Item.mask = TVIF_PARAM;\r
237                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
238 \r
239                                                         TmpHost.Level = GetNodeLevel(Item.lParam) | SET_LEVEL_GROUP ;\r
240                                                         Level1 = Item.lParam + 1;\r
241                                                         CurrentHost = Level1;\r
242                                                 }\r
243                                                 else\r
244                                                 {\r
245                                                         TmpHost.Level = 0 | SET_LEVEL_GROUP;\r
246                                                         Level1 = -1;\r
247                                                         CurrentHost = Hosts;\r
248                                                 }\r
249                                                 AddHostToList(&TmpHost, Level1, SET_LEVEL_SAME);\r
250                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
251                                         }\r
252                                         break;\r
253 \r
254                                 case HOST_SET :\r
255                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
256                                         {\r
257                                                 Item.hItem = hItem;\r
258                                                 Item.mask = TVIF_PARAM;\r
259                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
260                                                 CurrentHost = Item.lParam;\r
261 \r
262                                                 CopyHostFromList(CurrentHost, &TmpHost);\r
263                                                 Level1 = IsNodeGroup(CurrentHost);\r
264                                                 if(((Level1 == NO) && (DispHostSetDlg(hDlg) == YES)) ||\r
265                                                    ((Level1 == YES) && (InputDialogBox(group_dlg, hDlg, NULL, TmpHost.HostName, HOST_NAME_LEN+1, &Level1, IDH_HELP_TOPIC_0000001) == YES)))\r
266                                                 {\r
267                                                         UpdateHostToList(CurrentHost, &TmpHost);\r
268                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
269                                                 }\r
270                                         }\r
271                                         break;\r
272 \r
273                                 case HOST_COPY :\r
274                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
275                                         {\r
276                                                 Item.hItem = hItem;\r
277                                                 Item.mask = TVIF_PARAM;\r
278                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
279                                                 CurrentHost = Item.lParam;\r
280 \r
281                                                 CopyHostFromList(CurrentHost, &TmpHost);\r
282                                                 strcpy(TmpHost.BookMark, "\0");\r
283                                                 CurrentHost++;\r
284                                                 AddHostToList(&TmpHost, CurrentHost, SET_LEVEL_SAME);\r
285                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
286                                         }\r
287                                         break;\r
288 \r
289                                 case HOST_DEL :\r
290                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
291                                         {\r
292                                                 Item.hItem = hItem;\r
293                                                 Item.mask = TVIF_PARAM;\r
294                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
295                                                 CurrentHost = Item.lParam;\r
296                                                 Level1 = IsNodeGroup(CurrentHost);\r
297 \r
298                                                 if(((Level1 == YES) && (DialogBox(GetFtpInst(), MAKEINTRESOURCE(groupdel_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)) ||\r
299                                                    ((Level1 == NO) && (DialogBox(GetFtpInst(), MAKEINTRESOURCE(hostdel_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)))\r
300                                                 {\r
301                                                         DelHostFromList(CurrentHost);\r
302                                                         if(CurrentHost >= Hosts)\r
303                                                                 CurrentHost = max1(0, Hosts-1);\r
304                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
305                                                 }\r
306                                         }\r
307                                         break;\r
308 \r
309                                 case HOST_UP :\r
310                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
311                                         {\r
312                                                 Item.hItem = hItem;\r
313                                                 Item.mask = TVIF_PARAM;\r
314                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
315                                                 CurrentHost = Item.lParam;\r
316 \r
317                                                 if(CurrentHost > 0)\r
318                                                 {\r
319                                                         Data1 = HostListTop;\r
320                                                         for(Level1 = CurrentHost; Level1 > 0; Level1--)\r
321                                                                 Data1 = GetNextNode(Data1);\r
322                                                         Level1 = GetNodeLevel(CurrentHost);\r
323 \r
324                                                         Data2 = HostListTop;\r
325                                                         for(Level2 = CurrentHost-1; Level2 > 0; Level2--)\r
326                                                                 Data2 = GetNextNode(Data2);\r
327                                                         Level2 = GetNodeLevel(CurrentHost-1);\r
328 \r
329                                                         if((Level1 == Level2) && (Data2->Set.Level & SET_LEVEL_GROUP))\r
330                                                         {\r
331                                                                 //Data2\82Ìchild\82Ö\r
332                                                                 if(Data1->Next != NULL)\r
333                                                                         Data1->Next->Prev = Data1->Prev;\r
334                                                                 if(Data1->Prev != NULL)\r
335                                                                         Data1->Prev->Next = Data1->Next;\r
336                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
337                                                                         Data1->Parent->Child = Data1->Next;\r
338                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
339                                                                         HostListTop = Data1->Next;\r
340 \r
341                                                                 Data1->Next = Data2->Child;\r
342                                                                 Data1->Prev = NULL;\r
343                                                                 Data1->Parent = Data2;\r
344                                                                 Data2->Child = Data1;\r
345                                                         }\r
346                                                         else if(Level1 < Level2)\r
347                                                         {\r
348                                                                 //Data1\82ÌPrev\82ÌChild\82ÌNext\82Ì\96\96\94ö\82Ö\r
349                                                                 Data2 = Data1->Prev->Child;\r
350                                                                 while(Data2->Next != NULL)\r
351                                                                         Data2 = Data2->Next;\r
352 \r
353                                                                 if(Data1->Next != NULL)\r
354                                                                         Data1->Next->Prev = Data1->Prev;\r
355                                                                 if(Data1->Prev != NULL)\r
356                                                                         Data1->Prev->Next = Data1->Next;\r
357                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
358                                                                         Data1->Parent->Child = Data1->Next;\r
359                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
360                                                                         HostListTop = Data1->Next;\r
361 \r
362                                                                 Data2->Next = Data1;\r
363                                                                 Data1->Prev = Data2;\r
364                                                                 Data1->Next = NULL;\r
365                                                                 Data1->Parent = Data2->Parent;\r
366                                                         }\r
367                                                         else\r
368                                                         {\r
369                                                                 //Data2\82Ìprev\82Ö\r
370                                                                 if(Data1->Next != NULL)\r
371                                                                         Data1->Next->Prev = Data1->Prev;\r
372                                                                 if(Data1->Prev != NULL)\r
373                                                                         Data1->Prev->Next = Data1->Next;\r
374                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
375                                                                         Data1->Parent->Child = Data1->Next;\r
376                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
377                                                                         HostListTop = Data1->Next;\r
378 \r
379                                                                 if(Data2->Prev != NULL)\r
380                                                                         Data2->Prev->Next = Data1;\r
381                                                                 Data1->Prev = Data2->Prev;\r
382                                                                 Data2->Prev = Data1;\r
383                                                                 Data1->Next = Data2;\r
384                                                                 Data1->Parent = Data2->Parent;\r
385 \r
386                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data2))\r
387                                                                         Data1->Parent->Child = Data1;\r
388                                                                 if((Data1->Parent == NULL) && (HostListTop == Data2))\r
389                                                                         HostListTop = Data1;\r
390                                                         }\r
391 \r
392                                                         CurrentHost = GetNodeNumByData(Data1);\r
393                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
394                                                 }\r
395                                         }\r
396                                         break;\r
397 \r
398                                 case HOST_DOWN :\r
399                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
400                                         {\r
401                                                 Item.hItem = hItem;\r
402                                                 Item.mask = TVIF_PARAM;\r
403                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
404                                                 CurrentHost = Item.lParam;\r
405 \r
406                                                 Data1 = HostListTop;\r
407                                                 for(Level1 = CurrentHost; Level1 > 0; Level1--)\r
408                                                         Data1 = GetNextNode(Data1);\r
409                                                 Level1 = GetNodeLevel(CurrentHost);\r
410 \r
411                                                 Data2 = NULL;\r
412                                                 Level2 = SET_LEVEL_SAME;\r
413                                                 if(CurrentHost < Hosts-1)\r
414                                                 {\r
415                                                         Data2 = HostListTop;\r
416                                                         for(Level2 = CurrentHost+1; Level2 > 0; Level2--)\r
417                                                                 Data2 = GetNextNode(Data2);\r
418                                                         Level2 = GetNodeLevel(CurrentHost+1);\r
419 \r
420                                                         if(Level1 < Level2)\r
421                                                         {\r
422                                                                 if(Data1->Next != NULL)\r
423                                                                 {\r
424                                                                         //Data2 = Data1\82ÌNext\r
425                                                                         Data2 = Data1->Next;\r
426                                                                         Level2 = GetNodeLevelByData(Data2);\r
427                                                                 }\r
428                                                                 else if(Data1->Parent != NULL)\r
429                                                                 {\r
430                                                                         Data2 = NULL;\r
431                                                                         Level2 = SET_LEVEL_SAME;\r
432                                                                 }\r
433                                                         }\r
434                                                 }\r
435 \r
436                                                 if(((Data2 == NULL) && (Level1 > 0)) ||\r
437                                                    (Level1 > Level2))\r
438                                                 {\r
439                                                         //Data1\82ÌParent\82ÌNext\82Ö\r
440                                                         Data2 = Data1->Parent;\r
441 \r
442                                                         if(Data1->Next != NULL)\r
443                                                                 Data1->Next->Prev = Data1->Prev;\r
444                                                         if(Data1->Prev != NULL)\r
445                                                                 Data1->Prev->Next = Data1->Next;\r
446                                                         if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
447                                                                 Data1->Parent->Child = Data1->Next;\r
448                                                         if((Data1->Parent == NULL) && (HostListTop == Data1))\r
449                                                                 HostListTop = Data1->Next;\r
450 \r
451                                                         if(Data2->Next != NULL)\r
452                                                                 Data2->Next->Prev = Data1;\r
453                                                         Data1->Next = Data2->Next;\r
454                                                         Data2->Next = Data1;\r
455                                                         Data1->Prev = Data2;\r
456                                                         Data1->Parent = Data2->Parent;\r
457 \r
458                                                         if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
459                                                                 Data1->Parent->Child = Data2;\r
460                                                         if((Data1->Parent == NULL) && (HostListTop == Data1))\r
461                                                                 HostListTop = Data2;\r
462                                                 }\r
463                                                 else if(Level1 == Level2)\r
464                                                 {\r
465                                                         if(Data2->Set.Level & SET_LEVEL_GROUP)\r
466                                                         {\r
467                                                                 //Data2\82ÌChild\82Ö\r
468                                                                 if(Data1->Next != NULL)\r
469                                                                         Data1->Next->Prev = Data1->Prev;\r
470                                                                 if(Data1->Prev != NULL)\r
471                                                                         Data1->Prev->Next = Data1->Next;\r
472                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
473                                                                         Data1->Parent->Child = Data1->Next;\r
474                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
475                                                                         HostListTop = Data1->Next;\r
476 \r
477                                                                 if(Data2->Child != NULL)\r
478                                                                         Data2->Child->Prev = Data1;\r
479                                                                 Data1->Next = Data2->Child;\r
480                                                                 Data1->Prev = NULL;\r
481                                                                 Data1->Parent = Data2;\r
482                                                                 Data2->Child = Data1;\r
483                                                         }\r
484                                                         else\r
485                                                         {\r
486                                                                 //Data2\82ÌNext\82Ö\r
487                                                                 if(Data1->Next != NULL)\r
488                                                                         Data1->Next->Prev = Data1->Prev;\r
489                                                                 if(Data1->Prev != NULL)\r
490                                                                         Data1->Prev->Next = Data1->Next;\r
491                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
492                                                                         Data1->Parent->Child = Data1->Next;\r
493                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
494                                                                         HostListTop = Data1->Next;\r
495 \r
496                                                                 if(Data2->Next != NULL)\r
497                                                                         Data2->Next->Prev = Data1;\r
498                                                                 Data1->Next = Data2->Next;\r
499                                                                 Data2->Next = Data1;\r
500                                                                 Data1->Prev = Data2;\r
501                                                                 Data1->Parent = Data2->Parent;\r
502 \r
503                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
504                                                                         Data1->Parent->Child = Data2;\r
505                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
506                                                                         HostListTop = Data2;\r
507                                                         }\r
508                                                 }\r
509 \r
510                                                 CurrentHost = GetNodeNumByData(Data1);\r
511                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
512                                         }\r
513                                         break;\r
514 \r
515                                 case HOST_LIST :\r
516                                         if(HIWORD(wParam) == LBN_DBLCLK)\r
517                                                 PostMessage(hDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0);\r
518                                         break;\r
519 \r
520                                 case IDHELP :\r
521                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000027);\r
522                                         break;\r
523                         }\r
524                         SetFocus(GetDlgItem(hDlg, HOST_LIST));\r
525                         return(TRUE);\r
526 \r
527                 case WM_SIZING :\r
528                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
529                     return(TRUE);\r
530 \r
531                 case WM_SELECT_HOST :\r
532                         HitInfo.pt.x = LOWORD(lParam);\r
533                         HitInfo.pt.y = HIWORD(lParam);\r
534                         HitInfo.flags = TVHT_ONITEM;\r
535                         hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0);\r
536                         HitInfo.hItem = hItem;\r
537                         if((HTREEITEM)SendMessage(GetDlgItem(hDlg, HOST_LIST), TVM_HITTEST, 0, (LPARAM)&HitInfo) == hItem)\r
538                         {\r
539                                 if(IsWindowEnabled(GetDlgItem(hDlg, IDOK)) == TRUE)\r
540                                         PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);\r
541                         }\r
542                         break;\r
543 \r
544                 case WM_NOTIFY:\r
545                         tView = (NM_TREEVIEW FAR *)lParam;\r
546                         switch(tView->hdr.idFrom)\r
547                         {\r
548                                 case HOST_LIST :\r
549                                         tViewPos = tView->itemNew.hItem;\r
550                                         hItem = tView->itemNew.hItem;\r
551                                         switch(tView->hdr.code)\r
552                                         {\r
553                                                 case TVN_SELCHANGED :\r
554                                                         /* \83t\83H\83\8b\83_\82ª\91I\82Î\82ê\82½\82Æ\82«\82Í\90Ú\91±\81A\83R\83s\81[\83{\83^\83\93\82Í\8bÖ\8e~ */\r
555                                                         Item.hItem = hItem;\r
556                                                         Item.mask = TVIF_PARAM;\r
557                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
558                                                         if(IsNodeGroup(Item.lParam) == YES)\r
559                                                         {\r
560                                                                 EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);\r
561                                                                 EnableWindow(GetDlgItem(hDlg, HOST_COPY), FALSE);\r
562                                                         }\r
563                                                         else\r
564                                                         {\r
565                                                                 EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);\r
566                                                                 if(AskConnecting() == NO)\r
567                                                                         EnableWindow(GetDlgItem(hDlg, HOST_COPY), TRUE);\r
568                                                         }\r
569                                                         break;\r
570                                         }\r
571                                         break;\r
572                         }\r
573                         break;\r
574         }\r
575     return(FALSE);\r
576 }\r
577 \r
578 \r
579 /*----- \83z\83X\83g\88ê\97\97TreeView\82Ì\83\81\83b\83Z\81[\83W\8f\88\97\9d ------------------------------------\r
580 *\r
581 *       Parameter\r
582 *               HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
583 *               UINT message  : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
584 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
585 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
586 *\r
587 *       Return Value\r
588 *               \83\81\83b\83Z\81[\83W\82É\91Î\89\9e\82·\82é\96ß\82è\92l\r
589 *----------------------------------------------------------------------------*/\r
590 \r
591 static LRESULT CALLBACK HostListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
592 {\r
593         switch (message)\r
594         {\r
595                 case WM_LBUTTONDBLCLK :\r
596                         PostMessage(GetParent(hWnd), WM_SELECT_HOST, 0, lParam);\r
597                         break;\r
598         }\r
599         return(CallWindowProc(HostListProcPtr, hWnd, message, wParam, lParam));\r
600 }\r
601 \r
602 \r
603 /*----- \8e\9f\82Ì\90Ý\92è\94Ô\8d\86\82Ì\83m\81[\83h\82ð\95Ô\82· --------------------------------------------\r
604 *\r
605 *       Parameter\r
606 *               HOSTLISTDATA *Pos : \83m\81[\83h\83f\81[\83^\r
607 *\r
608 *       Return Value\r
609 *               HOSTLISTDATA *\8e\9f\82Ì\83m\81[\83h\r
610 *                       NULL=\8e\9f\82Í\82È\82¢\r
611 *----------------------------------------------------------------------------*/\r
612 \r
613 static HOSTLISTDATA *GetNextNode(HOSTLISTDATA *Pos)\r
614 {\r
615         HOSTLISTDATA *Ret;\r
616 \r
617         Ret = NULL;\r
618         if(Pos->Child != NULL)\r
619                 Ret = Pos->Child;\r
620         else\r
621         {\r
622                 if(Pos->Next != NULL)\r
623                         Ret = Pos->Next;\r
624                 else\r
625                 {\r
626                         while(Pos->Parent != NULL)\r
627                         {\r
628                                 Pos = Pos->Parent;\r
629                                 if(Pos->Next != NULL)\r
630                                 {\r
631                                         Ret = Pos->Next;\r
632                                         break;\r
633                                 }\r
634                         }\r
635                 }\r
636         }\r
637         return(Ret);\r
638 }\r
639 \r
640 \r
641 /*----- \83m\81[\83h\82Ì\83\8c\83x\83\8b\90\94\82ð\95Ô\82·\81i\90Ý\92è\94Ô\8d\86\8ew\92è\81j --------------------------------\r
642 *\r
643 *       Parameter\r
644 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
645 *\r
646 *       Return Value\r
647 *               int \83\8c\83x\83\8b\90\94 (-1=\90Ý\92è\82ª\82È\82¢\81j\r
648 *----------------------------------------------------------------------------*/\r
649 \r
650 static int GetNodeLevel(int Num)\r
651 {\r
652         int Ret;\r
653         HOSTLISTDATA *Pos;\r
654 \r
655         Ret = -1;\r
656         if((Num >= 0) && (Num < Hosts))\r
657         {\r
658                 Pos = GetNodeByNum(Num);\r
659                 Ret = 0;\r
660                 while(Pos->Parent != NULL)\r
661                 {\r
662                         Pos = Pos->Parent;\r
663                         Ret++;\r
664                 }\r
665         }\r
666         return(Ret);\r
667 }\r
668 \r
669 \r
670 /*----- \83m\81[\83h\82Ì\83\8c\83x\83\8b\90\94\82ð\95Ô\82·\81i\83m\81[\83h\83f\81[\83^\8ew\92è\81j-----------------------------\r
671 *\r
672 *       Parameter\r
673 *               HOSTLISTDATA *Data : \90Ý\92è\92l\r
674 *\r
675 *       Return Value\r
676 *               int \83\8c\83x\83\8b\90\94\r
677 *----------------------------------------------------------------------------*/\r
678 \r
679 static int GetNodeLevelByData(HOSTLISTDATA *Data)\r
680 {\r
681         int Ret;\r
682 \r
683         Ret = 0;\r
684         while(Data->Parent != NULL)\r
685         {\r
686                 Data = Data->Parent;\r
687                 Ret++;\r
688         }\r
689         return(Ret);\r
690 }\r
691 \r
692 \r
693 /*----- \83m\81[\83h\82Ì\90Ý\92è\94Ô\8d\86\82ð\95Ô\82· ------------------------------------------------\r
694 *\r
695 *       Parameter\r
696 *               HOSTLISTDATA *Data : \90Ý\92è\92l\r
697 *\r
698 *       Return Value\r
699 *               int \90Ý\92è\94Ô\8d\86\r
700 *----------------------------------------------------------------------------*/\r
701 \r
702 static int GetNodeNumByData(HOSTLISTDATA *Data)\r
703 {\r
704         int Ret;\r
705         HOSTLISTDATA *Pos;\r
706 \r
707         Ret = 0;\r
708         Pos = HostListTop;\r
709         while(Pos != Data)\r
710         {\r
711                 Pos = GetNextNode(Pos);\r
712                 Ret++;\r
713         }\r
714         return(Ret);\r
715 }\r
716 \r
717 \r
718 /*----- \8ew\92è\94Ô\8d\86\82Ì\83m\81[\83h\82ð\95Ô\82· ------------------------------------------------\r
719 *\r
720 *       Parameter\r
721 *               int Num : \90Ý\92è\94Ô\8d\86\r
722 *\r
723 *       Return Value\r
724 *               HOSTLISTDATA * : \90Ý\92è\92l\r
725 *----------------------------------------------------------------------------*/\r
726 \r
727 static HOSTLISTDATA *GetNodeByNum(int Num)\r
728 {\r
729         HOSTLISTDATA *Pos;\r
730 \r
731         Pos = HostListTop;\r
732         for(; Num > 0; Num--)\r
733                 Pos = GetNextNode(Pos);\r
734 \r
735         return(Pos);\r
736 }\r
737 \r
738 \r
739 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\8ae\83m\81[\83h\82Ì\83\8c\83x\83\8b\94Ô\8d\86\82ð\83Z\83b\83g ----------------------------\r
740 *\r
741 *       Parameter\r
742 *               int Num : \90Ý\92è\94Ô\8d\86\r
743 *\r
744 *       Return Value\r
745 *               HOSTLISTDATA * : \90Ý\92è\92l\r
746 *----------------------------------------------------------------------------*/\r
747 \r
748 static int SetNodeLevelAll(void)\r
749 {\r
750         HOSTLISTDATA *Pos;\r
751         int i;\r
752 \r
753         Pos = HostListTop;\r
754         for(i = 0; i < Hosts; i++)\r
755         {\r
756                 Pos->Set.Level &= ~SET_LEVEL_MASK;\r
757                 Pos->Set.Level |= GetNodeLevelByData(Pos);\r
758                 Pos = GetNextNode(Pos);\r
759         }\r
760         return(SUCCESS);\r
761 }\r
762 \r
763 \r
764 /*----- \90Ý\92è\92l\83\8a\83X\83g\82É\92Ç\89Á ----------------------------------------------------\r
765 *\r
766 *       Parameter\r
767 *               HOSTDATA *Set : \92Ç\89Á\82·\82é\90Ý\92è\92l\r
768 *               int Pos : \92Ç\89Á\82·\82é\88Ê\92u (0\81` : -1=\8dÅ\8cã)\r
769 *               int Level : \83\8c\83x\83\8b\90\94 (SET_LEVEL_SAME=\92Ç\89Á\88Ê\92u\82Ì\82à\82Ì\82Æ\93¯\83\8c\83x\83\8b)\r
770 *\r
771 *       Return Value\r
772 *               int \83X\83e\81[\83^\83X\r
773 *                       SUCCESS/FAIL\r
774 *----------------------------------------------------------------------------*/\r
775 \r
776 int AddHostToList(HOSTDATA *Set, int Pos, int Level)\r
777 {\r
778         int Sts;\r
779         HOSTLISTDATA *New;\r
780         HOSTLISTDATA *Last;\r
781         int Cur;\r
782 \r
783         Sts = FAIL;\r
784         if((Pos >= -1) && (Pos <= Hosts))\r
785         {\r
786                 if(Pos == -1)\r
787                         Pos = Hosts;\r
788                 Level &= SET_LEVEL_MASK;\r
789 \r
790                 if((New = malloc(sizeof(HOSTLISTDATA))) != NULL)\r
791                 {\r
792                         memcpy(&New->Set, Set, sizeof(HOSTDATA));\r
793                         New->Next = NULL;\r
794                         New->Prev = NULL;\r
795                         New->Child = NULL;\r
796                         New->Parent = NULL;\r
797 \r
798                         if(HostListTop == NULL)\r
799                         {\r
800                                 if(Pos == 0)\r
801                                         HostListTop = New;\r
802                         }\r
803                         else\r
804                         {\r
805                                 if(Pos == 0)\r
806                                 {\r
807                                         New->Next = HostListTop;\r
808                                         HostListTop = New;\r
809                                 }\r
810                                 else\r
811                                 {\r
812                                         Cur = GetNodeLevel(Pos-1);\r
813                                         Last = HostListTop;\r
814                                         for(Pos--; Pos > 0; Pos--)\r
815                                                 Last = GetNextNode(Last);\r
816                                         if((Level != SET_LEVEL_SAME) && (Level > Cur))\r
817                                         {\r
818                                                 New->Next = Last->Child;\r
819                                                 New->Parent = Last;\r
820                                                 Last->Child = New;\r
821                                                 if(New->Next != NULL)\r
822                                                         New->Next->Prev = New;\r
823                                         }\r
824                                         else\r
825                                         {\r
826                                                 if((Level >= 0) && (Level < SET_LEVEL_SAME))\r
827                                                 {\r
828                                                         for(; Level < Cur; Cur--)\r
829                                                                 Last = Last->Parent;\r
830                                                 }\r
831                                                 New->Prev = Last;\r
832                                                 New->Next = Last->Next;\r
833                                                 New->Parent = Last->Parent;\r
834                                                 Last->Next = New;\r
835                                                 if(New->Next != NULL)\r
836                                                         New->Next->Prev = New;\r
837                                         }\r
838                                 }\r
839                         }\r
840                         Hosts++;\r
841                         Sts = SUCCESS;\r
842                 }\r
843         }\r
844         return(Sts);\r
845 }\r
846 \r
847 \r
848 /*----- \90Ý\92è\92l\83\8a\83X\83g\82ð\8dX\90V\82·\82é ------------------------------------------------\r
849 *\r
850 *       Parameter\r
851 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
852 *               HOSTDATA *Set : \90Ý\92è\92l\82ð\83R\83s\81[\82·\82é\83\8f\81[\83N\r
853 *\r
854 *       Return Value\r
855 *               int \83X\83e\81[\83^\83X\r
856 *                       SUCCESS/FAIL\r
857 *----------------------------------------------------------------------------*/\r
858 \r
859 static int UpdateHostToList(int Num, HOSTDATA *Set)\r
860 {\r
861         int Sts;\r
862         HOSTLISTDATA *Pos;\r
863 \r
864         Sts = FAIL;\r
865         if((Num >= 0) && (Num < Hosts))\r
866         {\r
867                 Pos = GetNodeByNum(Num);\r
868                 memcpy(&Pos->Set, Set, sizeof(HOSTDATA));\r
869                 Sts = SUCCESS;\r
870         }\r
871         return(Sts);\r
872 }\r
873 \r
874 \r
875 /*----- \90Ý\92è\92l\83\8a\83X\83g\82©\82ç\8dí\8f\9c --------------------------------------------------\r
876 *\r
877 *       Parameter\r
878 *               int Num : \8dí\8f\9c\82·\82é\94Ô\8d\86\r
879 *\r
880 *       Return Value\r
881 *               int \83X\83e\81[\83^\83X\r
882 *                       SUCCESS/FAIL\r
883 *----------------------------------------------------------------------------*/\r
884 \r
885 static int DelHostFromList(int Num)\r
886 {\r
887         int Sts;\r
888         HOSTLISTDATA *Pos;\r
889 \r
890         Sts = FAIL;\r
891         if((Num >= 0) && (Num < Hosts))\r
892         {\r
893                 if(Num == 0)\r
894                 {\r
895                         Pos = HostListTop;\r
896                         if(Pos->Child != NULL)\r
897                                 DeleteChildAndNext(Pos->Child);\r
898                         HostListTop = Pos->Next;\r
899                 }\r
900                 else\r
901                 {\r
902                         Pos = GetNodeByNum(Num);\r
903                         if(Pos->Child != NULL)\r
904                                 DeleteChildAndNext(Pos->Child);\r
905 \r
906                         if(Pos->Next != NULL)\r
907                                 Pos->Next->Prev = Pos->Prev;\r
908                         if(Pos->Prev != NULL)\r
909                                 Pos->Prev->Next = Pos->Next;\r
910                         if((Pos->Parent != NULL) && (Pos->Parent->Child == Pos))\r
911                                 Pos->Parent->Child = Pos->Next;\r
912                 }\r
913                 free(Pos);\r
914                 Hosts--;\r
915                 Sts = SUCCESS;\r
916         }\r
917         return(Sts);\r
918 }\r
919 \r
920 \r
921 /*----- \90Ý\92è\92l\83\8a\83X\83g\82©\82ç\83m\81[\83h\83f\81[\83^\82ð\8dí\8f\9c ------------------------------------\r
922 *\r
923 *       Parameter\r
924 *               HOSTLISTDATA *Pos : \8dí\8f\9c\82·\82é\83m\81[\83h\r
925 *\r
926 *       Return Value\r
927 *               int \83X\83e\81[\83^\83X\r
928 *                       SUCCESS/FAIL\r
929 *\r
930 *       Note\r
931 *               Pos->Next, Pos->Child\82Ì\91S\82Ä\82Ì\83m\81[\83h\82ð\8dí\8f\9c\82·\82é\r
932 *----------------------------------------------------------------------------*/\r
933 \r
934 static int DeleteChildAndNext(HOSTLISTDATA *Pos)\r
935 {\r
936         HOSTLISTDATA *Next;\r
937 \r
938         while(Pos != NULL)\r
939         {\r
940                 if(Pos->Child != NULL)\r
941                         DeleteChildAndNext(Pos->Child);\r
942 \r
943                 Next = Pos->Next;\r
944                 free(Pos);\r
945                 Hosts--;\r
946                 Pos = Next;\r
947         }\r
948         return(SUCCESS);\r
949 }\r
950 \r
951 \r
952 /*----- \90Ý\92è\92l\83\8a\83X\83g\82©\82ç\90Ý\92è\92l\82ð\8eæ\82è\8fo\82· --------------------------------------\r
953 *\r
954 *       Parameter\r
955 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
956 *               HOSTDATA *Set : \90Ý\92è\92l\82ð\83R\83s\81[\82·\82é\83\8f\81[\83N\r
957 *\r
958 *       Return Value\r
959 *               int \83X\83e\81[\83^\83X\r
960 *                       SUCCESS/FAIL\r
961 *\r
962 *       Note\r
963 *               \8c»\8dÝ\83z\83X\83g\82É\90Ú\91±\92\86\82Ì\8e\9e\82Í\81ACopyHostFromListInConnect() \82ð\8eg\82¤\8e\96\r
964 *----------------------------------------------------------------------------*/\r
965 \r
966 int CopyHostFromList(int Num, HOSTDATA *Set)\r
967 {\r
968         int Sts;\r
969         HOSTLISTDATA *Pos;\r
970 \r
971         Sts = FAIL;\r
972         if((Num >= 0) && (Num < Hosts))\r
973         {\r
974                 Pos = GetNodeByNum(Num);\r
975                 memcpy(Set, &Pos->Set, sizeof(HOSTDATA));\r
976                 Sts = SUCCESS;\r
977         }\r
978         return(Sts);\r
979 }\r
980 \r
981 \r
982 /*----- \90Ý\92è\92l\83\8a\83X\83g\82©\82ç\90Ý\92è\92l\82ð\8eæ\82è\8fo\82· --------------------------------------\r
983 *\r
984 *       Parameter\r
985 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
986 *               HOSTDATA *Set : \90Ý\92è\92l\82ð\83R\83s\81[\82·\82é\83\8f\81[\83N\r
987 *\r
988 *       Return Value\r
989 *               int \83X\83e\81[\83^\83X\r
990 *                       SUCCESS/FAIL\r
991 *\r
992 *       Note\r
993 *               \8c»\8dÝ\83z\83X\83g\82É\90Ú\91±\92\86\82Ì\8e\9e\82É\8eg\82¤\r
994 *----------------------------------------------------------------------------*/\r
995 \r
996 int CopyHostFromListInConnect(int Num, HOSTDATA *Set)\r
997 {\r
998         int Sts;\r
999         HOSTLISTDATA *Pos;\r
1000 \r
1001         Sts = FAIL;\r
1002         if((Num >= 0) && (Num < Hosts))\r
1003         {\r
1004                 Pos = GetNodeByNum(Num);\r
1005                 strcpy(Set->ChmodCmd, Pos->Set.ChmodCmd);\r
1006                 Set->Port = Pos->Set.Port;\r
1007                 Set->Anonymous = Pos->Set.Anonymous;\r
1008                 Set->KanjiCode = Pos->Set.KanjiCode;\r
1009                 Set->KanaCnv = Pos->Set.KanaCnv;\r
1010                 Set->NameKanjiCode = Pos->Set.NameKanjiCode;\r
1011                 Set->NameKanaCnv = Pos->Set.NameKanaCnv;\r
1012                 Set->Pasv = Pos->Set.Pasv;\r
1013                 Set->FireWall = Pos->Set.FireWall;\r
1014                 Set->ListCmdOnly = Pos->Set.ListCmdOnly;\r
1015                 Set->UseNLST_R = Pos->Set.UseNLST_R;\r
1016                 Set->LastDir = Pos->Set.LastDir;\r
1017                 Set->TimeZone = Pos->Set.TimeZone;\r
1018                 Sts = SUCCESS;\r
1019         }\r
1020         return(Sts);\r
1021 }\r
1022 \r
1023 \r
1024 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\83u\83b\83N\83}\81[\83N\82ð\8dX\90V --------------------------------------\r
1025 *\r
1026 *       Parameter\r
1027 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1028 *               char *Bmask : \83u\83b\83N\83}\81[\83N\95\8e\9a\97ñ\r
1029 *               int Len : \83u\83b\83N\83}\81[\83N\95\8e\9a\97ñ\82Ì\92·\82³\r
1030 *\r
1031 *       Return Value\r
1032 *               int \83X\83e\81[\83^\83X\r
1033 *                       SUCCESS/FAIL\r
1034 *----------------------------------------------------------------------------*/\r
1035 \r
1036 int SetHostBookMark(int Num, char *Bmask, int Len)\r
1037 {\r
1038         int Sts;\r
1039         HOSTLISTDATA *Pos;\r
1040 \r
1041         Sts = FAIL;\r
1042         if((Num >= 0) && (Num < Hosts))\r
1043         {\r
1044                 Pos = GetNodeByNum(Num);\r
1045                 memcpy(Pos->Set.BookMark, Bmask, Len);\r
1046                 Sts = SUCCESS;\r
1047         }\r
1048         return(Sts);\r
1049 }\r
1050 \r
1051 \r
1052 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\83u\83b\83N\83}\81[\83N\95\8e\9a\97ñ\82ð\95Ô\82· --------------------------------\r
1053 *\r
1054 *       Parameter\r
1055 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1056 *\r
1057 *       Return Value\r
1058 *               char *\83u\83b\83N\83}\81[\83N\95\8e\9a\97ñ\r
1059 *----------------------------------------------------------------------------*/\r
1060 \r
1061 char *AskHostBookMark(int Num)\r
1062 {\r
1063         char *Ret;\r
1064         HOSTLISTDATA *Pos;\r
1065 \r
1066         Ret = NULL;\r
1067         if((Num >= 0) && (Num < Hosts))\r
1068         {\r
1069                 Pos = GetNodeByNum(Num);\r
1070                 Ret = Pos->Set.BookMark;\r
1071         }\r
1072         return(Ret);\r
1073 }\r
1074 \r
1075 \r
1076 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\83f\83B\83\8c\83N\83g\83\8a\82ð\8dX\90V --------------------------------------\r
1077 *\r
1078 *       Parameter\r
1079 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1080 *               char *LocDir : \83\8d\81[\83J\83\8b\82Ì\83f\83B\83\8c\83N\83g\83\8a\r
1081 *               char *HostDir : \83z\83X\83g\82Ì\83f\83B\83\8c\83N\83g\83\8a\r
1082 *\r
1083 *       Return Value\r
1084 *               int \83X\83e\81[\83^\83X\r
1085 *                       SUCCESS/FAIL\r
1086 *----------------------------------------------------------------------------*/\r
1087 \r
1088 int SetHostDir(int Num, char *LocDir, char *HostDir)\r
1089 {\r
1090         int Sts;\r
1091         HOSTLISTDATA *Pos;\r
1092 \r
1093         Sts = FAIL;\r
1094         if((Num >= 0) && (Num < Hosts))\r
1095         {\r
1096                 Pos = GetNodeByNum(Num);\r
1097                 strcpy(Pos->Set.LocalInitDir, LocDir);\r
1098                 strcpy(Pos->Set.RemoteInitDir, HostDir);\r
1099                 Sts = SUCCESS;\r
1100         }\r
1101         return(Sts);\r
1102 }\r
1103 \r
1104 \r
1105 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\83p\83X\83\8f\81[\83h\82ð\8dX\90V ----------------------------------------\r
1106 *\r
1107 *       Parameter\r
1108 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1109 *               char *Pass : \83p\83X\83\8f\81[\83h\r
1110 *\r
1111 *       Return Value\r
1112 *               int \83X\83e\81[\83^\83X\r
1113 *                       SUCCESS/FAIL\r
1114 *----------------------------------------------------------------------------*/\r
1115 \r
1116 int SetHostPassword(int Num, char *Pass)\r
1117 {\r
1118         int Sts;\r
1119         HOSTLISTDATA *Pos;\r
1120 \r
1121         Sts = FAIL;\r
1122         if((Num >= 0) && (Num < Hosts))\r
1123         {\r
1124                 Pos = GetNodeByNum(Num);\r
1125                 strcpy(Pos->Set.PassWord, Pass);\r
1126                 Sts = SUCCESS;\r
1127         }\r
1128         return(Sts);\r
1129 }\r
1130 \r
1131 \r
1132 /*----- \8ew\92è\82Ì\90Ý\92è\96¼\82ð\8e\9d\82Â\90Ý\92è\82Ì\94Ô\8d\86\82ð\95Ô\82· ------------------------------------\r
1133 *\r
1134 *       Parameter\r
1135 *               char *Name : \90Ý\92è\96¼\r
1136 *\r
1137 *       Return Value\r
1138 *               int \90Ý\92è\94Ô\8d\86 (0\81`)\r
1139 *                       -1=\8c©\82Â\82©\82ç\82È\82¢\r
1140 *----------------------------------------------------------------------------*/\r
1141 \r
1142 int SearchHostName(char *Name)\r
1143 {\r
1144         int Ret;\r
1145         int i;\r
1146         HOSTLISTDATA *Pos;\r
1147 \r
1148         Ret = -1;\r
1149         Pos = HostListTop;\r
1150         for(i = 0; i < Hosts; i++)\r
1151         {\r
1152                 if(strcmp(Name, Pos->Set.HostName) == 0)\r
1153                 {\r
1154                         Ret = i;\r
1155                         break;\r
1156                 }\r
1157                 Pos = GetNextNode(Pos);\r
1158         }\r
1159         return(Ret);\r
1160 }\r
1161 \r
1162 \r
1163 /*----- \90Ý\92è\92l\83\8a\83X\83g\82Ì\83\\81[\83g\95û\96@\82ð\8dX\90V ----------------------------------------\r
1164 *\r
1165 *       Parameter\r
1166 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1167 *               int LFSort : \83\8d\81[\83J\83\8b\82Ì\83t\83@\83C\83\8b\82Ì\83\\81[\83g\95û\96@\r
1168 *               int LDSort : \83\8d\81[\83J\83\8b\82Ì\83t\83H\83\8b\83_\82Ì\83\\81[\83g\95û\96@\r
1169 *               int RFSort : \83\8a\83\82\81[\83g\82Ì\83t\83@\83C\83\8b\82Ì\83\\81[\83g\95û\96@\r
1170 *               int RDSort : \83\8a\83\82\81[\83g\82Ì\83t\83H\83\8b\83_\82Ì\83\\81[\83g\95û\96@\r
1171 *\r
1172 *       Return Value\r
1173 *               int \83X\83e\81[\83^\83X\r
1174 *                       SUCCESS/FAIL\r
1175 *----------------------------------------------------------------------------*/\r
1176 \r
1177 int SetHostSort(int Num, int LFSort, int LDSort, int RFSort, int RDSort)\r
1178 {\r
1179         int Sts;\r
1180         HOSTLISTDATA *Pos;\r
1181 \r
1182         Sts = FAIL;\r
1183         if((Num >= 0) && (Num < Hosts))\r
1184         {\r
1185                 Pos = GetNodeByNum(Num);\r
1186                 Pos->Set.Sort = LFSort * 0x1000000 | LDSort * 0x10000 | RFSort * 0x100 | RDSort;\r
1187                 Sts = SUCCESS;\r
1188         }\r
1189         return(Sts);\r
1190 }\r
1191 \r
1192 \r
1193 /*----- \93o\98^\82³\82ê\82Ä\82¢\82é\83\\81[\83g\95û\96@\82ð\95ª\89ð\82·\82é ------------------------------------\r
1194 *\r
1195 *       Parameter\r
1196 *               ulong Sort : \83\\81[\83g\95û\96\r
1197 *               int *LFSort : \83\8d\81[\83J\83\8b\82Ì\83t\83@\83C\83\8b\82Ì\83\\81[\83g\95û\96@\82ð\8ai\94[\82·\82é\83\8f\81[\83N\r
1198 *               int *LDSort : \83\8d\81[\83J\83\8b\82Ì\83t\83H\83\8b\83_\82Ì\83\\81[\83g\95û\96@\82ð\8ai\94[\82·\82é\83\8f\81[\83N\r
1199 *               int *RFSort : \83\8a\83\82\81[\83g\82Ì\83t\83@\83C\83\8b\82Ì\83\\81[\83g\95û\96@\82ð\8ai\94[\82·\82é\83\8f\81[\83N\r
1200 *               int *RDSort : \83\8a\83\82\81[\83g\82Ì\83t\83H\83\8b\83_\82Ì\83\\81[\83g\95û\96@\82ð\8ai\94[\82·\82é\83\8f\81[\83N\r
1201 *\r
1202 *       Return Value\r
1203 *               \82È\82µ\r
1204 *----------------------------------------------------------------------------*/\r
1205 \r
1206 void DecomposeSortType(ulong Sort, int *LFSort, int *LDSort, int *RFSort, int *RDSort)\r
1207 {\r
1208         *LFSort = (int)((Sort / 0x1000000) & 0xFF);\r
1209         *LDSort = (int)((Sort / 0x10000) & 0xFF);\r
1210         *RFSort = (int)((Sort / 0x100) & 0xFF);\r
1211         *RDSort = (int)(Sort & 0xFF);\r
1212         return;\r
1213 }\r
1214 \r
1215 \r
1216 /*----- \8c»\8dÝ\90Ú\91±\92\86\82Ì\90Ý\92è\94Ô\8d\86\82ð\95Ô\82· --------------------------------------------\r
1217 *\r
1218 *       Parameter\r
1219 *               \82È\82µ\r
1220 *\r
1221 *       Return Value\r
1222 *               int \90Ý\92è\94Ô\8d\86\r
1223 *----------------------------------------------------------------------------*/\r
1224 \r
1225 int AskCurrentHost(void)\r
1226 {\r
1227         return(ConnectingHost);\r
1228 }\r
1229 \r
1230 \r
1231 /*----- \8c»\8dÝ\90Ú\91±\92\86\82Ì\90Ý\92è\94Ô\8d\86\82ð\83Z\83b\83g\82·\82é --------------------------------------\r
1232 *\r
1233 *       Parameter\r
1234 *               int Num : \90Ý\92è\94Ô\8d\86\r
1235 *\r
1236 *       Return Value\r
1237 *               \82È\82µ\r
1238 *----------------------------------------------------------------------------*/\r
1239 \r
1240 void SetCurrentHost(int Num)\r
1241 {\r
1242         ConnectingHost = Num;\r
1243         return;\r
1244 }\r
1245 \r
1246 \r
1247 /*----- \83f\83t\83H\83\8b\83g\90Ý\92è\92l\82ð\8eæ\82è\8fo\82· --------------------------------------------\r
1248 *\r
1249 *       Parameter\r
1250 *               HOSTDATA *Set : \90Ý\92è\92l\82ð\83R\83s\81[\82·\82é\83\8f\81[\83N\r
1251 *\r
1252 *       Return Value\r
1253 *               \82È\82µ\r
1254 *----------------------------------------------------------------------------*/\r
1255 \r
1256 void CopyDefaultHost(HOSTDATA *Set)\r
1257 {\r
1258         Set->Level = 0;\r
1259         strcpy(Set->HostName, "");\r
1260         strcpy(Set->HostAdrs, "");\r
1261         strcpy(Set->UserName, "");\r
1262         strcpy(Set->PassWord, "");\r
1263         strcpy(Set->Account, "");\r
1264         strcpy(Set->LocalInitDir, DefaultLocalPath);\r
1265         strcpy(Set->RemoteInitDir, "");\r
1266         memcpy(Set->BookMark, "\0\0", 2);\r
1267         strcpy(Set->ChmodCmd, CHMOD_CMD_NOR);\r
1268         strcpy(Set->LsName, LS_FNAME);\r
1269         strcpy(Set->InitCmd, "");\r
1270         Set->Port = PORT_NOR;\r
1271         Set->Anonymous = NO;\r
1272         Set->KanjiCode = KANJI_NOCNV;\r
1273         Set->KanaCnv = YES;\r
1274         Set->NameKanjiCode = KANJI_NOCNV;\r
1275         Set->NameKanaCnv = NO;\r
1276         Set->Pasv = YES;\r
1277         Set->FireWall = NO;\r
1278         Set->ListCmdOnly = YES;\r
1279         Set->UseNLST_R = YES;\r
1280         Set->LastDir = NO;\r
1281         Set->TimeZone = 9;                              /* GMT+9 (JST) */\r
1282         Set->HostType = HTYPE_AUTO;\r
1283         Set->SyncMove = NO;\r
1284         Set->NoFullPath = NO;\r
1285         Set->Sort = SORT_NOTSAVED;\r
1286         Set->Security = SECURITY_AUTO;\r
1287         Set->Dialup = NO;\r
1288         Set->DialupAlways = NO;\r
1289         Set->DialupNotify = YES;\r
1290         strcpy(Set->DialEntry, "");\r
1291         return;\r
1292 }\r
1293 \r
1294 \r
1295 /*----- \90Ý\92è\96¼\88ê\97\97\82ð\83E\83B\83\93\83h\83E\82É\91\97\82é ------------------------------------------\r
1296 *\r
1297 *       Parameter\r
1298 *               HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1299 *               int Cur : \r
1300 *\r
1301 *       Return Value\r
1302 *               \82È\82µ\r
1303 *----------------------------------------------------------------------------*/\r
1304 \r
1305 static void SendAllHostNames(HWND hWnd, int Cur)\r
1306 {\r
1307         int i;\r
1308         HOSTLISTDATA *Pos;\r
1309         TV_INSERTSTRUCT tvIns;\r
1310         HTREEITEM hItem;\r
1311         HTREEITEM hItemCur;\r
1312         HTREEITEM *Level;\r
1313         int CurLevel;\r
1314 \r
1315         hItemCur = NULL;\r
1316 \r
1317         /* \82¿\82ç\82Â\82­\82Ì\82Å\8dÄ\95`\89æ\8bÖ\8e~ */\r
1318         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)FALSE, 0);\r
1319 \r
1320         SendMessage(hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);         /* \91S\82Ä\82ð\8dí\8f\9c */\r
1321 \r
1322         if((Level = malloc(sizeof(HTREEITEM*) * Hosts + 1)) != NULL)\r
1323         {\r
1324                 Pos = HostListTop;\r
1325                 for(i = 0; i < Hosts; i++)\r
1326                 {\r
1327                         if(Pos->Set.Level & SET_LEVEL_GROUP)\r
1328                         {\r
1329                                 tvIns.item.iImage = 0;\r
1330                                 tvIns.item.iSelectedImage = 0;\r
1331                         }\r
1332                         else\r
1333                         {\r
1334                                 tvIns.item.iImage = 2;\r
1335                                 tvIns.item.iSelectedImage = 2;\r
1336                         }\r
1337 \r
1338                         CurLevel = GetNodeLevel(i);\r
1339                         if(CurLevel == 0)\r
1340                                 tvIns.hParent = TVI_ROOT;\r
1341                         else\r
1342                                 tvIns.hParent = Level[CurLevel - 1];\r
1343 \r
1344                         tvIns.hInsertAfter = TVI_LAST;\r
1345                         tvIns.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;\r
1346         //              tvIns.item.hItem = 0;\r
1347         //              tvIns.item.state = 0;\r
1348         //              tvIns.item.stateMask = 0;\r
1349                         tvIns.item.pszText = Pos->Set.HostName;\r
1350                         tvIns.item.cchTextMax = 0;\r
1351                         tvIns.item.cChildren = 1;\r
1352                         tvIns.item.lParam = i;\r
1353                         hItem = (HTREEITEM)SendMessage(hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvIns);\r
1354 \r
1355                         if(Pos->Set.Level & SET_LEVEL_GROUP)\r
1356                                 Level[CurLevel] = hItem;\r
1357 \r
1358 //                      DoPrintf("%d = %x", i, hItem);\r
1359                         if(i == Cur)\r
1360                         {\r
1361                                 hItemCur = hItem;\r
1362                         }\r
1363                         Pos = GetNextNode(Pos);\r
1364                 }\r
1365                 free(Level);\r
1366         }\r
1367 \r
1368         /* \8dÄ\95`\89æ */\r
1369         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)TRUE, 0);\r
1370 \r
1371         if(hItemCur != NULL)\r
1372         {\r
1373                 SendMessage(hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItemCur);\r
1374 //              SendMessage(hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItemCur);\r
1375         }\r
1376         UpdateWindow(hWnd);\r
1377 \r
1378         return;\r
1379 }\r
1380 \r
1381 \r
1382 /*----- \90Ý\92è\92l\82ª\83O\83\8b\81[\83v\82©\82Ç\82¤\82©\82ð\95Ô\82· ----------------------------------------\r
1383 *\r
1384 *       Parameter\r
1385 *               int Num : \90Ý\92è\92l\8d\86\94Ô\8d\86\r
1386 *\r
1387 *       Return Value\r
1388 *               int \83O\83\8b\81[\83v\82©\82Ç\82¤\82©\r
1389 *                       YES/NO/-1=\90Ý\92è\92l\82ª\82È\82¢\r
1390 *----------------------------------------------------------------------------*/\r
1391 \r
1392 static int IsNodeGroup(int Num)\r
1393 {\r
1394         int Ret;\r
1395         HOSTLISTDATA *Pos;\r
1396 \r
1397         Ret = -1;\r
1398         if((Num >= 0) && (Num < Hosts))\r
1399         {\r
1400                 Pos = GetNodeByNum(Num);\r
1401                 Ret = (Pos->Set.Level & SET_LEVEL_GROUP) ? YES : NO;\r
1402         }\r
1403         return(Ret);\r
1404 }\r
1405 \r
1406 \r
1407 /*----- WS_FTP.INI\82©\82ç\82Ì\83C\83\93\83|\81[\83g --------------------------------------------\r
1408 *\r
1409 *       Parameter\r
1410 *               \82È\82µ\r
1411 *\r
1412 *       Return Value\r
1413 *               \82È\82µ\r
1414 *----------------------------------------------------------------------------*/\r
1415 \r
1416 void ImportFromWSFTP(void)\r
1417 {\r
1418         FILE *Strm;\r
1419         char Buf[FMAX_PATH+1];\r
1420         HOSTDATA Host;\r
1421         int InHost;\r
1422 \r
1423         strcpy(Buf, "WS_FTP.INI");\r
1424         if(SelectFile(GetMainHwnd(), Buf, MSGJPN126, MSGJPN276, NULL, OFN_FILEMUSTEXIST, 0) == TRUE)\r
1425         {\r
1426                 if((Strm = fopen(Buf, "rt")) != NULL)\r
1427                 {\r
1428                         InHost = NO;\r
1429                         while(fgets(Buf, FMAX_PATH, Strm) != NULL)\r
1430                         {\r
1431                                 if(Buf[0] == '[')\r
1432                                 {\r
1433                                         if(InHost == YES)\r
1434                                         {\r
1435                                                 AddHostToList(&Host, -1, 0);\r
1436                                                 InHost = NO;\r
1437                                         }\r
1438                                         if(_stricmp(Buf, "[_config_]\n") != 0)\r
1439                                         {\r
1440                                                 CopyDefaultHost(&Host);\r
1441 \r
1442                                                 *(Buf + strlen(Buf) - 2) = NUL;\r
1443                                                 memset(Host.HostName, NUL, HOST_NAME_LEN+1);\r
1444                                                 strncpy(Host.HostName, Buf+1, HOST_NAME_LEN);\r
1445                                                 InHost = YES;\r
1446                                         }\r
1447                                 }\r
1448                                 else if(InHost == YES)\r
1449                                 {\r
1450                                         FormatIniString(Buf);\r
1451 \r
1452                                         if(_strnicmp(Buf, "HOST=", 5) == 0)\r
1453                                         {\r
1454                                                 memset(Host.HostAdrs, NUL, HOST_ADRS_LEN+1);\r
1455                                                 strncpy(Host.HostAdrs, Buf+5, HOST_ADRS_LEN);\r
1456                                         }\r
1457                                         else if(_strnicmp(Buf, "UID=", 4) == 0)\r
1458                                         {\r
1459                                                 memset(Host.UserName, NUL, USER_NAME_LEN+1);\r
1460                                                 strncpy(Host.UserName, Buf+4, USER_NAME_LEN);\r
1461                                                 if(strcmp(Host.UserName, "anonymous") == 0)\r
1462                                                         strcpy(Host.PassWord, UserMailAdrs);\r
1463                                         }\r
1464                                         else if(_strnicmp(Buf, "LOCDIR=", 7) == 0)\r
1465                                         {\r
1466                                                 memset(Host.LocalInitDir, NUL, INIT_DIR_LEN+1);\r
1467                                                 strncpy(Host.LocalInitDir, Buf+7, INIT_DIR_LEN);\r
1468                                         }\r
1469                                         else if(_strnicmp(Buf, "DIR=", 4) == 0)\r
1470                                         {\r
1471                                                 memset(Host.RemoteInitDir, NUL, INIT_DIR_LEN+1);\r
1472                                                 strncpy(Host.RemoteInitDir, Buf+4, INIT_DIR_LEN);\r
1473                                         }\r
1474                                         else if(_strnicmp(Buf, "PASVMODE=", 9) == 0)\r
1475                                                 Host.Pasv = (atoi(Buf+9) == 0) ? 0 : 1;\r
1476                                         else if(_strnicmp(Buf, "FIREWALL=", 9) == 0)\r
1477                                                 Host.FireWall = (atoi(Buf+9) == 0) ? 0 : 1;\r
1478                                 }\r
1479                         }\r
1480 \r
1481                         if(InHost == YES)\r
1482                                 AddHostToList(&Host, -1, 0);\r
1483                         fclose(Strm);\r
1484                 }\r
1485         }\r
1486         return;\r
1487 }\r
1488 \r
1489 \r
1490 \r
1491 /*----- \83z\83X\83g\90Ý\92è\82Ì\83v\83\8d\83p\83e\83B\83V\81[\83g ------------------------------------------\r
1492 *\r
1493 *       Parameter\r
1494 *               HWND hDlg : \90e\83E\83C\83\93\83h\83E\82Ì\83n\83\93\83h\83\8b\r
1495 *\r
1496 *       Return Value\r
1497 *               \82È\82µ\r
1498 *----------------------------------------------------------------------------*/\r
1499 \r
1500 static int DispHostSetDlg(HWND hDlg)\r
1501 {\r
1502         PROPSHEETPAGE psp[5];\r
1503         PROPSHEETHEADER psh;\r
1504 \r
1505         psp[0].dwSize = sizeof(PROPSHEETPAGE);\r
1506         psp[0].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1507         psp[0].hInstance = GetFtpInst();\r
1508         psp[0].pszTemplate = MAKEINTRESOURCE(hset_main_dlg);\r
1509         psp[0].pszIcon = NULL;\r
1510         psp[0].pfnDlgProc = MainSettingProc;\r
1511         psp[0].pszTitle = MSGJPN127;\r
1512         psp[0].lParam = 0;\r
1513         psp[0].pfnCallback = NULL;\r
1514 \r
1515         psp[1].dwSize = sizeof(PROPSHEETPAGE);\r
1516         psp[1].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1517         psp[1].hInstance = GetFtpInst();\r
1518         psp[1].pszTemplate = MAKEINTRESOURCE(hset_adv_dlg);\r
1519         psp[1].pszIcon = NULL;\r
1520         psp[1].pfnDlgProc = AdvSettingProc;\r
1521         psp[1].pszTitle = MSGJPN128;\r
1522         psp[1].lParam = 0;\r
1523         psp[1].pfnCallback = NULL;\r
1524 \r
1525         psp[2].dwSize = sizeof(PROPSHEETPAGE);\r
1526         psp[2].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1527         psp[2].hInstance = GetFtpInst();\r
1528         psp[2].pszTemplate = MAKEINTRESOURCE(hset_code_dlg);\r
1529         psp[2].pszIcon = NULL;\r
1530         psp[2].pfnDlgProc = CodeSettingProc;\r
1531         psp[2].pszTitle = MSGJPN129;\r
1532         psp[2].lParam = 0;\r
1533         psp[2].pfnCallback = NULL;\r
1534 \r
1535         psp[3].dwSize = sizeof(PROPSHEETPAGE);\r
1536         psp[3].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1537         psp[3].hInstance = GetFtpInst();\r
1538         psp[3].pszTemplate = MAKEINTRESOURCE(hset_dialup_dlg);\r
1539         psp[3].pszIcon = NULL;\r
1540         psp[3].pfnDlgProc = DialupSettingProc;\r
1541         psp[3].pszTitle = MSGJPN130;\r
1542         psp[3].lParam = 0;\r
1543         psp[3].pfnCallback = NULL;\r
1544 \r
1545         psp[4].dwSize = sizeof(PROPSHEETPAGE);\r
1546         psp[4].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1547         psp[4].hInstance = GetFtpInst();\r
1548         psp[4].pszTemplate = MAKEINTRESOURCE(hset_adv2_dlg);\r
1549         psp[4].pszIcon = NULL;\r
1550         psp[4].pfnDlgProc = Adv2SettingProc;\r
1551         psp[4].pszTitle = MSGJPN131;\r
1552         psp[4].lParam = 0;\r
1553         psp[4].pfnCallback = NULL;\r
1554 \r
1555         psh.dwSize = sizeof(PROPSHEETHEADER);\r
1556         psh.dwFlags = PSH_HASHELP | PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE;\r
1557         psh.hwndParent = hDlg;\r
1558         psh.hInstance = GetFtpInst();\r
1559         psh.pszIcon = NULL;\r
1560         psh.pszCaption = MSGJPN132;\r
1561         psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);\r
1562         psh.nStartPage = 0;\r
1563         psh.ppsp = (LPCPROPSHEETPAGE)&psp;\r
1564         psh.pfnCallback = NULL;\r
1565 \r
1566         Apply = NO;\r
1567         PropertySheet(&psh);\r
1568 \r
1569         return(Apply);\r
1570 }\r
1571 \r
1572 \r
1573 /*----- \8aî\96{\90Ý\92è\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N --------------------------------------\r
1574 *\r
1575 *       Parameter\r
1576 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1577 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
1578 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
1579 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
1580 *\r
1581 *       Return Value\r
1582 *               BOOL TRUE/FALSE\r
1583 *----------------------------------------------------------------------------*/\r
1584 \r
1585 static BOOL CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1586 {\r
1587         long wStyle;\r
1588         char Tmp[FMAX_PATH+1];\r
1589         NMHDR *pnmhdr;\r
1590 \r
1591         switch (iMessage)\r
1592         {\r
1593                 case WM_INITDIALOG :\r
1594                         SendDlgItemMessage(hDlg, HSET_HOST, EM_LIMITTEXT, HOST_NAME_LEN, 0);\r
1595                         SendDlgItemMessage(hDlg, HSET_ADRS, EM_LIMITTEXT, HOST_ADRS_LEN, 0);\r
1596                         SendDlgItemMessage(hDlg, HSET_USER, EM_LIMITTEXT, USER_NAME_LEN, 0);\r
1597                         SendDlgItemMessage(hDlg, HSET_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);\r
1598                         SendDlgItemMessage(hDlg, HSET_LOCAL, EM_LIMITTEXT, INIT_DIR_LEN, 0);\r
1599                         SendDlgItemMessage(hDlg, HSET_REMOTE, EM_LIMITTEXT, INIT_DIR_LEN, 0);\r
1600                         SendDlgItemMessage(hDlg, HSET_HOST, WM_SETTEXT, 0, (LPARAM)TmpHost.HostName);\r
1601                         SendDlgItemMessage(hDlg, HSET_ADRS, WM_SETTEXT, 0, (LPARAM)TmpHost.HostAdrs);\r
1602                         SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)TmpHost.UserName);\r
1603                         SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)TmpHost.PassWord);\r
1604                         SendDlgItemMessage(hDlg, HSET_LOCAL, WM_SETTEXT, 0, (LPARAM)TmpHost.LocalInitDir);\r
1605                         SendDlgItemMessage(hDlg, HSET_REMOTE, WM_SETTEXT, 0, (LPARAM)TmpHost.RemoteInitDir);\r
1606                         SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_SETCHECK, TmpHost.Anonymous, 0);\r
1607                         SendDlgItemMessage(hDlg, HSET_LASTDIR, BM_SETCHECK, TmpHost.LastDir, 0);\r
1608                         if(AskConnecting() == NO)\r
1609                                 EnableWindow(GetDlgItem(hDlg, HSET_REMOTE_CUR), FALSE);\r
1610                         return(TRUE);\r
1611 \r
1612                 case WM_NOTIFY:\r
1613                         pnmhdr = (NMHDR FAR *)lParam;\r
1614                         switch(pnmhdr->code)\r
1615                         {\r
1616                                 case PSN_APPLY :\r
1617                                         SendDlgItemMessage(hDlg, HSET_HOST, WM_GETTEXT, HOST_NAME_LEN+1, (LPARAM)TmpHost.HostName);\r
1618                                         SendDlgItemMessage(hDlg, HSET_ADRS, WM_GETTEXT, HOST_ADRS_LEN+1, (LPARAM)TmpHost.HostAdrs);\r
1619                                         RemoveTailingSpaces(TmpHost.HostAdrs);\r
1620                                         SendDlgItemMessage(hDlg, HSET_USER, WM_GETTEXT, USER_NAME_LEN+1, (LPARAM)TmpHost.UserName);\r
1621                                         SendDlgItemMessage(hDlg, HSET_PASS, WM_GETTEXT, PASSWORD_LEN+1, (LPARAM)TmpHost.PassWord);\r
1622                                         SendDlgItemMessage(hDlg, HSET_LOCAL, WM_GETTEXT, INIT_DIR_LEN+1, (LPARAM)TmpHost.LocalInitDir);\r
1623                                         SendDlgItemMessage(hDlg, HSET_REMOTE, WM_GETTEXT, INIT_DIR_LEN+1, (LPARAM)TmpHost.RemoteInitDir);\r
1624                                         TmpHost.Anonymous = SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_GETCHECK, 0, 0);\r
1625                                         TmpHost.LastDir = SendDlgItemMessage(hDlg, HSET_LASTDIR, BM_GETCHECK, 0, 0);\r
1626                                         if((strlen(TmpHost.HostName) == 0) && (strlen(TmpHost.HostAdrs) > 0))\r
1627                                         {\r
1628                                                 memset(TmpHost.HostName, NUL, HOST_NAME_LEN+1);\r
1629                                                 strncpy(TmpHost.HostName, TmpHost.HostAdrs, HOST_NAME_LEN);\r
1630                                         }\r
1631                                         else if((strlen(TmpHost.HostName) > 0) && (strlen(TmpHost.HostAdrs) == 0))\r
1632                                         {\r
1633                                                 memset(TmpHost.HostAdrs, NUL, HOST_ADRS_LEN+1);\r
1634                                                 strncpy(TmpHost.HostAdrs, TmpHost.HostName, HOST_ADRS_LEN);\r
1635                                         }\r
1636                                         Apply = YES;\r
1637                                         break;\r
1638 \r
1639                                 case PSN_RESET :\r
1640                                         break;\r
1641 \r
1642                                 case PSN_HELP :\r
1643                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000028);\r
1644                                         break;\r
1645                         }\r
1646                         break;\r
1647 \r
1648                 case WM_COMMAND :\r
1649                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1650                         {\r
1651                                 case HSET_LOCAL_BR :\r
1652                                         if(SelectDir(hDlg, TmpHost.LocalInitDir, INIT_DIR_LEN) == TRUE)\r
1653                                                 SendDlgItemMessage(hDlg, HSET_LOCAL, WM_SETTEXT, 0, (LPARAM)TmpHost.LocalInitDir);\r
1654                                         break;\r
1655 \r
1656                                 case HSET_REMOTE_CUR :\r
1657                                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1658                                                 SendDlgItemMessage(hDlg, HSET_REMOTE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1659                                         break;\r
1660 \r
1661                                 case HSET_ANONYMOUS :\r
1662                                         if(SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_GETCHECK, 0, 0) == 1)\r
1663                                         {\r
1664                                                 SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)"anonymous");\r
1665                                                 wStyle = GetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE);\r
1666                                                 wStyle &= ~ES_PASSWORD;\r
1667                                                 SetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE, wStyle);\r
1668                                                 SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)UserMailAdrs);\r
1669                                         }\r
1670                                         else\r
1671                                         {\r
1672                                                 SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)"");\r
1673                                                 wStyle = GetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE);\r
1674                                                 wStyle |= ES_PASSWORD;\r
1675                                                 SetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE, wStyle);\r
1676                                                 SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)"");\r
1677                                         }\r
1678                                         break;\r
1679                         }\r
1680             return(TRUE);\r
1681         }\r
1682         return(FALSE);\r
1683 }\r
1684 \r
1685 \r
1686 /*----- \8ag\92£\90Ý\92è\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N --------------------------------------\r
1687 *\r
1688 *       Parameter\r
1689 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1690 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
1691 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
1692 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
1693 *\r
1694 *       Return Value\r
1695 *               BOOL TRUE/FALSE\r
1696 *----------------------------------------------------------------------------*/\r
1697 \r
1698 static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1699 {\r
1700         NMHDR *pnmhdr;\r
1701         char Tmp[20];\r
1702         int i;\r
1703 \r
1704         switch (iMessage)\r
1705         {\r
1706                 case WM_INITDIALOG :\r
1707                         SendDlgItemMessage(hDlg, HSET_PORT, EM_LIMITTEXT, 5, 0);\r
1708                         sprintf(Tmp, "%d", TmpHost.Port);\r
1709                         SendDlgItemMessage(hDlg, HSET_PORT, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1710                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, EM_LIMITTEXT, ACCOUNT_LEN, 0);\r
1711                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, WM_SETTEXT, 0, (LPARAM)TmpHost.Account);\r
1712                         SendDlgItemMessage(hDlg, HSET_PASV, BM_SETCHECK, TmpHost.Pasv, 0);\r
1713                         SendDlgItemMessage(hDlg, HSET_FIREWALL, BM_SETCHECK, TmpHost.FireWall, 0);\r
1714                         SendDlgItemMessage(hDlg, HSET_SYNCMOVE, BM_SETCHECK, TmpHost.SyncMove, 0);\r
1715                         for(i = -12; i <= 12; i++)\r
1716                         {\r
1717                                 if(i == 0)\r
1718                                         sprintf(Tmp, "GMT");\r
1719                                 else if(i == 9)\r
1720                                         sprintf(Tmp, MSGJPN133, i);\r
1721                                 else\r
1722                                         sprintf(Tmp, "GMT%+02d:00", i);\r
1723                                 SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_ADDSTRING, 0, (LPARAM)Tmp);\r
1724                         }\r
1725                         SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_SETCURSEL, TmpHost.TimeZone+12, 0);\r
1726 \r
1727                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN134);\r
1728                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN135);\r
1729                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN136);\r
1730                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN137);\r
1731                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN138);\r
1732                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_SETCURSEL, TmpHost.Security, 0);\r
1733                         SendDlgItemMessage(hDlg, HSET_INITCMD, EM_LIMITTEXT, INITCMD_LEN, 0);\r
1734                         SendDlgItemMessage(hDlg, HSET_INITCMD, WM_SETTEXT, 0, (LPARAM)TmpHost.InitCmd);\r
1735                         return(TRUE);\r
1736 \r
1737                 case WM_NOTIFY:\r
1738                         pnmhdr = (NMHDR FAR *)lParam;\r
1739                         switch(pnmhdr->code)\r
1740                         {\r
1741                                 case PSN_APPLY :\r
1742                                         TmpHost.Pasv = SendDlgItemMessage(hDlg, HSET_PASV, BM_GETCHECK, 0, 0);\r
1743                                         TmpHost.FireWall = SendDlgItemMessage(hDlg, HSET_FIREWALL, BM_GETCHECK, 0, 0);\r
1744                                         TmpHost.SyncMove = SendDlgItemMessage(hDlg, HSET_SYNCMOVE, BM_GETCHECK, 0, 0);\r
1745                                         SendDlgItemMessage(hDlg, HSET_PORT, WM_GETTEXT, 5+1, (LPARAM)Tmp);\r
1746                                         TmpHost.Port = atoi(Tmp);\r
1747                                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, WM_GETTEXT, ACCOUNT_LEN+1, (LPARAM)TmpHost.Account);\r
1748                                         TmpHost.TimeZone = SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_GETCURSEL, 0, 0) - 12;\r
1749                                         TmpHost.Security = SendDlgItemMessage(hDlg, HSET_SECURITY, CB_GETCURSEL, 0, 0);\r
1750                                         SendDlgItemMessage(hDlg, HSET_INITCMD, WM_GETTEXT, INITCMD_LEN+1, (LPARAM)TmpHost.InitCmd);\r
1751                                         Apply = YES;\r
1752                                         break;\r
1753 \r
1754                                 case PSN_RESET :\r
1755                                         break;\r
1756 \r
1757                                 case PSN_HELP :\r
1758                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000029);\r
1759                                         break;\r
1760                         }\r
1761                         break;\r
1762 \r
1763                 case WM_COMMAND :\r
1764                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1765                         {\r
1766                                 case HSET_PORT_NOR :\r
1767                                         sprintf(Tmp, "%d", PORT_NOR);\r
1768                                         SendDlgItemMessage(hDlg, HSET_PORT, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1769                                         break;\r
1770                         }\r
1771                         return(TRUE);\r
1772         }\r
1773         return(FALSE);\r
1774 }\r
1775 \r
1776 \r
1777 /*----- \95\8e\9a\83R\81[\83h\90Ý\92è\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N --------------------------------\r
1778 *\r
1779 *       Parameter\r
1780 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1781 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
1782 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
1783 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
1784 *\r
1785 *       Return Value\r
1786 *               BOOL TRUE/FALSE\r
1787 *----------------------------------------------------------------------------*/\r
1788 \r
1789 static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1790 {\r
1791         NMHDR *pnmhdr;\r
1792 \r
1793         // UTF-8\91Î\89\9e\r
1794         static const RADIOBUTTON KanjiButton[] = {\r
1795                 { HSET_NO_CNV, KANJI_NOCNV },\r
1796                 { HSET_SJIS_CNV, KANJI_SJIS },\r
1797                 { HSET_JIS_CNV, KANJI_JIS },\r
1798                 { HSET_EUC_CNV, KANJI_EUC },\r
1799                 { HSET_UTF8N_CNV, KANJI_UTF8N }\r
1800         };\r
1801         #define KANJIBUTTONS    (sizeof(KanjiButton)/sizeof(RADIOBUTTON))\r
1802 \r
1803         static const RADIOBUTTON NameKanjiButton[] = {\r
1804                 { HSET_FN_AUTO_CNV, KANJI_AUTO },\r
1805                 { HSET_FN_SJIS_CNV, KANJI_SJIS },\r
1806                 { HSET_FN_JIS_CNV, KANJI_JIS },\r
1807                 { HSET_FN_EUC_CNV, KANJI_EUC },\r
1808                 { HSET_FN_SMH_CNV, KANJI_SMB_HEX },\r
1809                 { HSET_FN_SMC_CNV, KANJI_SMB_CAP },\r
1810                 { HSET_FN_UTF8N_CNV, KANJI_UTF8N }              // UTF-8N\91Î\89\9e\r
1811         };\r
1812         #define NAMEKANJIBUTTONS        (sizeof(NameKanjiButton)/sizeof(RADIOBUTTON))\r
1813 \r
1814         switch (iMessage)\r
1815         {\r
1816                 case WM_INITDIALOG :\r
1817                         SetRadioButtonByValue(hDlg, TmpHost.KanjiCode, KanjiButton, KANJIBUTTONS);\r
1818                         SendDlgItemMessage(hDlg, HSET_HANCNV, BM_SETCHECK, TmpHost.KanaCnv, 0);\r
1819                         SetRadioButtonByValue(hDlg, TmpHost.NameKanjiCode, NameKanjiButton, NAMEKANJIBUTTONS);\r
1820                         SendDlgItemMessage(hDlg, HSET_FN_HANCNV, BM_SETCHECK, TmpHost.NameKanaCnv, 0);\r
1821                         return(TRUE);\r
1822 \r
1823                 case WM_NOTIFY:\r
1824                         pnmhdr = (NMHDR FAR *)lParam;\r
1825                         switch(pnmhdr->code)\r
1826                         {\r
1827                                 case PSN_APPLY :\r
1828                                         TmpHost.KanjiCode = AskRadioButtonValue(hDlg, KanjiButton, KANJIBUTTONS);\r
1829                                         TmpHost.KanaCnv = SendDlgItemMessage(hDlg, HSET_HANCNV, BM_GETCHECK, 0, 0);\r
1830                                         TmpHost.NameKanjiCode = AskRadioButtonValue(hDlg, NameKanjiButton, NAMEKANJIBUTTONS);\r
1831                                         TmpHost.NameKanaCnv = SendDlgItemMessage(hDlg, HSET_FN_HANCNV, BM_GETCHECK, 0, 0);\r
1832                                         Apply = YES;\r
1833                                         break;\r
1834 \r
1835                                 case PSN_RESET :\r
1836                                         break;\r
1837 \r
1838                                 case PSN_HELP :\r
1839                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000030);\r
1840                                         break;\r
1841                         }\r
1842                         break;\r
1843 \r
1844                 case WM_COMMAND :\r
1845                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1846                         {\r
1847                                 case HSET_JIS_CNV :\r
1848                                 case HSET_EUC_CNV :\r
1849                                         EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), TRUE);\r
1850                                         break;\r
1851 \r
1852                                 // UTF-8\91Î\89\9e\r
1853                                 case HSET_NO_CNV :\r
1854                                 case HSET_SJIS_CNV :\r
1855                                 case HSET_UTF8N_CNV :\r
1856                                         EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), FALSE);\r
1857                                         break;\r
1858 \r
1859                                 case HSET_FN_JIS_CNV :\r
1860                                 case HSET_FN_EUC_CNV :\r
1861                                         EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), TRUE);\r
1862                                         break;\r
1863 \r
1864                                 case HSET_FN_AUTO_CNV :\r
1865                                 case HSET_FN_SJIS_CNV :\r
1866                                 case HSET_FN_SMH_CNV :\r
1867                                 case HSET_FN_SMC_CNV :\r
1868                                 case HSET_FN_UTF8N_CNV :        // UTF-8N\91Î\89\9e\r
1869                                         EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), FALSE);\r
1870                                         break;\r
1871                         }\r
1872                         return(TRUE);\r
1873         }\r
1874         return(FALSE);\r
1875 }\r
1876 \r
1877 \r
1878 /*----- \83_\83C\83A\83\8b\83A\83b\83v\90Ý\92è\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N ----------------------------\r
1879 *\r
1880 *       Parameter\r
1881 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1882 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
1883 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
1884 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
1885 *\r
1886 *       Return Value\r
1887 *               BOOL TRUE/FALSE\r
1888 *----------------------------------------------------------------------------*/\r
1889 \r
1890 static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1891 {\r
1892         NMHDR *pnmhdr;\r
1893 \r
1894         switch (iMessage)\r
1895         {\r
1896                 case WM_INITDIALOG :\r
1897                         SendDlgItemMessage(hDlg, HSET_DIALUP, BM_SETCHECK, TmpHost.Dialup, 0);\r
1898                         SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_SETCHECK, TmpHost.DialupAlways, 0);\r
1899                         SendDlgItemMessage(hDlg, HSET_DIALNOTIFY, BM_SETCHECK, TmpHost.DialupNotify, 0);\r
1900                         if(AskRasUsable() == NO)\r
1901                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUP), FALSE);\r
1902                         if((TmpHost.DialupAlways == NO) || (AskRasUsable() == NO))\r
1903                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1904                         if((TmpHost.Dialup == NO) || (AskRasUsable() == NO))\r
1905                         {\r
1906                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), FALSE);\r
1907                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), FALSE);\r
1908                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1909                         }\r
1910                         SetRasEntryToComboBox(hDlg, HSET_DIALENTRY, TmpHost.DialEntry);\r
1911                         return(TRUE);\r
1912 \r
1913                 case WM_NOTIFY:\r
1914                         pnmhdr = (NMHDR FAR *)lParam;\r
1915                         switch(pnmhdr->code)\r
1916                         {\r
1917                                 case PSN_APPLY :\r
1918                                         TmpHost.Dialup = SendDlgItemMessage(hDlg, HSET_DIALUP, BM_GETCHECK, 0, 0);\r
1919                                         TmpHost.DialupAlways = SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_GETCHECK, 0, 0);\r
1920                                         TmpHost.DialupNotify = SendDlgItemMessage(hDlg, HSET_DIALNOTIFY, BM_GETCHECK, 0, 0);\r
1921                                         SendDlgItemMessage(hDlg, HSET_DIALENTRY, WM_GETTEXT, RAS_NAME_LEN+1, (LPARAM)TmpHost.DialEntry);\r
1922                                         Apply = YES;\r
1923                                         break;\r
1924 \r
1925                                 case PSN_RESET :\r
1926                                         break;\r
1927 \r
1928                                 case PSN_HELP :\r
1929                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000031);\r
1930                                         break;\r
1931                         }\r
1932                         break;\r
1933 \r
1934                 case WM_COMMAND :\r
1935                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1936                         {\r
1937                                 case HSET_DIALUP :\r
1938                                         if(SendDlgItemMessage(hDlg, HSET_DIALUP, BM_GETCHECK, 0, 0) == 0)\r
1939                                         {\r
1940                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), FALSE);\r
1941                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), FALSE);\r
1942                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1943                                                 break;\r
1944                                         }\r
1945                                         else\r
1946                                         {\r
1947                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), TRUE);\r
1948                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), TRUE);\r
1949                                         }\r
1950                                         /* \82±\82±\82Ébreak\82Í\82È\82¢ */\r
1951 \r
1952                                 case HSET_DIALUSETHIS :\r
1953                                         if(SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_GETCHECK, 0, 0) == 0)\r
1954                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1955                                         else\r
1956                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), TRUE);\r
1957                                         break;\r
1958                         }\r
1959                         return(TRUE);\r
1960         }\r
1961         return(FALSE);\r
1962 }\r
1963 \r
1964 \r
1965 /*----- \8d\82\93x\90Ý\92è\83E\83C\83\93\83h\83E\82Ì\83R\81[\83\8b\83o\83b\83N --------------------------------------\r
1966 *\r
1967 *       Parameter\r
1968 *               HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
1969 *               UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
1970 *               WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
1971 *               LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
1972 *\r
1973 *       Return Value\r
1974 *               BOOL TRUE/FALSE\r
1975 *----------------------------------------------------------------------------*/\r
1976 \r
1977 static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1978 {\r
1979         NMHDR *pnmhdr;\r
1980         int Num;\r
1981 \r
1982         switch (iMessage)\r
1983         {\r
1984                 case WM_INITDIALOG :\r
1985                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, EM_LIMITTEXT, CHMOD_CMD_LEN, 0);\r
1986                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_SETTEXT, 0, (LPARAM)TmpHost.ChmodCmd);\r
1987                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, EM_LIMITTEXT, NLST_NAME_LEN, 0);\r
1988                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_SETTEXT, 0, (LPARAM)TmpHost.LsName);\r
1989                         SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_SETCHECK, TmpHost.ListCmdOnly, 0);\r
1990                         if(TmpHost.ListCmdOnly == YES)\r
1991                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
1992                         SendDlgItemMessage(hDlg, HSET_NLST_R, BM_SETCHECK, TmpHost.UseNLST_R, 0);\r
1993                         SendDlgItemMessage(hDlg, HSET_FULLPATH, BM_SETCHECK, TmpHost.NoFullPath, 0);\r
1994                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN139);\r
1995                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN140);\r
1996                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN141);\r
1997                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN142);\r
1998                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN143);\r
1999                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN144);\r
2000                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN289);\r
2001                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN295);\r
2002                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_SETCURSEL, TmpHost.HostType, 0);\r
2003                         if(TmpHost.HostType == 2)\r
2004                         {\r
2005                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2006                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), FALSE);\r
2007                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), FALSE);\r
2008                         }\r
2009                         return(TRUE);\r
2010 \r
2011                 case WM_NOTIFY:\r
2012                         pnmhdr = (NMHDR FAR *)lParam;\r
2013                         switch(pnmhdr->code)\r
2014                         {\r
2015                                 case PSN_APPLY :\r
2016                                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_GETTEXT, CHMOD_CMD_LEN+1, (LPARAM)TmpHost.ChmodCmd);\r
2017                                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_GETTEXT, NLST_NAME_LEN+1, (LPARAM)TmpHost.LsName);\r
2018                                         TmpHost.ListCmdOnly = SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_GETCHECK, 0, 0);\r
2019                                         TmpHost.UseNLST_R = SendDlgItemMessage(hDlg, HSET_NLST_R, BM_GETCHECK, 0, 0);\r
2020                                         TmpHost.NoFullPath = SendDlgItemMessage(hDlg, HSET_FULLPATH, BM_GETCHECK, 0, 0);\r
2021                                         TmpHost.HostType = SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_GETCURSEL, 0, 0);\r
2022                                         Apply = YES;\r
2023                                         break;\r
2024 \r
2025                                 case PSN_RESET :\r
2026                                         break;\r
2027 \r
2028                                 case PSN_HELP :\r
2029                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000032);\r
2030                                         break;\r
2031                         }\r
2032                         break;\r
2033 \r
2034                 case WM_COMMAND :\r
2035                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2036                         {\r
2037                                 case HSET_CHMOD_NOR :\r
2038                                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_SETTEXT, 0, (LPARAM)CHMOD_CMD_NOR);\r
2039                                         break;\r
2040 \r
2041                                 case HSET_LS_FNAME_NOR :\r
2042                                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_SETTEXT, 0, (LPARAM)LS_FNAME);\r
2043                                         break;\r
2044 \r
2045                                 case HSET_LISTCMD :\r
2046                                         if(SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_GETCHECK, 0, 0) == 0)\r
2047                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), TRUE);\r
2048                                         else\r
2049                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2050                                         break;\r
2051 \r
2052                                 case HSET_HOSTTYPE :\r
2053                                         Num = SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_GETCURSEL, 0, 0);\r
2054                                         if(Num == 2)\r
2055                                         {\r
2056                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2057                                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), FALSE);\r
2058                                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), FALSE);\r
2059                                         }\r
2060                                         else\r
2061                                         {\r
2062                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), TRUE);\r
2063                                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), TRUE);\r
2064                                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), TRUE);\r
2065                                         }\r
2066                                         break;\r
2067                         }\r
2068                         return(TRUE);\r
2069         }\r
2070         return(FALSE);\r
2071 }\r
2072 \r
2073 \r