OSDN Git Service

Add protection for password edit controls.
[ffftp/ffftp.git] / bookmark.c
1 /*=============================================================================\r
2 *\r
3 *                                                               ブックマーク\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 // UTF-8対応\r
31 //#define WINVER 0x400\r
32 \r
33 #define STRICT\r
34 // IPv6対応\r
35 #include <winsock2.h>\r
36 #include <windows.h>\r
37 #include <stdio.h>\r
38 #include <stdlib.h>\r
39 #include <string.h>\r
40 #include <mbstring.h>\r
41 #include <malloc.h>\r
42 #include <windowsx.h>\r
43 #include <commctrl.h>\r
44 \r
45 #include "common.h"\r
46 #include "resource.h"\r
47 \r
48 #include <htmlhelp.h>\r
49 #include "helpid.h"\r
50 \r
51 // UTF-8対応\r
52 #undef __MBSWRAPPER_H__\r
53 #include "mbswrapper.h"\r
54 \r
55 \r
56 /*===== プロトタイプ =====*/\r
57 \r
58 static int AddBookMark(char *Path);\r
59 static int GetBothPath(char *Str, char **Path1, char **Path2);\r
60 // 64ビット対応\r
61 //static BOOL CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
62 //static BOOL CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
63 static INT_PTR CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
64 static INT_PTR CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
65 \r
66 /*===== 外部参照 =====*/\r
67 \r
68 extern HWND hHelpWin;\r
69 \r
70 /* 設定値 */\r
71 extern HFONT ListFont;          /* リストボックスのフォント */\r
72 extern SIZE BmarkDlgSize;\r
73 \r
74 \r
75 \r
76 /*----- ブックマークをクリアする ----------------------------------------------\r
77 *\r
78 *       Parameter\r
79 *               なし\r
80 *\r
81 *       Return Value\r
82 *               なし\r
83 *----------------------------------------------------------------------------*/\r
84 \r
85 void ClearBookMark(void)\r
86 {\r
87         HMENU hMenu;\r
88 \r
89         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
90         while(GetMenuItemCount(hMenu) > DEFAULT_BMARK_ITEM)\r
91                 DeleteMenu(hMenu, DEFAULT_BMARK_ITEM, MF_BYPOSITION);\r
92         return;\r
93 }\r
94 \r
95 \r
96 /*----- カレントディレクトリをブックマークに追加 ------------------------------\r
97 *\r
98 *       Parameter\r
99 *               int Win : ウインドウ番号 (WIN_xxx)\r
100 *\r
101 *       Return Value\r
102 *               なし\r
103 *----------------------------------------------------------------------------*/\r
104 \r
105 void AddCurDirToBookMark(int Win)\r
106 {\r
107         char Buf[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
108 \r
109         if(Win == WIN_LOCAL)\r
110         {\r
111                 strcpy(Buf, BMARK_MARK_LOCAL);\r
112                 AskLocalCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
113         }\r
114         else if(Win == WIN_REMOTE)\r
115         {\r
116                 strcpy(Buf, BMARK_MARK_REMOTE);\r
117                 AskRemoteCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
118         }\r
119         else\r
120         {\r
121                 strcpy(Buf, BMARK_MARK_BOTH);\r
122                 AskLocalCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
123                 strcat(Buf, BMARK_SEP);\r
124                 AskRemoteCurDir(Buf + strlen(Buf), FMAX_PATH);\r
125         }\r
126         AddBookMark(Buf);\r
127         return;\r
128 }\r
129 \r
130 \r
131 /*----- ブックマークにパスを登録する ------------------------------------------\r
132 *\r
133 *       Parameter\r
134 *               char *Path : パス名\r
135 *\r
136 *       Return Value\r
137 *               int ステータス\r
138 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
139 *----------------------------------------------------------------------------*/\r
140 \r
141 static int AddBookMark(char *Path)\r
142 {\r
143         HMENU hMenu;\r
144         int MarkID;\r
145         int Sts;\r
146 \r
147         Sts = FFFTP_FAIL;\r
148         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
149         MarkID = (GetMenuItemCount(hMenu) - DEFAULT_BMARK_ITEM) + MENU_BMARK_TOP;\r
150         if(AppendMenu(hMenu, MF_STRING, MarkID, Path) == TRUE)\r
151                 Sts = FFFTP_SUCCESS;\r
152         return(Sts);\r
153 }\r
154 \r
155 \r
156 /*----- 指定のIDを持つブックマークのパスを返す --------------------------------\r
157 *\r
158 *       Parameter\r
159 *               int MarkID : ID\r
160 *               char *Local : ローカル側のパスを返すバッファ\r
161 *               char *Remote : リモート側のパスを返すバッファ\r
162 *               int Max : バッファのサイズ\r
163 *\r
164 *       Return Value\r
165 *               int ステータス (BMARK_TYPE_xxx)\r
166 *----------------------------------------------------------------------------*/\r
167 \r
168 int AskBookMarkText(int MarkID, char *Local, char *Remote, int Max)\r
169 {\r
170         HMENU hMenu;\r
171         MENUITEMINFO mInfo;\r
172         int Sts;\r
173         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
174         char *Path1;\r
175         char *Path2;\r
176         int Num;\r
177 \r
178         memset(Local, NUL, Max);\r
179         memset(Remote, NUL, Max);\r
180 \r
181         Sts = BMARK_TYPE_NONE;\r
182         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
183 \r
184         mInfo.cbSize = sizeof(MENUITEMINFO);\r
185         mInfo.fMask = MIIM_TYPE;\r
186         mInfo.dwTypeData = Tmp;\r
187         mInfo.cch = BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN;\r
188         if(GetMenuItemInfo(hMenu, MarkID, FALSE, &mInfo) == TRUE)\r
189         {\r
190                 Num = GetBothPath(Tmp, &Path1, &Path2);\r
191                 if(strncmp(Tmp, BMARK_MARK_LOCAL, BMARK_MARK_LEN) == 0)\r
192                 {\r
193                         Sts = BMARK_TYPE_LOCAL;\r
194                         strncpy(Local, Path1, Max-1);\r
195                 }\r
196                 else if(strncmp(Tmp, BMARK_MARK_REMOTE, BMARK_MARK_LEN) == 0)\r
197                 {\r
198                         Sts = BMARK_TYPE_REMOTE;\r
199                         strncpy(Remote, Path1, Max-1);\r
200                 }\r
201                 else if(strncmp(Tmp, BMARK_MARK_BOTH, BMARK_MARK_LEN) == 0)\r
202                 {\r
203                         if(Num == 2)\r
204                         {\r
205                                 strncpy(Local, Path1, Max-1);\r
206                                 strncpy(Remote, Path2, Max-1);\r
207                                 Sts = BMARK_TYPE_BOTH;\r
208                         }\r
209                 }\r
210         }\r
211         return(Sts);\r
212 }\r
213 \r
214 \r
215 /*----- ブックマークの文字列から2つのパスを取り出す --------------------------\r
216 *\r
217 *       Parameter\r
218 *               char *Str : 文字列\r
219 *               char **Local : ローカル側のパスの先頭を返すワーク\r
220 *               char **Remote : リモート側のパスの先頭を返すワーク\r
221 *\r
222 *       Return Value\r
223 *               int パスの個数 (1 or 2)\r
224 *\r
225 *       Note\r
226 *               Strの内容を書き換える\r
227 *----------------------------------------------------------------------------*/\r
228 \r
229 static int GetBothPath(char *Str, char **Path1, char **Path2)\r
230 {\r
231         char *Pos;\r
232         int Ret;\r
233 \r
234         Ret = 1;\r
235         *Path1 = Str + BMARK_MARK_LEN;\r
236 \r
237         Pos = _mbsstr(Str, BMARK_SEP);\r
238         if(Pos != NULL)\r
239         {\r
240                 Ret = 2;\r
241                 *Pos = NUL;\r
242                 *Path2 = Pos + BMARK_SEP_LEN;\r
243         }\r
244         return(Ret);\r
245 }\r
246 \r
247 \r
248 /*----- ブックマークを接続中のホストリストに保存する --------------------------\r
249 *\r
250 *       Parameter\r
251 *               なし\r
252 *\r
253 *       Return Value\r
254 *               なし\r
255 *----------------------------------------------------------------------------*/\r
256 \r
257 void SaveBookMark(void)\r
258 {\r
259         HMENU hMenu;\r
260         MENUITEMINFO mInfo;\r
261         int i;\r
262         int Cnt;\r
263         char *Buf;\r
264         char *Pos;\r
265         int Len;\r
266         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
267         int CurHost;\r
268 \r
269         if(AskConnecting() == YES)\r
270         {\r
271                 if((CurHost = AskCurrentHost()) != HOSTNUM_NOENTRY)\r
272                 {\r
273                         if((Buf = malloc(BOOKMARK_SIZE)) != NULL)\r
274                         {\r
275                                 hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
276 \r
277                                 Pos = Buf;\r
278                                 Len = 0;\r
279                                 Cnt = GetMenuItemCount(hMenu);\r
280                                 for(i = DEFAULT_BMARK_ITEM; i < Cnt; i++)\r
281                                 {\r
282                                         mInfo.cbSize = sizeof(MENUITEMINFO);\r
283                                         mInfo.fMask = MIIM_TYPE;\r
284                                         mInfo.dwTypeData = Tmp;\r
285                                         mInfo.cch = FMAX_PATH;\r
286                                         if(GetMenuItemInfo(hMenu, i, TRUE, &mInfo) == TRUE)\r
287                                         {\r
288                                                 if(Len + strlen(Tmp) + 2 <= BOOKMARK_SIZE)\r
289                                                 {\r
290                                                         strcpy(Pos, Tmp);\r
291                                                         Pos += strlen(Tmp) + 1;\r
292                                                         Len += strlen(Tmp) + 1;\r
293                                                 }\r
294                                         }\r
295                                 }\r
296 \r
297                                 if(Pos == Buf)\r
298                                 {\r
299                                         memset(Buf, NUL, 2);\r
300                                         Len = 2;\r
301                                 }\r
302                                 else\r
303                                 {\r
304                                         *Pos = NUL;\r
305                                         Len++;\r
306                                 }\r
307 \r
308                                 SetHostBookMark(CurHost, Buf, Len);\r
309 \r
310                                 free(Buf);\r
311                         }\r
312                 }\r
313         }\r
314         return;\r
315 }\r
316 \r
317 \r
318 /*----- ホストリストからブックマークを読み込む --------------------------------\r
319 *\r
320 *       Parameter\r
321 *               なし\r
322 *\r
323 *       Return Value\r
324 *               なし\r
325 *----------------------------------------------------------------------------*/\r
326 \r
327 void LoadBookMark(void)\r
328 {\r
329         char *Buf;\r
330         char *Pos;\r
331         int CurHost;\r
332         char Tmp[FMAX_PATH + BMARK_MARK_LEN + 1];\r
333 \r
334         if(AskConnecting() == YES)\r
335         {\r
336                 if((CurHost = AskCurrentHost()) != HOSTNUM_NOENTRY)\r
337                 {\r
338                         if((Buf = AskHostBookMark(CurHost)) != NULL)\r
339                         {\r
340                                 ClearBookMark();\r
341                                 Pos = Buf;\r
342                                 while(*Pos != NUL)\r
343                                 {\r
344                                         /* 旧フォーマットのための処理 */\r
345                                         /* (パスに"L"や"H"がついてない物) */\r
346                                         if((strncmp(Pos, BMARK_MARK_LOCAL, BMARK_MARK_LEN) != 0) &&\r
347                                            (strncmp(Pos, BMARK_MARK_REMOTE, BMARK_MARK_LEN) != 0) &&\r
348                                            (strncmp(Pos, BMARK_MARK_BOTH, BMARK_MARK_LEN) != 0))\r
349                                         {\r
350                                                 strcpy(Tmp, BMARK_MARK_REMOTE);\r
351                                                 strcat(Tmp, Pos);\r
352                                                 AddBookMark(Tmp);\r
353                                         }\r
354                                         else\r
355                                                 AddBookMark(Pos);\r
356 \r
357                                         Pos += strlen(Pos) + 1;\r
358                                 }\r
359                         }\r
360                 }\r
361         }\r
362         return;\r
363 }\r
364 \r
365 \r
366 /*----- ブックマーク編集ウインドウ --------------------------------------------\r
367 *\r
368 *       Parameter\r
369 *               なし\r
370 *\r
371 *       Return Value\r
372 *               ステータス (YES=実行/NO=取消)\r
373 *----------------------------------------------------------------------------*/\r
374 \r
375 int EditBookMark(void)\r
376 {\r
377         int Sts;\r
378 \r
379         Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(bmark_dlg), GetMainHwnd(), EditBookMarkProc);\r
380         return(Sts);\r
381 }\r
382 \r
383 \r
384 /*----- ブックマーク編集ウインドウのコールバック ------------------------------\r
385 *\r
386 *       Parameter\r
387 *               HWND hDlg : ウインドウハンドル\r
388 *               UINT message : メッセージ番号\r
389 *               WPARAM wParam : メッセージの WPARAM 引数\r
390 *               LPARAM lParam : メッセージの LPARAM 引数\r
391 *\r
392 *       Return Value\r
393 *               BOOL TRUE/FALSE\r
394 *----------------------------------------------------------------------------*/\r
395 \r
396 // 64ビット対応\r
397 //static BOOL CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
398 static INT_PTR CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
399 {\r
400         HMENU hMenu;\r
401         MENUITEMINFO mInfo;\r
402         int Cur;\r
403         int Max;\r
404         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
405 \r
406         static DIALOGSIZE DlgSize = {\r
407                 { BMARK_NEW, BMARK_SET, BMARK_DEL, BMARK_DOWN, BMARK_UP, IDHELP, BMARK_SIZEGRIP, -1 },\r
408                 { IDOK, BMARK_JUMP, BMARK_SIZEGRIP, -1 },\r
409                 { BMARK_LIST, -1 },\r
410                 { 0, 0 },\r
411                 { 0, 0 }\r
412         };\r
413 \r
414         switch (message)\r
415         {\r
416                 case WM_INITDIALOG :\r
417                         if(ListFont != NULL)\r
418                                 SendDlgItemMessage(hDlg, BMARK_LIST, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
419 \r
420                         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
421                         Max = GetMenuItemCount(hMenu);\r
422                         for(Cur = DEFAULT_BMARK_ITEM; Cur < Max; Cur++)\r
423                         {\r
424                                 mInfo.cbSize = sizeof(MENUITEMINFO);\r
425                                 mInfo.fMask = MIIM_TYPE;\r
426                                 mInfo.dwTypeData = Tmp;\r
427                                 mInfo.cch = FMAX_PATH;\r
428                                 if(GetMenuItemInfo(hMenu, Cur, TRUE, &mInfo) == TRUE)\r
429                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
430                         }\r
431                         DlgSizeInit(hDlg, &DlgSize, &BmarkDlgSize);\r
432                     return(TRUE);\r
433 \r
434                 case WM_COMMAND :\r
435                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
436                         {\r
437                                 case BMARK_JUMP :\r
438                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
439                                                 PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(Cur+MENU_BMARK_TOP, 0), 0);\r
440                                         /* ここに break はない */\r
441 \r
442                                 case IDCANCEL :\r
443                                 case IDOK :\r
444                                         ClearBookMark();\r
445                                         Max = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0);\r
446                                         for(Cur = 0; Cur < Max; Cur++)\r
447                                         {\r
448                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
449                                                 AddBookMark(Tmp);\r
450                                         }\r
451                                         AskDlgSize(hDlg, &DlgSize, &BmarkDlgSize);\r
452                                         EndDialog(hDlg, YES);\r
453                                         break;\r
454 \r
455                                 case BMARK_SET :\r
456                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
457                                         {\r
458                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
459                                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(bmark_edit_dlg), hDlg, BookMarkEditCallBack, (LPARAM)Tmp) == YES)\r
460                                                 {\r
461                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
462                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, Cur, (LPARAM)Tmp);\r
463                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
464                                                 }\r
465                                         }\r
466                                         break;\r
467 \r
468                                 case BMARK_NEW :\r
469                                         strcpy(Tmp, "");\r
470                                         if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(bmark_edit_dlg), hDlg, BookMarkEditCallBack, (LPARAM)Tmp) == YES)\r
471                                         {\r
472                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
473                                                 Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0) - 1;\r
474                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
475                                         }\r
476                                         break;\r
477 \r
478                                 case BMARK_DEL :\r
479                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
480                                         {\r
481                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
482                                                 if(Cur >= SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0))\r
483                                                         Cur = max1(0, SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0)-1);\r
484                                                 if(SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0) > 0)\r
485                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
486                                         }\r
487                                         break;\r
488 \r
489                                 case BMARK_UP :\r
490                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
491                                         {\r
492                                                 if(Cur > 0)\r
493                                                 {\r
494                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
495                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
496                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, --Cur, (LPARAM)Tmp);\r
497                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
498                                                 }\r
499                                         }\r
500                                         break;\r
501 \r
502                                 case BMARK_DOWN :\r
503                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
504                                         {\r
505                                                 if(Cur < SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0)-1)\r
506                                                 {\r
507                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
508                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
509                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, ++Cur, (LPARAM)Tmp);\r
510                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
511                                                 }\r
512                                         }\r
513                                         break;\r
514 \r
515                                 case IDHELP :\r
516                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000019);\r
517                                         break;\r
518                         }\r
519                         return(TRUE);\r
520 \r
521                 case WM_SIZING :\r
522                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
523                     return(TRUE);\r
524 \r
525         }\r
526     return(FALSE);\r
527 }\r
528 \r
529 \r
530 /*----- ブックマーク入力ダイアログのコールバック ------------------------------\r
531 *\r
532 *       Parameter\r
533 *               HWND hDlg : ウインドウハンドル\r
534 *               UINT message : メッセージ番号\r
535 *               WPARAM wParam : メッセージの WPARAM 引数\r
536 *               LPARAM lParam : メッセージの LPARAM 引数\r
537 *\r
538 *       Return Value\r
539 *               BOOL TRUE/FALSE\r
540 *----------------------------------------------------------------------------*/\r
541 \r
542 // 64ビット対応\r
543 //static BOOL CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
544 static INT_PTR CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
545 {\r
546         static char *Str;\r
547         char *Path1;\r
548         char *Path2;\r
549         char Local[FMAX_PATH+1];\r
550         char Remote[FMAX_PATH+1];\r
551         int Num;\r
552 \r
553         switch (iMessage)\r
554         {\r
555                 case WM_INITDIALOG :\r
556                         Str = (char *)lParam;\r
557                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, EM_LIMITTEXT, FMAX_PATH-1, 0);\r
558                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, EM_LIMITTEXT, FMAX_PATH-1, 0);\r
559                         if(strlen(Str) > BMARK_MARK_LEN)\r
560                         {\r
561                                 Num = GetBothPath(Str, &Path1, &Path2);\r
562                                 if(strncmp(Str, BMARK_MARK_LOCAL, BMARK_MARK_LEN) == 0)\r
563                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_SETTEXT, 0, (LPARAM)Path1);\r
564                                 else if(strncmp(Str, BMARK_MARK_REMOTE, BMARK_MARK_LEN) == 0)\r
565                                 {\r
566                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_SETTEXT, 0, (LPARAM)Path1);\r
567                                         /* ホスト側にカーソルを移動しておく */\r
568                                         SetFocus(GetDlgItem(hDlg, BEDIT_REMOTE));\r
569                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, EM_SETSEL, 0, -1);\r
570                                         return(FALSE);\r
571                                 }\r
572                                 else if((strncmp(Str, BMARK_MARK_BOTH, BMARK_MARK_LEN) == 0) && (Num == 2))\r
573                                 {\r
574                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_SETTEXT, 0, (LPARAM)Path1);\r
575                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_SETTEXT, 0, (LPARAM)Path2);\r
576                                 }\r
577                         }\r
578                         return(TRUE);\r
579 \r
580                 case WM_COMMAND :\r
581                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
582                         {\r
583                                 case IDOK :\r
584                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Local);\r
585                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Remote);\r
586                                         if(strlen(Local) > 0)\r
587                                         {\r
588                                                 if(strlen(Remote) > 0)\r
589                                                 {\r
590                                                         /* 両方 */\r
591                                                         strcpy(Str, BMARK_MARK_BOTH);\r
592                                                         strcat(Str, Local);\r
593                                                         strcat(Str, BMARK_SEP);\r
594                                                         strcat(Str, Remote);\r
595                                                 }\r
596                                                 else\r
597                                                 {\r
598                                                         /* ローカルのみ */\r
599                                                         strcpy(Str, BMARK_MARK_LOCAL);\r
600                                                         strcat(Str, Local);\r
601                                                 }\r
602                                                 EndDialog(hDlg, YES);\r
603                                         }\r
604                                         else if(strlen(Remote) > 0)\r
605                                         {\r
606                                                 /* ホストのみ */\r
607                                                 strcpy(Str, BMARK_MARK_REMOTE);\r
608                                                 strcat(Str, Remote);\r
609                                                 EndDialog(hDlg, YES);\r
610                                         }\r
611                                         else\r
612                                                 EndDialog(hDlg, NO);\r
613                                         break;\r
614 \r
615                                 case IDCANCEL :\r
616                                         EndDialog(hDlg, NO);\r
617                                         break;\r
618                         }\r
619             return(TRUE);\r
620         }\r
621         return(FALSE);\r
622 }\r
623 \r
624 \r