ftpapi.pas 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Yuri Prokushev ([email protected]).
  4. Functions from FTPAPI.DLL (part of standard OS/2 Warp 4/eCS installation).
  5. This program is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU Library General Public License (LGPL) as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version. This program is
  9. distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE.
  12. See the GNU Library General Public License for more details. You should
  13. have received a copy of the GNU Library General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. **********************************************************************}
  17. {
  18. @abstract(a unit to handle FTP)
  19. @author(Yuri Prokushev ([email protected]))
  20. @created(22 Jul 2002)
  21. @lastmod(01 Oct 2002)
  22. This is functions from FTPAPI.DLL. Goal is ftp manipulation.
  23. Warning: This code is alfa. Future versions of this unit will propably
  24. not be compatible.
  25. @todo(Rework some functions to support strings longer then 255 chars)
  26. @todo(Finish functions description)
  27. }
  28. unit FTPAPI;
  29. {****************************************************************************
  30. RTL configuration
  31. ****************************************************************************}
  32. interface
  33. uses
  34. OS2Def,
  35. PMWin,
  36. Strings;
  37. Const
  38. // window message id for post xfer updates
  39. WM_FTPAPI_XFER_UPDATE = WM_USER + 1000;
  40. // Transfer types is ASCII
  41. T_ASCII = 1;
  42. // Transfer types is EBCDIC
  43. T_EBCDIC = 2;
  44. // Transfer types is BINARY
  45. T_BINARY = 3;
  46. // command/reply trace file modes
  47. M_OVERLAY = 1;
  48. M_APPEND = 2;
  49. // command/reply tracing error codes
  50. // invalid trace file open mode
  51. TRCMODE = 1;
  52. // unable to open trace file
  53. TRCOPEN = 2;
  54. // Common error codes (try Ftp_ErrNo, all other functions returns usually
  55. // 0 if all ok, -1 if all bad)
  56. // No any error
  57. FTPNOERROR = 00;
  58. // Unknown service.
  59. FTPSERVICE = 01;
  60. // Unknown host.
  61. FTPHOST = 02;
  62. // Unable to obtain socket.
  63. FTPSOCKET = 03;
  64. // Unable to connect to server.
  65. FTPCONNECT = 04;
  66. // Login failed.
  67. FTPLOGIN = 05;
  68. // Transfer aborted.
  69. FTPABORT = 06;
  70. // Problem opening the local file.
  71. FTPLOCALFILE = 07;
  72. // Problem initializing data connection.
  73. FTPDATACONN = 08;
  74. // Command failed.
  75. FTPCOMMAND = 09;
  76. // Proxy server does not support third party transfers.
  77. FTPPROXYTHIRD = 10;
  78. // No primary connection for proxy transfer.
  79. FTPNOPRIMARY = 11;
  80. // No code page translation table was loaded
  81. FTPNOXLATETBL = 12;
  82. // ping error codes
  83. // All ok
  84. PINGOK = 0;
  85. // Host does not reply
  86. PINGREPLY = -1;
  87. // Unable to obtain socket
  88. PINGSOCKET = -3;
  89. // Unknown protocol ICMP
  90. PINGPROTO = -4;
  91. // Send failed
  92. PINGSEND = -5;
  93. // Recv() failed
  94. PINGRECV = -6;
  95. // Unknown host (can't resolve)
  96. PINGHOST = -7;
  97. // Restart Specific
  98. REST_GET = 1;
  99. REST_PUT = 2;
  100. Const
  101. // Short functions vars
  102. ShortHost: String='';
  103. ShortUserId: String='';
  104. ShortPasswd: String='';
  105. ShortAcct: String='';
  106. ShortTransferType: Integer = T_ASCII;
  107. {****************************************************************************
  108. Opening and Closing Functions
  109. ****************************************************************************}
  110. // Defines Host, UserId, Passwd and Acct for short function calls
  111. Function FtpSetUser(Host, UserId, Passwd, Acct: String): Integer;
  112. // Defines TransferType for short function calls
  113. Function FtpSetBinary(TransferType: Integer): Integer;
  114. // Stores the string containing the FTP API version
  115. // Buf is the buffer to store version string
  116. // BufLen is length of the buffer
  117. // Version string is null-terminated and truncated to buffer length
  118. Function FtpVer(var Buf; BufLen: Integer): Integer; cdecl;
  119. Function FtpVer(Var Buf: String): Integer;
  120. // Closes all current connections
  121. Procedure FtpLogoff; cdecl;
  122. {****************************************************************************
  123. File Action Functions
  124. ****************************************************************************}
  125. // Appends information to a remote file
  126. // Host is hostname. Use 'hostname portnumber' to specify non-standard port
  127. // UserID is user ID
  128. // Passwd is password
  129. // Acct is account (can be nil)
  130. // Local is local filename
  131. // Remote is Remote filename
  132. // TransferType is type of transfer (T_* constants)
  133. Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: PChar;
  134. Transfertype: Integer): Integer; cdecl;
  135. Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: String;
  136. Transfertype: Integer): Integer;
  137. Function FTPAppend(Local, Remote: PChar; Transfertype: Integer): Integer;
  138. Function FTPAppend(Local, Remote: String; Transfertype: Integer): Integer;
  139. Function FTPAppend(Local, Remote: PChar): Integer;
  140. Function FTPAppend(Local, Remote: String): Integer;
  141. // Deletes files on a remote host
  142. Function FtpDelete(Host, UserId, Passwd, Acct, Name: PChar): Integer; cdecl;
  143. Function FtpDelete(Host, UserId, Passwd, Acct, Name: String): Integer;
  144. Function FtpDelete(Name: PChar): Integer;
  145. Function FtpDelete(Name: String): Integer;
  146. // Renames a file on a remote host
  147. Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: PChar): Integer; cdecl;
  148. Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: String): Integer;
  149. Function FtpRename(NameFrom, NameTo: PChar): Integer;
  150. Function FtpRename(NameFrom, NameTo: String): Integer;
  151. // Gets a file from an FTP server
  152. // Mode is either 'w' for re_w_rite, or 'a' for _a_ppend
  153. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType: integer): Integer; cdecl;
  154. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: integer): Integer;
  155. Function FtpGet(Local, Remote, Mode: PChar; TransferType: integer): Integer;
  156. Function FtpGet(Local, Remote, Mode: String; TransferType: integer): Integer;
  157. Function FtpGet(Local, Remote, Mode: PChar): Integer;
  158. Function FtpGet(Local, Remote, Mode: String): Integer;
  159. // Transfers a file to an FTP server
  160. Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
  161. Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
  162. Function FtpPut(Local, Remote: PChar; TransferType: Integer): Integer;
  163. Function FtpPut(Local, Remote: String; TransferType: Integer): Integer;
  164. Function FtpPut(Local, Remote: PChar): Integer;
  165. Function FtpPut(Local, Remote: String): Integer;
  166. // Transfers a file to a host and ensures it is created with a unique name
  167. Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
  168. Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
  169. Function FtpPutUnique(Local, Remote: PChar; TransferType: Integer): Integer;
  170. Function FtpPutUnique(Local, Remote: String; TransferType: Integer): Integer;
  171. Function FtpPutUnique(Local, Remote: PChar): Integer;
  172. Function FtpPutUnique(Local, Remote: String): Integer;
  173. // Restarts an aborted transaction from the point of interruption
  174. Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType, Rest: Integer): Longint; cdecl;
  175. Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
  176. Function FtpReStart(Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
  177. Function FtpReStart(Local, Remote, Mode: String; Rest: Integer): Longint;
  178. {****************************************************************************
  179. Directory Listing Functions
  180. ****************************************************************************}
  181. // Gets directory information in short format from a remote host and stores it to a local file
  182. // You can use named pipes here to avoid a need for creating a real file
  183. Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
  184. Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
  185. Function FtpLs(Local, Pattern: String): Integer;
  186. // Gets a directory in wide format from a host and stores it in file Local
  187. // See comment regarding named pipes above
  188. Function FtpDir(Host, UserId, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
  189. Function FtpDir(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
  190. Function FtpDir(Local, Pattern: String): Integer;
  191. {****************************************************************************
  192. Directory Action Functions
  193. ****************************************************************************}
  194. // Changes the current working directory on a host
  195. Function FtpCd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
  196. Function FtpCd(Host, Userid, Passwd, Acct, Dir: String): Integer;
  197. Function FtpCd(Dir: String): Integer;
  198. // Creates a new directory on a target machine
  199. Function FtpMkd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
  200. Function FtpMkd(Host, Userid, Passwd, Acct, Dir: String): Integer;
  201. Function FtpMkd(Dir: String): Integer;
  202. // Removes a directory on a target machine
  203. Function FtpRmd(Host, UserId, Passwd, Acct, Dir: PChar): Integer; cdecl;
  204. Function FtpRmd(Host, UserId, Passwd, Acct, Dir: String): Integer;
  205. Function FtpRmd(Dir: String): Integer;
  206. // Stores the string containing the FTP server description of the current
  207. // working directory on the host to the buffer
  208. Function FtpPwd(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
  209. Function FtpPwd(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
  210. Function FtpPwd(var Buf: String): Integer;
  211. {****************************************************************************
  212. Remote Server Functions
  213. ****************************************************************************}
  214. // Sends a string to the server verbatim
  215. Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: PChar): Integer; cdecl;
  216. Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: String): Integer;
  217. Function FtpQuote(QuoteStr: String): Integer;
  218. // Executes the site command
  219. Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: PChar): Integer; cdecl;
  220. Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: String): Integer;
  221. Function FtpSite(SiteStr: String): Integer;
  222. // Stores the string containing the FTP server description of the operating
  223. // system running on the host in a buffer
  224. Function FtpSys(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
  225. Function FtpSys(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
  226. Function FtpSys(var Buf: String): Integer;
  227. // Transfers a file between two remote servers without sending the file to
  228. // the local host
  229. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  230. Host2, UserId2, Passwd2, Acct2,
  231. FN1, FN2: PChar; TransferType: Integer): Integer; cdecl;
  232. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  233. Host2, UserId2, Passwd2, Acct2,
  234. FN1, FN2: String; TransferType: Integer): Integer;
  235. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  236. Host2, UserId2, Passwd2, Acct2,
  237. FN1, FN2: String): Integer;
  238. // Resolves a host name and sends a ping to the remote host to determine if the host is responding
  239. Function FtpPing(Host: PChar; Len: Integer; var Addr: Longint): Integer; cdecl;
  240. Function FtpPing(Host: String; Len: Integer; var Addr: Longint): Integer;
  241. // Sends a ping to the remote host to determine if the host is responding
  242. Function Ping(Addr: Longint; Len: Integer): Integer; cdecl;
  243. // Returns the size of a file on the remote host
  244. Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: Pchar; TransferType: Integer): Longint; cdecl;
  245. Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: Integer): Longint;
  246. Function FtpRemSize(Local, Remote, Mode: String; TransferType: Integer): Longint;
  247. Function FtpRemSize(Local, Remote, Mode: String): Longint;
  248. // Maintain the original date/time of files received.
  249. Function Keep_File_Date(LocalFile, RemoteFile: PChar): Boolean; cdecl;
  250. Function Keep_File_Date(LocalFile, RemoteFile: String): Boolean;
  251. {****************************************************************************
  252. Trace Functions
  253. ****************************************************************************}
  254. // Opens the trace file specified and starts tracing
  255. Function FtpTrcOn(FileSpec: PChar; Mode: Integer): Integer; cdecl;
  256. Function FtpTrcOn(FileSpec: String; Mode: Integer): Integer; cdecl;
  257. // Closes the trace file, and stops tracing of the command and reply sequences that
  258. // were sent over the control connection between the local and remote hosts
  259. Function FtpTrcOff: Integer; cdecl;
  260. {****************************************************************************
  261. Other Functions
  262. ****************************************************************************}
  263. // FTP error No
  264. Function Ftp_ErrNo: Integer; cdecl;
  265. (* Undocumented / unimplemented functions:
  266. Function FtpXLate(Dig: Longint; St:PChar): Longint; cdecl;
  267. Procedure FtpXferWnd(var _hwnd: HWND); cdecl;
  268. Procedure FtpSetConvertMode(var code: integer); cdecl;
  269. Procedure FtpSetEncodeMode(var code: integer); cdecl;
  270. Procedure FtpSetDecodeMode(var code: integer); cdecl;
  271. Function FtpSetActiveMode(var UseActiveOnly: integer): integer; cdecl;
  272. *)
  273. implementation
  274. const
  275. FTPAPIDLL = 'FTPAPI';
  276. Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: PChar;
  277. Transfertype: Integer): Integer; cdecl;
  278. external FTPAPIDLL index 1;
  279. Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: String;
  280. Transfertype: Integer): Integer;
  281. Var
  282. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  283. Begin
  284. StrPCopy(@_Host, Host);
  285. StrPCopy(@_UserId, UserId);
  286. StrPCopy(@_Passwd, Passwd);
  287. StrPCopy(@_Acct, Acct);
  288. StrPCopy(@_Local, Local);
  289. StrPCopy(@_Remote, Remote);
  290. FtpAppend:=FtpAppend(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
  291. End;
  292. Function FTPAppend(Local, Remote: PChar; TransferType: Integer): Integer;
  293. Var
  294. Host, UserId, Passwd, Acct: Array[0..255] of Char;
  295. Begin
  296. StrPCopy(@Host, ShortHost);
  297. StrPCopy(@UserId, ShortUserId);
  298. StrPCopy(@Passwd, ShortPasswd);
  299. StrPCopy(@Acct, ShortAcct);
  300. FtpAppend:=FtpAppend(@Host, @UserId, @Passwd, @Acct, Local, Remote, TransferType);
  301. End;
  302. Function FTPAppend(Local, Remote: PChar): Integer;
  303. Begin
  304. FtpAppend:=FtpAppend(Local, Remote, ShortTransferType);
  305. End;
  306. Function FTPAppend(Local, Remote: String; TransferType: Integer): Integer;
  307. Var
  308. _Local, _Remote: Array[0..255] of Char;
  309. Begin
  310. StrPCopy(@_Local, Local);
  311. StrPCopy(@_Remote, Remote);
  312. FtpAppend:=FtpAppend(@_Local, @_Remote, TransferType);
  313. End;
  314. Function FTPAppend(Local, Remote: String): Integer;
  315. Var
  316. _Local, _Remote: Array[0..255] of Char;
  317. Begin
  318. StrPCopy(@_Local, Local);
  319. StrPCopy(@_Remote, Remote);
  320. FtpAppend:=FtpAppend(@_Local, @_Remote);
  321. End;
  322. Function FtpCd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
  323. external FTPAPIDLL index 2;
  324. Function FtpCd(Host, Userid, Passwd, Acct, Dir: String): Integer;
  325. Var
  326. _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
  327. Begin
  328. GetMem(_Host, Length(Host)+1);
  329. GetMem(_UserId, Length(UserId)+1);
  330. GetMem(_Passwd, Length(Passwd)+1);
  331. GetMem(_Acct, Length(Acct)+1);
  332. GetMem(_Dir, Length(Dir)+1);
  333. StrPCopy(_Host, Host);
  334. StrPCopy(_UserId, UserId);
  335. StrPCopy(_Passwd, Passwd);
  336. StrPCopy(_Acct, Acct);
  337. StrPCopy(_Dir, Dir);
  338. FtpCd:=FtpCd(_Host, _Userid, _Passwd, _Acct, _Dir);
  339. FreeMem(_Host, Length(Host)+1);
  340. FreeMem(_UserId, Length(UserId)+1);
  341. FreeMem(_Passwd, Length(Passwd)+1);
  342. FreeMem(_Acct, Length(Acct)+1);
  343. FreeMem(_Dir, Length(Dir)+1);
  344. End;
  345. Function FtpCd(Dir: String): Integer;
  346. Begin
  347. FtpCd:=FtpCd(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
  348. End;
  349. Function FtpDelete(Host, UserId, Passwd, Acct, Name: PChar): Integer; cdecl;
  350. external FTPAPIDLL index 3;
  351. Function FtpDelete(Host, UserId, Passwd, Acct, Name: String): Integer;
  352. Var
  353. _Host, _UserId, _Passwd, _Acct, _Name: Array[0..255] of Char;
  354. Begin
  355. StrPCopy(@_Host, Host);
  356. StrPCopy(@_UserId, UserId);
  357. StrPCopy(@_Passwd, Passwd);
  358. StrPCopy(@_Acct, Acct);
  359. StrPCopy(@_Name, Name);
  360. FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, @_Name);
  361. End;
  362. Function FtpDelete(Name: PChar): Integer;
  363. Var
  364. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  365. Begin
  366. StrPCopy(@_Host, ShortHost);
  367. StrPCopy(@_UserId, ShortUserId);
  368. StrPCopy(@_Passwd, ShortPasswd);
  369. StrPCopy(@_Acct, ShortAcct);
  370. FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, Name);
  371. End;
  372. Function FtpDelete(Name: String): Integer;
  373. Var
  374. _Host, _UserId, _Passwd, _Acct, _Name: Array[0..255] of Char;
  375. Begin
  376. StrPCopy(@_Host, ShortHost);
  377. StrPCopy(@_UserId, ShortUserId);
  378. StrPCopy(@_Passwd, ShortPasswd);
  379. StrPCopy(@_Acct, ShortAcct);
  380. StrPCopy(@_Name, Name);
  381. FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, @_Name);
  382. End;
  383. Function FtpDir(Host, UserId, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
  384. external FTPAPIDLL index 4;
  385. Function FtpDir(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
  386. Var
  387. _Host, _UserId, _Passwd, _Acct, _Local, _Pattern: PChar;
  388. Begin
  389. GetMem(_Host, Length(Host)+1);
  390. GetMem(_UserId, Length(UserId)+1);
  391. GetMem(_Passwd, Length(Passwd)+1);
  392. GetMem(_Acct, Length(Acct)+1);
  393. GetMem(_Local, Length(Local)+1);
  394. GetMem(_Pattern, Length(Pattern)+1);
  395. StrPCopy(_Host, Host);
  396. StrPCopy(_UserId, UserId);
  397. StrPCopy(_Passwd, Passwd);
  398. StrPCopy(_Acct, Acct);
  399. StrPCopy(_Local, Local);
  400. StrPCopy(_Pattern, Pattern);
  401. FtpDir:=FtpDir(_Host, _Userid, _Passwd, _Acct, _Local, _Pattern);
  402. FreeMem(_Host, Length(Host)+1);
  403. FreeMem(_UserId, Length(UserId)+1);
  404. FreeMem(_Passwd, Length(Passwd)+1);
  405. FreeMem(_Acct, Length(Acct)+1);
  406. FreeMem(_Local, Length(Local)+1);
  407. FreeMem(_Pattern, Length(Pattern)+1);
  408. End;
  409. Function FtpDir(Local, Pattern: String): Integer;
  410. Begin
  411. FtpDir:=FtpDir(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Pattern);
  412. End;
  413. Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
  414. external FTPAPIDLL index 7;
  415. Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
  416. Var
  417. _Host, _UserId, _Passwd, _Acct, _Local, _Pattern: PChar;
  418. Begin
  419. GetMem(_Host, Length(Host)+1);
  420. GetMem(_UserId, Length(UserId)+1);
  421. GetMem(_Passwd, Length(Passwd)+1);
  422. GetMem(_Acct, Length(Acct)+1);
  423. GetMem(_Local, Length(Local)+1);
  424. GetMem(_Pattern, Length(Pattern)+1);
  425. StrPCopy(_Host, Host);
  426. StrPCopy(_UserId, UserId);
  427. StrPCopy(_Passwd, Passwd);
  428. StrPCopy(_Acct, Acct);
  429. StrPCopy(_Local, Local);
  430. StrPCopy(_Pattern, Pattern);
  431. FtpLs:=FtpLs(_Host, _Userid, _Passwd, _Acct, _Local, _Pattern);
  432. FreeMem(_Host, Length(Host)+1);
  433. FreeMem(_UserId, Length(UserId)+1);
  434. FreeMem(_Passwd, Length(Passwd)+1);
  435. FreeMem(_Acct, Length(Acct)+1);
  436. FreeMem(_Local, Length(Local)+1);
  437. FreeMem(_Pattern, Length(Pattern)+1);
  438. End;
  439. Function FtpLs(Local, Pattern: String): Integer;
  440. Begin
  441. FtpLs:=FtpLs(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Pattern);
  442. End;
  443. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType: integer): Integer; cdecl;
  444. external FTPAPIDLL index 5;
  445. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: integer): Integer;
  446. Var
  447. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  448. Begin
  449. StrPCopy(@_Host, Host);
  450. StrPCopy(@_UserId, UserId);
  451. StrPCopy(@_Passwd, Passwd);
  452. StrPCopy(@_Acct, Acct);
  453. StrPCopy(@_Local, Local);
  454. StrPCopy(@_Remote, Remote);
  455. StrPCopy(@_Mode, Mode);
  456. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
  457. End;
  458. Function FtpGet(Local, Remote, Mode: PChar; TransferType: integer): Integer;
  459. Var
  460. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  461. Begin
  462. StrPCopy(@_Host, ShortHost);
  463. StrPCopy(@_UserId, ShortUserId);
  464. StrPCopy(@_Passwd, ShortPasswd);
  465. StrPCopy(@_Acct, ShortAcct);
  466. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, TransferType);
  467. End;
  468. Function FtpGet(Local, Remote, Mode: String; TransferType: integer): Integer;
  469. Var
  470. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  471. Begin
  472. StrPCopy(@_Host, ShortHost);
  473. StrPCopy(@_UserId, ShortUserId);
  474. StrPCopy(@_Passwd, ShortPasswd);
  475. StrPCopy(@_Acct, ShortAcct);
  476. StrPCopy(@_Local, Local);
  477. StrPCopy(@_Remote, Remote);
  478. StrPCopy(@_Mode, Mode);
  479. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
  480. End;
  481. Function FtpGet(Local, Remote, Mode: PChar): Integer;
  482. Var
  483. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  484. Begin
  485. StrPCopy(@_Host, ShortHost);
  486. StrPCopy(@_UserId, ShortUserId);
  487. StrPCopy(@_Passwd, ShortPasswd);
  488. StrPCopy(@_Acct, ShortAcct);
  489. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, ShortTransferType);
  490. End;
  491. Function FtpGet(Local, Remote, Mode: String): Integer;
  492. Var
  493. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  494. Begin
  495. StrPCopy(@_Host, ShortHost);
  496. StrPCopy(@_UserId, ShortUserId);
  497. StrPCopy(@_Passwd, ShortPasswd);
  498. StrPCopy(@_Acct, ShortAcct);
  499. StrPCopy(@_Local, Local);
  500. StrPCopy(@_Remote, Remote);
  501. StrPCopy(@_Mode, Mode);
  502. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, ShortTransferType);
  503. End;
  504. Procedure FtpLogoff; cdecl;
  505. external FTPAPIDLL index 6;
  506. Function FtpMkd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
  507. external FTPAPIDLL index 8;
  508. Function FtpMkD(Host, Userid, Passwd, Acct, Dir: String): Integer;
  509. Var
  510. _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
  511. Begin
  512. GetMem(_Host, Length(Host)+1);
  513. GetMem(_UserId, Length(UserId)+1);
  514. GetMem(_Passwd, Length(Passwd)+1);
  515. GetMem(_Acct, Length(Acct)+1);
  516. GetMem(_Dir, Length(Dir)+1);
  517. StrPCopy(_Host, Host);
  518. StrPCopy(_UserId, UserId);
  519. StrPCopy(_Passwd, Passwd);
  520. StrPCopy(_Acct, Acct);
  521. StrPCopy(_Dir, Dir);
  522. FtpMkD:=FtpMkD(_Host, _Userid, _Passwd, _Acct, _Dir);
  523. FreeMem(_Host, Length(Host)+1);
  524. FreeMem(_UserId, Length(UserId)+1);
  525. FreeMem(_Passwd, Length(Passwd)+1);
  526. FreeMem(_Acct, Length(Acct)+1);
  527. FreeMem(_Dir, Length(Dir)+1);
  528. End;
  529. Function FtpMkD(Dir: String): Integer;
  530. Begin
  531. FtpMkD:=FtpMkD(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
  532. End;
  533. Function FtpPing(Host: PChar; Len: Integer; var Addr: Longint): Integer; cdecl;
  534. external FTPAPIDLL index 9;
  535. Function FtpPing(Host: String; Len: Integer; var Addr: Longint): Integer;
  536. var
  537. _Host: PChar;
  538. Begin
  539. GetMem(_Host, Length(Host)+1);
  540. StrPCopy(_Host, Host);
  541. FtpPing:=FtpPing(_Host, Len, Addr);
  542. FreeMem(_Host, Length(Host)+1);
  543. End;
  544. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  545. Host2, UserId2, Passwd2, Acct2,
  546. FN1, FN2: PChar; TransferType: Integer): Integer; cdecl;
  547. external FTPAPIDLL index 10;
  548. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  549. Host2, UserId2, Passwd2, Acct2,
  550. FN1, FN2: String; TransferType: Integer): Integer;
  551. Begin
  552. Host1:=Host2+#0;
  553. Host2:=Host2+#0;
  554. UserId1:=UserId1+#0;
  555. UserId2:=UserId2+#0;
  556. Passwd1:=Passwd1+#0;
  557. Passwd2:=Passwd2+#0;
  558. Acct1:=Acct1+#0;
  559. Acct2:=Acct2+#0;
  560. FN1:=FN1+#0;
  561. FN2:=FN2+#0;
  562. FtpProxy:=FtpProxy(@Host1[1], @UserId1[1], @Passwd1[1], @Acct1[1],
  563. @Host2[1], @UserId2[1], @Passwd2[1], @Acct2[1],
  564. @FN1[1], @FN2[1], TransferType);
  565. End;
  566. Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
  567. Host2, UserId2, Passwd2, Acct2,
  568. FN1, FN2: String): Integer;
  569. Begin
  570. FtpProxy:=FtpProxy(Host1, UserId1, Passwd1, Acct1,
  571. Host2, UserId2, Passwd2, Acct2,
  572. FN1, FN2, ShortTransferType);
  573. End;
  574. Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
  575. external FTPAPIDLL index 11;
  576. Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
  577. Var
  578. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  579. Begin
  580. StrPCopy(@_Host, Host);
  581. StrPCopy(@_UserId, UserId);
  582. StrPCopy(@_Passwd, Passwd);
  583. StrPCopy(@_Acct, Acct);
  584. StrPCopy(@_Local, Local);
  585. StrPCopy(@_Remote, Remote);
  586. FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
  587. End;
  588. Function FtpPut(Local, Remote: PChar; TransferType: Integer): Integer;
  589. Var
  590. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  591. Begin
  592. StrPCopy(@_Host, ShortHost);
  593. StrPCopy(@_UserId, ShortUserId);
  594. StrPCopy(@_Passwd, ShortPasswd);
  595. StrPCopy(@_Acct, ShortAcct);
  596. FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, TransferType);
  597. End;
  598. Function FtpPut(Local, Remote: String; TransferType: Integer): Integer;
  599. Var
  600. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  601. Begin
  602. StrPCopy(@_Host, ShortHost);
  603. StrPCopy(@_UserId, ShortUserId);
  604. StrPCopy(@_Passwd, ShortPasswd);
  605. StrPCopy(@_Acct, ShortAcct);
  606. StrPCopy(@_Local, Local);
  607. StrPCopy(@_Remote, Remote);
  608. FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
  609. End;
  610. Function FtpPut(Local, Remote: PChar): Integer;
  611. Var
  612. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  613. Begin
  614. StrPCopy(@_Host, ShortHost);
  615. StrPCopy(@_UserId, ShortUserId);
  616. StrPCopy(@_Passwd, ShortPasswd);
  617. StrPCopy(@_Acct, ShortAcct);
  618. FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, ShortTransferType);
  619. End;
  620. Function FtpPut(Local, Remote: String): Integer;
  621. Var
  622. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  623. Begin
  624. StrPCopy(@_Host, ShortHost);
  625. StrPCopy(@_UserId, ShortUserId);
  626. StrPCopy(@_Passwd, ShortPasswd);
  627. StrPCopy(@_Acct, ShortAcct);
  628. StrPCopy(@_Local, Local);
  629. StrPCopy(@_Remote, Remote);
  630. FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, ShortTransferType);
  631. End;
  632. Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
  633. external FTPAPIDLL index 12;
  634. Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
  635. Var
  636. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  637. Begin
  638. StrPCopy(@_Host, Host);
  639. StrPCopy(@_UserId, UserId);
  640. StrPCopy(@_Passwd, Passwd);
  641. StrPCopy(@_Acct, Acct);
  642. StrPCopy(@_Local, Local);
  643. StrPCopy(@_Remote, Remote);
  644. FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
  645. End;
  646. Function FtpPutUnique(Local, Remote: PChar; TransferType: Integer): Integer;
  647. Var
  648. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  649. Begin
  650. StrPCopy(@_Host, ShortHost);
  651. StrPCopy(@_UserId, ShortUserId);
  652. StrPCopy(@_Passwd, ShortPasswd);
  653. StrPCopy(@_Acct, ShortAcct);
  654. FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, TransferType);
  655. End;
  656. Function FtpPutUnique(Local, Remote: String; TransferType: Integer): Integer;
  657. Var
  658. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  659. Begin
  660. StrPCopy(@_Host, ShortHost);
  661. StrPCopy(@_UserId, ShortUserId);
  662. StrPCopy(@_Passwd, ShortPasswd);
  663. StrPCopy(@_Acct, ShortAcct);
  664. StrPCopy(@_Local, Local);
  665. StrPCopy(@_Remote, Remote);
  666. FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
  667. End;
  668. Function FtpPutUnique(Local, Remote: PChar): Integer;
  669. Var
  670. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  671. Begin
  672. StrPCopy(@_Host, ShortHost);
  673. StrPCopy(@_UserId, ShortUserId);
  674. StrPCopy(@_Passwd, ShortPasswd);
  675. StrPCopy(@_Acct, ShortAcct);
  676. FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, ShortTransferType);
  677. End;
  678. Function FtpPutUnique(Local, Remote: String): Integer;
  679. Var
  680. _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
  681. Begin
  682. StrPCopy(@_Host, ShortHost);
  683. StrPCopy(@_UserId, ShortUserId);
  684. StrPCopy(@_Passwd, ShortPasswd);
  685. StrPCopy(@_Acct, ShortAcct);
  686. StrPCopy(@_Local, Local);
  687. StrPCopy(@_Remote, Remote);
  688. FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, ShortTransferType);
  689. End;
  690. Function FtpPwd(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
  691. external FTPAPIDLL index 13;
  692. Function FtpPwd(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
  693. Var
  694. _Host, _UserId, _Passwd, _Acct: PChar;
  695. _Buf: Array[0..255] of Char;
  696. Begin
  697. GetMem(_Host, Length(Host)+1);
  698. GetMem(_UserId, Length(UserId)+1);
  699. GetMem(_Passwd, Length(Passwd)+1);
  700. GetMem(_Acct, Length(Acct)+1);
  701. StrPCopy(_Host, Host);
  702. StrPCopy(_UserId, UserId);
  703. StrPCopy(_Passwd, Passwd);
  704. StrPCopy(_Acct, Acct);
  705. FtpPwd:=FtpPwd(_Host, _UserId, _Passwd, _Acct, @_Buf, SizeOf(_Buf));
  706. Buf:=StrPas(@_Buf);
  707. FreeMem(_Host, Length(Host)+1);
  708. FreeMem(_UserId, Length(UserId)+1);
  709. FreeMem(_Passwd, Length(Passwd)+1);
  710. FreeMem(_Acct, Length(Acct)+1);
  711. End;
  712. Function FtpPwd(var Buf: String): Integer;
  713. Begin
  714. FtpPwd:=FtpPwd(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Buf);
  715. End;
  716. Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: PChar): Integer; cdecl;
  717. external FTPAPIDLL index 14;
  718. Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: String): Integer;
  719. Var
  720. _Host, _UserId, _Passwd, _Acct, _QuoteStr: PChar;
  721. Begin
  722. GetMem(_Host, Length(Host)+1);
  723. GetMem(_UserId, Length(UserId)+1);
  724. GetMem(_Passwd, Length(Passwd)+1);
  725. GetMem(_Acct, Length(Acct)+1);
  726. GetMem(_QuoteStr, Length(QuoteStr)+1);
  727. StrPCopy(_Host, Host);
  728. StrPCopy(_UserId, UserId);
  729. StrPCopy(_Passwd, Passwd);
  730. StrPCopy(_Acct, Acct);
  731. StrPCopy(_QuoteStr, QuoteStr);
  732. FtpQuote:=FtpQuote(_Host, _UserId, _Passwd, _Acct, _QuoteStr);
  733. FreeMem(_Host, Length(Host)+1);
  734. FreeMem(_UserId, Length(UserId)+1);
  735. FreeMem(_Passwd, Length(Passwd)+1);
  736. FreeMem(_Acct, Length(Acct)+1);
  737. FreeMem(_QuoteStr, Length(QuoteStr)+1);
  738. End;
  739. Function FtpQuote(QuoteStr: String): Integer;
  740. Begin
  741. FtpQuote:=FtpQuote(ShortHost, ShortUserId, ShortPasswd, ShortAcct, QuoteStr);
  742. End;
  743. Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: PChar): Integer; cdecl;
  744. external FTPAPIDLL index 15;
  745. Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: String): Integer;
  746. Var
  747. _Host, _UserId, _Passwd, _Acct, _NameFrom, _NameTo: Array[0..255] of Char;
  748. Begin
  749. StrPCopy(@_Host, Host);
  750. StrPCopy(@_UserId, UserId);
  751. StrPCopy(@_Passwd, Passwd);
  752. StrPCopy(@_Acct, Acct);
  753. StrPCopy(@_NameTo, NameTo);
  754. StrPCopy(@_NameFrom, NameFrom);
  755. FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, @_NameFrom, @_NameTo);
  756. End;
  757. Function FtpRename(NameFrom, NameTo: PChar): Integer;
  758. Var
  759. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  760. Begin
  761. StrPCopy(@_Host, ShortHost);
  762. StrPCopy(@_UserId, ShortUserId);
  763. StrPCopy(@_Passwd, ShortPasswd);
  764. StrPCopy(@_Acct, ShortAcct);
  765. FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, NameFrom, NameTo);
  766. End;
  767. Function FtpRename(NameFrom, NameTo: String): Integer;
  768. Var
  769. _Host, _UserId, _Passwd, _Acct, _NameFrom, _NameTo: Array[0..255] of Char;
  770. Begin
  771. StrPCopy(@_Host, ShortHost);
  772. StrPCopy(@_UserId, ShortUserId);
  773. StrPCopy(@_Passwd, ShortPasswd);
  774. StrPCopy(@_Acct, ShortAcct);
  775. StrPCopy(@_NameTo, NameTo);
  776. StrPCopy(@_NameFrom, NameFrom);
  777. FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, @_NameFrom, @_NameTo);
  778. End;
  779. Function FtpRmd(Host, UserId, Passwd, Acct, Dir: PChar): Integer; cdecl;
  780. external FTPAPIDLL index 16;
  781. Function FtpRmD(Host, Userid, Passwd, Acct, Dir: String): Integer;
  782. Var
  783. _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
  784. Begin
  785. GetMem(_Host, Length(Host)+1);
  786. GetMem(_UserId, Length(UserId)+1);
  787. GetMem(_Passwd, Length(Passwd)+1);
  788. GetMem(_Acct, Length(Acct)+1);
  789. GetMem(_Dir, Length(Dir)+1);
  790. StrPCopy(_Host, Host);
  791. StrPCopy(_UserId, UserId);
  792. StrPCopy(_Passwd, Passwd);
  793. StrPCopy(_Acct, Acct);
  794. StrPCopy(_Dir, Dir);
  795. FtpRmD:=FtpRmD(_Host, _Userid, _Passwd, _Acct, _Dir);
  796. FreeMem(_Host, Length(Host)+1);
  797. FreeMem(_UserId, Length(UserId)+1);
  798. FreeMem(_Passwd, Length(Passwd)+1);
  799. FreeMem(_Acct, Length(Acct)+1);
  800. FreeMem(_Dir, Length(Dir)+1);
  801. End;
  802. Function FtpRmD(Dir: String): Integer;
  803. Begin
  804. FtpRmD:=FtpRmD(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
  805. End;
  806. Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: PChar): Integer; cdecl;
  807. external FTPAPIDLL index 17;
  808. Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: String): Integer;
  809. Var
  810. _Host, _UserId, _Passwd, _Acct, _SiteStr: PChar;
  811. Begin
  812. GetMem(_Host, Length(Host)+1);
  813. GetMem(_UserId, Length(UserId)+1);
  814. GetMem(_Passwd, Length(Passwd)+1);
  815. GetMem(_Acct, Length(Acct)+1);
  816. GetMem(_SiteStr, Length(SiteStr)+1);
  817. StrPCopy(_Host, Host);
  818. StrPCopy(_UserId, UserId);
  819. StrPCopy(_Passwd, Passwd);
  820. StrPCopy(_Acct, Acct);
  821. StrPCopy(_SiteStr, SiteStr);
  822. FtpSite:=FtpSite(_Host, _Userid, _Passwd, _Acct, _SiteStr);
  823. FreeMem(_Host, Length(Host)+1);
  824. FreeMem(_UserId, Length(UserId)+1);
  825. FreeMem(_Passwd, Length(Passwd)+1);
  826. FreeMem(_Acct, Length(Acct)+1);
  827. FreeMem(_SiteStr, Length(SiteStr)+1);
  828. End;
  829. Function FtpSite(SiteStr: String): Integer;
  830. Begin
  831. FtpSite:=FtpSite(ShortHost, ShortUserid, ShortPasswd, ShortAcct, SiteStr);
  832. End;
  833. Function FtpSys(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
  834. external FTPAPIDLL index 18;
  835. Function FtpSys(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
  836. var
  837. _Buf: Array[0..255] of char;
  838. Begin
  839. Host:=Host+#0;
  840. UserId:=UserId+#0;
  841. Passwd:=Passwd+#0;
  842. Acct:=Acct+#0;
  843. FtpSys:=FtpSys(@Host[1], @UserId[1], @Passwd[1], @Acct[1], @_Buf, SizeOf(Buf));
  844. Buf:=StrPas(@_Buf);
  845. End;
  846. Function FtpSys(var Buf: String): Integer;
  847. Begin
  848. FtpSys:=FtpSys(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Buf);
  849. End;
  850. Function Ping(Addr: Longint; Len: Integer): Integer; cdecl;
  851. external FTPAPIDLL index 19;
  852. Function Ftp_ErrNo: Integer; cdecl;
  853. external FTPAPIDLL index 21;
  854. Function FtpVer(var Buf; BufLen: Integer): Integer; cdecl;
  855. external FTPAPIDLL index 23;
  856. Function FtpVer(var Buf: String): Integer;
  857. var
  858. T:array[0..255] of char;
  859. begin
  860. FtpVer:=FtpVer(T, SizeOf(T));
  861. Buf:=StrPas(T);
  862. end;
  863. Function FtpTrcOn(FileSpec: PChar; Mode: Integer): Integer; cdecl;
  864. external FTPAPIDLL index 24;
  865. Function FtpTrcOn(FileSpec: String; Mode: Integer): Integer; cdecl;
  866. Begin
  867. FileSpec:=FileSpec+#0;
  868. FtpTrcOn:=FtpTrcOn(@FileSpec[1], Mode);
  869. End;
  870. Function FtpTrcOff: Integer; cdecl;
  871. external FTPAPIDLL index 25;
  872. Function Keep_File_Date(LocalFile, RemoteFile: PChar): Boolean; cdecl;
  873. external FTPAPIDLL index 30;
  874. Function Keep_File_Date(LocalFile, RemoteFile: String): Boolean;
  875. Begin
  876. LocalFile:=LocalFile+#0;
  877. RemoteFile:=RemoteFile+#0;
  878. Keep_File_Date:=Keep_File_Date(@LocalFile[1], @RemoteFile[1]);
  879. End;
  880. Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType, Rest: Integer): Longint; cdecl;
  881. external FTPAPIDLL index 31;
  882. Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
  883. Var
  884. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: PChar;
  885. Begin
  886. GetMem(_Host, Length(Host)+1);
  887. GetMem(_UserId, Length(UserId)+1);
  888. GetMem(_Passwd, Length(Passwd)+1);
  889. GetMem(_Acct, Length(Acct)+1);
  890. GetMem(_Local, Length(Local)+1);
  891. GetMem(_Remote, Length(Remote)+1);
  892. GetMem(_Mode, Length(Mode)+1);
  893. StrPCopy(_Host, Host);
  894. StrPCopy(_UserId, UserId);
  895. StrPCopy(_Passwd, Passwd);
  896. StrPCopy(_Acct, Acct);
  897. StrPCopy(_Local, Local);
  898. StrPCopy(_Remote, Remote);
  899. StrPCopy(_Mode, Mode);
  900. FtpReStart:=FtpReStart(_Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode, TransferType, Rest);
  901. FreeMem(_Host, Length(Host)+1);
  902. FreeMem(_UserId, Length(UserId)+1);
  903. FreeMem(_Passwd, Length(Passwd)+1);
  904. FreeMem(_Acct, Length(Acct)+1);
  905. FreeMem(_Local, Length(Local)+1);
  906. FreeMem(_Remote, Length(Remote)+1);
  907. FreeMem(_Mode, Length(Mode)+1);
  908. End;
  909. Function FtpReStart(Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
  910. Begin
  911. FtpReStart:=FtpReStart(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, TransferType, Rest);
  912. End;
  913. Function FtpReStart(Local, Remote, Mode: String; Rest: Integer): Longint;
  914. Begin
  915. FtpReStart:=FtpReStart(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, ShortTransferType, Rest);
  916. End;
  917. Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: Pchar; TransferType: Integer): Longint; cdecl;
  918. external FTPAPIDLL index 32;
  919. Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: Integer): Longint;
  920. Begin
  921. Host:=Host+#0;
  922. UserId:=UserId+#0;
  923. Passwd:=Passwd+#0;
  924. Acct:=Acct+#0;
  925. Local:=Local+#0;
  926. Remote:=Remote+#0;
  927. Mode:=Mode+#0;
  928. FtpRemSize:=FtpRemSize(@Host[1], @UserId[1], @Passwd[1], @Acct[1], @Local[1], @Remote[1], @Mode[1], TransferType);
  929. End;
  930. Function FtpRemSize(Local, Remote, Mode: String; TransferType: Integer): Longint;
  931. Begin
  932. FtpRemSize:=FtpRemSize(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, TransferType);
  933. End;
  934. Function FtpRemSize(Local, Remote, Mode: String): Longint;
  935. Begin
  936. FtpRemSize:=FtpRemSize(Local, Remote, Mode, ShortTransferType);
  937. End;
  938. Function FtpSetUser(Host, UserId, Passwd, Acct: String): Integer;
  939. Begin
  940. ShortHost:=Host;
  941. ShortUserId:=UserId;
  942. ShortPasswd:=Passwd;
  943. ShortAcct:=Acct;
  944. FtpSetUser:=0;
  945. If (Host='') or (UserId='') then FtpSetUser:=-1;
  946. End;
  947. Function FtpSetBinary(TransferType: Integer): Integer;
  948. Begin
  949. ShortTransferType:=TransferType;
  950. FtpSetBinary:=0;
  951. End;
  952. (* Undocumented functions follow
  953. Function FtpXLate(Dig: Longint; St:PChar): Longint; cdecl;
  954. external FTPAPIDLL index 22;
  955. Procedure FtpXferWnd(var _hwnd: HWND); cdecl; external FTPAPIDLL index 26;
  956. Procedure FtpSetConvertMode(var code: integer); cdecl;
  957. external FTPAPIDLL index 27;
  958. Procedure FtpSetEncodeMode(var code: integer); cdecl;
  959. external FTPAPIDLL index 28;
  960. Procedure FtpSetDecodeMode(var code: integer); cdecl;
  961. external FTPAPIDLL index 29;
  962. Absolutely no information about following functions:
  963. var FtpErrNo: integer; cdecl; external FTPAPIDLL index 20; // seems to be a copy of ftp_errno
  964. //³ 00033 ³ FTPQUOTEREPLY // Seems to be direct command send (reply to ftpquote)
  965. //³ 00034 ³ FtpSetActiveMode
  966. *)
  967. End.
  968. {
  969. $Log$
  970. Revision 1.3 2004-11-28 16:16:25 hajny
  971. * workaround for IE200411171
  972. Revision 1.2 2002/10/25 06:53:51 hajny
  973. * ftpapi corrections
  974. Revision 1.1 2002/10/21 21:43:08 hajny
  975. + ftpapi interface unit added
  976. }