Debian Codegraph @

plugins/wfx/ftp/synapse/synafpc.pas

raw
1 {==============================================================================|
2 | Project : Ararat Synapse | 001.003.001 |
3 |==============================================================================|
4 | Content: Utils for FreePascal compatibility |
5 |==============================================================================|
6 | Copyright (c)1999-2013, Lukas Gebauer |
7 | All rights reserved. |
8 | |
9 | Redistribution and use in source and binary forms, with or without |
10 | modification, are permitted provided that the following conditions are met: |
11 | |
12 | Redistributions of source code must retain the above copyright notice, this |
13 | list of conditions and the following disclaimer. |
14 | |
15 | Redistributions in binary form must reproduce the above copyright notice, |
16 | this list of conditions and the following disclaimer in the documentation |
17 | and/or other materials provided with the distribution. |
18 | |
19 | Neither the name of Lukas Gebauer nor the names of its contributors may |
20 | be used to endorse or promote products derived from this software without |
21 | specific prior written permission. |
22 | |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
24 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
25 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
26 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
33 | DAMAGE. |
34 |==============================================================================|
35 | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
36 | Portions created by Lukas Gebauer are Copyright (c)2003-2013. |
37 | All Rights Reserved. |
38 |==============================================================================|
39 | Contributor(s): |
40 | Tomas Hajny (OS2 support) |
41 |==============================================================================|
42 | History: see HISTORY.HTM from distribution package |
43 | (Found at URL: http://www.ararat.cz/synapse/) |
44 |==============================================================================}
45
46 {:@exclude}
47
48 {$IFDEF FPC}
49 {$MODE DELPHI}
50 {$ENDIF}
51 {$H+}
52 //old Delphi does not have MSWINDOWS define.
53 {$IFDEF WIN32}
54 {$IFNDEF MSWINDOWS}
55 {$DEFINE MSWINDOWS}
56 {$ENDIF}
57 {$ENDIF}
58
59 unit synafpc;
60
61 interface
62
63 uses
64 {$IFDEF FPC}
65 dynlibs, sysutils;
66 {$ELSE}
67 {$IFDEF MSWINDOWS}
68 Windows;
69 {$ELSE}
70 SysUtils;
71 {$ENDIF}
72 {$ENDIF}
73
74 {$IFDEF FPC}
75 type
76 TLibHandle = dynlibs.TLibHandle;
77
78 function LoadLibrary(ModuleName: PChar): TLibHandle;
79 function FreeLibrary(Module: TLibHandle): LongBool;
80 function GetProcAddress(Module: TLibHandle; Proc: PChar): Pointer;
81 function GetModuleFileName(Module: TLibHandle; Buffer: PChar; BufLen: Integer): Integer;
82 {$ELSE} //not FPC
83 type
84 {$IFDEF CIL}
85 TLibHandle = Integer;
86 PtrInt = Integer;
87 {$ELSE}
88 TLibHandle = HModule;
89 {$IFDEF WIN64}
90 PtrInt = NativeInt;
91 {$ELSE}
92 PtrInt = Integer;
93 {$ENDIF}
94 {$ENDIF}
95 {$IFDEF VER100}
96 LongWord = DWord;
97 {$ENDIF}
98 {$ENDIF}
99
100 procedure Sleep(milliseconds: Cardinal);
101
102
103 implementation
104
105 {==============================================================================}
106 {$IFDEF FPC}
107 function LoadLibrary(ModuleName: PChar): TLibHandle;
108 begin
109 Result := dynlibs.LoadLibrary(Modulename);
110 end;
111
112 function FreeLibrary(Module: TLibHandle): LongBool;
113 begin
114 Result := dynlibs.UnloadLibrary(Module);
115 end;
116
117 function GetProcAddress(Module: TLibHandle; Proc: PChar): Pointer;
118 begin
119 {$IFDEF OS2GCC}
120 Result := dynlibs.GetProcedureAddress(Module, '_' + Proc);
121 {$ELSE OS2GCC}
122 Result := dynlibs.GetProcedureAddress(Module, Proc);
123 {$ENDIF OS2GCC}
124 end;
125
126 function GetModuleFileName(Module: TLibHandle; Buffer: PChar; BufLen: Integer): Integer;
127 begin
128 Result := 0;
129 end;
130
131 {$ELSE}
132 {$ENDIF}
133
134 procedure Sleep(milliseconds: Cardinal);
135 begin
136 {$IFDEF MSWINDOWS}
137 {$IFDEF FPC}
138 sysutils.sleep(milliseconds);
139 {$ELSE}
140 windows.sleep(milliseconds);
141 {$ENDIF}
142 {$ELSE}
143 sysutils.sleep(milliseconds);
144 {$ENDIF}
145
146 end;
147
148 end.