Loweynet
Revisão | 756eb24e756aa444a4f4bc2bfd2640d525ccdcb1 (tree) |
---|---|
Hora | 2011-09-11 23:59:43 |
Autor | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
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.
@@ -335,6 +335,10 @@ | ||
335 | 335 | > |
336 | 336 | </File> |
337 | 337 | <File |
338 | + RelativePath=".\socketwrapper.c" | |
339 | + > | |
340 | + </File> | |
341 | + <File | |
338 | 342 | RelativePath=".\statuswin.c" |
339 | 343 | > |
340 | 344 | </File> |
@@ -375,6 +379,10 @@ | ||
375 | 379 | RelativePath=".\Resource\resource.h" |
376 | 380 | > |
377 | 381 | </File> |
382 | + <File | |
383 | + RelativePath=".\socketwrapper.h" | |
384 | + > | |
385 | + </File> | |
378 | 386 | </Filter> |
379 | 387 | <Filter |
380 | 388 | Name="Resource Files" |
@@ -284,6 +284,10 @@ | ||
284 | 284 | > |
285 | 285 | </File> |
286 | 286 | <File |
287 | + RelativePath=".\mbswrapper.c" | |
288 | + > | |
289 | + </File> | |
290 | + <File | |
287 | 291 | RelativePath=".\md4.c" |
288 | 292 | > |
289 | 293 | </File> |
@@ -332,6 +336,10 @@ | ||
332 | 336 | > |
333 | 337 | </File> |
334 | 338 | <File |
339 | + RelativePath=".\socketwrapper.c" | |
340 | + > | |
341 | + </File> | |
342 | + <File | |
335 | 343 | RelativePath=".\statuswin.c" |
336 | 344 | > |
337 | 345 | </File> |
@@ -365,9 +373,17 @@ | ||
365 | 373 | > |
366 | 374 | </File> |
367 | 375 | <File |
376 | + RelativePath=".\mbswrapper.h" | |
377 | + > | |
378 | + </File> | |
379 | + <File | |
368 | 380 | RelativePath=".\Resource\resource.h" |
369 | 381 | > |
370 | 382 | </File> |
383 | + <File | |
384 | + RelativePath=".\socketwrapper.h" | |
385 | + > | |
386 | + </File> | |
371 | 387 | </Filter> |
372 | 388 | <Filter |
373 | 389 | Name="Resource Files" |
@@ -335,6 +335,10 @@ | ||
335 | 335 | > |
336 | 336 | </File> |
337 | 337 | <File |
338 | + RelativePath=".\socketwrapper.c" | |
339 | + > | |
340 | + </File> | |
341 | + <File | |
338 | 342 | RelativePath=".\statuswin.c" |
339 | 343 | > |
340 | 344 | </File> |
@@ -375,6 +379,10 @@ | ||
375 | 379 | RelativePath=".\Resource_eng\resource.h" |
376 | 380 | > |
377 | 381 | </File> |
382 | + <File | |
383 | + RelativePath=".\socketwrapper.h" | |
384 | + > | |
385 | + </File> | |
378 | 386 | </Filter> |
379 | 387 | <Filter |
380 | 388 | Name="Resource Files" |
@@ -284,6 +284,10 @@ | ||
284 | 284 | > |
285 | 285 | </File> |
286 | 286 | <File |
287 | + RelativePath=".\mbswrapper.c" | |
288 | + > | |
289 | + </File> | |
290 | + <File | |
287 | 291 | RelativePath=".\md4.c" |
288 | 292 | > |
289 | 293 | </File> |
@@ -332,6 +336,10 @@ | ||
332 | 336 | > |
333 | 337 | </File> |
334 | 338 | <File |
339 | + RelativePath=".\socketwrapper.c" | |
340 | + > | |
341 | + </File> | |
342 | + <File | |
335 | 343 | RelativePath=".\statuswin.c" |
336 | 344 | > |
337 | 345 | </File> |
@@ -365,9 +373,17 @@ | ||
365 | 373 | > |
366 | 374 | </File> |
367 | 375 | <File |
376 | + RelativePath=".\mbswrapper.h" | |
377 | + > | |
378 | + </File> | |
379 | + <File | |
368 | 380 | RelativePath=".\Resource_eng\resource.h" |
369 | 381 | > |
370 | 382 | </File> |
383 | + <File | |
384 | + RelativePath=".\socketwrapper.h" | |
385 | + > | |
386 | + </File> | |
371 | 387 | </Filter> |
372 | 388 | <Filter |
373 | 389 | Name="Resource Files" |
@@ -1341,6 +1341,15 @@ BEGIN | ||
1341 | 1341 | CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,172,42,8,8 |
1342 | 1342 | END |
1343 | 1343 | |
1344 | +hset_crypt_dlg DIALOG 0, 0, 207, 139 | |
1345 | +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION | |
1346 | +FONT 9, "lr oSVbN" | |
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 | + | |
1344 | 1353 | |
1345 | 1354 | ///////////////////////////////////////////////////////////////////////////// |
1346 | 1355 | // |
@@ -108,6 +108,7 @@ | ||
108 | 108 | #define forcepasschange_dlg 186 |
109 | 109 | #define newmasterpasswd_dlg 187 |
110 | 110 | #define masterpasswd_dlg 188 |
111 | +#define hset_crypt_dlg 189 | |
111 | 112 | #define TRANS_TIME_BAR 1002 |
112 | 113 | #define TRANS_TEXT 1003 |
113 | 114 | #define TRANS_REMOTE 1003 |
@@ -419,6 +420,9 @@ | ||
419 | 420 | #define HSET_SJIS_CNV 1195 |
420 | 421 | #define HSET_UTF8N_CNV 1196 |
421 | 422 | #define HSET_FN_SJIS_CNV 1197 |
423 | +#define HSET_FTPES 1198 | |
424 | +#define HSET_FTPIS 1199 | |
425 | +#define HSET_SFTP 1200 | |
422 | 426 | #define MENU_END 40001 |
423 | 427 | #define MENU_EXIT 40001 |
424 | 428 | #define MENU_CONNECT 40003 |
@@ -602,9 +606,9 @@ | ||
602 | 606 | // |
603 | 607 | #ifdef APSTUDIO_INVOKED |
604 | 608 | #ifndef APSTUDIO_READONLY_SYMBOLS |
605 | -#define _APS_NEXT_RESOURCE_VALUE 189 | |
609 | +#define _APS_NEXT_RESOURCE_VALUE 190 | |
606 | 610 | #define _APS_NEXT_COMMAND_VALUE 40175 |
607 | -#define _APS_NEXT_CONTROL_VALUE 1198 | |
611 | +#define _APS_NEXT_CONTROL_VALUE 1201 | |
608 | 612 | #define _APS_NEXT_SYMED_VALUE 101 |
609 | 613 | #endif |
610 | 614 | #endif |
@@ -1201,6 +1201,15 @@ BEGIN | ||
1201 | 1201 | CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,173,39,8,8 |
1202 | 1202 | END |
1203 | 1203 | |
1204 | +hset_crypt_dlg DIALOG 0, 0, 207, 139 | |
1205 | +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION | |
1206 | +FONT 9, "lr oSVbN" | |
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 | + | |
1204 | 1213 | |
1205 | 1214 | ///////////////////////////////////////////////////////////////////////////// |
1206 | 1215 | // |
@@ -108,6 +108,7 @@ | ||
108 | 108 | #define forcepasschange_dlg 186 |
109 | 109 | #define newmasterpasswd_dlg 187 |
110 | 110 | #define masterpasswd_dlg 188 |
111 | +#define hset_crypt_dlg 189 | |
111 | 112 | #define TRANS_TIME_BAR 1002 |
112 | 113 | #define TRANS_TEXT 1003 |
113 | 114 | #define TRANS_REMOTE 1003 |
@@ -419,6 +420,9 @@ | ||
419 | 420 | #define HSET_SJIS_CNV 1195 |
420 | 421 | #define HSET_UTF8N_CNV 1196 |
421 | 422 | #define HSET_FN_SJIS_CNV 1197 |
423 | +#define HSET_FTPES 1198 | |
424 | +#define HSET_FTPIS 1199 | |
425 | +#define HSET_SFTP 1200 | |
422 | 426 | #define MENU_END 40001 |
423 | 427 | #define MENU_EXIT 40001 |
424 | 428 | #define MENU_CONNECT 40003 |
@@ -602,9 +606,9 @@ | ||
602 | 606 | // |
603 | 607 | #ifdef APSTUDIO_INVOKED |
604 | 608 | #ifndef APSTUDIO_READONLY_SYMBOLS |
605 | -#define _APS_NEXT_RESOURCE_VALUE 189 | |
609 | +#define _APS_NEXT_RESOURCE_VALUE 190 | |
606 | 610 | #define _APS_NEXT_COMMAND_VALUE 40175 |
607 | -#define _APS_NEXT_CONTROL_VALUE 1198 | |
611 | +#define _APS_NEXT_CONTROL_VALUE 1201 | |
608 | 612 | #define _APS_NEXT_SYMED_VALUE 101 |
609 | 613 | #endif |
610 | 614 | #endif |
@@ -853,6 +853,12 @@ LIST_UNIX_70 | ||
853 | 853 | #define DEFAULT_PASSWORD "DefaultPassword" |
854 | 854 | #define MAX_PASSWORD_LEN 128 |
855 | 855 | |
856 | +// ûÊMÎ | |
857 | +#define CRYPT_NONE 0 | |
858 | +#define CRYPT_FTPES 1 | |
859 | +#define CRYPT_FTPIS 2 | |
860 | +#define CRYPT_SFTP 3 | |
861 | + | |
856 | 862 | |
857 | 863 | /*================================================= |
858 | 864 | * XgN` |
@@ -896,6 +902,11 @@ typedef struct { | ||
896 | 902 | int DialupAlways; /* íɱÌGgÖÚ±·é©Ç¤© (YES/NO) */ |
897 | 903 | int DialupNotify; /* ÄÚ±ÌÛÉmF·é (YES/NO) */ |
898 | 904 | char DialEntry[RAS_NAME_LEN+1]; /* _CAAbvGg */ |
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) */ | |
899 | 910 | } HOSTDATA; |
900 | 911 | |
901 | 912 |
@@ -942,6 +953,10 @@ typedef struct historydata { | ||
942 | 953 | int DialupAlways; /* íɱÌGgÖÚ±·é©Ç¤© (YES/NO) */ |
943 | 954 | int DialupNotify; /* ÄÚ±ÌÛÉmF·é (YES/NO) */ |
944 | 955 | char DialEntry[RAS_NAME_LEN+1]; /* _CAAbvGg */ |
956 | + // ûÊMÎ | |
957 | + int UseFTPES; /* FTPESÅÚ±·é (YES/NO) */ | |
958 | + int UseFTPIS; /* FTPISÅÚ±·é (YES/NO) */ | |
959 | + int UseSFTP; /* SFTPÅÚ±·é (YES/NO) */ | |
945 | 960 | struct historydata *Next; |
946 | 961 | } HISTORYDATA; |
947 | 962 |
@@ -962,11 +977,14 @@ typedef struct transpacket { | ||
962 | 977 | FILETIME Time; /* t@CÌÔ(UTC) */ |
963 | 978 | int Attr; /* t@CÌ®« */ |
964 | 979 | int KanjiCode; /* ¿R[h (KANJI_xxx) */ |
965 | - int KanjiCodeDesired; /* Ï·æÌ¿R[h (KANJI_xxx) */ | |
980 | + // UTF-8Î | |
981 | + int KanjiCodeDesired; /* [JÌ¿R[h (KANJI_xxx) */ | |
966 | 982 | int KanaCnv; /* ¼pJiðSpÉÏ·(YES/NO) */ |
967 | 983 | int Mode; /* ][h (EXIST_xxx) */ |
968 | 984 | HWND hWndTrans; /* ]_CAOÌEChEnh */ |
969 | 985 | int Abort; /* ]~tO (ABORT_xxx) */ |
986 | + // ûÊMÎ | |
987 | + int CryptMode; /* ûÊM[h (CRYPT_xxx) */ | |
970 | 988 | struct transpacket *Next; |
971 | 989 | } TRANSPACKET; |
972 | 990 |
@@ -1169,6 +1187,8 @@ int AskForceIni(void); | ||
1169 | 1187 | int BackgrndMessageProc(void); |
1170 | 1188 | void ResetAutoExitFlg(void); |
1171 | 1189 | int AskAutoExit(void); |
1190 | +// ûÊMÎ | |
1191 | +BOOL __stdcall SSLTimeoutCallback(); | |
1172 | 1192 | |
1173 | 1193 | /*===== filelist.c =====*/ |
1174 | 1194 |
@@ -1340,6 +1360,11 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork); | ||
1340 | 1360 | SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork); |
1341 | 1361 | int AskTryingConnect(void); |
1342 | 1362 | int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data); |
1363 | +// ûÊMÎ | |
1364 | +int AskCryptMode(void); | |
1365 | +int AskUseFTPES(void); | |
1366 | +int AskUseFTPIS(void); | |
1367 | +int AskUseSFTP(void); | |
1343 | 1368 | |
1344 | 1369 | /*===== cache.c =====*/ |
1345 | 1370 |
@@ -2,11 +2,15 @@ | ||
2 | 2 | /* OPENVMSpÌR[hðLøÉ·éBóûaì¬Ìpb`ðgÝÝܵ½B */ |
3 | 3 | #define HAVE_OPENVMS |
4 | 4 | |
5 | -//SÌÉe¿·éÝèͱ±ÉLq·é\è | |
6 | -//àðUTF-8Ƶĵ¢}`oCg¶Ch¶APIbp[ðgp·é | |
5 | +// SÌÉe¿·éÝèͱ±ÉLq·é\è | |
6 | +// àðUTF-8Ƶĵ¢}`oCg¶Ch¶APIbp[ðgp·é | |
7 | 7 | #include "mbswrapper.h" |
8 | -//gp·éCPUð1ÂÉÀè·éi}`RACPUÌÁ諺Åt@CÊMÉNbV ·éoOÎôj | |
8 | +// OpenSSLp\Pbgbp[ðgp·é | |
9 | +#include "socketwrapper.h" | |
10 | +// gp·éCPUð1ÂÉÀè·éi}`RACPUÌÁ諺Åt@CÊMÉNbV ·éoOÎôj | |
9 | 11 | #define DISABLE_MULTI_CPUS |
10 | -//lbg[Nobt@ð³øÉ·éiÊM~ãÉ[gÌfBNgª\¦³êÈ¢oOÎôj | |
11 | -//#define DISABLE_NETWORK_BUFFERS | |
12 | +// t@C]pÌlbg[Nobt@ð³øÉ·éiÊM~ãÉ[gÌfBNgª\¦³êÈ¢oOÎôj | |
13 | +//#define DISABLE_TRANSFER_NETWORK_BUFFERS | |
14 | +// Rg[pÌlbg[Nobt@ð³øÉ·éit[YÎôj | |
15 | +#define DISABLE_CONTROL_NETWORK_BUFFERS | |
12 | 16 |
@@ -1213,6 +1213,12 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port | ||
1213 | 1213 | { |
1214 | 1214 | if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET) |
1215 | 1215 | { |
1216 | + // obt@ð³ø | |
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 | |
1216 | 1222 | while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM) |
1217 | 1223 | ; |
1218 | 1224 |
@@ -1221,6 +1227,8 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port | ||
1221 | 1227 | Flg = 1; |
1222 | 1228 | if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR) |
1223 | 1229 | ReportWSError("setsockopt", WSAGetLastError()); |
1230 | + if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR) | |
1231 | + ReportWSError("setsockopt", WSAGetLastError()); | |
1224 | 1232 | #pragma aaa |
1225 | 1233 | Flg = 1; |
1226 | 1234 | 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 | ||
1299 | 1307 | else |
1300 | 1308 | strcpy(Buf, User); |
1301 | 1309 | |
1310 | + // FTPESÎ | |
1311 | + // 2ñÈãÄÎêéª é½ßùÉFTPESÅÚ±µÄ¢ÄàÄmF | |
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 | + | |
1302 | 1343 | ReInPass = NO; |
1303 | 1344 | do |
1304 | 1345 | { |
@@ -2123,3 +2164,24 @@ int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data) | ||
2123 | 2164 | |
2124 | 2165 | |
2125 | 2166 | |
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 | + |
@@ -200,6 +200,7 @@ void DownLoadProc(int ChName, int ForceFile, int All) | ||
200 | 200 | Pkt.Size = Pos->Size; |
201 | 201 | Pkt.Time = Pos->Time; |
202 | 202 | Pkt.KanjiCode = AskHostKanjiCode(); |
203 | + // UTF-8Î | |
203 | 204 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
204 | 205 | Pkt.KanaCnv = AskHostKanaCnv(); |
205 | 206 |
@@ -302,6 +303,7 @@ void DirectDownLoadProc(char *Fname) | ||
302 | 303 | /* TCYÆútÍ]¤XbhÅæ¾µAZbg·é */ |
303 | 304 | |
304 | 305 | Pkt.KanjiCode = AskHostKanjiCode(); |
306 | + // UTF-8Î | |
305 | 307 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
306 | 308 | Pkt.KanaCnv = AskHostKanaCnv(); |
307 | 309 |
@@ -553,6 +555,7 @@ void MirrorDownloadProc(int Notify) | ||
553 | 555 | Pkt.Time = RemotePos->Time; |
554 | 556 | // Pkt.Attr = 0; |
555 | 557 | Pkt.KanjiCode = AskHostKanjiCode(); |
558 | + // UTF-8Î | |
556 | 559 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
557 | 560 | Pkt.KanaCnv = AskHostKanaCnv(); |
558 | 561 | Pkt.Mode = EXIST_OVW; |
@@ -947,6 +950,7 @@ void UpLoadListProc(int ChName, int All) | ||
947 | 950 | Pkt.Time = Pos->Time; |
948 | 951 | Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); |
949 | 952 | Pkt.KanjiCode = AskHostKanjiCode(); |
953 | + // UTF-8Î | |
950 | 954 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
951 | 955 | Pkt.KanaCnv = AskHostKanaCnv(); |
952 | 956 | Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList); |
@@ -1098,6 +1102,7 @@ void UpLoadDragProc(WPARAM wParam) | ||
1098 | 1102 | Pkt.Time = Pos->Time; |
1099 | 1103 | Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); |
1100 | 1104 | Pkt.KanjiCode = AskHostKanjiCode(); |
1105 | + // UTF-8Î | |
1101 | 1106 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
1102 | 1107 | Pkt.KanaCnv = AskHostKanaCnv(); |
1103 | 1108 | Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList); |
@@ -1365,6 +1370,7 @@ void MirrorUploadProc(int Notify) | ||
1365 | 1370 | Pkt.Time = LocalPos->Time; |
1366 | 1371 | Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); |
1367 | 1372 | Pkt.KanjiCode = AskHostKanjiCode(); |
1373 | + // UTF-8Î | |
1368 | 1374 | Pkt.KanjiCodeDesired = AskLocalKanjiCode(); |
1369 | 1375 | Pkt.KanaCnv = AskHostKanaCnv(); |
1370 | 1376 | Pkt.Mode = EXIST_OVW; |
@@ -57,7 +57,7 @@ | ||
57 | 57 | #define SOCKBUF_SIZE (256 * 1024) |
58 | 58 | /* End */ |
59 | 59 | |
60 | -#ifdef DISABLE_NETWORK_BUFFERS | |
60 | +#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS | |
61 | 61 | #undef BUFSIZE |
62 | 62 | #define BUFSIZE (64 * 1024) // RWINlȺÅ[ªÈ嫳ª]ܵ¢ÆvíêéB |
63 | 63 | #undef SET_BUFFER_SIZE |
@@ -1017,7 +1017,17 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork) | ||
1017 | 1017 | |
1018 | 1018 | if(data_socket != INVALID_SOCKET) |
1019 | 1019 | { |
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); | |
1021 | 1031 | // data_socket = DoClose(data_socket); |
1022 | 1032 | } |
1023 | 1033 | } |
@@ -1070,6 +1080,8 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork) | ||
1070 | 1080 | { |
1071 | 1081 | if((data_socket = connectsock(Adrs, Port, MSGJPN091, CancelCheckWork)) != INVALID_SOCKET) |
1072 | 1082 | { |
1083 | + // Ϫ¢ú»ÌoOC³ | |
1084 | + Flg = 1; | |
1073 | 1085 | if(setsockopt(data_socket, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR) |
1074 | 1086 | ReportWSError("setsockopt", WSAGetLastError()); |
1075 | 1087 |
@@ -1079,7 +1091,17 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork) | ||
1079 | 1091 | iRetCode = command(Pkt->ctrl_skt, Reply, CancelCheckWork, "%s", Buf); |
1080 | 1092 | if(iRetCode/100 == FTP_PRELIM) |
1081 | 1093 | { |
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); | |
1083 | 1105 | // data_socket = DoClose(data_socket); |
1084 | 1106 | } |
1085 | 1107 | else |
@@ -1155,8 +1177,8 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc | ||
1155 | 1177 | /* End */ |
1156 | 1178 | #endif |
1157 | 1179 | |
1158 | -#ifdef DISABLE_NETWORK_BUFFERS | |
1159 | - // O̽ßóMobt@ð³øÉ·éB | |
1180 | + // O̽ßóMobt@ð³øÉ·é | |
1181 | +#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS | |
1160 | 1182 | int buf_size = 0; |
1161 | 1183 | setsockopt(dSkt, SOL_SOCKET, SO_RCVBUF, (char *)&buf_size, sizeof(buf_size)); |
1162 | 1184 | #endif |
@@ -2002,7 +2024,17 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt) | ||
2002 | 2024 | |
2003 | 2025 | if(data_socket != INVALID_SOCKET) |
2004 | 2026 | { |
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); | |
2006 | 2038 | data_socket = DoClose(data_socket); |
2007 | 2039 | } |
2008 | 2040 | } |
@@ -2052,6 +2084,8 @@ static int UpLoadPassive(TRANSPACKET *Pkt) | ||
2052 | 2084 | { |
2053 | 2085 | if((data_socket = connectsock(Adrs, Port, MSGJPN109, &Canceled)) != INVALID_SOCKET) |
2054 | 2086 | { |
2087 | + // Ϫ¢ú»ÌoOC³ | |
2088 | + Flg = 1; | |
2055 | 2089 | if(setsockopt(data_socket, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR) |
2056 | 2090 | ReportWSError("setsockopt", WSAGetLastError()); |
2057 | 2091 |
@@ -2064,7 +2098,17 @@ static int UpLoadPassive(TRANSPACKET *Pkt) | ||
2064 | 2098 | iRetCode = command(Pkt->ctrl_skt, Reply, &Canceled, "%s", Buf); |
2065 | 2099 | if(iRetCode/100 == FTP_PRELIM) |
2066 | 2100 | { |
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); | |
2068 | 2112 | |
2069 | 2113 | data_socket = DoClose(data_socket); |
2070 | 2114 | } |
@@ -2140,8 +2184,8 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt) | ||
2140 | 2184 | /* End */ |
2141 | 2185 | #endif |
2142 | 2186 | |
2143 | -#ifdef DISABLE_NETWORK_BUFFERS | |
2144 | - // O̽ßMobt@ð³øÉ·éB | |
2187 | + // O̽ßMobt@ð³øÉ·é | |
2188 | +#ifdef DISABLE_TRANSFER_NETWORK_BUFFERS | |
2145 | 2189 | int buf_size = 0; |
2146 | 2190 | setsockopt(dSkt, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof(buf_size)); |
2147 | 2191 | #endif |
@@ -3021,7 +3065,7 @@ static int IsSpecialDevice(char *Fname) | ||
3021 | 3065 | int Sts; |
3022 | 3066 | |
3023 | 3067 | Sts = NO; |
3024 | - // oOC³ | |
3068 | + // ärªs®SÈoOC³ | |
3025 | 3069 | // if((_stricmp(Fname, "CON") == 0) || |
3026 | 3070 | // (_stricmp(Fname, "PRN") == 0) || |
3027 | 3071 | // (_stricmp(Fname, "AUX") == 0) || |
@@ -223,6 +223,10 @@ static void CopyHostToHistory(HOSTDATA *Host, HISTORYDATA *New) | ||
223 | 223 | New->DialupAlways = Host->DialupAlways; |
224 | 224 | New->DialupNotify = Host->DialupNotify; |
225 | 225 | strcpy(New->DialEntry, Host->DialEntry); |
226 | + // ûÊMÎ | |
227 | + New->UseFTPES = Host->UseFTPES; | |
228 | + New->UseFTPIS = Host->UseFTPIS; | |
229 | + New->UseSFTP = Host->UseSFTP; | |
226 | 230 | return; |
227 | 231 | } |
228 | 232 |
@@ -272,6 +276,10 @@ void CopyHistoryToHost(HISTORYDATA *Hist, HOSTDATA *Host) | ||
272 | 276 | Host->DialupAlways = Hist->DialupAlways; |
273 | 277 | Host->DialupNotify = Hist->DialupNotify; |
274 | 278 | strcpy(Host->DialEntry, Hist->DialEntry); |
279 | + // ûÊMÎ | |
280 | + Host->UseFTPES = Hist->UseFTPES; | |
281 | + Host->UseFTPIS = Hist->UseFTPIS; | |
282 | + Host->UseSFTP = Hist->UseSFTP; | |
275 | 283 | return; |
276 | 284 | } |
277 | 285 |
@@ -63,6 +63,8 @@ static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPA | ||
63 | 63 | static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam); |
64 | 64 | static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam); |
65 | 65 | 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); | |
66 | 68 | |
67 | 69 | /*===== OQÆ =====*/ |
68 | 70 |
@@ -1015,6 +1017,10 @@ int CopyHostFromListInConnect(int Num, HOSTDATA *Set) | ||
1015 | 1017 | Set->UseNLST_R = Pos->Set.UseNLST_R; |
1016 | 1018 | Set->LastDir = Pos->Set.LastDir; |
1017 | 1019 | 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; | |
1018 | 1024 | Sts = SUCCESS; |
1019 | 1025 | } |
1020 | 1026 | return(Sts); |
@@ -1288,6 +1294,11 @@ void CopyDefaultHost(HOSTDATA *Set) | ||
1288 | 1294 | Set->DialupAlways = NO; |
1289 | 1295 | Set->DialupNotify = YES; |
1290 | 1296 | strcpy(Set->DialEntry, ""); |
1297 | + // ûÊMÎ | |
1298 | + Set->CryptMode = CRYPT_NONE; | |
1299 | + Set->UseFTPES = YES; | |
1300 | + Set->UseFTPIS = YES; | |
1301 | + Set->UseSFTP = YES; | |
1291 | 1302 | return; |
1292 | 1303 | } |
1293 | 1304 |
@@ -1499,7 +1510,9 @@ void ImportFromWSFTP(void) | ||
1499 | 1510 | |
1500 | 1511 | static int DispHostSetDlg(HWND hDlg) |
1501 | 1512 | { |
1502 | - PROPSHEETPAGE psp[5]; | |
1513 | +// SFTPAFTPESAFTPISÎ | |
1514 | +// PROPSHEETPAGE psp[5]; | |
1515 | + PROPSHEETPAGE psp[6]; | |
1503 | 1516 | PROPSHEETHEADER psh; |
1504 | 1517 | |
1505 | 1518 | psp[0].dwSize = sizeof(PROPSHEETPAGE); |
@@ -1552,6 +1565,17 @@ static int DispHostSetDlg(HWND hDlg) | ||
1552 | 1565 | psp[4].lParam = 0; |
1553 | 1566 | psp[4].pfnCallback = NULL; |
1554 | 1567 | |
1568 | +// SFTPAFTPESAFTPISÎ | |
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 | + | |
1555 | 1579 | psh.dwSize = sizeof(PROPSHEETHEADER); |
1556 | 1580 | psh.dwFlags = PSH_HASHELP | PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE; |
1557 | 1581 | psh.hwndParent = hDlg; |
@@ -1851,11 +1875,11 @@ static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LP | ||
1851 | 1875 | |
1852 | 1876 | // UTF-8Î |
1853 | 1877 | case HSET_NO_CNV : |
1854 | - case HSET_SJIS_CNV : | |
1855 | 1878 | case HSET_UTF8N_CNV : |
1856 | 1879 | EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), FALSE); |
1857 | 1880 | break; |
1858 | 1881 | |
1882 | + case HSET_SJIS_CNV : | |
1859 | 1883 | case HSET_FN_JIS_CNV : |
1860 | 1884 | case HSET_FN_EUC_CNV : |
1861 | 1885 | EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), TRUE); |
@@ -2071,3 +2095,65 @@ static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LP | ||
2071 | 2095 | } |
2072 | 2096 | |
2073 | 2097 | |
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: wvgsbN | |
2151 | +// hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000032); | |
2152 | + break; | |
2153 | + } | |
2154 | + break; | |
2155 | + } | |
2156 | + return(FALSE); | |
2157 | +} | |
2158 | + | |
2159 | + |
@@ -236,6 +236,10 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi | ||
236 | 236 | |
237 | 237 | InitCommonControls(); |
238 | 238 | |
239 | +#ifdef USE_OPENSSL | |
240 | + LoadOpenSSL(); | |
241 | +#endif | |
242 | + | |
239 | 243 | Ret = FALSE; |
240 | 244 | hWndFtp = NULL; |
241 | 245 | hInstFtp = hInstance; |
@@ -265,6 +269,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi | ||
265 | 269 | Ret = Msg.wParam; |
266 | 270 | } |
267 | 271 | UnregisterClass(FtpClassStr, hInstFtp); |
272 | +#ifdef USE_OPENSSL | |
273 | + FreeOpenSSL(); | |
274 | +#endif | |
268 | 275 | OleUninitialize(); |
269 | 276 | return(Ret); |
270 | 277 | } |
@@ -375,6 +382,9 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) | ||
375 | 382 | { |
376 | 383 | LoadRegistory(); |
377 | 384 | |
385 | + // ûÊMÎ | |
386 | + SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback); | |
387 | + | |
378 | 388 | LoadJre(); |
379 | 389 | if(NoRasControl == NO) |
380 | 390 | LoadRasLib(); |
@@ -458,6 +468,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) | ||
458 | 468 | } |
459 | 469 | } |
460 | 470 | |
471 | + // ûÊMÎ | |
472 | +#ifdef USE_OPENSSL | |
473 | + if(IsOpenSSLLoaded()) | |
474 | + SetTaskMsg(MSGJPN318); | |
475 | + else | |
476 | + SetTaskMsg(MSGJPN319); | |
477 | +#endif | |
478 | + | |
461 | 479 | if(sts == FAIL) |
462 | 480 | DeleteAllObject(); |
463 | 481 |
@@ -969,6 +987,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA | ||
969 | 987 | DispTransferType(); |
970 | 988 | CheckHistoryNum(0); |
971 | 989 | SetAllHistoryToMenu(); |
990 | + // ûÊMÎ | |
991 | + SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback); | |
972 | 992 | break; |
973 | 993 | |
974 | 994 | case MENU_FILTER : |
@@ -2577,6 +2597,7 @@ int BackgrndMessageProc(void) | ||
2577 | 2597 | int Ret; |
2578 | 2598 | |
2579 | 2599 | Ret = NO; |
2600 | + SendMessage(GetMainHwnd(), WM_NULL, 0, 0); | |
2580 | 2601 | while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) |
2581 | 2602 | { |
2582 | 2603 | if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) |
@@ -2669,3 +2690,19 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd ) | ||
2669 | 2690 | } |
2670 | 2691 | return 0; |
2671 | 2692 | } |
2693 | + | |
2694 | +// ûÊMÎ | |
2695 | +BOOL __stdcall SSLTimeoutCallback() | |
2696 | +{ | |
2697 | + Sleep(1); | |
2698 | + if(BackgrndMessageProc() == YES) | |
2699 | + return TRUE; | |
2700 | + // O̽ßc[o[ÌMENU_ABORTàmF | |
2701 | +// if(MainTransPkt.Abort != ABORT_NONE) | |
2702 | +// { | |
2703 | +// MainTransPkt.Abort = ABORT_NONE; | |
2704 | +// return TRUE; | |
2705 | +// } | |
2706 | + return FALSE; | |
2707 | +} | |
2708 | + |
@@ -414,6 +414,20 @@ START_ROUTINE | ||
414 | 414 | pw0 = DuplicateMtoW((LPCSTR)lParam, -1); |
415 | 415 | r = SendMessageW(hWnd, CB_ADDSTRING, wParam, (LPARAM)pw0); |
416 | 416 | 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 | + // obt@·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; | |
417 | 431 | case CB_INSERTSTRING: |
418 | 432 | pw0 = DuplicateMtoW((LPCSTR)lParam, -1); |
419 | 433 | r = SendMessageW(hWnd, CB_INSERTSTRING, wParam, (LPARAM)pw0); |
@@ -441,12 +455,18 @@ START_ROUTINE | ||
441 | 455 | break; |
442 | 456 | case LB_GETTEXT: |
443 | 457 | Size = SendMessageW(hWnd, LB_GETTEXTLEN, wParam, 0) + 1; |
444 | - pw0 = AllocateStringW(Size * 4); | |
458 | + pw0 = AllocateStringW(Size); | |
445 | 459 | SendMessageW(hWnd, LB_GETTEXT, wParam, (LPARAM)pw0); |
446 | 460 | // obt@·s¾Ì½ßI[o[ÌÂ\« è |
447 | 461 | WtoM((LPSTR)lParam, Size * 4, pw0, -1); |
448 | 462 | r = TerminateStringM((LPSTR)lParam, Size * 4); |
449 | 463 | 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; | |
450 | 470 | default: |
451 | 471 | r = SendMessageW(hWnd, Msg, wParam, lParam); |
452 | 472 | break; |
@@ -1343,8 +1363,3 @@ END_ROUTINE | ||
1343 | 1363 | return r; |
1344 | 1364 | } |
1345 | 1365 | |
1346 | - | |
1347 | - | |
1348 | - | |
1349 | - | |
1350 | - |
@@ -310,3 +310,10 @@ | ||
310 | 310 | #define MSGJPN310 "EUC Kanji Code (Local)" |
311 | 311 | #define MSGJPN311 "JIS Kanji Code (Local)" |
312 | 312 | #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." |
@@ -310,3 +310,10 @@ | ||
310 | 310 | #define MSGJPN310 "EUC Kanji Code (Local)" |
311 | 311 | #define MSGJPN311 "JIS Kanji Code (Local)" |
312 | 312 | #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." |
@@ -310,3 +310,10 @@ | ||
310 | 310 | #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" |
311 | 311 | #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" |
312 | 312 | #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." |
@@ -310,3 +310,10 @@ | ||
310 | 310 | #define MSGJPN310 "[JÌ¿R[hÍEUC" |
311 | 311 | #define MSGJPN311 "[JÌ¿R[hÍJIS" |
312 | 312 | #define MSGJPN312 "[JÌ¿R[hÍUTF-8N" |
313 | +#define MSGJPN313 "û" | |
314 | +#define MSGJPN314 "ÊMÍû³êĢܹñ.\r\næOÒÉpX[h¨æÑàeðTó³êéÂ\«ª èÜ·." | |
315 | +#define MSGJPN315 "FTP over Explicit SSL/TLS (FTPES)ðgpµÜ·." | |
316 | +#define MSGJPN316 "FTP over Inplicit SSL/TLS (FTPIS)ðgpµÜ·." | |
317 | +#define MSGJPN317 "SSH FTP (SFTP)ðgpµÜ·." | |
318 | +#define MSGJPN318 "OpenSSLªÇÝÜêܵ½." | |
319 | +#define MSGJPN319 "OpenSSLªCXg[³êĢܹñ.\r\nÊMÌûÍsíêܹñ." |
@@ -462,6 +462,10 @@ void SaveRegistory(void) | ||
462 | 462 | SaveIntNum(hKey5, "UseIt", Hist.DialupAlways, DefaultHist.DialupAlways); |
463 | 463 | SaveIntNum(hKey5, "Notify", Hist.DialupNotify, DefaultHist.DialupNotify); |
464 | 464 | 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); | |
465 | 469 | |
466 | 470 | CloseSubKey(hKey5); |
467 | 471 | n++; |
@@ -530,6 +534,10 @@ void SaveRegistory(void) | ||
530 | 534 | SaveIntNum(hKey5, "UseIt", Host.DialupAlways, DefaultHost.DialupAlways); |
531 | 535 | SaveIntNum(hKey5, "Notify", Host.DialupNotify, DefaultHost.DialupNotify); |
532 | 536 | 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); | |
533 | 541 | } |
534 | 542 | CloseSubKey(hKey5); |
535 | 543 | } |
@@ -780,6 +788,10 @@ int LoadRegistory(void) | ||
780 | 788 | ReadIntValueFromReg(hKey5, "UseIt", &Hist.DialupAlways); |
781 | 789 | ReadIntValueFromReg(hKey5, "Notify", &Hist.DialupNotify); |
782 | 790 | 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); | |
783 | 795 | |
784 | 796 | CloseSubKey(hKey5); |
785 | 797 | AddHistoryToHistory(&Hist); |
@@ -845,6 +857,10 @@ int LoadRegistory(void) | ||
845 | 857 | ReadIntValueFromReg(hKey5, "UseIt", &Host.DialupAlways); |
846 | 858 | ReadIntValueFromReg(hKey5, "Notify", &Host.DialupNotify); |
847 | 859 | 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); | |
848 | 864 | |
849 | 865 | CloseSubKey(hKey5); |
850 | 866 |
@@ -1025,7 +1025,15 @@ static int ReadOneLine(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork) | ||
1025 | 1025 | memset(Buf, 0, Max); |
1026 | 1026 | |
1027 | 1027 | if((SizeOnce == -2) || (AskTransferNow() == YES)) |
1028 | - DisconnectSet(); | |
1028 | + // ]ÉSÄ~ðs¤Æs³Èf[^ª¾çêéêÌoOC³ | |
1029 | + // G[ÌíÞÉæÁÄͳÀ[vÆX^bNI[o[t[ÌÂ\« è | |
1030 | +// DisconnectSet(); | |
1031 | + { | |
1032 | + if(SizeOnce == -1) | |
1033 | + ReConnectCmdSkt(); | |
1034 | + else | |
1035 | + DisconnectSet(); | |
1036 | + } | |
1029 | 1037 | } |
1030 | 1038 | else |
1031 | 1039 | { |
@@ -73,8 +73,11 @@ typedef struct { | ||
73 | 73 | } ASYNCSIGNALDATABASE; |
74 | 74 | |
75 | 75 | |
76 | -#define MAX_SIGNAL_ENTRY 10 | |
77 | -#define MAX_SIGNAL_ENTRY_DBASE 5 | |
76 | +// XbhÕËÌoOC³ | |
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 | |
78 | 81 | |
79 | 82 | |
80 | 83 |
@@ -104,6 +107,8 @@ static ASYNCSIGNAL Signal[MAX_SIGNAL_ENTRY]; | ||
104 | 107 | static ASYNCSIGNALDATABASE SignalDbase[MAX_SIGNAL_ENTRY_DBASE]; |
105 | 108 | |
106 | 109 | //static HANDLE hAsyncTblAccMutex; |
110 | +// XbhÕËÌoOC³ | |
111 | +static HANDLE hAsyncTblAccMutex; | |
107 | 112 | |
108 | 113 | |
109 | 114 |
@@ -148,10 +153,18 @@ int MakeSocketWin(HWND hWnd, HINSTANCE hInst) | ||
148 | 153 | { |
149 | 154 | // hAsyncTblAccMutex = CreateMutex(NULL, FALSE, NULL); |
150 | 155 | |
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 | + // XbhÕËÌoOC³ | |
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 | + } | |
155 | 168 | Sts = SUCCESS; |
156 | 169 | } |
157 | 170 | return(Sts); |
@@ -170,6 +183,9 @@ int MakeSocketWin(HWND hWnd, HINSTANCE hInst) | ||
170 | 183 | void DeleteSocketWin(void) |
171 | 184 | { |
172 | 185 | // CloseHandle(hAsyncTblAccMutex); |
186 | + // XbhÕËÌoOC³ | |
187 | + CloseHandle(hAsyncTblAccMutex); | |
188 | + hAsyncTblAccMutex = NULL; | |
173 | 189 | |
174 | 190 | if(hWndSocket != NULL) |
175 | 191 | DestroyWindow(hWndSocket); |
@@ -196,6 +212,8 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP | ||
196 | 212 | switch(message) |
197 | 213 | { |
198 | 214 | case WM_ASYNC_SOCKET : |
215 | + // XbhÕËÌoOC³ | |
216 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
199 | 217 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
200 | 218 | { |
201 | 219 | if(Signal[Pos].Socket == (SOCKET)wParam) |
@@ -247,9 +265,13 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP | ||
247 | 265 | break; |
248 | 266 | } |
249 | 267 | } |
268 | + // XbhÕËÌoOC³ | |
269 | + ReleaseMutex(hAsyncTblAccMutex); | |
250 | 270 | break; |
251 | 271 | |
252 | 272 | case WM_ASYNC_DBASE : |
273 | + // XbhÕËÌoOC³ | |
274 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
253 | 275 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++) |
254 | 276 | { |
255 | 277 | if(SignalDbase[Pos].Async == (HANDLE)wParam) |
@@ -268,6 +290,8 @@ static LRESULT CALLBACK SocketWndProc(HWND hWnd, UINT message, WPARAM wParam, LP | ||
268 | 290 | break; |
269 | 291 | } |
270 | 292 | } |
293 | + // XbhÕËÌoOC³ | |
294 | + ReleaseMutex(hAsyncTblAccMutex); | |
271 | 295 | break; |
272 | 296 | |
273 | 297 | default : |
@@ -293,6 +317,8 @@ static int AskAsyncDone(SOCKET s, int *Error, int Mask) | ||
293 | 317 | int Sts; |
294 | 318 | int Pos; |
295 | 319 | |
320 | + // XbhÕËÌoOC³ | |
321 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
296 | 322 | Sts = NO; |
297 | 323 | *Error = 0; |
298 | 324 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
@@ -344,6 +370,8 @@ static int AskAsyncDone(SOCKET s, int *Error, int Mask) | ||
344 | 370 | break; |
345 | 371 | } |
346 | 372 | } |
373 | + // XbhÕËÌoOC³ | |
374 | + ReleaseMutex(hAsyncTblAccMutex); | |
347 | 375 | |
348 | 376 | if(Pos == MAX_SIGNAL_ENTRY) |
349 | 377 | { |
@@ -375,6 +403,8 @@ static int AskAsyncDoneDbase(HANDLE Async, int *Error) | ||
375 | 403 | int Sts; |
376 | 404 | int Pos; |
377 | 405 | |
406 | + // XbhÕËÌoOC³ | |
407 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
378 | 408 | Sts = NO; |
379 | 409 | *Error = 0; |
380 | 410 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++) |
@@ -392,6 +422,8 @@ static int AskAsyncDoneDbase(HANDLE Async, int *Error) | ||
392 | 422 | break; |
393 | 423 | } |
394 | 424 | } |
425 | + // XbhÕËÌoOC³ | |
426 | + ReleaseMutex(hAsyncTblAccMutex); | |
395 | 427 | |
396 | 428 | if(Pos == MAX_SIGNAL_ENTRY_DBASE) |
397 | 429 | { |
@@ -417,6 +449,8 @@ static int RegistAsyncTable(SOCKET s) | ||
417 | 449 | int Sts; |
418 | 450 | int Pos; |
419 | 451 | |
452 | + // XbhÕËÌoOC³ | |
453 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
420 | 454 | Sts = NO; |
421 | 455 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
422 | 456 | { |
@@ -426,9 +460,13 @@ static int RegistAsyncTable(SOCKET s) | ||
426 | 460 | break; |
427 | 461 | } |
428 | 462 | } |
463 | + // XbhÕËÌoOC³ | |
464 | + ReleaseMutex(hAsyncTblAccMutex); | |
429 | 465 | |
430 | 466 | if(Pos == MAX_SIGNAL_ENTRY) |
431 | 467 | { |
468 | + // XbhÕËÌoOC³ | |
469 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
432 | 470 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
433 | 471 | { |
434 | 472 | if(Signal[Pos].Socket == INVALID_SOCKET) |
@@ -447,6 +485,8 @@ static int RegistAsyncTable(SOCKET s) | ||
447 | 485 | break; |
448 | 486 | } |
449 | 487 | } |
488 | + // XbhÕËÌoOC³ | |
489 | + ReleaseMutex(hAsyncTblAccMutex); | |
450 | 490 | |
451 | 491 | if(Pos == MAX_SIGNAL_ENTRY) |
452 | 492 | { |
@@ -473,6 +513,8 @@ static int RegistAsyncTableDbase(HANDLE Async) | ||
473 | 513 | int Sts; |
474 | 514 | int Pos; |
475 | 515 | |
516 | + // XbhÕËÌoOC³ | |
517 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
476 | 518 | Sts = NO; |
477 | 519 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++) |
478 | 520 | { |
@@ -482,9 +524,13 @@ static int RegistAsyncTableDbase(HANDLE Async) | ||
482 | 524 | break; |
483 | 525 | } |
484 | 526 | } |
527 | + // XbhÕËÌoOC³ | |
528 | + ReleaseMutex(hAsyncTblAccMutex); | |
485 | 529 | |
486 | 530 | if(Pos == MAX_SIGNAL_ENTRY_DBASE) |
487 | 531 | { |
532 | + // XbhÕËÌoOC³ | |
533 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
488 | 534 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
489 | 535 | { |
490 | 536 | if(SignalDbase[Pos].Async == 0) |
@@ -499,6 +545,8 @@ static int RegistAsyncTableDbase(HANDLE Async) | ||
499 | 545 | break; |
500 | 546 | } |
501 | 547 | } |
548 | + // XbhÕËÌoOC³ | |
549 | + ReleaseMutex(hAsyncTblAccMutex); | |
502 | 550 | |
503 | 551 | if(Pos == MAX_SIGNAL_ENTRY_DBASE) |
504 | 552 | { |
@@ -525,6 +573,8 @@ static int UnRegistAsyncTable(SOCKET s) | ||
525 | 573 | int Sts; |
526 | 574 | int Pos; |
527 | 575 | |
576 | + // XbhÕËÌoOC³ | |
577 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
528 | 578 | Sts = NO; |
529 | 579 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY; Pos++) |
530 | 580 | { |
@@ -538,6 +588,8 @@ static int UnRegistAsyncTable(SOCKET s) | ||
538 | 588 | break; |
539 | 589 | } |
540 | 590 | } |
591 | + // XbhÕËÌoOC³ | |
592 | + ReleaseMutex(hAsyncTblAccMutex); | |
541 | 593 | return(Sts); |
542 | 594 | } |
543 | 595 |
@@ -556,6 +608,8 @@ static int UnRegistAsyncTableDbase(HANDLE Async) | ||
556 | 608 | int Sts; |
557 | 609 | int Pos; |
558 | 610 | |
611 | + // XbhÕËÌoOC³ | |
612 | + WaitForSingleObject(hAsyncTblAccMutex, INFINITE); | |
559 | 613 | Sts = NO; |
560 | 614 | for(Pos = 0; Pos < MAX_SIGNAL_ENTRY_DBASE; Pos++) |
561 | 615 | { |
@@ -569,6 +623,8 @@ static int UnRegistAsyncTableDbase(HANDLE Async) | ||
569 | 623 | break; |
570 | 624 | } |
571 | 625 | } |
626 | + // XbhÕËÌoOC³ | |
627 | + ReleaseMutex(hAsyncTblAccMutex); | |
572 | 628 | return(Sts); |
573 | 629 | } |
574 | 630 |
@@ -652,7 +708,12 @@ int do_closesocket(SOCKET s) | ||
652 | 708 | #endif |
653 | 709 | CancelCheckWork = NO; |
654 | 710 | |
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); | |
656 | 717 | if(Ret == SOCKET_ERROR) |
657 | 718 | { |
658 | 719 | Error = 0; |
@@ -703,7 +764,12 @@ int do_connect(SOCKET s, const struct sockaddr *name, int namelen, int *CancelCh | ||
703 | 764 | Ret = WSAAsyncSelect(s, hWndSocket, WM_ASYNC_SOCKET, FD_CONNECT | FD_CLOSE | FD_ACCEPT | FD_READ | FD_WRITE); |
704 | 765 | if(Ret != SOCKET_ERROR) |
705 | 766 | { |
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); | |
707 | 773 | if(Ret == SOCKET_ERROR) |
708 | 774 | { |
709 | 775 | do |
@@ -797,7 +863,12 @@ SOCKET do_accept(SOCKET s, struct sockaddr *addr, int *addrlen) | ||
797 | 863 | { |
798 | 864 | do |
799 | 865 | { |
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); | |
801 | 872 | if(Ret2 != INVALID_SOCKET) |
802 | 873 | { |
803 | 874 | #if DBG_MSG |
@@ -866,7 +937,10 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance | ||
866 | 937 | if(TimeOut != 0) |
867 | 938 | time(&StartTime); |
868 | 939 | |
869 | - while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES)) | |
940 | + // FTPSÎ | |
941 | + // OpenSSLÅÍóMmFÍ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)) | |
870 | 944 | { |
871 | 945 | if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES) |
872 | 946 | { |
@@ -897,13 +971,38 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance | ||
897 | 971 | DoPrintf("## recv()"); |
898 | 972 | #endif |
899 | 973 | |
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); | |
901 | 980 | if(Ret != SOCKET_ERROR) |
902 | 981 | break; |
903 | 982 | Error = WSAGetLastError(); |
904 | 983 | Sleep(1); |
905 | 984 | if(BackgrndMessageProc() == YES) |
906 | 985 | break; |
986 | + // FTPSÎ | |
987 | + // óMmFðoCpXµ½½ß±±Å^CAEgÌmF | |
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; | |
907 | 1006 | } |
908 | 1007 | while(Error == WSAEWOULDBLOCK); |
909 | 1008 | } |
@@ -948,7 +1047,10 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int | ||
948 | 1047 | if(BackgrndMessageProc() == YES) |
949 | 1048 | *CancelCheckWork = YES; |
950 | 1049 | |
951 | - while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES)) | |
1050 | + // FTPSÎ | |
1051 | + // Mobt@Ìó«mFÉÍ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)) | |
952 | 1054 | { |
953 | 1055 | if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES) |
954 | 1056 | { |
@@ -980,7 +1082,12 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int | ||
980 | 1082 | DoPrintf("## send()"); |
981 | 1083 | #endif |
982 | 1084 | |
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); | |
984 | 1091 | if(Ret != SOCKET_ERROR) |
985 | 1092 | { |
986 | 1093 | #if DBG_MSG |
@@ -992,6 +1099,26 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int | ||
992 | 1099 | Sleep(1); |
993 | 1100 | if(BackgrndMessageProc() == YES) |
994 | 1101 | break; |
1102 | + // FTPSÎ | |
1103 | + // Mobt@mFðoCpXµ½½ß±±Å^CAEgÌmF | |
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; | |
995 | 1122 | } |
996 | 1123 | while(Error == WSAEWOULDBLOCK); |
997 | 1124 | } |
@@ -0,0 +1,299 @@ | ||
1 | +// socketwrapper.cpp | |
2 | +// Copyright (C) 2011 Suguru Kawamoto | |
3 | +// \Pbgbp[ | |
4 | +// socketÖAÖðOpenSSLpÉu· | |
5 | +// RpCÉÍOpenSSLÌwb_[t@CªKv | |
6 | +// ÀsÉÍOpenSSLÌDLLªKv | |
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ÌlSVG[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 | + |
@@ -0,0 +1,29 @@ | ||
1 | +// socketwrapper.h | |
2 | +// Copyright (C) 2011 Suguru Kawamoto | |
3 | +// \Pbgbp[ | |
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 | + |