• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FFFTPのソースコードです。


Commit MetaInfo

Revision756eb24e756aa444a4f4bc2bfd2640d525ccdcb1 (tree)
Zeit2011-09-11 23:59:43
Autors_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

Fix bugs of UTF-8 to UTF-16 API bridge.
Add UIs for encryption.
Add support for FTP over Explicit SSL/TLS (OpenSSL is required).
Fix bugs of synchronization between threads.
Fix bugs of behavior caused by uninitialized variables.
Fix bugs of algorithm to wait for SOCKET signals.

Ändern Zusammenfassung

Diff

Binary files a/FFFTP.exe and b/FFFTP.exe differ
--- a/FFFTP.vc90.vcproj
+++ b/FFFTP.vc90.vcproj
@@ -335,6 +335,10 @@
335335 >
336336 </File>
337337 <File
338+ RelativePath=".\socketwrapper.c"
339+ >
340+ </File>
341+ <File
338342 RelativePath=".\statuswin.c"
339343 >
340344 </File>
@@ -375,6 +379,10 @@
375379 RelativePath=".\Resource\resource.h"
376380 >
377381 </File>
382+ <File
383+ RelativePath=".\socketwrapper.h"
384+ >
385+ </File>
378386 </Filter>
379387 <Filter
380388 Name="Resource Files"
--- a/FFFTP.vcproj
+++ b/FFFTP.vcproj
@@ -284,6 +284,10 @@
284284 >
285285 </File>
286286 <File
287+ RelativePath=".\mbswrapper.c"
288+ >
289+ </File>
290+ <File
287291 RelativePath=".\md4.c"
288292 >
289293 </File>
@@ -332,6 +336,10 @@
332336 >
333337 </File>
334338 <File
339+ RelativePath=".\socketwrapper.c"
340+ >
341+ </File>
342+ <File
335343 RelativePath=".\statuswin.c"
336344 >
337345 </File>
@@ -365,9 +373,17 @@
365373 >
366374 </File>
367375 <File
376+ RelativePath=".\mbswrapper.h"
377+ >
378+ </File>
379+ <File
368380 RelativePath=".\Resource\resource.h"
369381 >
370382 </File>
383+ <File
384+ RelativePath=".\socketwrapper.h"
385+ >
386+ </File>
371387 </Filter>
372388 <Filter
373389 Name="Resource Files"
--- a/FFFTP_English.vc90.vcproj
+++ b/FFFTP_English.vc90.vcproj
@@ -335,6 +335,10 @@
335335 >
336336 </File>
337337 <File
338+ RelativePath=".\socketwrapper.c"
339+ >
340+ </File>
341+ <File
338342 RelativePath=".\statuswin.c"
339343 >
340344 </File>
@@ -375,6 +379,10 @@
375379 RelativePath=".\Resource_eng\resource.h"
376380 >
377381 </File>
382+ <File
383+ RelativePath=".\socketwrapper.h"
384+ >
385+ </File>
378386 </Filter>
379387 <Filter
380388 Name="Resource Files"
--- a/FFFTP_English.vcproj
+++ b/FFFTP_English.vcproj
@@ -284,6 +284,10 @@
284284 >
285285 </File>
286286 <File
287+ RelativePath=".\mbswrapper.c"
288+ >
289+ </File>
290+ <File
287291 RelativePath=".\md4.c"
288292 >
289293 </File>
@@ -332,6 +336,10 @@
332336 >
333337 </File>
334338 <File
339+ RelativePath=".\socketwrapper.c"
340+ >
341+ </File>
342+ <File
335343 RelativePath=".\statuswin.c"
336344 >
337345 </File>
@@ -365,9 +373,17 @@
365373 >
366374 </File>
367375 <File
376+ RelativePath=".\mbswrapper.h"
377+ >
378+ </File>
379+ <File
368380 RelativePath=".\Resource_eng\resource.h"
369381 >
370382 </File>
383+ <File
384+ RelativePath=".\socketwrapper.h"
385+ >
386+ </File>
371387 </Filter>
372388 <Filter
373389 Name="Resource Files"
Binary files a/Resource/FFFTP.APS and b/Resource/FFFTP.APS differ
--- a/Resource/FFFTP.rc
+++ b/Resource/FFFTP.rc
@@ -1341,6 +1341,15 @@ BEGIN
13411341 CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,172,42,8,8
13421342 END
13431343
1344+hset_crypt_dlg DIALOG 0, 0, 207, 139
1345+STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
1346+FONT 9, "‚l‚r ‚oƒSƒVƒbƒN"
1347+BEGIN
1348+ CONTROL "FTPS (Explicit)‚Őڑ±",HSET_FTPES,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,7,148,10
1349+ CONTROL "FTPS (Inplicit)‚Őڑ±",HSET_FTPIS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,21,148,10
1350+ CONTROL "SFTP‚Őڑ±",HSET_SFTP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,148,10
1351+END
1352+
13441353
13451354 /////////////////////////////////////////////////////////////////////////////
13461355 //
--- a/Resource/resource.h
+++ b/Resource/resource.h
@@ -108,6 +108,7 @@
108108 #define forcepasschange_dlg 186
109109 #define newmasterpasswd_dlg 187
110110 #define masterpasswd_dlg 188
111+#define hset_crypt_dlg 189
111112 #define TRANS_TIME_BAR 1002
112113 #define TRANS_TEXT 1003
113114 #define TRANS_REMOTE 1003
@@ -419,6 +420,9 @@
419420 #define HSET_SJIS_CNV 1195
420421 #define HSET_UTF8N_CNV 1196
421422 #define HSET_FN_SJIS_CNV 1197
423+#define HSET_FTPES 1198
424+#define HSET_FTPIS 1199
425+#define HSET_SFTP 1200
422426 #define MENU_END 40001
423427 #define MENU_EXIT 40001
424428 #define MENU_CONNECT 40003
@@ -602,9 +606,9 @@
602606 //
603607 #ifdef APSTUDIO_INVOKED
604608 #ifndef APSTUDIO_READONLY_SYMBOLS
605-#define _APS_NEXT_RESOURCE_VALUE 189
609+#define _APS_NEXT_RESOURCE_VALUE 190
606610 #define _APS_NEXT_COMMAND_VALUE 40175
607-#define _APS_NEXT_CONTROL_VALUE 1198
611+#define _APS_NEXT_CONTROL_VALUE 1201
608612 #define _APS_NEXT_SYMED_VALUE 101
609613 #endif
610614 #endif
Binary files a/Resource_eng/FFFTP-eng.aps and b/Resource_eng/FFFTP-eng.aps differ
--- a/Resource_eng/FFFTP-eng.rc
+++ b/Resource_eng/FFFTP-eng.rc
@@ -1201,6 +1201,15 @@ BEGIN
12011201 CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,173,39,8,8
12021202 END
12031203
1204+hset_crypt_dlg DIALOG 0, 0, 207, 139
1205+STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
1206+FONT 9, "‚l‚r ‚oƒSƒVƒbƒN"
1207+BEGIN
1208+ CONTROL "Connect with FTPS (Explicit)",HSET_FTPES,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,7,148,10
1209+ CONTROL "Connect with FTPS (Inplicit)",HSET_FTPIS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,21,148,10
1210+ CONTROL "Connect with SFTP",HSET_SFTP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,148,10
1211+END
1212+
12041213
12051214 /////////////////////////////////////////////////////////////////////////////
12061215 //
--- a/Resource_eng/resource.h
+++ b/Resource_eng/resource.h
@@ -108,6 +108,7 @@
108108 #define forcepasschange_dlg 186
109109 #define newmasterpasswd_dlg 187
110110 #define masterpasswd_dlg 188
111+#define hset_crypt_dlg 189
111112 #define TRANS_TIME_BAR 1002
112113 #define TRANS_TEXT 1003
113114 #define TRANS_REMOTE 1003
@@ -419,6 +420,9 @@
419420 #define HSET_SJIS_CNV 1195
420421 #define HSET_UTF8N_CNV 1196
421422 #define HSET_FN_SJIS_CNV 1197
423+#define HSET_FTPES 1198
424+#define HSET_FTPIS 1199
425+#define HSET_SFTP 1200
422426 #define MENU_END 40001
423427 #define MENU_EXIT 40001
424428 #define MENU_CONNECT 40003
@@ -602,9 +606,9 @@
602606 //
603607 #ifdef APSTUDIO_INVOKED
604608 #ifndef APSTUDIO_READONLY_SYMBOLS
605-#define _APS_NEXT_RESOURCE_VALUE 189
609+#define _APS_NEXT_RESOURCE_VALUE 190
606610 #define _APS_NEXT_COMMAND_VALUE 40175
607-#define _APS_NEXT_CONTROL_VALUE 1198
611+#define _APS_NEXT_CONTROL_VALUE 1201
608612 #define _APS_NEXT_SYMED_VALUE 101
609613 #endif
610614 #endif
--- a/common.h
+++ b/common.h
@@ -853,6 +853,12 @@ LIST_UNIX_70
853853 #define DEFAULT_PASSWORD "DefaultPassword"
854854 #define MAX_PASSWORD_LEN 128
855855
856+// ˆÃ†‰»’ʐM‘Ήž
857+#define CRYPT_NONE 0
858+#define CRYPT_FTPES 1
859+#define CRYPT_FTPIS 2
860+#define CRYPT_SFTP 3
861+
856862
857863 /*=================================================
858864 * ƒXƒgƒ‰ƒNƒ`ƒƒ
@@ -896,6 +902,11 @@ typedef struct {
896902 int DialupAlways; /* í‚É‚±‚̃Gƒ“ƒgƒŠ‚֐ڑ±‚·‚é‚©‚Ç‚¤‚© (YES/NO) */
897903 int DialupNotify; /* ÄÚ‘±‚̍ۂɊm”F‚·‚é (YES/NO) */
898904 char DialEntry[RAS_NAME_LEN+1]; /* ƒ_ƒCƒAƒ‹ƒAƒbƒvƒGƒ“ƒgƒŠ */
905+ // ˆÃ†‰»’ʐM‘Ήž
906+ int CryptMode; /* ˆÃ†‰»’ʐMƒ‚[ƒh (CRYPT_xxx) */
907+ int UseFTPES; /* FTPES‚Őڑ±‚·‚é (YES/NO) */
908+ int UseFTPIS; /* FTPIS‚Őڑ±‚·‚é (YES/NO) */
909+ int UseSFTP; /* SFTP‚Őڑ±‚·‚é (YES/NO) */
899910 } HOSTDATA;
900911
901912
@@ -942,6 +953,10 @@ typedef struct historydata {
942953 int DialupAlways; /* í‚É‚±‚̃Gƒ“ƒgƒŠ‚֐ڑ±‚·‚é‚©‚Ç‚¤‚© (YES/NO) */
943954 int DialupNotify; /* ÄÚ‘±‚̍ۂɊm”F‚·‚é (YES/NO) */
944955 char DialEntry[RAS_NAME_LEN+1]; /* ƒ_ƒCƒAƒ‹ƒAƒbƒvƒGƒ“ƒgƒŠ */
956+ // ˆÃ†‰»’ʐM‘Ήž
957+ int UseFTPES; /* FTPES‚Őڑ±‚·‚é (YES/NO) */
958+ int UseFTPIS; /* FTPIS‚Őڑ±‚·‚é (YES/NO) */
959+ int UseSFTP; /* SFTP‚Őڑ±‚·‚é (YES/NO) */
945960 struct historydata *Next;
946961 } HISTORYDATA;
947962
@@ -962,11 +977,14 @@ typedef struct transpacket {
962977 FILETIME Time; /* ƒtƒ@ƒCƒ‹‚ÌŽžŠÔ(UTC) */
963978 int Attr; /* ƒtƒ@ƒCƒ‹‚Ì‘®« */
964979 int KanjiCode; /* Š¿ŽšƒR[ƒh (KANJI_xxx) */
965- int KanjiCodeDesired; /* •ÏŠ·æ‚ÌŠ¿ŽšƒR[ƒh (KANJI_xxx) */
980+ // UTF-8‘Ήž
981+ int KanjiCodeDesired; /* ƒ[ƒJƒ‹‚ÌŠ¿ŽšƒR[ƒh (KANJI_xxx) */
966982 int KanaCnv; /* ”¼ŠpƒJƒi‚ð‘SŠp‚É•ÏŠ·(YES/NO) */
967983 int Mode; /* “]‘—ƒ‚[ƒh (EXIST_xxx) */
968984 HWND hWndTrans; /* “]‘—’†ƒ_ƒCƒAƒƒO‚̃EƒCƒ“ƒhƒEƒnƒ“ƒhƒ‹ */
969985 int Abort; /* “]‘—’†Ž~ƒtƒ‰ƒO (ABORT_xxx) */
986+ // ˆÃ†‰»’ʐM‘Ήž
987+ int CryptMode; /* ˆÃ†‰»’ʐMƒ‚[ƒh (CRYPT_xxx) */
970988 struct transpacket *Next;
971989 } TRANSPACKET;
972990
@@ -1169,6 +1187,8 @@ int AskForceIni(void);
11691187 int BackgrndMessageProc(void);
11701188 void ResetAutoExitFlg(void);
11711189 int AskAutoExit(void);
1190+// ˆÃ†‰»’ʐM‘Ήž
1191+BOOL __stdcall SSLTimeoutCallback();
11721192
11731193 /*===== filelist.c =====*/
11741194
@@ -1340,6 +1360,11 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork);
13401360 SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork);
13411361 int AskTryingConnect(void);
13421362 int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data);
1363+// ˆÃ†‰»’ʐM‘Ήž
1364+int AskCryptMode(void);
1365+int AskUseFTPES(void);
1366+int AskUseFTPIS(void);
1367+int AskUseSFTP(void);
13431368
13441369 /*===== cache.c =====*/
13451370
--- a/config.h
+++ b/config.h
@@ -2,11 +2,15 @@
22 /* OPENVMS—p‚̃R[ƒh‚ð—LŒø‚É‚·‚éB”óŒû“aì¬‚̃pƒbƒ`‚ð‘g‚ݍž‚Ý‚Ü‚µ‚½B */
33 #define HAVE_OPENVMS
44
5-//‘S‘̂ɉe‹¿‚·‚éÝ’è‚Í‚±‚±‚É‹Lq‚·‚é—\’è
6-//“à•”‚ðUTF-8‚Æ‚µ‚Ĉµ‚¢ƒ}ƒ‹ƒ`ƒoƒCƒg•¶ŽšƒƒCƒh•¶ŽšAPIƒ‰ƒbƒp[‚ðŽg—p‚·‚é
5+// ‘S‘̂ɉe‹¿‚·‚éÝ’è‚Í‚±‚±‚É‹Lq‚·‚é—\’è
6+// “à•”‚ðUTF-8‚Æ‚µ‚Ĉµ‚¢ƒ}ƒ‹ƒ`ƒoƒCƒg•¶ŽšƒƒCƒh•¶ŽšAPIƒ‰ƒbƒp[‚ðŽg—p‚·‚é
77 #include "mbswrapper.h"
8-//Žg—p‚·‚éCPU‚ð1ŒÂ‚ÉŒÀ’è‚·‚éiƒ}ƒ‹ƒ`ƒRƒACPU‚Ì“Á’èŠÂ‹«‰º‚Ńtƒ@ƒCƒ‹’ʐM’†‚ɃNƒ‰ƒbƒVƒ…‚·‚éƒoƒO‘΍ôj
8+// OpenSSL—pƒ\ƒPƒbƒgƒ‰ƒbƒp[‚ðŽg—p‚·‚é
9+#include "socketwrapper.h"
10+// Žg—p‚·‚éCPU‚ð1ŒÂ‚ÉŒÀ’è‚·‚éiƒ}ƒ‹ƒ`ƒRƒACPU‚Ì“Á’èŠÂ‹«‰º‚Ńtƒ@ƒCƒ‹’ʐM’†‚ɃNƒ‰ƒbƒVƒ…‚·‚éƒoƒO‘΍ôj
911 #define DISABLE_MULTI_CPUS
10-//ƒlƒbƒgƒ[ƒNƒoƒbƒtƒ@‚𖳌ø‚É‚·‚éi’ʐM’†Ž~Œã‚ɃŠƒ‚[ƒg‚̃fƒBƒŒƒNƒgƒŠ‚ª•\Ž¦‚³‚ê‚È‚¢ƒoƒO‘΍ôj
11-//#define DISABLE_NETWORK_BUFFERS
12+// ƒtƒ@ƒCƒ‹“]‘——p‚̃lƒbƒgƒ[ƒNƒoƒbƒtƒ@‚𖳌ø‚É‚·‚éi’ʐM’†Ž~Œã‚ɃŠƒ‚[ƒg‚̃fƒBƒŒƒNƒgƒŠ‚ª•\Ž¦‚³‚ê‚È‚¢ƒoƒO‘΍ôj
13+//#define DISABLE_TRANSFER_NETWORK_BUFFERS
14+// ƒRƒ“ƒgƒ[ƒ‹—p‚̃lƒbƒgƒ[ƒNƒoƒbƒtƒ@‚𖳌ø‚É‚·‚éiƒtƒŠ[ƒY‘΍ôj
15+#define DISABLE_CONTROL_NETWORK_BUFFERS
1216
--- a/connect.c
+++ b/connect.c
@@ -1213,6 +1213,12 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
12131213 {
12141214 if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)
12151215 {
1216+ // ƒoƒbƒtƒ@‚𖳌ø
1217+#ifdef DISABLE_CONTROL_NETWORK_BUFFERS
1218+ int BufferSize = 0;
1219+ setsockopt(ContSock, SOL_SOCKET, SO_SNDBUF, (char*)&BufferSize, sizeof(int));
1220+ setsockopt(ContSock, SOL_SOCKET, SO_RCVBUF, (char*)&BufferSize, sizeof(int));
1221+#endif
12161222 while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)
12171223 ;
12181224
@@ -1221,6 +1227,8 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
12211227 Flg = 1;
12221228 if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
12231229 ReportWSError("setsockopt", WSAGetLastError());
1230+ if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1231+ ReportWSError("setsockopt", WSAGetLastError());
12241232 #pragma aaa
12251233 Flg = 1;
12261234 if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
@@ -1299,6 +1307,39 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
12991307 else
13001308 strcpy(Buf, User);
13011309
1310+ // FTPES‘Ήž
1311+ // 2‰ñˆÈãŒÄ‚΂ê‚鎖‚ª‚ ‚邽‚ߊù‚ÉFTPES‚Őڑ±‚µ‚Ä‚¢‚Ä‚àÄŠm”F
1312+ if(CurHost.CryptMode == CRYPT_NONE || CurHost.CryptMode == CRYPT_FTPES)
1313+ {
1314+ if(IsOpenSSLLoaded() && CurHost.UseFTPES == YES && (Sts = command(ContSock, Reply, &CancelFlg, "AUTH TLS")) == 234)
1315+ {
1316+ // SSL‚ɐ؂è‘Ö‚¦
1317+ SetTaskMsg(MSGJPN315);
1318+ CurHost.CryptMode = CRYPT_FTPES;
1319+ if(AttachSSL(ContSock))
1320+ {
1321+ if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)
1322+ {
1323+ if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)
1324+ {
1325+ }
1326+ else
1327+ Sts = FTP_ERROR;
1328+ }
1329+ else
1330+ Sts = FTP_ERROR;
1331+ }
1332+ else
1333+ Sts = FTP_ERROR;
1334+ }
1335+ else
1336+ {
1337+ // ˆÃ†‰»‚È‚µ
1338+ CurHost.CryptMode = CRYPT_NONE;
1339+ SetTaskMsg(MSGJPN314);
1340+ }
1341+ }
1342+
13021343 ReInPass = NO;
13031344 do
13041345 {
@@ -2123,3 +2164,24 @@ int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)
21232164
21242165
21252166
2167+// ˆÃ†‰»’ʐM‘Ήž
2168+int AskCryptMode(void)
2169+{
2170+ return(CurHost.CryptMode);
2171+}
2172+
2173+int AskUseFTPES(void)
2174+{
2175+ return(CurHost.UseFTPES);
2176+}
2177+
2178+int AskUseFTPIS(void)
2179+{
2180+ return(CurHost.UseFTPIS);
2181+}
2182+
2183+int AskUseSFTP(void)
2184+{
2185+ return(CurHost.UseSFTP);
2186+}
2187+
--- a/ftpproc.c
+++ b/ftpproc.c
@@ -200,6 +200,7 @@ void DownLoadProc(int ChName, int ForceFile, int All)
200200 Pkt.Size = Pos->Size;
201201 Pkt.Time = Pos->Time;
202202 Pkt.KanjiCode = AskHostKanjiCode();
203+ // UTF-8‘Ήž
203204 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
204205 Pkt.KanaCnv = AskHostKanaCnv();
205206
@@ -302,6 +303,7 @@ void DirectDownLoadProc(char *Fname)
302303 /* ƒTƒCƒY‚Æ“ú•t‚Í“]‘—‘¤ƒXƒŒƒbƒh‚Ŏ擾‚µAƒZƒbƒg‚·‚é */
303304
304305 Pkt.KanjiCode = AskHostKanjiCode();
306+ // UTF-8‘Ήž
305307 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
306308 Pkt.KanaCnv = AskHostKanaCnv();
307309
@@ -553,6 +555,7 @@ void MirrorDownloadProc(int Notify)
553555 Pkt.Time = RemotePos->Time;
554556 // Pkt.Attr = 0;
555557 Pkt.KanjiCode = AskHostKanjiCode();
558+ // UTF-8‘Ήž
556559 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
557560 Pkt.KanaCnv = AskHostKanaCnv();
558561 Pkt.Mode = EXIST_OVW;
@@ -947,6 +950,7 @@ void UpLoadListProc(int ChName, int All)
947950 Pkt.Time = Pos->Time;
948951 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);
949952 Pkt.KanjiCode = AskHostKanjiCode();
953+ // UTF-8‘Ήž
950954 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
951955 Pkt.KanaCnv = AskHostKanaCnv();
952956 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);
@@ -1098,6 +1102,7 @@ void UpLoadDragProc(WPARAM wParam)
10981102 Pkt.Time = Pos->Time;
10991103 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);
11001104 Pkt.KanjiCode = AskHostKanjiCode();
1105+ // UTF-8‘Ήž
11011106 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
11021107 Pkt.KanaCnv = AskHostKanaCnv();
11031108 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);
@@ -1365,6 +1370,7 @@ void MirrorUploadProc(int Notify)
13651370 Pkt.Time = LocalPos->Time;
13661371 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);
13671372 Pkt.KanjiCode = AskHostKanjiCode();
1373+ // UTF-8‘Ήž
13681374 Pkt.KanjiCodeDesired = AskLocalKanjiCode();
13691375 Pkt.KanaCnv = AskHostKanaCnv();
13701376 Pkt.Mode = EXIST_OVW;
--- a/getput.c
+++ b/getput.c
@@ -57,7 +57,7 @@
5757 #define SOCKBUF_SIZE (256 * 1024)
5858 /* End */
5959
60-#ifdef DISABLE_NETWORK_BUFFERS
60+#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS
6161 #undef BUFSIZE
6262 #define BUFSIZE (64 * 1024) // RWIN’lˆÈ‰º‚ŏ[•ª‚È‘å‚«‚³‚ª–]‚Ü‚µ‚¢‚ÆŽv‚í‚ê‚éB
6363 #undef SET_BUFFER_SIZE
@@ -1017,7 +1017,17 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
10171017
10181018 if(data_socket != INVALID_SOCKET)
10191019 {
1020- iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1020+ // FTPS‘Ήž
1021+// iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1022+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1023+ {
1024+ if(AttachSSL(data_socket))
1025+ iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1026+ else
1027+ iRetCode = FTP_ERROR;
1028+ }
1029+ else
1030+ iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
10211031 // data_socket = DoClose(data_socket);
10221032 }
10231033 }
@@ -1070,6 +1080,8 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
10701080 {
10711081 if((data_socket = connectsock(Adrs, Port, MSGJPN091, CancelCheckWork)) != INVALID_SOCKET)
10721082 {
1083+ // •Ï”‚ª–¢‰Šú‰»‚̃oƒOC³
1084+ Flg = 1;
10731085 if(setsockopt(data_socket, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
10741086 ReportWSError("setsockopt", WSAGetLastError());
10751087
@@ -1079,7 +1091,17 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
10791091 iRetCode = command(Pkt->ctrl_skt, Reply, CancelCheckWork, "%s", Buf);
10801092 if(iRetCode/100 == FTP_PRELIM)
10811093 {
1082- iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1094+ // FTPS‘Ήž
1095+// iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1096+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1097+ {
1098+ if(AttachSSL(data_socket))
1099+ iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
1100+ else
1101+ iRetCode = FTP_ERROR;
1102+ }
1103+ else
1104+ iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);
10831105 // data_socket = DoClose(data_socket);
10841106 }
10851107 else
@@ -1155,8 +1177,8 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
11551177 /* End */
11561178 #endif
11571179
1158-#ifdef DISABLE_NETWORK_BUFFERS
1159- // ”O‚Ì‚½‚ߎóMƒoƒbƒtƒ@‚𖳌ø‚É‚·‚éB
1180+ // ”O‚Ì‚½‚ߎóMƒoƒbƒtƒ@‚𖳌ø‚É‚·‚é
1181+#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS
11601182 int buf_size = 0;
11611183 setsockopt(dSkt, SOL_SOCKET, SO_RCVBUF, (char *)&buf_size, sizeof(buf_size));
11621184 #endif
@@ -2002,7 +2024,17 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
20022024
20032025 if(data_socket != INVALID_SOCKET)
20042026 {
2005- iRetCode = UpLoadFile(Pkt, data_socket);
2027+ // FTPS‘Ήž
2028+// iRetCode = UpLoadFile(Pkt, data_socket);
2029+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
2030+ {
2031+ if(AttachSSL(data_socket))
2032+ iRetCode = UpLoadFile(Pkt, data_socket);
2033+ else
2034+ iRetCode = FTP_ERROR;
2035+ }
2036+ else
2037+ iRetCode = UpLoadFile(Pkt, data_socket);
20062038 data_socket = DoClose(data_socket);
20072039 }
20082040 }
@@ -2052,6 +2084,8 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
20522084 {
20532085 if((data_socket = connectsock(Adrs, Port, MSGJPN109, &Canceled)) != INVALID_SOCKET)
20542086 {
2087+ // •Ï”‚ª–¢‰Šú‰»‚̃oƒOC³
2088+ Flg = 1;
20552089 if(setsockopt(data_socket, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
20562090 ReportWSError("setsockopt", WSAGetLastError());
20572091
@@ -2064,7 +2098,17 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
20642098 iRetCode = command(Pkt->ctrl_skt, Reply, &Canceled, "%s", Buf);
20652099 if(iRetCode/100 == FTP_PRELIM)
20662100 {
2067- iRetCode = UpLoadFile(Pkt, data_socket);
2101+ // FTPS‘Ήž
2102+// iRetCode = UpLoadFile(Pkt, data_socket);
2103+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
2104+ {
2105+ if(AttachSSL(data_socket))
2106+ iRetCode = UpLoadFile(Pkt, data_socket);
2107+ else
2108+ iRetCode = FTP_ERROR;
2109+ }
2110+ else
2111+ iRetCode = UpLoadFile(Pkt, data_socket);
20682112
20692113 data_socket = DoClose(data_socket);
20702114 }
@@ -2140,8 +2184,8 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
21402184 /* End */
21412185 #endif
21422186
2143-#ifdef DISABLE_NETWORK_BUFFERS
2144- // ”O‚Ì‚½‚ß‘—Mƒoƒbƒtƒ@‚𖳌ø‚É‚·‚éB
2187+ // ”O‚Ì‚½‚ß‘—Mƒoƒbƒtƒ@‚𖳌ø‚É‚·‚é
2188+#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS
21452189 int buf_size = 0;
21462190 setsockopt(dSkt, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof(buf_size));
21472191 #endif
@@ -3021,7 +3065,7 @@ static int IsSpecialDevice(char *Fname)
30213065 int Sts;
30223066
30233067 Sts = NO;
3024- // ƒoƒOC³
3068+ // ”äŠr‚ª•sŠ®‘S‚ȃoƒOC³
30253069 // if((_stricmp(Fname, "CON") == 0) ||
30263070 // (_stricmp(Fname, "PRN") == 0) ||
30273071 // (_stricmp(Fname, "AUX") == 0) ||
--- a/history.c
+++ b/history.c
@@ -223,6 +223,10 @@ static void CopyHostToHistory(HOSTDATA *Host, HISTORYDATA *New)
223223 New->DialupAlways = Host->DialupAlways;
224224 New->DialupNotify = Host->DialupNotify;
225225 strcpy(New->DialEntry, Host->DialEntry);
226+ // ˆÃ†‰»’ʐM‘Ήž
227+ New->UseFTPES = Host->UseFTPES;
228+ New->UseFTPIS = Host->UseFTPIS;
229+ New->UseSFTP = Host->UseSFTP;
226230 return;
227231 }
228232
@@ -272,6 +276,10 @@ void CopyHistoryToHost(HISTORYDATA *Hist, HOSTDATA *Host)
272276 Host->DialupAlways = Hist->DialupAlways;
273277 Host->DialupNotify = Hist->DialupNotify;
274278 strcpy(Host->DialEntry, Hist->DialEntry);
279+ // ˆÃ†‰»’ʐM‘Ήž
280+ Host->UseFTPES = Hist->UseFTPES;
281+ Host->UseFTPIS = Hist->UseFTPIS;
282+ Host->UseSFTP = Hist->UseSFTP;
275283 return;
276284 }
277285
--- a/hostman.c
+++ b/hostman.c
@@ -63,6 +63,8 @@ static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPA
6363 static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
6464 static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
6565 static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
66+// ˆÃ†‰»’ʐM‘Ήž
67+static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
6668
6769 /*===== ŠO•”ŽQÆ =====*/
6870
@@ -1015,6 +1017,10 @@ int CopyHostFromListInConnect(int Num, HOSTDATA *Set)
10151017 Set->UseNLST_R = Pos->Set.UseNLST_R;
10161018 Set->LastDir = Pos->Set.LastDir;
10171019 Set->TimeZone = Pos->Set.TimeZone;
1020+ // ˆÃ†‰»’ʐM‘Ήž
1021+ Set->UseFTPES = Pos->Set.UseFTPES;
1022+ Set->UseFTPIS = Pos->Set.UseFTPIS;
1023+ Set->UseSFTP = Pos->Set.UseSFTP;
10181024 Sts = SUCCESS;
10191025 }
10201026 return(Sts);
@@ -1288,6 +1294,11 @@ void CopyDefaultHost(HOSTDATA *Set)
12881294 Set->DialupAlways = NO;
12891295 Set->DialupNotify = YES;
12901296 strcpy(Set->DialEntry, "");
1297+ // ˆÃ†‰»’ʐM‘Ήž
1298+ Set->CryptMode = CRYPT_NONE;
1299+ Set->UseFTPES = YES;
1300+ Set->UseFTPIS = YES;
1301+ Set->UseSFTP = YES;
12911302 return;
12921303 }
12931304
@@ -1499,7 +1510,9 @@ void ImportFromWSFTP(void)
14991510
15001511 static int DispHostSetDlg(HWND hDlg)
15011512 {
1502- PROPSHEETPAGE psp[5];
1513+// SFTPAFTPESAFTPIS‘Ήž
1514+// PROPSHEETPAGE psp[5];
1515+ PROPSHEETPAGE psp[6];
15031516 PROPSHEETHEADER psh;
15041517
15051518 psp[0].dwSize = sizeof(PROPSHEETPAGE);
@@ -1552,6 +1565,17 @@ static int DispHostSetDlg(HWND hDlg)
15521565 psp[4].lParam = 0;
15531566 psp[4].pfnCallback = NULL;
15541567
1568+// SFTPAFTPESAFTPIS‘Ήž
1569+ psp[5].dwSize = sizeof(PROPSHEETPAGE);
1570+ psp[5].dwFlags = PSP_USETITLE | PSP_HASHELP;
1571+ psp[5].hInstance = GetFtpInst();
1572+ psp[5].pszTemplate = MAKEINTRESOURCE(hset_crypt_dlg);
1573+ psp[5].pszIcon = NULL;
1574+ psp[5].pfnDlgProc = CryptSettingProc;
1575+ psp[5].pszTitle = MSGJPN313;
1576+ psp[5].lParam = 0;
1577+ psp[5].pfnCallback = NULL;
1578+
15551579 psh.dwSize = sizeof(PROPSHEETHEADER);
15561580 psh.dwFlags = PSH_HASHELP | PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE;
15571581 psh.hwndParent = hDlg;
@@ -1851,11 +1875,11 @@ static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LP
18511875
18521876 // UTF-8‘Ήž
18531877 case HSET_NO_CNV :
1854- case HSET_SJIS_CNV :
18551878 case HSET_UTF8N_CNV :
18561879 EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), FALSE);
18571880 break;
18581881
1882+ case HSET_SJIS_CNV :
18591883 case HSET_FN_JIS_CNV :
18601884 case HSET_FN_EUC_CNV :
18611885 EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), TRUE);
@@ -2071,3 +2095,65 @@ static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LP
20712095 }
20722096
20732097
2098+// ˆÃ†‰»’ʐM‘Ήž
2099+static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
2100+{
2101+ NMHDR *pnmhdr;
2102+ int Num;
2103+
2104+ switch (iMessage)
2105+ {
2106+ case WM_INITDIALOG :
2107+ if(IsOpenSSLLoaded())
2108+ {
2109+ SendDlgItemMessage(hDlg, HSET_FTPES, BM_SETCHECK, TmpHost.UseFTPES, 0);
2110+ SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, TmpHost.UseFTPIS, 0);
2111+ SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, TmpHost.UseSFTP, 0);
2112+ }
2113+ else
2114+ {
2115+ SendDlgItemMessage(hDlg, HSET_FTPES, BM_SETCHECK, BST_UNCHECKED, 0);
2116+ EnableWindow(GetDlgItem(hDlg, HSET_FTPES), FALSE);
2117+ SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, BST_UNCHECKED, 0);
2118+ EnableWindow(GetDlgItem(hDlg, HSET_FTPIS), FALSE);
2119+ SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, BST_UNCHECKED, 0);
2120+ EnableWindow(GetDlgItem(hDlg, HSET_SFTP), FALSE);
2121+ }
2122+ // TODO: FTPIS‘Ήž
2123+ SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, BST_UNCHECKED, 0);
2124+ EnableWindow(GetDlgItem(hDlg, HSET_FTPIS), FALSE);
2125+ // TODO: SFTP‘Ήž
2126+ SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, BST_UNCHECKED, 0);
2127+ EnableWindow(GetDlgItem(hDlg, HSET_SFTP), FALSE);
2128+ return(TRUE);
2129+
2130+ case WM_NOTIFY:
2131+ pnmhdr = (NMHDR FAR *)lParam;
2132+ switch(pnmhdr->code)
2133+ {
2134+ case PSN_APPLY :
2135+ if(IsOpenSSLLoaded())
2136+ {
2137+ TmpHost.UseFTPES = SendDlgItemMessage(hDlg, HSET_FTPES, BM_GETCHECK, 0, 0);
2138+ // TODO: FTPIS‘Ήž
2139+// TmpHost.UseFTPIS = SendDlgItemMessage(hDlg, HSET_FTPIS, BM_GETCHECK, 0, 0);
2140+ // TODO: SFTP‘Ήž
2141+// TmpHost.UseSFTP = SendDlgItemMessage(hDlg, HSET_SFTP, BM_GETCHECK, 0, 0);
2142+ }
2143+ Apply = YES;
2144+ break;
2145+
2146+ case PSN_RESET :
2147+ break;
2148+
2149+ case PSN_HELP :
2150+ // TODO: ƒwƒ‹ƒvƒgƒsƒbƒN
2151+// hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000032);
2152+ break;
2153+ }
2154+ break;
2155+ }
2156+ return(FALSE);
2157+}
2158+
2159+
--- a/main.c
+++ b/main.c
@@ -236,6 +236,10 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
236236
237237 InitCommonControls();
238238
239+#ifdef USE_OPENSSL
240+ LoadOpenSSL();
241+#endif
242+
239243 Ret = FALSE;
240244 hWndFtp = NULL;
241245 hInstFtp = hInstance;
@@ -265,6 +269,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
265269 Ret = Msg.wParam;
266270 }
267271 UnregisterClass(FtpClassStr, hInstFtp);
272+#ifdef USE_OPENSSL
273+ FreeOpenSSL();
274+#endif
268275 OleUninitialize();
269276 return(Ret);
270277 }
@@ -375,6 +382,9 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
375382 {
376383 LoadRegistory();
377384
385+ // ˆÃ†‰»’ʐM‘Ήž
386+ SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);
387+
378388 LoadJre();
379389 if(NoRasControl == NO)
380390 LoadRasLib();
@@ -458,6 +468,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
458468 }
459469 }
460470
471+ // ˆÃ†‰»’ʐM‘Ήž
472+#ifdef USE_OPENSSL
473+ if(IsOpenSSLLoaded())
474+ SetTaskMsg(MSGJPN318);
475+ else
476+ SetTaskMsg(MSGJPN319);
477+#endif
478+
461479 if(sts == FAIL)
462480 DeleteAllObject();
463481
@@ -969,6 +987,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
969987 DispTransferType();
970988 CheckHistoryNum(0);
971989 SetAllHistoryToMenu();
990+ // ˆÃ†‰»’ʐM‘Ήž
991+ SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);
972992 break;
973993
974994 case MENU_FILTER :
@@ -2577,6 +2597,7 @@ int BackgrndMessageProc(void)
25772597 int Ret;
25782598
25792599 Ret = NO;
2600+ SendMessage(GetMainHwnd(), WM_NULL, 0, 0);
25802601 while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
25812602 {
25822603 if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))
@@ -2669,3 +2690,19 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd )
26692690 }
26702691 return 0;
26712692 }
2693+
2694+// ˆÃ†‰»’ʐM‘Ήž
2695+BOOL __stdcall SSLTimeoutCallback()
2696+{
2697+ Sleep(1);
2698+ if(BackgrndMessageProc() == YES)
2699+ return TRUE;
2700+ // ”O‚Ì‚½‚߃c[ƒ‹ƒo[‚ÌMENU_ABORT‚àŠm”F
2701+// if(MainTransPkt.Abort != ABORT_NONE)
2702+// {
2703+// MainTransPkt.Abort = ABORT_NONE;
2704+// return TRUE;
2705+// }
2706+ return FALSE;
2707+}
2708+
--- a/mbswrapper.c
+++ b/mbswrapper.c
@@ -414,6 +414,20 @@ START_ROUTINE
414414 pw0 = DuplicateMtoW((LPCSTR)lParam, -1);
415415 r = SendMessageW(hWnd, CB_ADDSTRING, wParam, (LPARAM)pw0);
416416 break;
417+ case CB_GETLBTEXT:
418+ Size = SendMessageW(hWnd, CB_GETLBTEXTLEN, wParam, 0) + 1;
419+ pw0 = AllocateStringW(Size);
420+ SendMessageW(hWnd, CB_GETLBTEXT, wParam, (LPARAM)pw0);
421+ // ƒoƒbƒtƒ@’·•s–¾‚Ì‚½‚߃I[ƒo[ƒ‰ƒ“‚̉”\«‚ ‚è
422+ WtoM((LPSTR)lParam, Size * 4, pw0, -1);
423+ r = TerminateStringM((LPSTR)lParam, Size * 4);
424+ break;
425+ case CB_GETLBTEXTLEN:
426+ Size = SendMessageW(hWnd, CB_GETLBTEXTLEN, wParam, 0) + 1;
427+ pw0 = AllocateStringW(Size);
428+ SendMessageW(hWnd, WM_GETTEXT, wParam, (LPARAM)pw0);
429+ r = WtoM(NULL, 0, pw0, -1) - 1;
430+ break;
417431 case CB_INSERTSTRING:
418432 pw0 = DuplicateMtoW((LPCSTR)lParam, -1);
419433 r = SendMessageW(hWnd, CB_INSERTSTRING, wParam, (LPARAM)pw0);
@@ -441,12 +455,18 @@ START_ROUTINE
441455 break;
442456 case LB_GETTEXT:
443457 Size = SendMessageW(hWnd, LB_GETTEXTLEN, wParam, 0) + 1;
444- pw0 = AllocateStringW(Size * 4);
458+ pw0 = AllocateStringW(Size);
445459 SendMessageW(hWnd, LB_GETTEXT, wParam, (LPARAM)pw0);
446460 // ƒoƒbƒtƒ@’·•s–¾‚Ì‚½‚߃I[ƒo[ƒ‰ƒ“‚̉”\«‚ ‚è
447461 WtoM((LPSTR)lParam, Size * 4, pw0, -1);
448462 r = TerminateStringM((LPSTR)lParam, Size * 4);
449463 break;
464+ case LB_GETTEXTLEN:
465+ Size = SendMessageW(hWnd, LB_GETTEXTLEN, wParam, 0) + 1;
466+ pw0 = AllocateStringW(Size);
467+ SendMessageW(hWnd, WM_GETTEXT, wParam, (LPARAM)pw0);
468+ r = WtoM(NULL, 0, pw0, -1) - 1;
469+ break;
450470 default:
451471 r = SendMessageW(hWnd, Msg, wParam, lParam);
452472 break;
@@ -1343,8 +1363,3 @@ END_ROUTINE
13431363 return r;
13441364 }
13451365
1346-
1347-
1348-
1349-
1350-
--- a/mesg-eng.h
+++ b/mesg-eng.h
@@ -310,3 +310,10 @@
310310 #define MSGJPN310 "EUC Kanji Code (Local)"
311311 #define MSGJPN311 "JIS Kanji Code (Local)"
312312 #define MSGJPN312 "UTF-8N Kanji Code (Local)"
313+#define MSGJPN313 "Encryption"
314+#define MSGJPN314 "Communication is not encrypted.\r\nPassword and other data may be intercepted by a third party."
315+#define MSGJPN315 "Using FTP over Explicit SSL/TLS (FTPES)."
316+#define MSGJPN316 "Using FTP over Inplicit SSL/TLS (FTPIS)."
317+#define MSGJPN317 "Using SSH FTP (SFTP)."
318+#define MSGJPN318 "OpenSSL is loaded."
319+#define MSGJPN319 "OpenSSL is not installed.\r\nCommunication will not be encrypted."
--- a/mesg-eng.old.h
+++ b/mesg-eng.old.h
@@ -310,3 +310,10 @@
310310 #define MSGJPN310 "EUC Kanji Code (Local)"
311311 #define MSGJPN311 "JIS Kanji Code (Local)"
312312 #define MSGJPN312 "UTF-8N Kanji Code (Local)"
313+#define MSGJPN313 "Encryption"
314+#define MSGJPN314 "Communication is not encrypted.\r\nPassword and other data may be intercepted by a third party."
315+#define MSGJPN315 "Using FTP over Explicit SSL/TLS (FTPES)."
316+#define MSGJPN316 "Using FTP over Inplicit SSL/TLS (FTPIS)."
317+#define MSGJPN317 "Using SSH FTP (SFTP)."
318+#define MSGJPN318 "OpenSSL is loaded."
319+#define MSGJPN319 "OpenSSL is not installed.\r\nCommunication will not be encrypted."
--- a/mesg-jpn.h
+++ b/mesg-jpn.h
@@ -310,3 +310,10 @@
310310 #define MSGJPN310 "\xE3\x83\xAD\xE3\x83\xBC\xE3\x82\xAB\xE3\x83\xAB\xE3\x81\xAE\xE6\xBC\xA2\xE5\xAD\x97\xE3\x82\xB3\xE3\x83\xBC\xE3\x83\x89\xE3\x81\xAF\x45UC"
311311 #define MSGJPN311 "\xE3\x83\xAD\xE3\x83\xBC\xE3\x82\xAB\xE3\x83\xAB\xE3\x81\xAE\xE6\xBC\xA2\xE5\xAD\x97\xE3\x82\xB3\xE3\x83\xBC\xE3\x83\x89\xE3\x81\xAFJIS"
312312 #define MSGJPN312 "\xE3\x83\xAD\xE3\x83\xBC\xE3\x82\xAB\xE3\x83\xAB\xE3\x81\xAE\xE6\xBC\xA2\xE5\xAD\x97\xE3\x82\xB3\xE3\x83\xBC\xE3\x83\x89\xE3\x81\xAFUTF-8N"
313+#define MSGJPN313 "\xE6\x9A\x97\xE5\x8F\xB7\xE5\x8C\x96"
314+#define MSGJPN314 "\xE9\x80\x9A\xE4\xBF\xA1\xE3\x81\xAF\xE6\x9A\x97\xE5\x8F\xB7\xE5\x8C\x96\xE3\x81\x95\xE3\x82\x8C\xE3\x81\xA6\xE3\x81\x84\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93.\r\n\xE7\xAC\xAC\xE4\xB8\x89\xE8\x80\x85\xE3\x81\xAB\xE3\x83\x91\xE3\x82\xB9\xE3\x83\xAF\xE3\x83\xBC\xE3\x83\x89\xE3\x81\x8A\xE3\x82\x88\xE3\x81\xB3\xE5\x86\x85\xE5\xAE\xB9\xE3\x82\x92\xE5\x82\x8D\xE5\x8F\x97\xE3\x81\x95\xE3\x82\x8C\xE3\x82\x8B\xE5\x8F\xAF\xE8\x83\xBD\xE6\x80\xA7\xE3\x81\x8C\xE3\x81\x82\xE3\x82\x8A\xE3\x81\xBE\xE3\x81\x99."
315+#define MSGJPN315 "FTP over Explicit SSL/TLS (FTPES)\xE3\x82\x92\xE4\xBD\xBF\xE7\x94\xA8\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x99."
316+#define MSGJPN316 "FTP over Inplicit SSL/TLS (FTPIS)\xE3\x82\x92\xE4\xBD\xBF\xE7\x94\xA8\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x99."
317+#define MSGJPN317 "SSH FTP (SFTP)\xE3\x82\x92\xE4\xBD\xBF\xE7\x94\xA8\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x99."
318+#define MSGJPN318 "OpenSSL\xE3\x81\x8C\xE8\xAA\xAD\xE3\x81\xBF\xE8\xBE\xBC\xE3\x81\xBE\xE3\x82\x8C\xE3\x81\xBE\xE3\x81\x97\xE3\x81\x9F."
319+#define MSGJPN319 "OpenSSL\xE3\x81\x8C\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB\xE3\x81\x95\xE3\x82\x8C\xE3\x81\xA6\xE3\x81\x84\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93.\r\n\xE9\x80\x9A\xE4\xBF\xA1\xE3\x81\xAE\xE6\x9A\x97\xE5\x8F\xB7\xE5\x8C\x96\xE3\x81\xAF\xE8\xA1\x8C\xE3\x82\x8F\xE3\x82\x8C\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93."
--- a/mesg-jpn.old.h
+++ b/mesg-jpn.old.h
@@ -310,3 +310,10 @@
310310 #define MSGJPN310 "ƒ[ƒJƒ‹‚ÌŠ¿ŽšƒR[ƒh‚ÍEUC"
311311 #define MSGJPN311 "ƒ[ƒJƒ‹‚ÌŠ¿ŽšƒR[ƒh‚ÍJIS"
312312 #define MSGJPN312 "ƒ[ƒJƒ‹‚ÌŠ¿ŽšƒR[ƒh‚ÍUTF-8N"
313+#define MSGJPN313 "ˆÃ†‰»"
314+#define MSGJPN314 "’ʐM‚͈͆‰»‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ.\r\n‘æŽOŽÒ‚ɃpƒXƒ[ƒh‚¨‚æ‚Ñ“à—e‚ð–TŽó‚³‚ê‚é‰Â”\«‚ª‚ ‚è‚Ü‚·."
315+#define MSGJPN315 "FTP over Explicit SSL/TLS (FTPES)‚ðŽg—p‚µ‚Ü‚·."
316+#define MSGJPN316 "FTP over Inplicit SSL/TLS (FTPIS)‚ðŽg—p‚µ‚Ü‚·."
317+#define MSGJPN317 "SSH FTP (SFTP)‚ðŽg—p‚µ‚Ü‚·."
318+#define MSGJPN318 "OpenSSL‚ª“ǂݍž‚Ü‚ê‚Ü‚µ‚½."
319+#define MSGJPN319 "OpenSSL‚ªƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ.\r\n’ʐM‚̈͆‰»‚͍s‚í‚ê‚Ü‚¹‚ñ."
--- a/registory.c
+++ b/registory.c
@@ -462,6 +462,10 @@ void SaveRegistory(void)
462462 SaveIntNum(hKey5, "UseIt", Hist.DialupAlways, DefaultHist.DialupAlways);
463463 SaveIntNum(hKey5, "Notify", Hist.DialupNotify, DefaultHist.DialupNotify);
464464 SaveStr(hKey5, "DialTo", Hist.DialEntry, DefaultHist.DialEntry);
465+ // ˆÃ†‰»’ʐM‘Ήž
466+ SaveIntNum(hKey5, "FTPES", Hist.UseFTPES, DefaultHist.UseFTPES);
467+ SaveIntNum(hKey5, "FTPIS", Hist.UseFTPIS, DefaultHist.UseFTPIS);
468+ SaveIntNum(hKey5, "SFTP", Hist.UseSFTP, DefaultHist.UseSFTP);
465469
466470 CloseSubKey(hKey5);
467471 n++;
@@ -530,6 +534,10 @@ void SaveRegistory(void)
530534 SaveIntNum(hKey5, "UseIt", Host.DialupAlways, DefaultHost.DialupAlways);
531535 SaveIntNum(hKey5, "Notify", Host.DialupNotify, DefaultHost.DialupNotify);
532536 SaveStr(hKey5, "DialTo", Host.DialEntry, DefaultHost.DialEntry);
537+ // ˆÃ†‰»’ʐM‘Ήž
538+ SaveIntNum(hKey5, "FTPES", Host.UseFTPES, DefaultHost.UseFTPES);
539+ SaveIntNum(hKey5, "FTPIS", Host.UseFTPIS, DefaultHost.UseFTPIS);
540+ SaveIntNum(hKey5, "SFTP", Host.UseSFTP, DefaultHost.UseSFTP);
533541 }
534542 CloseSubKey(hKey5);
535543 }
@@ -780,6 +788,10 @@ int LoadRegistory(void)
780788 ReadIntValueFromReg(hKey5, "UseIt", &Hist.DialupAlways);
781789 ReadIntValueFromReg(hKey5, "Notify", &Hist.DialupNotify);
782790 ReadStringFromReg(hKey5, "DialTo", Hist.DialEntry, RAS_NAME_LEN+1);
791+ // ˆÃ†‰»’ʐM‘Ήž
792+ ReadIntValueFromReg(hKey5, "FTPES", &Hist.UseFTPES);
793+ ReadIntValueFromReg(hKey5, "FTPIS", &Hist.UseFTPIS);
794+ ReadIntValueFromReg(hKey5, "SFTP", &Hist.UseSFTP);
783795
784796 CloseSubKey(hKey5);
785797 AddHistoryToHistory(&Hist);
@@ -845,6 +857,10 @@ int LoadRegistory(void)
845857 ReadIntValueFromReg(hKey5, "UseIt", &Host.DialupAlways);
846858 ReadIntValueFromReg(hKey5, "Notify", &Host.DialupNotify);
847859 ReadStringFromReg(hKey5, "DialTo", Host.DialEntry, RAS_NAME_LEN+1);
860+ // ˆÃ†‰»’ʐM‘Ήž
861+ ReadIntValueFromReg(hKey5, "FTPES", &Host.UseFTPES);
862+ ReadIntValueFromReg(hKey5, "FTPIS", &Host.UseFTPIS);
863+ ReadIntValueFromReg(hKey5, "SFTP", &Host.UseSFTP);
848864
849865 CloseSubKey(hKey5);
850866
--- a/remote.c
+++ b/remote.c
@@ -1025,7 +1025,15 @@ static int ReadOneLine(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork)
10251025 memset(Buf, 0, Max);
10261026
10271027 if((SizeOnce == -2) || (AskTransferNow() == YES))
1028- DisconnectSet();
1028+ // “]‘—’†‚É‘S‚Ä’†Ž~‚ðs‚¤‚Æ•s³‚ȃf[ƒ^‚ª“¾‚ç‚ê‚éê‡‚̃oƒOC³
1029+ // ƒGƒ‰[‚ÌŽí—Þ‚É‚æ‚Á‚Ä‚Í–³ŒÀƒ‹[ƒv‚ƃXƒ^ƒbƒNƒI[ƒo[ƒtƒ[‚̉”\«‚ ‚è
1030+// DisconnectSet();
1031+ {
1032+ if(SizeOnce == -1)
1033+ ReConnectCmdSkt();
1034+ else
1035+ DisconnectSet();
1036+ }
10291037 }
10301038 else
10311039 {
--- a/socket.c
+++ b/socket.c
@@ -73,8 +73,11 @@ typedef struct {
7373 } ASYNCSIGNALDATABASE;
7474
7575
76-#define MAX_SIGNAL_ENTRY 10
77-#define MAX_SIGNAL_ENTRY_DBASE 5
76+// ƒXƒŒƒbƒhÕ“˂̃oƒOC³
77+//#define MAX_SIGNAL_ENTRY 10
78+//#define MAX_SIGNAL_ENTRY_DBASE 5
79+#define MAX_SIGNAL_ENTRY 100
80+#define MAX_SIGNAL_ENTRY_DBASE 50
7881
7982
8083
@@ -104,6 +107,8 @@ static ASYNCSIGNAL Signal[MAX_SIGNAL_ENTRY];
104107 static ASYNCSIGNALDATABASE SignalDbase[MAX_SIGNAL_ENTRY_DBASE];
105108
106109 //static HANDLE hAsyncTblAccMutex;
110+// ƒXƒŒƒbƒhÕ“˂̃oƒOC³
111+static HANDLE hAsyncTblAccMutex;
107112
108113
109114
@@ -148,10 +153,18 @@ int MakeSocketWin(HWND hWnd, HINSTANCE hInst)
148153 {
149154 // hAsyncTblAccMutex = CreateMutex(NULL, FALSE, NULL);
150155
151- for(i = 0; i < MAX_SIGNAL_ENTRY; i++)
152- Signal[i].Socket = INVALID_SOCKET;
153- for(i = 0; i < MAX_SIGNAL_ENTRY_DBASE; i++)
154- SignalDbase[i].Async = 0;
156+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
157+// for(i = 0; i < MAX_SIGNAL_ENTRY; i++)
158+// Signal[i].Socket = INVALID_SOCKET;
159+// for(i = 0; i < MAX_SIGNAL_ENTRY_DBASE; i++)
160+// SignalDbase[i].Async = 0;
161+ if(hAsyncTblAccMutex = CreateMutex(NULL, FALSE, NULL))
162+ {
163+ for(i = 0; i < MAX_SIGNAL_ENTRY; i++)
164+ Signal[i].Socket = INVALID_SOCKET;
165+ for(i = 0; i < MAX_SIGNAL_ENTRY_DBASE; i++)
166+ SignalDbase[i].Async = 0;
167+ }
155168 Sts = SUCCESS;
156169 }
157170 return(Sts);
@@ -170,6 +183,9 @@ int MakeSocketWin(HWND hWnd, HINSTANCE hInst)
170183 void DeleteSocketWin(void)
171184 {
172185 // CloseHandle(hAsyncTblAccMutex);
186+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
187+ CloseHandle(hAsyncTblAccMutex);
188+ hAsyncTblAccMutex = NULL;
173189
174190 if(hWndSocket != NULL)
175191 DestroyWindow(hWndSocket);
@@ -196,6 +212,8 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
196212 switch(message)
197213 {
198214 case WM_ASYNC_SOCKET :
215+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
216+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
199217 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
200218 {
201219 if(Signal[Pos].Socket == (SOCKET)wParam)
@@ -247,9 +265,13 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
247265 break;
248266 }
249267 }
268+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
269+ ReleaseMutex(hAsyncTblAccMutex);
250270 break;
251271
252272 case WM_ASYNC_DBASE :
273+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
274+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
253275 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++)
254276 {
255277 if(SignalDbase[Pos].Async == (HANDLE)wParam)
@@ -268,6 +290,8 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
268290 break;
269291 }
270292 }
293+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
294+ ReleaseMutex(hAsyncTblAccMutex);
271295 break;
272296
273297 default :
@@ -293,6 +317,8 @@ static int AskAsyncDone(SOCKET s, int *Error, int Mask)
293317 int Sts;
294318 int Pos;
295319
320+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
321+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
296322 Sts = NO;
297323 *Error = 0;
298324 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
@@ -344,6 +370,8 @@ static int AskAsyncDone(SOCKET s, int *Error, int Mask)
344370 break;
345371 }
346372 }
373+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
374+ ReleaseMutex(hAsyncTblAccMutex);
347375
348376 if(Pos == MAX_SIGNAL_ENTRY)
349377 {
@@ -375,6 +403,8 @@ static int AskAsyncDoneDbase(HANDLE Async, int *Error)
375403 int Sts;
376404 int Pos;
377405
406+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
407+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
378408 Sts = NO;
379409 *Error = 0;
380410 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++)
@@ -392,6 +422,8 @@ static int AskAsyncDoneDbase(HANDLE Async, int *Error)
392422 break;
393423 }
394424 }
425+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
426+ ReleaseMutex(hAsyncTblAccMutex);
395427
396428 if(Pos == MAX_SIGNAL_ENTRY_DBASE)
397429 {
@@ -417,6 +449,8 @@ static int RegistAsyncTable(SOCKET s)
417449 int Sts;
418450 int Pos;
419451
452+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
453+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
420454 Sts = NO;
421455 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
422456 {
@@ -426,9 +460,13 @@ static int RegistAsyncTable(SOCKET s)
426460 break;
427461 }
428462 }
463+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
464+ ReleaseMutex(hAsyncTblAccMutex);
429465
430466 if(Pos == MAX_SIGNAL_ENTRY)
431467 {
468+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
469+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
432470 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
433471 {
434472 if(Signal[Pos].Socket == INVALID_SOCKET)
@@ -447,6 +485,8 @@ static int RegistAsyncTable(SOCKET s)
447485 break;
448486 }
449487 }
488+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
489+ ReleaseMutex(hAsyncTblAccMutex);
450490
451491 if(Pos == MAX_SIGNAL_ENTRY)
452492 {
@@ -473,6 +513,8 @@ static int RegistAsyncTableDbase(HANDLE Async)
473513 int Sts;
474514 int Pos;
475515
516+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
517+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
476518 Sts = NO;
477519 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++)
478520 {
@@ -482,9 +524,13 @@ static int RegistAsyncTableDbase(HANDLE Async)
482524 break;
483525 }
484526 }
527+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
528+ ReleaseMutex(hAsyncTblAccMutex);
485529
486530 if(Pos == MAX_SIGNAL_ENTRY_DBASE)
487531 {
532+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
533+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
488534 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
489535 {
490536 if(SignalDbase[Pos].Async == 0)
@@ -499,6 +545,8 @@ static int RegistAsyncTableDbase(HANDLE Async)
499545 break;
500546 }
501547 }
548+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
549+ ReleaseMutex(hAsyncTblAccMutex);
502550
503551 if(Pos == MAX_SIGNAL_ENTRY_DBASE)
504552 {
@@ -525,6 +573,8 @@ static int UnRegistAsyncTable(SOCKET s)
525573 int Sts;
526574 int Pos;
527575
576+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
577+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
528578 Sts = NO;
529579 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++)
530580 {
@@ -538,6 +588,8 @@ static int UnRegistAsyncTable(SOCKET s)
538588 break;
539589 }
540590 }
591+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
592+ ReleaseMutex(hAsyncTblAccMutex);
541593 return(Sts);
542594 }
543595
@@ -556,6 +608,8 @@ static int UnRegistAsyncTableDbase(HANDLE Async)
556608 int Sts;
557609 int Pos;
558610
611+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
612+ WaitForSingleObject(hAsyncTblAccMutex, INFINITE);
559613 Sts = NO;
560614 for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++)
561615 {
@@ -569,6 +623,8 @@ static int UnRegistAsyncTableDbase(HANDLE Async)
569623 break;
570624 }
571625 }
626+ // ƒXƒŒƒbƒhÕ“˂̃oƒOC³
627+ ReleaseMutex(hAsyncTblAccMutex);
572628 return(Sts);
573629 }
574630
@@ -652,7 +708,12 @@ int do_closesocket(SOCKET s)
652708 #endif
653709 CancelCheckWork = NO;
654710
655- Ret = closesocket(s);
711+ // FTPS‘Ήž
712+// Ret = closesocket(s);
713+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
714+ Ret = closesocketS(s);
715+ else
716+ Ret = closesocket(s);
656717 if(Ret == SOCKET_ERROR)
657718 {
658719 Error = 0;
@@ -703,7 +764,12 @@ int do_connect(SOCKET s, const struct sockaddr *name, int namelen, int *CancelCh
703764 Ret = WSAAsyncSelect(s, hWndSocket, WM_ASYNC_SOCKET, FD_CONNECT | FD_CLOSE | FD_ACCEPT | FD_READ | FD_WRITE);
704765 if(Ret != SOCKET_ERROR)
705766 {
706- Ret = connect(s, name, namelen);
767+ // FTPS‘Ήž
768+// Ret = connect(s, name, namelen);
769+ if(AskCryptMode() == CRYPT_FTPIS)
770+ Ret = connectS(s, name, namelen);
771+ else
772+ Ret = connect(s, name, namelen);
707773 if(Ret == SOCKET_ERROR)
708774 {
709775 do
@@ -797,7 +863,12 @@ SOCKET do_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
797863 {
798864 do
799865 {
800- Ret2 = accept(s, addr, addrlen);
866+ // FTPS‘Ήž
867+// Ret2 = accept(s, addr, addrlen);
868+ if(AskCryptMode() == CRYPT_FTPIS)
869+ Ret2 = acceptS(s, addr, addrlen);
870+ else
871+ Ret2 = accept(s, addr, addrlen);
801872 if(Ret2 != INVALID_SOCKET)
802873 {
803874 #if DBG_MSG
@@ -866,7 +937,10 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance
866937 if(TimeOut != 0)
867938 time(&StartTime);
868939
869- while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
940+ // FTPS‘Ήž
941+ // OpenSSL‚Å‚ÍŽóMŠm”F‚ÍFD_READ‚ª•¡”‰ñŽóM‚³‚ê‚é‰Â”\«‚ª‚ ‚é
942+// while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
943+ while(AskCryptMode() == CRYPT_NONE && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
870944 {
871945 if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
872946 {
@@ -897,13 +971,38 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance
897971 DoPrintf("## recv()");
898972 #endif
899973
900- Ret = recv(s, buf, len, flags);
974+ // FTPS‘Ήž
975+// Ret = recv(s, buf, len, flags);
976+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
977+ Ret = recvS(s, buf, len, flags);
978+ else
979+ Ret = recv(s, buf, len, flags);
901980 if(Ret != SOCKET_ERROR)
902981 break;
903982 Error = WSAGetLastError();
904983 Sleep(1);
905984 if(BackgrndMessageProc() == YES)
906985 break;
986+ // FTPS‘Ήž
987+ // ŽóMŠm”F‚ðƒoƒCƒpƒX‚µ‚½‚½‚ß‚±‚±‚Ń^ƒCƒ€ƒAƒEƒg‚ÌŠm”F
988+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
989+ {
990+ if(BackgrndMessageProc() == YES)
991+ *CancelCheckWork = YES;
992+ }
993+ else if(TimeOut != 0)
994+ {
995+ time(&ElapseTime);
996+ ElapseTime -= StartTime;
997+ if(ElapseTime >= TimeOut)
998+ {
999+ DoPrintf("do_recv timed out");
1000+ *TimeOutErr = YES;
1001+ *CancelCheckWork = YES;
1002+ }
1003+ }
1004+ if(*CancelCheckWork == YES)
1005+ break;
9071006 }
9081007 while(Error == WSAEWOULDBLOCK);
9091008 }
@@ -948,7 +1047,10 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
9481047 if(BackgrndMessageProc() == YES)
9491048 *CancelCheckWork = YES;
9501049
951- while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1050+ // FTPS‘Ήž
1051+ // ‘—Mƒoƒbƒtƒ@‚Ì‹ó‚«Šm”F‚ɂ͉e‹¿‚µ‚È‚¢‚ª”O‚Ì‚½‚ß
1052+// while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1053+ while(AskCryptMode() == CRYPT_NONE && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
9521054 {
9531055 if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
9541056 {
@@ -980,7 +1082,12 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
9801082 DoPrintf("## send()");
9811083 #endif
9821084
983- Ret = send(s, buf, len, flags);
1085+ // FTPS‘Ήž
1086+// Ret = send(s, buf, len, flags);
1087+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1088+ Ret = sendS(s, buf, len, flags);
1089+ else
1090+ Ret = send(s, buf, len, flags);
9841091 if(Ret != SOCKET_ERROR)
9851092 {
9861093 #if DBG_MSG
@@ -992,6 +1099,26 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
9921099 Sleep(1);
9931100 if(BackgrndMessageProc() == YES)
9941101 break;
1102+ // FTPS‘Ήž
1103+ // ‘—Mƒoƒbƒtƒ@Šm”F‚ðƒoƒCƒpƒX‚µ‚½‚½‚ß‚±‚±‚Ń^ƒCƒ€ƒAƒEƒg‚ÌŠm”F
1104+ if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1105+ {
1106+ if(BackgrndMessageProc() == YES)
1107+ *CancelCheckWork = YES;
1108+ }
1109+ else if(TimeOut != 0)
1110+ {
1111+ time(&ElapseTime);
1112+ ElapseTime -= StartTime;
1113+ if(ElapseTime >= TimeOut)
1114+ {
1115+ DoPrintf("do_recv timed out");
1116+ *TimeOutErr = YES;
1117+ *CancelCheckWork = YES;
1118+ }
1119+ }
1120+ if(*CancelCheckWork == YES)
1121+ break;
9951122 }
9961123 while(Error == WSAEWOULDBLOCK);
9971124 }
--- /dev/null
+++ b/socketwrapper.c
@@ -0,0 +1,299 @@
1+// socketwrapper.cpp
2+// Copyright (C) 2011 Suguru Kawamoto
3+// ƒ\ƒPƒbƒgƒ‰ƒbƒp[
4+// socketŠÖ˜AŠÖ”‚ðOpenSSL—p‚É’uŠ·
5+// ƒRƒ“ƒpƒCƒ‹‚É‚ÍOpenSSL‚̃wƒbƒ_[ƒtƒ@ƒCƒ‹‚ª•K—v
6+// ŽÀs‚É‚ÍOpenSSL‚ÌDLL‚ª•K—v
7+
8+#include <windows.h>
9+#include <mmsystem.h>
10+#include <openssl/ssl.h>
11+
12+#include "socketwrapper.h"
13+
14+typedef void (__stdcall* _SSL_load_error_strings)();
15+typedef int (__stdcall* _SSL_library_init)();
16+typedef SSL_METHOD* (__stdcall* _SSLv23_method)();
17+typedef SSL_CTX* (__stdcall* _SSL_CTX_new)(SSL_METHOD*);
18+typedef void (__stdcall* _SSL_CTX_free)(SSL_CTX*);
19+typedef SSL* (__stdcall* _SSL_new)(SSL_CTX*);
20+typedef void (__stdcall* _SSL_free)(SSL*);
21+typedef int (__stdcall* _SSL_shutdown)(SSL*);
22+typedef int (__stdcall* _SSL_get_fd)(SSL*);
23+typedef int (__stdcall* _SSL_set_fd)(SSL*, int);
24+typedef int (__stdcall* _SSL_accept)(SSL*);
25+typedef int (__stdcall* _SSL_connect)(SSL*);
26+typedef int (__stdcall* _SSL_write)(SSL*, const void*, int);
27+typedef int (__stdcall* _SSL_peek)(SSL*, void*, int);
28+typedef int (__stdcall* _SSL_read)(SSL*, void*, int);
29+typedef int (__stdcall* _SSL_get_error)(SSL*, int);
30+
31+_SSL_load_error_strings pSSL_load_error_strings;
32+_SSL_library_init pSSL_library_init;
33+_SSLv23_method pSSLv23_method;
34+_SSL_CTX_new pSSL_CTX_new;
35+_SSL_CTX_free pSSL_CTX_free;
36+_SSL_new pSSL_new;
37+_SSL_free pSSL_free;
38+_SSL_shutdown pSSL_shutdown;
39+_SSL_get_fd pSSL_get_fd;
40+_SSL_set_fd pSSL_set_fd;
41+_SSL_accept pSSL_accept;
42+_SSL_connect pSSL_connect;
43+_SSL_write pSSL_write;
44+_SSL_peek pSSL_peek;
45+_SSL_read pSSL_read;
46+_SSL_get_error pSSL_get_error;
47+
48+#define MAX_SSL_SOCKET 16
49+
50+BOOL g_bOpenSSLLoaded;
51+HMODULE g_hOpenSSL;
52+CRITICAL_SECTION g_OpenSSLLock;
53+DWORD g_OpenSSLTimeout;
54+LPSSLTIMEOUTCALLBACK g_pOpenSSLTimeoutCallback;
55+SSL_CTX* g_pOpenSSLCTX;
56+SSL* g_pOpenSSLHandle[MAX_SSL_SOCKET];
57+
58+BOOL __stdcall DefaultSSLTimeoutCallback()
59+{
60+ Sleep(100);
61+ return FALSE;
62+}
63+
64+BOOL LoadOpenSSL()
65+{
66+ if(g_bOpenSSLLoaded)
67+ return FALSE;
68+ g_hOpenSSL = LoadLibrary("ssleay32.dll");
69+ if(!g_hOpenSSL)
70+ g_hOpenSSL = LoadLibrary("libssl32.dll");
71+ if(!g_hOpenSSL
72+ || !(pSSL_load_error_strings = (_SSL_load_error_strings)GetProcAddress(g_hOpenSSL, "SSL_load_error_strings"))
73+ || !(pSSL_library_init = (_SSL_library_init)GetProcAddress(g_hOpenSSL, "SSL_library_init"))
74+ || !(pSSLv23_method = (_SSLv23_method)GetProcAddress(g_hOpenSSL, "SSLv23_method"))
75+ || !(pSSL_CTX_new = (_SSL_CTX_new)GetProcAddress(g_hOpenSSL, "SSL_CTX_new"))
76+ || !(pSSL_CTX_free = (_SSL_CTX_free)GetProcAddress(g_hOpenSSL, "SSL_CTX_free"))
77+ || !(pSSL_new = (_SSL_new)GetProcAddress(g_hOpenSSL, "SSL_new"))
78+ || !(pSSL_free = (_SSL_free)GetProcAddress(g_hOpenSSL, "SSL_free"))
79+ || !(pSSL_shutdown = (_SSL_shutdown)GetProcAddress(g_hOpenSSL, "SSL_shutdown"))
80+ || !(pSSL_get_fd = (_SSL_get_fd)GetProcAddress(g_hOpenSSL, "SSL_get_fd"))
81+ || !(pSSL_set_fd = (_SSL_set_fd)GetProcAddress(g_hOpenSSL, "SSL_set_fd"))
82+ || !(pSSL_accept = (_SSL_accept)GetProcAddress(g_hOpenSSL, "SSL_accept"))
83+ || !(pSSL_connect = (_SSL_connect)GetProcAddress(g_hOpenSSL, "SSL_connect"))
84+ || !(pSSL_write = (_SSL_write)GetProcAddress(g_hOpenSSL, "SSL_write"))
85+ || !(pSSL_peek = (_SSL_peek)GetProcAddress(g_hOpenSSL, "SSL_peek"))
86+ || !(pSSL_read = (_SSL_read)GetProcAddress(g_hOpenSSL, "SSL_read"))
87+ || !(pSSL_get_error = (_SSL_get_error)GetProcAddress(g_hOpenSSL, "SSL_get_error")))
88+ {
89+ FreeLibrary(g_hOpenSSL);
90+ g_hOpenSSL = NULL;
91+ return FALSE;
92+ }
93+ InitializeCriticalSection(&g_OpenSSLLock);
94+ pSSL_load_error_strings();
95+ pSSL_library_init();
96+ SetSSLTimeoutCallback(60000, DefaultSSLTimeoutCallback);
97+ g_bOpenSSLLoaded = TRUE;
98+ return TRUE;
99+}
100+
101+void FreeOpenSSL()
102+{
103+ int i;
104+ if(!g_bOpenSSLLoaded)
105+ return;
106+ EnterCriticalSection(&g_OpenSSLLock);
107+ for(i = 0; i < MAX_SSL_SOCKET; i++)
108+ {
109+ if(g_pOpenSSLHandle[i])
110+ {
111+ pSSL_shutdown(g_pOpenSSLHandle[i]);
112+ pSSL_free(g_pOpenSSLHandle[i]);
113+ g_pOpenSSLHandle[i] = NULL;
114+ }
115+ }
116+ if(g_pOpenSSLCTX)
117+ pSSL_CTX_free(g_pOpenSSLCTX);
118+ g_pOpenSSLCTX = NULL;
119+ FreeLibrary(g_hOpenSSL);
120+ g_hOpenSSL = NULL;
121+ LeaveCriticalSection(&g_OpenSSLLock);
122+ DeleteCriticalSection(&g_OpenSSLLock);
123+ g_bOpenSSLLoaded = FALSE;
124+}
125+
126+BOOL IsOpenSSLLoaded()
127+{
128+ return g_bOpenSSLLoaded;
129+}
130+
131+SSL** GetUnusedSSLPointer()
132+{
133+ int i;
134+ for(i = 0; i < MAX_SSL_SOCKET; i++)
135+ {
136+ if(!g_pOpenSSLHandle[i])
137+ return &g_pOpenSSLHandle[i];
138+ }
139+ return NULL;
140+}
141+
142+SSL** FindSSLPointerFromSocket(SOCKET s)
143+{
144+ int i;
145+ for(i = 0; i < MAX_SSL_SOCKET; i++)
146+ {
147+ if(g_pOpenSSLHandle[i])
148+ {
149+ if(pSSL_get_fd(g_pOpenSSLHandle[i]) == s)
150+ return &g_pOpenSSLHandle[i];
151+ }
152+ }
153+ return NULL;
154+}
155+
156+void SetSSLTimeoutCallback(DWORD Timeout, LPSSLTIMEOUTCALLBACK pCallback)
157+{
158+ EnterCriticalSection(&g_OpenSSLLock);
159+ g_OpenSSLTimeout = Timeout;
160+ g_pOpenSSLTimeoutCallback = pCallback;
161+ LeaveCriticalSection(&g_OpenSSLLock);
162+}
163+
164+BOOL AttachSSL(SOCKET s)
165+{
166+ BOOL r;
167+ DWORD Time;
168+ SSL** ppSSL;
169+ r = FALSE;
170+ Time = timeGetTime();
171+ EnterCriticalSection(&g_OpenSSLLock);
172+ if(!g_pOpenSSLCTX)
173+ g_pOpenSSLCTX = pSSL_CTX_new(pSSLv23_method());
174+ if(g_pOpenSSLCTX)
175+ {
176+ if(ppSSL = GetUnusedSSLPointer())
177+ {
178+ if(*ppSSL = pSSL_new(g_pOpenSSLCTX))
179+ {
180+ if(pSSL_set_fd(*ppSSL, s) != 0)
181+ {
182+ r = TRUE;
183+ // SSL‚̃lƒSƒVƒG[ƒVƒ‡ƒ“‚É‚ÍŽžŠÔ‚ª‚©‚©‚éê‡‚ª‚ ‚é
184+ while(pSSL_connect(*ppSSL) != 1)
185+ {
186+ LeaveCriticalSection(&g_OpenSSLLock);
187+ if(g_pOpenSSLTimeoutCallback() || timeGetTime() - Time >= g_OpenSSLTimeout)
188+ {
189+ DetachSSL(s);
190+ r = FALSE;
191+ EnterCriticalSection(&g_OpenSSLLock);
192+ break;
193+ }
194+ EnterCriticalSection(&g_OpenSSLLock);
195+ }
196+ }
197+ else
198+ DetachSSL(s);
199+ }
200+ }
201+ }
202+ LeaveCriticalSection(&g_OpenSSLLock);
203+ return r;
204+}
205+
206+BOOL DetachSSL(SOCKET s)
207+{
208+ BOOL r;
209+ SSL** ppSSL;
210+ r = FALSE;
211+ EnterCriticalSection(&g_OpenSSLLock);
212+ if(ppSSL = FindSSLPointerFromSocket(s))
213+ {
214+ pSSL_shutdown(*ppSSL);
215+ pSSL_free(*ppSSL);
216+ *ppSSL = NULL;
217+ r = TRUE;
218+ }
219+ LeaveCriticalSection(&g_OpenSSLLock);
220+ return r;
221+}
222+
223+BOOL IsSSLAttached(SOCKET s)
224+{
225+ SSL** ppSSL;
226+ EnterCriticalSection(&g_OpenSSLLock);
227+ ppSSL = FindSSLPointerFromSocket(s);
228+ LeaveCriticalSection(&g_OpenSSLLock);
229+ if(!ppSSL)
230+ return TRUE;
231+ return TRUE;
232+}
233+
234+SOCKET socketS(int af, int type, int protocol)
235+{
236+ return socket(af, type, protocol);
237+}
238+
239+int bindS(SOCKET s, const struct sockaddr *addr, int namelen)
240+{
241+ return bind(s, addr, namelen);
242+}
243+
244+int listenS(SOCKET s, int backlog)
245+{
246+ return listen(s, backlog);
247+}
248+
249+SOCKET acceptS(SOCKET s, struct sockaddr *addr, int *addrlen)
250+{
251+ SOCKET r;
252+ r = accept(s, addr, addrlen);
253+ if(!AttachSSL(r))
254+ {
255+ closesocket(r);
256+ return INVALID_SOCKET;
257+ }
258+ return r;
259+}
260+
261+int connectS(SOCKET s, const struct sockaddr *name, int namelen)
262+{
263+ int r;
264+ r = connect(s, name, namelen);
265+ if(!AttachSSL(r))
266+ return SOCKET_ERROR;
267+ return r;
268+}
269+
270+int closesocketS(SOCKET s)
271+{
272+ DetachSSL(s);
273+ return closesocket(s);
274+}
275+
276+int sendS(SOCKET s, const char * buf, int len, int flags)
277+{
278+ SSL** ppSSL;
279+ EnterCriticalSection(&g_OpenSSLLock);
280+ ppSSL = FindSSLPointerFromSocket(s);
281+ LeaveCriticalSection(&g_OpenSSLLock);
282+ if(!ppSSL)
283+ return send(s, buf, len, flags);
284+ return pSSL_write(*ppSSL, buf, len);
285+}
286+
287+int recvS(SOCKET s, char * buf, int len, int flags)
288+{
289+ SSL** ppSSL;
290+ EnterCriticalSection(&g_OpenSSLLock);
291+ ppSSL = FindSSLPointerFromSocket(s);
292+ LeaveCriticalSection(&g_OpenSSLLock);
293+ if(!ppSSL)
294+ return recv(s, buf, len, flags);
295+ if(flags & MSG_PEEK)
296+ return pSSL_peek(*ppSSL, buf, len);
297+ return pSSL_read(*ppSSL, buf, len);
298+}
299+
--- /dev/null
+++ b/socketwrapper.h
@@ -0,0 +1,29 @@
1+// socketwrapper.h
2+// Copyright (C) 2011 Suguru Kawamoto
3+// ƒ\ƒPƒbƒgƒ‰ƒbƒp[
4+
5+#ifndef __SOCKETWRAPPER_H__
6+#define __SOCKETWRAPPER_H__
7+
8+#define USE_OPENSSL
9+
10+typedef BOOL (__stdcall* LPSSLTIMEOUTCALLBACK)();
11+
12+BOOL LoadOpenSSL();
13+void FreeOpenSSL();
14+BOOL IsOpenSSLLoaded();
15+void SetSSLTimeoutCallback(DWORD Timeout, LPSSLTIMEOUTCALLBACK pCallback);
16+BOOL AttachSSL(SOCKET s);
17+BOOL DetachSSL(SOCKET s);
18+BOOL IsSSLAttached(SOCKET s);
19+SOCKET socketS(int af, int type, int protocol);
20+int bindS(SOCKET s, const struct sockaddr *addr, int namelen);
21+int listenS(SOCKET s, int backlog);
22+SOCKET acceptS(SOCKET s, struct sockaddr *addr, int *addrlen);
23+int connectS(SOCKET s, const struct sockaddr *name, int namelen);
24+int closesocketS(SOCKET s);
25+int sendS(SOCKET s, const char * buf, int len, int flags);
26+int recvS(SOCKET s, char * buf, int len, int flags);
27+
28+#endif
29+