import.pas 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Peter Vreman
  4. This unit implements an uniform import object
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. unit import;
  18. {$i defines.inc}
  19. interface
  20. uses
  21. cutils,cclasses;
  22. type
  23. timported_item = class(tlinkedlistitem)
  24. ordnr : word;
  25. name,
  26. func : pstring;
  27. lab : pointer; { should be plabel, but this gaves problems with circular units }
  28. is_var : boolean;
  29. constructor Create(const n,s : string;o : word);
  30. constructor Create_var(const n,s : string);
  31. destructor Destroy;override;
  32. end;
  33. timportlist = class(tlinkedlistitem)
  34. dllname : pstring;
  35. imported_items : tlinkedlist;
  36. constructor Create(const n : string);
  37. destructor Destroy;Override;
  38. end;
  39. timportlib=class
  40. private
  41. notsupmsg : boolean;
  42. procedure NotSupported;
  43. public
  44. constructor Create;
  45. destructor Destroy;override;
  46. procedure preparelib(const s:string);virtual;
  47. procedure importprocedure(const func,module:string;index:longint;const name:string);virtual;
  48. procedure importvariable(const varname,module:string;const name:string);virtual;
  49. procedure generatelib;virtual;
  50. procedure generatesmartlib;virtual;
  51. end;
  52. var
  53. importlib : timportlib;
  54. procedure InitImport;
  55. procedure DoneImport;
  56. implementation
  57. uses
  58. systems,verbose,globals
  59. {$ifdef i386}
  60. {$ifndef NOTARGETLINUX}
  61. ,t_linux
  62. {$endif}
  63. {$ifndef NOTARGETFREEBSD}
  64. ,t_fbsd
  65. {$endif}
  66. {$ifndef NOTARGETSUNOS}
  67. ,t_sunos
  68. {$endif}
  69. {$ifndef NOTARGETOS2}
  70. ,t_os2
  71. {$endif}
  72. {$ifndef NOTARGETWIN32}
  73. ,t_win32
  74. {$endif}
  75. {$ifndef NOTARGETNETWARE}
  76. ,t_nwm
  77. {$endif}
  78. {$ifndef NOTARGETGO32V2}
  79. ,t_go32v2
  80. {$endif}
  81. {$endif}
  82. {$ifdef m68k}
  83. {$ifndef NOTARGETLINUX}
  84. ,t_linux
  85. {$endif}
  86. {$endif}
  87. {$ifdef powerpc}
  88. {$ifndef NOTARGETLINUX}
  89. ,t_linux
  90. {$endif}
  91. {$endif}
  92. {$ifdef alpha}
  93. {$ifndef NOTARGETLINUX}
  94. ,t_linux
  95. {$endif}
  96. {$endif}
  97. ;
  98. {****************************************************************************
  99. Timported_item
  100. ****************************************************************************}
  101. constructor timported_item.Create(const n,s : string;o : word);
  102. begin
  103. inherited Create;
  104. func:=stringdup(n);
  105. name:=stringdup(s);
  106. ordnr:=o;
  107. lab:=nil;
  108. is_var:=false;
  109. end;
  110. constructor timported_item.create_var(const n,s : string);
  111. begin
  112. inherited Create;
  113. func:=stringdup(n);
  114. name:=stringdup(s);
  115. ordnr:=0;
  116. lab:=nil;
  117. is_var:=true;
  118. end;
  119. destructor timported_item.destroy;
  120. begin
  121. stringdispose(name);
  122. stringdispose(func);
  123. inherited destroy;
  124. end;
  125. {****************************************************************************
  126. TImportlist
  127. ****************************************************************************}
  128. constructor timportlist.Create(const n : string);
  129. begin
  130. inherited Create;
  131. dllname:=stringdup(n);
  132. imported_items:=Tlinkedlist.Create;
  133. end;
  134. destructor timportlist.destroy;
  135. begin
  136. imported_items.free;
  137. stringdispose(dllname);
  138. end;
  139. {****************************************************************************
  140. TImportLib
  141. ****************************************************************************}
  142. constructor timportlib.Create;
  143. begin
  144. notsupmsg:=false;
  145. end;
  146. destructor timportlib.Destroy;
  147. begin
  148. end;
  149. procedure timportlib.NotSupported;
  150. begin
  151. { show the message only once }
  152. if not notsupmsg then
  153. begin
  154. Message(exec_e_dll_not_supported);
  155. notsupmsg:=true;
  156. end;
  157. end;
  158. procedure timportlib.preparelib(const s:string);
  159. begin
  160. NotSupported;
  161. end;
  162. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  163. begin
  164. NotSupported;
  165. end;
  166. procedure timportlib.importvariable(const varname,module:string;const name:string);
  167. begin
  168. NotSupported;
  169. end;
  170. procedure timportlib.generatelib;
  171. begin
  172. NotSupported;
  173. end;
  174. procedure timportlib.generatesmartlib;
  175. begin
  176. NotSupported;
  177. end;
  178. procedure DoneImport;
  179. begin
  180. if assigned(importlib) then
  181. importlib.free;
  182. end;
  183. procedure InitImport;
  184. begin
  185. case target_info.target of
  186. {$ifdef i386}
  187. {$ifndef NOTARGETLINUX}
  188. target_i386_Linux :
  189. importlib:=Timportliblinux.Create;
  190. {$endif}
  191. {$ifndef NOTARGETFREEBSD}
  192. target_i386_freebsd:
  193. importlib:=Timportlibfreebsd.Create;
  194. {$endif}
  195. {$ifndef NOTARGETSUNOS}
  196. target_i386_sunos:
  197. importlib:=Timportlibsunos.Create;
  198. {$endif}
  199. {$ifndef NOTARGETWIN32}
  200. target_i386_Win32 :
  201. importlib:=Timportlibwin32.Create;
  202. {$endif}
  203. {$ifndef NOTARGETOS2}
  204. target_i386_OS2 :
  205. importlib:=Timportlibos2.Create;
  206. {$endif}
  207. {$ifndef NOTARGETNETWARE}
  208. target_i386_netware :
  209. importlib:=Timportlibnetware.Create;
  210. {$endif}
  211. {$endif i386}
  212. {$ifdef m68k}
  213. target_m68k_Linux :
  214. importlib:=Timportliblinux.Create;
  215. {$endif m68k}
  216. {$ifdef alpha}
  217. target_alpha_Linux :
  218. importlib:=Timportliblinux.Create;
  219. {$endif alpha}
  220. {$ifdef powerpc}
  221. target_alpha_Linux :
  222. importlib:=Timportliblinux.Create;
  223. {$endif powerpc}
  224. else
  225. importlib:=Timportlib.Create;
  226. end;
  227. end;
  228. end.
  229. {
  230. $Log$
  231. Revision 1.10 2001-02-26 19:44:52 peter
  232. * merged generic m68k updates from fixes branch
  233. Revision 1.9 2001/02/03 00:09:02 peter
  234. * fixed netware typo in previous commit
  235. Revision 1.8 2001/02/02 22:43:39 peter
  236. * add notarget defines
  237. Revision 1.7 2000/12/25 00:07:26 peter
  238. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  239. tlinkedlist objects)
  240. Revision 1.6 2000/09/24 15:06:18 peter
  241. * use defines.inc
  242. Revision 1.5 2000/09/16 12:22:52 peter
  243. * freebsd support merged
  244. Revision 1.4 2000/09/11 17:00:23 florian
  245. + first implementation of Netware Module support, thanks to
  246. Armin Diehl ([email protected]) for providing the patches
  247. Revision 1.3 2000/08/27 16:11:51 peter
  248. * moved some util functions from globals,cobjects to cutils
  249. * splitted files into finput,fmodule
  250. Revision 1.2 2000/07/13 11:32:43 michael
  251. + removed logs
  252. }