/packages/os2units/src/ftpapi.pas

https://github.com/slibre/freepascal · Pascal · 1181 lines · 815 code · 192 blank · 174 comment · 0 complexity · 24668ab954839f9be0580d6a393d1a94 MD5 · raw file

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