ftpapi.pas 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  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: String): Integer;
  414. Var
  415. _Host, _UserId, _Passwd, _Acct, _Local, _Pattern: PChar;
  416. Begin
  417. GetMem(_Host, Length(Host)+1);
  418. GetMem(_UserId, Length(UserId)+1);
  419. GetMem(_Passwd, Length(Passwd)+1);
  420. GetMem(_Acct, Length(Acct)+1);
  421. GetMem(_Local, Length(Local)+1);
  422. GetMem(_Pattern, Length(Pattern)+1);
  423. StrPCopy(_Host, Host);
  424. StrPCopy(_UserId, UserId);
  425. StrPCopy(_Passwd, Passwd);
  426. StrPCopy(_Acct, Acct);
  427. StrPCopy(_Local, Local);
  428. StrPCopy(_Pattern, Pattern);
  429. FtpLs:=FtpLs(_Host, _Userid, _Passwd, _Acct, _Local, _Pattern);
  430. FreeMem(_Host, Length(Host)+1);
  431. FreeMem(_UserId, Length(UserId)+1);
  432. FreeMem(_Passwd, Length(Passwd)+1);
  433. FreeMem(_Acct, Length(Acct)+1);
  434. FreeMem(_Local, Length(Local)+1);
  435. FreeMem(_Pattern, Length(Pattern)+1);
  436. End;
  437. Function FtpLs(Local, Pattern: String): Integer;
  438. Begin
  439. FtpLs:=FtpLs(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Pattern);
  440. End;
  441. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType: integer): Integer; cdecl;
  442. external FTPAPIDLL index 5;
  443. Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: integer): Integer;
  444. Var
  445. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  446. Begin
  447. StrPCopy(@_Host, Host);
  448. StrPCopy(@_UserId, UserId);
  449. StrPCopy(@_Passwd, Passwd);
  450. StrPCopy(@_Acct, Acct);
  451. StrPCopy(@_Local, Local);
  452. StrPCopy(@_Remote, Remote);
  453. StrPCopy(@_Mode, Mode);
  454. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
  455. End;
  456. Function FtpGet(Local, Remote, Mode: PChar; TransferType: integer): Integer;
  457. Var
  458. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  459. Begin
  460. StrPCopy(@_Host, ShortHost);
  461. StrPCopy(@_UserId, ShortUserId);
  462. StrPCopy(@_Passwd, ShortPasswd);
  463. StrPCopy(@_Acct, ShortAcct);
  464. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, TransferType);
  465. End;
  466. Function FtpGet(Local, Remote, Mode: String; TransferType: integer): Integer;
  467. Var
  468. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  469. Begin
  470. StrPCopy(@_Host, ShortHost);
  471. StrPCopy(@_UserId, ShortUserId);
  472. StrPCopy(@_Passwd, ShortPasswd);
  473. StrPCopy(@_Acct, ShortAcct);
  474. StrPCopy(@_Local, Local);
  475. StrPCopy(@_Remote, Remote);
  476. StrPCopy(@_Mode, Mode);
  477. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
  478. End;
  479. Function FtpGet(Local, Remote, Mode: PChar): Integer;
  480. Var
  481. _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
  482. Begin
  483. StrPCopy(@_Host, ShortHost);
  484. StrPCopy(@_UserId, ShortUserId);
  485. StrPCopy(@_Passwd, ShortPasswd);
  486. StrPCopy(@_Acct, ShortAcct);
  487. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, ShortTransferType);
  488. End;
  489. Function FtpGet(Local, Remote, Mode: String): Integer;
  490. Var
  491. _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
  492. Begin
  493. StrPCopy(@_Host, ShortHost);
  494. StrPCopy(@_UserId, ShortUserId);
  495. StrPCopy(@_Passwd, ShortPasswd);
  496. StrPCopy(@_Acct, ShortAcct);
  497. StrPCopy(@_Local, Local);
  498. StrPCopy(@_Remote, Remote);
  499. StrPCopy(@_Mode, Mode);
  500. FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, ShortTransferType);
  501. End;
  502. Procedure FtpLogoff; cdecl;
  503. external FTPAPIDLL index 6;
  504. Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
  505. external FTPAPIDLL index 7;
  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.2 2002-10-25 06:53:51 hajny
  971. * ftpapi corrections
  972. Revision 1.1 2002/10/21 21:43:08 hajny
  973. + ftpapi interface unit added
  974. }