Browse Source

UPD: Use one way to include ssl implementation

Alexander Koblov 10 years ago
parent
commit
b3667e7f8c

+ 5 - 0
plugins/wfx/ftp/src/ftp.dpr

@@ -6,13 +6,18 @@ library ftp;
 
 uses
   Classes, FtpFunc, FtpUtils, FtpConfDlg
+  , ssl_openssl
 {$IF DEFINED(LINUX)}
   , ssl_gnutls_lib
+{$ELSEIF DEFINED(MSWINDOWS)}
+  , ssl_winssl_lib
 {$ENDIF}
   ;
 
 {$IF DEFINED(LINUX)}
 {$I ssl_gnutls_lib.inc}
+{$ELSEIF DEFINED(MSWINDOWS)}
+{$I ssl_winssl_lib.inc}
 {$ENDIF}
 
 exports

+ 1 - 1
plugins/wfx/ftp/src/ftpfunc.pas

@@ -98,7 +98,7 @@ var
 implementation
 
 uses
-  IniFiles, StrUtils, FtpAdv, FtpUtils, FtpConfDlg, syncobjs, ssl_openssl;
+  IniFiles, StrUtils, FtpAdv, FtpUtils, FtpConfDlg, syncobjs;
 
 var
   ActiveConnectionList, ConnectionList: TStringList;

+ 1 - 1
plugins/wfx/ftp/src/ftputils.pas

@@ -91,7 +91,7 @@ implementation
 uses
   Base64
   {$IFDEF MSWINDOWS}
-  , Windows, ssl_winssl_lib
+  , Windows
   {$ELSE}
   , UnixUtil
   {$ENDIF}

+ 20 - 0
plugins/wfx/ftp/synapse/ssl_winssl_lib.inc

@@ -0,0 +1,20 @@
+exports
+  SSL_library_init,
+  SSL_set_fd,
+  SSL_CTX_new,
+  SSL_CTX_free,
+  SSL_new,
+  SSL_free,
+  SSL_connect,
+  SSL_shutdown,
+  SSL_read,
+  SSL_write,
+  SSL_pending,
+  SSLv23_method,
+  SSLv2_method,
+  SSLv3_method,
+  TLSv1_method,
+  TLSv1_1_method,
+  TLSv1_2_method,
+  SSL_CTX_set_verify,
+  SSL_get_error;

+ 53 - 49
plugins/wfx/ftp/synapse/ssl_winssl_lib.pas

@@ -2,7 +2,7 @@
   SChannel to OpenSSL wrapper
 
   Copyright (c) 2008 Boris Krasnovskiy
-  Copyright (c) 2013 Alexander Koblov (pascal port)
+  Copyright (c) 2013-2015 Alexander Koblov (pascal port)
 
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
@@ -24,10 +24,61 @@ unit ssl_winssl_lib;
 
 interface
 
+uses
+  Windows, SynSock, JwaSspi, CTypes;
+
+type
+  PSSL_CTX = ^SSL_CTX;
+  SSL_CTX = record
+    dwProtocol: DWORD;
+    bVerify: BOOL;
+  end;
+
+  PSSL_METHOD = ^SSL_METHOD;
+  SSL_METHOD = record
+    dummy: DWORD;
+  end;
+
+  PSSL = ^SSL;
+  SSL = record
+    s: TSocket;
+    ctx: PSSL_CTX;
+    hContext: CtxtHandle;
+    hCreds: CredHandle;
+    pbRecDataBuf: PByte;
+    cbRecDataBuf: LONG;
+    sbRecDataBuf: LONG;
+    pbIoBuffer: PByte;
+    cbIoBuffer: LONG;
+    sbIoBuffer: LONG;
+    exIoBuffer: BOOL;
+    rmshtdn: BOOL;
+  end;
+
+function SSL_library_init(): cint; cdecl;
+function SSL_set_fd(ssl: PSSL; fd: cint): cint; cdecl;
+function SSL_CTX_new(method: PSSL_METHOD): PSSL_CTX; cdecl;
+procedure SSL_CTX_free(ctx: PSSL_CTX); cdecl;
+function SSL_new(ctx: PSSL_CTX): PSSL; cdecl;
+procedure SSL_free(ssl: PSSL); cdecl;
+function SSL_connect(ssl: PSSL): cint; cdecl;
+function SSL_shutdown(ssl: PSSL): cint; cdecl;
+function SSL_read(ssl: PSSL; buf: PByte; num: cint): cint; cdecl;
+function SSL_write(ssl: PSSL; const buf: PByte; num: cint): cint; cdecl;
+function SSL_pending(ssl: PSSL): cint; cdecl;
+function SSLv23_method(): PSSL_METHOD; cdecl;
+function SSLv2_method(): PSSL_METHOD; cdecl;
+function SSLv3_method(): PSSL_METHOD; cdecl;
+function TLSv1_method(): PSSL_METHOD; cdecl;
+function TLSv1_1_method(): PSSL_METHOD; cdecl;
+function TLSv1_2_method(): PSSL_METHOD; cdecl;
+procedure SSL_CTX_set_verify(ctx: PSSL_CTX; mode: cint; func: Pointer); cdecl;
+function SSL_get_error (ssl: PSSL; ret: cint): cint; cdecl;
+
 implementation
 
 uses
-  Windows, JwaSspi, JwaWinError, CTypes, SynSock,
+  JwaWinError,
   ssl_openssl_lib, blcksock, ssl_openssl;
 
 const
@@ -65,33 +116,7 @@ const
   UNISP_NAME_A = AnsiString('Microsoft Unified Security Protocol Provider');
   UNISP_NAME_W = WideString('Microsoft Unified Security Protocol Provider');
 
-type
-  PSSL_CTX = ^SSL_CTX;
-  SSL_CTX = record
-    dwProtocol: DWORD;
-    bVerify: BOOL;
-  end;
-
-  PSSL_METHOD = ^SSL_METHOD;
-  SSL_METHOD = record
-    dummy: DWORD;
-  end;
 
-  PSSL = ^SSL;
-  SSL = record
-    s: TSocket;
-    ctx: PSSL_CTX;
-    hContext: CtxtHandle;
-    hCreds: CredHandle;
-    pbRecDataBuf: PByte;
-    cbRecDataBuf: LONG;
-    sbRecDataBuf: LONG;
-    pbIoBuffer: PByte;
-    cbIoBuffer: LONG;
-    sbIoBuffer: LONG;
-    exIoBuffer: BOOL;
-    rmshtdn: BOOL;
-  end;
 
 type
   ALG_ID = type cuint;
@@ -867,27 +892,6 @@ begin
     Result := SSL_ERROR_ZERO_RETURN;
 end;
 
-exports
-  SSL_library_init,
-  SSL_set_fd,
-  SSL_CTX_new,
-  SSL_CTX_free,
-  SSL_new,
-  SSL_free,
-  SSL_connect,
-  SSL_shutdown,
-  SSL_read,
-  SSL_write,
-  SSL_pending,
-  SSLv23_method,
-  SSLv2_method,
-  SSLv3_method,
-  TLSv1_method,
-  TLSv1_1_method,
-  TLSv1_2_method,
-  SSL_CTX_set_verify,
-  SSL_get_error;
-
 var
   lpBuffer: TMemoryBasicInformation;
 begin