ftpapi.pas 39 KB

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