- improved MACOS compatibility
- workaround for some broken virtual serial ports - Added Lazarus package git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@129 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
		
							
								
								
									
										170
									
								
								laz_synapse.lpk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								laz_synapse.lpk
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,170 @@ | ||||
| <?xml version="1.0"?> | ||||
| <CONFIG> | ||||
|   <Package Version="3"> | ||||
|     <Name Value="laz_synapse"/> | ||||
|     <CompilerOptions> | ||||
|       <Version Value="8"/> | ||||
|       <SearchPaths> | ||||
|         <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)/"/> | ||||
|       </SearchPaths> | ||||
|       <Parsing> | ||||
|         <SyntaxOptions> | ||||
|           <UseAnsiStrings Value="True"/> | ||||
|         </SyntaxOptions> | ||||
|       </Parsing> | ||||
|       <Other> | ||||
|         <CompilerPath Value="$(CompPath)"/> | ||||
|       </Other> | ||||
|     </CompilerOptions> | ||||
|     <Files Count="33"> | ||||
|       <Item1> | ||||
|         <Filename Value="asn1util.pas"/> | ||||
|         <UnitName Value="asn1util"/> | ||||
|       </Item1> | ||||
|       <Item2> | ||||
|         <Filename Value="blcksock.pas"/> | ||||
|         <UnitName Value="blcksock"/> | ||||
|       </Item2> | ||||
|       <Item3> | ||||
|         <Filename Value="clamsend.pas"/> | ||||
|         <UnitName Value="clamsend"/> | ||||
|       </Item3> | ||||
|       <Item4> | ||||
|         <Filename Value="dnssend.pas"/> | ||||
|         <UnitName Value="dnssend"/> | ||||
|       </Item4> | ||||
|       <Item5> | ||||
|         <Filename Value="ftpsend.pas"/> | ||||
|         <UnitName Value="ftpsend"/> | ||||
|       </Item5> | ||||
|       <Item6> | ||||
|         <Filename Value="ftptsend.pas"/> | ||||
|         <UnitName Value="ftptsend"/> | ||||
|       </Item6> | ||||
|       <Item7> | ||||
|         <Filename Value="httpsend.pas"/> | ||||
|         <UnitName Value="httpsend"/> | ||||
|       </Item7> | ||||
|       <Item8> | ||||
|         <Filename Value="imapsend.pas"/> | ||||
|         <UnitName Value="imapsend"/> | ||||
|       </Item8> | ||||
|       <Item9> | ||||
|         <Filename Value="ldapsend.pas"/> | ||||
|         <UnitName Value="ldapsend"/> | ||||
|       </Item9> | ||||
|       <Item10> | ||||
|         <Filename Value="mimeinln.pas"/> | ||||
|         <UnitName Value="mimeinln"/> | ||||
|       </Item10> | ||||
|       <Item11> | ||||
|         <Filename Value="mimemess.pas"/> | ||||
|         <UnitName Value="mimemess"/> | ||||
|       </Item11> | ||||
|       <Item12> | ||||
|         <Filename Value="mimepart.pas"/> | ||||
|         <UnitName Value="mimepart"/> | ||||
|       </Item12> | ||||
|       <Item13> | ||||
|         <Filename Value="nntpsend.pas"/> | ||||
|         <UnitName Value="nntpsend"/> | ||||
|       </Item13> | ||||
|       <Item14> | ||||
|         <Filename Value="pingsend.pas"/> | ||||
|         <UnitName Value="pingsend"/> | ||||
|       </Item14> | ||||
|       <Item15> | ||||
|         <Filename Value="pop3send.pas"/> | ||||
|         <UnitName Value="pop3send"/> | ||||
|       </Item15> | ||||
|       <Item16> | ||||
|         <Filename Value="slogsend.pas"/> | ||||
|         <UnitName Value="slogsend"/> | ||||
|       </Item16> | ||||
|       <Item17> | ||||
|         <Filename Value="smtpsend.pas"/> | ||||
|         <UnitName Value="smtpsend"/> | ||||
|       </Item17> | ||||
|       <Item18> | ||||
|         <Filename Value="snmpsend.pas"/> | ||||
|         <UnitName Value="snmpsend"/> | ||||
|       </Item18> | ||||
|       <Item19> | ||||
|         <Filename Value="sntpsend.pas"/> | ||||
|         <UnitName Value="sntpsend"/> | ||||
|       </Item19> | ||||
|       <Item20> | ||||
|         <Filename Value="ssfpc.pas"/> | ||||
|         <AddToUsesPkgSection Value="False"/> | ||||
|         <UnitName Value="ssfpc"/> | ||||
|       </Item20> | ||||
|       <Item21> | ||||
|         <Filename Value="sswin32.pas"/> | ||||
|         <AddToUsesPkgSection Value="False"/> | ||||
|         <UnitName Value="sswin32"/> | ||||
|       </Item21> | ||||
|       <Item22> | ||||
|         <Filename Value="synachar.pas"/> | ||||
|         <UnitName Value="synachar"/> | ||||
|       </Item22> | ||||
|       <Item23> | ||||
|         <Filename Value="synacode.pas"/> | ||||
|         <UnitName Value="synacode"/> | ||||
|       </Item23> | ||||
|       <Item24> | ||||
|         <Filename Value="synacrypt.pas"/> | ||||
|         <UnitName Value="synacrypt"/> | ||||
|       </Item24> | ||||
|       <Item25> | ||||
|         <Filename Value="synadbg.pas"/> | ||||
|         <UnitName Value="synadbg"/> | ||||
|       </Item25> | ||||
|       <Item26> | ||||
|         <Filename Value="synafpc.pas"/> | ||||
|         <UnitName Value="synafpc"/> | ||||
|       </Item26> | ||||
|       <Item27> | ||||
|         <Filename Value="synaicnv.pas"/> | ||||
|         <UnitName Value="synaicnv"/> | ||||
|       </Item27> | ||||
|       <Item28> | ||||
|         <Filename Value="synaip.pas"/> | ||||
|         <UnitName Value="synaip"/> | ||||
|       </Item28> | ||||
|       <Item29> | ||||
|         <Filename Value="synamisc.pas"/> | ||||
|         <UnitName Value="synamisc"/> | ||||
|       </Item29> | ||||
|       <Item30> | ||||
|         <Filename Value="synaser.pas"/> | ||||
|         <UnitName Value="synaser"/> | ||||
|       </Item30> | ||||
|       <Item31> | ||||
|         <Filename Value="synautil.pas"/> | ||||
|         <UnitName Value="synautil"/> | ||||
|       </Item31> | ||||
|       <Item32> | ||||
|         <Filename Value="synsock.pas"/> | ||||
|         <UnitName Value="synsock"/> | ||||
|       </Item32> | ||||
|       <Item33> | ||||
|         <Filename Value="tlntsend.pas"/> | ||||
|         <UnitName Value="tlntsend"/> | ||||
|       </Item33> | ||||
|     </Files> | ||||
|     <Type Value="RunAndDesignTime"/> | ||||
|     <RequiredPkgs Count="1"> | ||||
|       <Item1> | ||||
|         <PackageName Value="FCL"/> | ||||
|         <MinVersion Major="1" Valid="True"/> | ||||
|       </Item1> | ||||
|     </RequiredPkgs> | ||||
|     <UsageOptions> | ||||
|       <UnitPath Value="$(PkgOutDir)"/> | ||||
|     </UsageOptions> | ||||
|     <PublishOptions> | ||||
|       <Version Value="2"/> | ||||
|       <IgnoreBinaries Value="False"/> | ||||
|     </PublishOptions> | ||||
|   </Package> | ||||
| </CONFIG> | ||||
							
								
								
									
										24
									
								
								laz_synapse.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								laz_synapse.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| { This file was automatically created by Lazarus. Do not edit! | ||||
|   This source is only used to compile and install the package. | ||||
|  } | ||||
|  | ||||
| unit laz_synapse;  | ||||
|  | ||||
| interface | ||||
|  | ||||
| uses | ||||
|     asn1util, blcksock, clamsend, dnssend, ftpsend, ftptsend, httpsend,  | ||||
|   imapsend, ldapsend, mimeinln, mimemess, mimepart, nntpsend, pingsend,  | ||||
|   pop3send, slogsend, smtpsend, snmpsend, sntpsend, synachar, synacode,  | ||||
|   synacrypt, synadbg, synafpc, synaicnv, synaip, synamisc, synaser, synautil,  | ||||
|   synsock, tlntsend, LazarusPackageIntf; | ||||
|  | ||||
| implementation | ||||
|  | ||||
| procedure Register;  | ||||
| begin | ||||
| end;  | ||||
|  | ||||
| initialization | ||||
|   RegisterPackage('laz_synapse', @Register);  | ||||
| end. | ||||
							
								
								
									
										10
									
								
								ssfpc.pas
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ssfpc.pas
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| {==============================================================================| | ||||
| | Project : Ararat Synapse                                       | 001.001.002 | | ||||
| | Project : Ararat Synapse                                       | 001.001.003 | | ||||
| |==============================================================================| | ||||
| | Content: Socket Independent Platform Layer - FreePascal definition include   | | ||||
| |==============================================================================| | ||||
| @@ -250,7 +250,13 @@ const | ||||
|  | ||||
|   MSG_OOB       = sockets.MSG_OOB;      // Process out-of-band data. | ||||
|   MSG_PEEK      = sockets.MSG_PEEK;     // Peek at incoming messages. | ||||
|   MSG_NOSIGNAL  = sockets.MSG_NOSIGNAL; // Do not generate SIGPIPE. | ||||
|   {$ifdef DARWIN} | ||||
|   MSG_NOSIGNAL  = $20000;  // Do not generate SIGPIPE. | ||||
|                            // Works under MAC OS X, but is undocumented, | ||||
|                            // So FPC doesn't include it | ||||
|   {$else} | ||||
|    MSG_NOSIGNAL  = sockets.MSG_NOSIGNAL; // Do not generate SIGPIPE. | ||||
|   {$endif} | ||||
|  | ||||
| const | ||||
|   WSAEINTR = ESysEINTR; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| {==============================================================================| | ||||
| | Project : Ararat Synapse                                       | 003.006.001 | | ||||
| | Project : Ararat Synapse                                       | 003.006.002 | | ||||
| |==============================================================================| | ||||
| | Content: SSL support by OpenSSL                                              | | ||||
| |==============================================================================| | ||||
| @@ -85,7 +85,11 @@ uses | ||||
|   Classes, | ||||
|   synafpc, | ||||
| {$IFNDEF MSWINDOWS} | ||||
|   Libc, SysUtils; | ||||
|   {$IFDEF FPC} | ||||
|   BaseUnix, SysUtils; | ||||
|   {$ELSE} | ||||
|    Libc, SysUtils; | ||||
|   {$ENDIF} | ||||
| {$ELSE} | ||||
|   Windows; | ||||
| {$ENDIF} | ||||
| @@ -1727,7 +1731,7 @@ begin | ||||
| {$ELSE} | ||||
|       SSLLibHandle := LoadLib(DLLSSLName); | ||||
|       SSLUtilHandle := LoadLib(DLLUtilName); | ||||
|   {$IFNDEF LINUX} | ||||
|   {$IFDEF MSWINDOWS} | ||||
|       if (SSLLibHandle = 0) then | ||||
|         SSLLibHandle := LoadLib(DLLSSLName2); | ||||
|   {$ENDIF} | ||||
|   | ||||
							
								
								
									
										17
									
								
								synamisc.pas
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								synamisc.pas
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| {==============================================================================| | ||||
| | Project : Ararat Synapse                                       | 001.003.000 | | ||||
| | Project : Ararat Synapse                                       | 001.003.001 | | ||||
| |==============================================================================| | ||||
| | Content: misc. procedures and functions                                      | | ||||
| |==============================================================================| | ||||
| @@ -50,6 +50,13 @@ | ||||
| {$Q-} | ||||
| {$H+} | ||||
|  | ||||
| //Kylix does not known UNIX define | ||||
| {$IFDEF LINUX} | ||||
|   {$IFNDEF UNIX} | ||||
|     {$DEFINE UNIX} | ||||
|   {$ENDIF} | ||||
| {$ENDIF} | ||||
|  | ||||
| {$IFDEF UNICODE} | ||||
|   {$WARN IMPLICIT_STRING_CAST OFF} | ||||
|   {$WARN IMPLICIT_STRING_CAST_LOSS OFF} | ||||
| @@ -69,7 +76,7 @@ interface | ||||
|  | ||||
| uses | ||||
|   synautil, blcksock, SysUtils, Classes | ||||
| {$IFDEF LINUX} | ||||
| {$IFDEF UNIX} | ||||
|   {$IFNDEF FPC} | ||||
|   , Libc | ||||
|   {$ENDIF} | ||||
| @@ -148,7 +155,7 @@ end; | ||||
|  | ||||
| {==============================================================================} | ||||
|  | ||||
| {$IFNDEF LINUX} | ||||
| {$IFNDEF UNIX} | ||||
| function GetDNSbyIpHlp: string; | ||||
| type | ||||
|   PTIP_ADDRESS_STRING = ^TIP_ADDRESS_STRING; | ||||
| @@ -240,7 +247,7 @@ end ; | ||||
| {$ENDIF} | ||||
|  | ||||
| function GetDNS: string; | ||||
| {$IFDEF LINUX} | ||||
| {$IFDEF UNIX} | ||||
| var | ||||
|   l: TStringList; | ||||
|   n: integer; | ||||
| @@ -287,7 +294,7 @@ end; | ||||
| {==============================================================================} | ||||
|  | ||||
| function GetIEProxy(protocol: string): TProxySetting; | ||||
| {$IFDEF LINUX} | ||||
| {$IFDEF UNIX} | ||||
| begin | ||||
|   Result.Host := ''; | ||||
|   Result.Port := ''; | ||||
|   | ||||
							
								
								
									
										65
									
								
								synaser.pas
									
									
									
									
									
								
							
							
						
						
									
										65
									
								
								synaser.pas
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| {==============================================================================| | ||||
| | Project : Ararat Synapse                                       | 007.004.000 | | ||||
| | Project : Ararat Synapse                                       | 007.005.000 | | ||||
| |==============================================================================| | ||||
| | Content: Serial port support                                                 | | ||||
| |==============================================================================| | ||||
| @@ -44,9 +44,9 @@ | ||||
| |==============================================================================} | ||||
|  | ||||
| {: @abstract(Serial port communication library) | ||||
| This unit contains a class that implements serial port communication for Windows | ||||
|  or Linux. This class provides numerous methods with same name and functionality | ||||
|   as methods of the Ararat Synapse TCP/IP library. | ||||
| This unit contains a class that implements serial port communication  | ||||
|  for Windows, Linux, Unix or MacOSx. This class provides numerous methods with  | ||||
|  same name and functionality as methods of the Ararat Synapse TCP/IP library. | ||||
|  | ||||
| The following is a small example how establish a connection by modem (in this | ||||
| case with my USB modem): | ||||
| @@ -76,6 +76,13 @@ case with my USB modem): | ||||
|   {$ENDIF} | ||||
| {$ENDIF} | ||||
|  | ||||
| //Kylix does not known UNIX define | ||||
| {$IFDEF LINUX} | ||||
|   {$IFNDEF UNIX} | ||||
|     {$DEFINE UNIX} | ||||
|   {$ENDIF} | ||||
| {$ENDIF} | ||||
|  | ||||
| {$IFDEF FPC} | ||||
|   {$MODE DELPHI} | ||||
|   {$IFDEF MSWINDOWS} | ||||
| @@ -189,10 +196,14 @@ type | ||||
|   PDCB = ^TDCB; | ||||
|  | ||||
| const | ||||
| {$IFDEF LINUX} | ||||
|   MaxRates = 30; | ||||
| {$IFDEF UNIX} | ||||
|   {$IFDEF DARWIN} | ||||
|   MaxRates = 18;  //MAC | ||||
|   {$ELSE} | ||||
|    MaxRates = 30; //UNIX | ||||
|   {$ENDIF} | ||||
| {$ELSE} | ||||
|   MaxRates = 19;  //FPC on some platforms not know high speeds? | ||||
|   MaxRates = 19;  //WIN | ||||
| {$ENDIF} | ||||
|   Rates: array[0..MaxRates, 0..1] of cardinal = | ||||
|   ( | ||||
| @@ -214,9 +225,10 @@ const | ||||
|     (38400, B38400), | ||||
|     (57600, B57600), | ||||
|     (115200, B115200), | ||||
|     (230400, B230400), | ||||
|     (460800, B460800) | ||||
| {$IFDEF LINUX} | ||||
|     (230400, B230400) | ||||
| {$IFNDEF DARWIN} | ||||
|     ,(460800, B460800) | ||||
|   {$IFDEF UNIX} | ||||
|     ,(500000, B500000), | ||||
|     (576000, B576000), | ||||
|     (921600, B921600), | ||||
| @@ -228,10 +240,16 @@ const | ||||
|     (3000000, B3000000), | ||||
|     (3500000, B3500000), | ||||
|     (4000000, B4000000) | ||||
|   {$ENDIF} | ||||
| {$ENDIF} | ||||
|     ); | ||||
| {$ENDIF} | ||||
|  | ||||
| {$IFDEF DARWIN} | ||||
| const // From fcntl.h | ||||
|   O_SYNC = $0080;  { synchronous writes } | ||||
| {$ENDIF} | ||||
|  | ||||
| const | ||||
|   sOK = 0; | ||||
|   sErr = integer(-1); | ||||
| @@ -310,11 +328,9 @@ type | ||||
|     procedure GetComNr(Value: string); virtual; | ||||
|     function PreTestFailing: boolean; virtual;{HGJ} | ||||
|     function TestCtrlLine: Boolean; virtual; | ||||
| {$IFNDEF MSWINDOWS} | ||||
| {$IFDEF UNIX}     | ||||
|     procedure DcbToTermios(const dcb: TDCB; var term: termios); virtual; | ||||
|     procedure TermiosToDcb(const term: termios; var dcb: TDCB); virtual; | ||||
| {$ENDIF} | ||||
| {$IFDEF LINUX} | ||||
|     function ReadLockfile: integer; virtual; | ||||
|     function LockfileName: String; virtual; | ||||
|     procedure CreateLockfile(PidNr: integer); virtual; | ||||
| @@ -325,7 +341,7 @@ type | ||||
|     {: data Control Block with communication parameters. Usable only when you | ||||
|      need to call API directly.} | ||||
|     DCB: Tdcb; | ||||
| {$IFNDEF MSWINDOWS} | ||||
| {$IFDEF UNIX} | ||||
|     TermiosStruc: termios; | ||||
| {$ENDIF} | ||||
|     {:Object constructor.} | ||||
| @@ -603,7 +619,7 @@ type | ||||
|  | ||||
|     {:Raise Synaser error with ErrNumber code. Usually used by internal routines.} | ||||
|     procedure RaiseSynaError(ErrNumber: integer); virtual; | ||||
| {$IFDEF LINUX} | ||||
| {$IFDEF UNIX} | ||||
|     function  cpomComportAccessible: boolean; virtual;{HGJ} | ||||
|     procedure cpomReleaseComport; virtual; {HGJ} | ||||
| {$ENDIF} | ||||
| @@ -764,7 +780,7 @@ end; | ||||
|  | ||||
| class function TBlockSerial.GetVersion: string; | ||||
| begin | ||||
| 	Result := 'SynaSer 7.4.0'; | ||||
| 	Result := 'SynaSer 7.5.0'; | ||||
| end; | ||||
|  | ||||
| procedure TBlockSerial.CloseSocket; | ||||
| @@ -778,7 +794,7 @@ begin | ||||
|   end; | ||||
|   if InstanceActive then | ||||
|   begin | ||||
|     {$IFDEF LINUX} | ||||
|     {$IFDEF UNIX} | ||||
|     if FLinuxLock then | ||||
|       cpomReleaseComport; | ||||
|     {$ENDIF} | ||||
| @@ -933,7 +949,7 @@ begin | ||||
|     SerialCheck(-1) | ||||
|   else | ||||
|     SerialCheck(0); | ||||
|   {$IFDEF LINUX} | ||||
|   {$IFDEF UNIX} | ||||
|   if FLastError <> sOK then | ||||
|     if FLinuxLock then | ||||
|       cpomReleaseComport; | ||||
| @@ -968,7 +984,7 @@ begin | ||||
|   begin | ||||
|     SetSynaError(ErrNoDeviceAnswer); | ||||
|     FileClose(FHandle);         {HGJ} | ||||
|     {$IFDEF LINUX} | ||||
|     {$IFDEF UNIX} | ||||
|     if FLinuxLock then | ||||
|       cpomReleaseComport;                {HGJ} | ||||
|     {$ENDIF}                             {HGJ} | ||||
| @@ -1807,7 +1823,8 @@ function TBlockSerial.CanRead(Timeout: integer): boolean; | ||||
| begin | ||||
|   Result := WaitingData > 0; | ||||
|   if not Result then | ||||
|     Result := CanEvent(EV_RXCHAR, Timeout); | ||||
|     Result := CanEvent(EV_RXCHAR, Timeout) or (WaitingData > 0); | ||||
|     //check WaitingData again due some broken virtual ports | ||||
|   if Result then | ||||
|     DoStatus(HR_CanRead, ''); | ||||
| end; | ||||
| @@ -1918,7 +1935,11 @@ begin | ||||
|   {$IFNDEF FPC} | ||||
|   SerialCheck(ioctl(FHandle, TCFLSH, TCIOFLUSH)); | ||||
|   {$ELSE} | ||||
|   SerialCheck(fpioctl(FHandle, TCFLSH, TCIOFLUSH)); | ||||
|     {$IFDEF DARWIN} | ||||
|     SerialCheck(fpioctl(FHandle, TCIOflush, TCIOFLUSH)); | ||||
|     {$ELSE} | ||||
|     SerialCheck(fpioctl(FHandle, TCFLSH, TCIOFLUSH)); | ||||
|     {$ENDIF} | ||||
|   {$ENDIF} | ||||
|   FBuffer := ''; | ||||
|   ExceptCheck; | ||||
| @@ -2154,7 +2175,7 @@ end; | ||||
|   Ownership Manager. | ||||
| } | ||||
|  | ||||
| {$IFDEF LINUX} | ||||
| {$IFDEF UNIX} | ||||
|  | ||||
| function TBlockSerial.LockfileName: String; | ||||
| var | ||||
|   | ||||
		Reference in New Issue
	
	Block a user