summaryrefslogtreecommitdiff
path: root/packages/os2units/src/ftpapi.pas
blob: ee46e8581a6f5efb376f0aef385a3e67ef62d89d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
{
    Copyright (c) 2002 by Yuri Prokushev (prokushev@freemail.ru).

    Functions from FTPAPI.DLL (part of standard OS/2 Warp 4/eCS installation).

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License (LGPL) as
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version. This program is
    distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.

    See the GNU Library General Public License for more details. You should
    have received a copy of the GNU Library General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

 **********************************************************************}

{
@abstract(a unit to handle FTP)
@author(Yuri Prokushev (prokushev@freemail.ru))
@created(22 Jul 2002)
@lastmod(01 Oct 2002)
This is functions from FTPAPI.DLL. Goal is ftp manipulation.
Warning: This code is alfa. Future versions of this unit will propably
not be compatible.
@todo(Rework some functions to support strings longer then 255 chars)
@todo(Finish functions description)
}
unit FTPAPI;

{****************************************************************************

                             RTL configuration

****************************************************************************}


interface

uses
  OS2Def,
  PMWin,
  Strings;

Const
  // window message id for post xfer updates
  WM_FTPAPI_XFER_UPDATE = WM_USER + 1000;

  // Transfer types is ASCII
  T_ASCII  = 1;
  // Transfer types is EBCDIC
  T_EBCDIC = 2;
  // Transfer types is BINARY
  T_BINARY = 3;

  // command/reply trace file modes
  M_OVERLAY = 1;
  M_APPEND  = 2;

  // command/reply tracing error codes

  // invalid trace file open mode
  TRCMODE = 1;
  // unable to open trace file
  TRCOPEN = 2;

  // Common error codes (try Ftp_ErrNo, all other functions returns usually
  // 0 if all ok, -1 if all bad)

  // No any error
  FTPNOERROR    = 00;
  // Unknown service.
  FTPSERVICE    = 01;
  // Unknown host.
  FTPHOST       = 02;
  // Unable to obtain socket.
  FTPSOCKET     = 03;
  // Unable to connect to server.
  FTPCONNECT    = 04;
  // Login failed.
  FTPLOGIN      = 05;
  // Transfer aborted.
  FTPABORT      = 06;
  // Problem opening the local file.
  FTPLOCALFILE  = 07;
  // Problem initializing data connection.
  FTPDATACONN   = 08;
  // Command failed.
  FTPCOMMAND    = 09;
  // Proxy server does not support third party transfers.
  FTPPROXYTHIRD = 10;
  // No primary connection for proxy transfer.
  FTPNOPRIMARY  = 11;
  // No code page translation table was loaded
  FTPNOXLATETBL = 12;

  // ping error codes

  // All ok
  PINGOK        = 0;
  // Host does not reply
  PINGREPLY     = -1;
  // Unable to obtain socket
  PINGSOCKET    = -3;
  // Unknown protocol ICMP
  PINGPROTO     = -4;
  // Send failed
  PINGSEND      = -5;
  // Recv() failed
  PINGRECV      = -6;
  // Unknown host (can't resolve)
  PINGHOST      = -7;

  // Restart Specific
  REST_GET = 1;
  REST_PUT = 2;

Const
  // Short functions vars
  ShortHost: String='';
  ShortUserId: String='';
  ShortPasswd: String='';
  ShortAcct: String='';
  ShortTransferType: Integer = T_ASCII;


{****************************************************************************

                          Opening and Closing Functions

****************************************************************************}

// Defines Host, UserId, Passwd and Acct for short function calls
Function FtpSetUser(Host, UserId, Passwd, Acct: String): Integer;

// Defines TransferType for short function calls
Function FtpSetBinary(TransferType: Integer): Integer;

// Stores the string containing the FTP API version
//   Buf is the buffer to store version string
//   BufLen is length of the buffer
// Version string is null-terminated and truncated to buffer length
Function FtpVer(var Buf; BufLen: Integer): Integer; cdecl;

Function FtpVer(Var Buf: String): Integer;

// Closes all current connections
Procedure FtpLogoff; cdecl;

{****************************************************************************

                       File Action Functions

****************************************************************************}

// Appends information to a remote file
//   Host is hostname. Use 'hostname portnumber' to specify non-standard port
//   UserID is user ID
//   Passwd is password
//   Acct is account (can be nil)
//   Local is local filename
//   Remote is Remote filename
//   TransferType is type of transfer (T_* constants)
Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: PChar;
                   Transfertype: Integer): Integer; cdecl;

Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: String;
                   Transfertype: Integer): Integer;

Function FTPAppend(Local, Remote: PChar; Transfertype: Integer): Integer;
Function FTPAppend(Local, Remote: String; Transfertype: Integer): Integer;

Function FTPAppend(Local, Remote: PChar): Integer;
Function FTPAppend(Local, Remote: String): Integer;

// Deletes files on a remote host
Function FtpDelete(Host, UserId, Passwd, Acct, Name: PChar): Integer; cdecl;

Function FtpDelete(Host, UserId, Passwd, Acct, Name: String): Integer;

Function FtpDelete(Name: PChar): Integer;
Function FtpDelete(Name: String): Integer;

// Renames a file on a remote host
Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: PChar): Integer; cdecl;

Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: String): Integer;

Function FtpRename(NameFrom, NameTo: PChar): Integer;
Function FtpRename(NameFrom, NameTo: String): Integer;

// Gets a file from an FTP server
// Mode is either 'w' for re_w_rite, or 'a' for _a_ppend
Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType: integer): Integer; cdecl;

Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: integer): Integer;

Function FtpGet(Local, Remote, Mode: PChar; TransferType: integer): Integer;
Function FtpGet(Local, Remote, Mode: String; TransferType: integer): Integer;

Function FtpGet(Local, Remote, Mode: PChar): Integer;
Function FtpGet(Local, Remote, Mode: String): Integer;

// Transfers a file to an FTP server
Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;

Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;

Function FtpPut(Local, Remote: PChar; TransferType: Integer): Integer;
Function FtpPut(Local, Remote: String; TransferType: Integer): Integer;

Function FtpPut(Local, Remote: PChar): Integer;
Function FtpPut(Local, Remote: String): Integer;

// Transfers a file to a host and ensures it is created with a unique name
Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;

Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;

Function FtpPutUnique(Local, Remote: PChar; TransferType: Integer): Integer;
Function FtpPutUnique(Local, Remote: String; TransferType: Integer): Integer;

Function FtpPutUnique(Local, Remote: PChar): Integer;
Function FtpPutUnique(Local, Remote: String): Integer;

// Restarts an aborted transaction from the point of interruption
Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType, Rest: Integer): Longint; cdecl;

Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;

Function FtpReStart(Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
Function FtpReStart(Local, Remote, Mode: String; Rest: Integer): Longint;


{****************************************************************************

                          Directory Listing Functions

****************************************************************************}

// Gets directory information in short format from a remote host and stores it to a local file
// You can use named pipes here to avoid a need for creating a real file
Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;

Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;

Function FtpLs(Local, Pattern: String): Integer;

// Gets a directory in wide format from a host and stores it in file Local
// See comment regarding named pipes above
Function FtpDir(Host, UserId, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;

Function FtpDir(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;

Function FtpDir(Local, Pattern: String): Integer;


{****************************************************************************

                          Directory Action Functions

****************************************************************************}

// Changes the current working directory on a host
Function FtpCd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;

Function FtpCd(Host, Userid, Passwd, Acct, Dir: String): Integer;

Function FtpCd(Dir: String): Integer;

// Creates a new directory on a target machine
Function FtpMkd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;

Function FtpMkd(Host, Userid, Passwd, Acct, Dir: String): Integer;

Function FtpMkd(Dir: String): Integer;

// Removes a directory on a target machine
Function FtpRmd(Host, UserId, Passwd, Acct, Dir: PChar): Integer; cdecl;

Function FtpRmd(Host, UserId, Passwd, Acct, Dir: String): Integer;

Function FtpRmd(Dir: String): Integer;

// Stores the string containing the FTP server description of the current
// working directory on the host to the buffer
Function FtpPwd(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;

Function FtpPwd(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;

Function FtpPwd(var Buf: String): Integer;

{****************************************************************************

                             Remote Server Functions

****************************************************************************}

// Sends a string to the server verbatim
Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: PChar): Integer; cdecl;

Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: String): Integer;

Function FtpQuote(QuoteStr: String): Integer;

// Executes the site command
Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: PChar): Integer; cdecl;

Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: String): Integer;

Function FtpSite(SiteStr: String): Integer;

// Stores the string containing the FTP server description of the operating
// system running on the host in a buffer
Function FtpSys(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;

Function FtpSys(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;

Function FtpSys(var Buf: String): Integer;


// Transfers a file between two remote servers without sending the file to
// the local host
Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: PChar; TransferType: Integer): Integer; cdecl;

Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: String; TransferType: Integer): Integer;

Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: String): Integer;

// Resolves a host name and sends a ping to the remote host to determine if the host is responding
Function FtpPing(Host: PChar; Len: Integer; var Addr: Longint): Integer; cdecl;

Function FtpPing(Host: String; Len: Integer; var Addr: Longint): Integer;

// Sends a ping to the remote host to determine if the host is responding
Function Ping(Addr: Longint; Len: Integer): Integer; cdecl;

// Returns the size of a file on the remote host
Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: Pchar; TransferType: Integer): Longint; cdecl;

Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: Integer): Longint;

Function FtpRemSize(Local, Remote, Mode: String; TransferType: Integer): Longint;

Function FtpRemSize(Local, Remote, Mode: String): Longint;

// Maintain the original date/time of files received.
Function Keep_File_Date(LocalFile, RemoteFile: PChar): Boolean; cdecl;

Function Keep_File_Date(LocalFile, RemoteFile: String): Boolean;

{****************************************************************************

                                  Trace Functions

****************************************************************************}


// Opens the trace file specified and starts tracing
Function FtpTrcOn(FileSpec: PChar; Mode: Integer): Integer; cdecl;

Function FtpTrcOn(FileSpec: String; Mode: Integer): Integer; cdecl;

// Closes the trace file, and stops tracing of the command and reply sequences that
// were sent over the control connection between the local and remote hosts
Function FtpTrcOff: Integer; cdecl;

{****************************************************************************

                                  Other Functions

****************************************************************************}

// FTP error No
Function Ftp_ErrNo: Integer; cdecl;


(* Undocumented / unimplemented functions:
Function FtpXLate(Dig: Longint; St:PChar): Longint; cdecl;
Procedure FtpXferWnd(var _hwnd: HWND); cdecl;
Procedure FtpSetConvertMode(var code: integer); cdecl;
Procedure FtpSetEncodeMode(var code: integer); cdecl;
Procedure FtpSetDecodeMode(var code: integer); cdecl;
Function FtpSetActiveMode(var UseActiveOnly: integer): integer; cdecl;
*)

implementation

const
  FTPAPIDLL = 'FTPAPI';

Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: PChar;
                   Transfertype: Integer): Integer; cdecl;
    external FTPAPIDLL index 1;

Function FTPAppend(Host, UserId, Passwd, Acct, Local, Remote: String;
                   Transfertype: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpAppend:=FtpAppend(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
End;

Function FTPAppend(Local, Remote: PChar; TransferType: Integer): Integer;
Var
  Host, UserId, Passwd, Acct: Array[0..255] of Char;
Begin
  StrPCopy(@Host, ShortHost);
  StrPCopy(@UserId, ShortUserId);
  StrPCopy(@Passwd, ShortPasswd);
  StrPCopy(@Acct, ShortAcct);
  FtpAppend:=FtpAppend(@Host, @UserId, @Passwd, @Acct, Local, Remote, TransferType);
End;

Function FTPAppend(Local, Remote: PChar): Integer;
Begin
  FtpAppend:=FtpAppend(Local, Remote, ShortTransferType);
End;

Function FTPAppend(Local, Remote: String; TransferType: Integer): Integer;
Var
  _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpAppend:=FtpAppend(@_Local, @_Remote, TransferType);
End;

Function FTPAppend(Local, Remote: String): Integer;
Var
  _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpAppend:=FtpAppend(@_Local, @_Remote);
End;

Function FtpCd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
    external FTPAPIDLL index 2;

Function FtpCd(Host, Userid, Passwd, Acct, Dir: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Dir, Length(Dir)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Dir, Dir);
  FtpCd:=FtpCd(_Host, _Userid, _Passwd, _Acct, _Dir);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Dir, Length(Dir)+1);
End;

Function FtpCd(Dir: String): Integer;
Begin
  FtpCd:=FtpCd(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
End;

Function FtpDelete(Host, UserId, Passwd, Acct, Name: PChar): Integer; cdecl;
    external FTPAPIDLL index 3;

Function FtpDelete(Host, UserId, Passwd, Acct, Name: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Name: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_Name, Name);
  FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, @_Name);
End;

Function FtpDelete(Name: PChar): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, Name);
End;

Function FtpDelete(Name: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Name: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Name, Name);
  FtpDelete:=FtpDelete(@_Host, @_UserId, @_Passwd, @_Acct, @_Name);
End;

Function FtpDir(Host, UserId, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
    external FTPAPIDLL index 4;

Function FtpDir(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Pattern: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Local, Length(Local)+1);
  GetMem(_Pattern, Length(Pattern)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Local, Local);
  StrPCopy(_Pattern, Pattern);
  FtpDir:=FtpDir(_Host, _Userid, _Passwd, _Acct, _Local, _Pattern);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Local, Length(Local)+1);
  FreeMem(_Pattern, Length(Pattern)+1);
End;

Function FtpDir(Local, Pattern: String): Integer;
Begin
  FtpDir:=FtpDir(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Pattern);
End;

Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: PChar): Integer; cdecl;
    external FTPAPIDLL index 7;

Function FtpLs(Host, Userid, Passwd, Acct, Local, Pattern: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Pattern: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Local, Length(Local)+1);
  GetMem(_Pattern, Length(Pattern)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Local, Local);
  StrPCopy(_Pattern, Pattern);
  FtpLs:=FtpLs(_Host, _Userid, _Passwd, _Acct, _Local, _Pattern);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Local, Length(Local)+1);
  FreeMem(_Pattern, Length(Pattern)+1);
End;

Function FtpLs(Local, Pattern: String): Integer;
Begin
  FtpLs:=FtpLs(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Pattern);
End;

Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType: integer): Integer; cdecl;
    external FTPAPIDLL index 5;

Function FtpGet(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  StrPCopy(@_Mode, Mode);
  FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
End;

Function FtpGet(Local, Remote, Mode: PChar; TransferType: integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, TransferType);
End;

Function FtpGet(Local, Remote, Mode: String; TransferType: integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  StrPCopy(@_Mode, Mode);
  FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, TransferType);
End;

Function FtpGet(Local, Remote, Mode: PChar): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, Mode, ShortTransferType);
End;

Function FtpGet(Local, Remote, Mode: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  StrPCopy(@_Mode, Mode);
  FtpGet:=FtpGet(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, @_Mode, ShortTransferType);
End;

Procedure FtpLogoff; cdecl;
    external FTPAPIDLL index 6;

Function FtpMkd(Host, Userid, Passwd, Acct, Dir: PChar): Integer; cdecl;
    external FTPAPIDLL index 8;

Function FtpMkD(Host, Userid, Passwd, Acct, Dir: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Dir, Length(Dir)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Dir, Dir);
  FtpMkD:=FtpMkD(_Host, _Userid, _Passwd, _Acct, _Dir);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Dir, Length(Dir)+1);
End;

Function FtpMkD(Dir: String): Integer;
Begin
  FtpMkD:=FtpMkD(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
End;

Function FtpPing(Host: PChar; Len: Integer; var Addr: Longint): Integer; cdecl;
    external FTPAPIDLL index 9;

Function FtpPing(Host: String; Len: Integer; var Addr: Longint): Integer;
var
  _Host: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  StrPCopy(_Host, Host);
  FtpPing:=FtpPing(_Host, Len, Addr);
  FreeMem(_Host, Length(Host)+1);
End;

Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: PChar; TransferType: Integer): Integer; cdecl;
    external FTPAPIDLL index 10;

Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: String; TransferType: Integer): Integer;
Begin
  Host1:=Host2+#0;
  Host2:=Host2+#0;
  UserId1:=UserId1+#0;
  UserId2:=UserId2+#0;
  Passwd1:=Passwd1+#0;
  Passwd2:=Passwd2+#0;
  Acct1:=Acct1+#0;
  Acct2:=Acct2+#0;
  FN1:=FN1+#0;
  FN2:=FN2+#0;
  FtpProxy:=FtpProxy(@Host1[1], @UserId1[1], @Passwd1[1], @Acct1[1],
                  @Host2[1], @UserId2[1], @Passwd2[1], @Acct2[1],
                  @FN1[1], @FN2[1], TransferType);
End;

Function FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2: String): Integer;
Begin
  FtpProxy:=FtpProxy(Host1, UserId1, Passwd1, Acct1,
                  Host2, UserId2, Passwd2, Acct2,
                  FN1, FN2, ShortTransferType);
End;

Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
    external FTPAPIDLL index 11;

Function FtpPut(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
End;

Function FtpPut(Local, Remote: PChar; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, TransferType);
End;

Function FtpPut(Local, Remote: String; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
End;

Function FtpPut(Local, Remote: PChar): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, ShortTransferType);
End;

Function FtpPut(Local, Remote: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPut:=FtpPut(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, ShortTransferType);
End;

Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: PChar; TransferType: Integer): Integer; cdecl;
    external FTPAPIDLL index 12;

Function FtpPutUnique(Host, UserId, Passwd, Acct, Local, Remote: String; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
End;

Function FtpPutUnique(Local, Remote: PChar; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, TransferType);
End;

Function FtpPutUnique(Local, Remote: String; TransferType: Integer): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, TransferType);
End;

Function FtpPutUnique(Local, Remote: PChar): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, Local, Remote, ShortTransferType);
End;

Function FtpPutUnique(Local, Remote: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_Local, Local);
  StrPCopy(@_Remote, Remote);
  FtpPutUnique:=FtpPutUnique(@_Host, @_UserId, @_Passwd, @_Acct, @_Local, @_Remote, ShortTransferType);
End;

Function FtpPwd(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
    external FTPAPIDLL index 13;

Function FtpPwd(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: PChar;
  _Buf: Array[0..255] of Char;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  FtpPwd:=FtpPwd(_Host, _UserId, _Passwd, _Acct, @_Buf, SizeOf(_Buf));
  Buf:=StrPas(@_Buf);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
End;

Function FtpPwd(var Buf: String): Integer;
Begin
  FtpPwd:=FtpPwd(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Buf);
End;


Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: PChar): Integer; cdecl;
    external FTPAPIDLL index 14;

Function FtpQuote(Host, UserId, Passwd, Acct, QuoteStr: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _QuoteStr: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_QuoteStr, Length(QuoteStr)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_QuoteStr, QuoteStr);
  FtpQuote:=FtpQuote(_Host, _UserId, _Passwd, _Acct, _QuoteStr);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_QuoteStr, Length(QuoteStr)+1);
End;

Function FtpQuote(QuoteStr: String): Integer;
Begin
  FtpQuote:=FtpQuote(ShortHost, ShortUserId, ShortPasswd, ShortAcct, QuoteStr);
End;

Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: PChar): Integer; cdecl;
    external FTPAPIDLL index 15;

Function FtpRename(Host, UserId, Passwd, Acct, NameFrom, NameTo: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _NameFrom, _NameTo: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, Host);
  StrPCopy(@_UserId, UserId);
  StrPCopy(@_Passwd, Passwd);
  StrPCopy(@_Acct, Acct);
  StrPCopy(@_NameTo, NameTo);
  StrPCopy(@_NameFrom, NameFrom);
  FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, @_NameFrom, @_NameTo);
End;

Function FtpRename(NameFrom, NameTo: PChar): Integer;
Var
  _Host, _UserId, _Passwd, _Acct: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, NameFrom, NameTo);
End;

Function FtpRename(NameFrom, NameTo: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _NameFrom, _NameTo: Array[0..255] of Char;
Begin
  StrPCopy(@_Host, ShortHost);
  StrPCopy(@_UserId, ShortUserId);
  StrPCopy(@_Passwd, ShortPasswd);
  StrPCopy(@_Acct, ShortAcct);
  StrPCopy(@_NameTo, NameTo);
  StrPCopy(@_NameFrom, NameFrom);
  FtpRename:=FtpRename(@_Host, @_UserId, @_Passwd, @_Acct, @_NameFrom, @_NameTo);
End;

Function FtpRmd(Host, UserId, Passwd, Acct, Dir: PChar): Integer; cdecl;
    external FTPAPIDLL index 16;

Function FtpRmD(Host, Userid, Passwd, Acct, Dir: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _Dir: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Dir, Length(Dir)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Dir, Dir);
  FtpRmD:=FtpRmD(_Host, _Userid, _Passwd, _Acct, _Dir);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Dir, Length(Dir)+1);
End;

Function FtpRmD(Dir: String): Integer;
Begin
  FtpRmD:=FtpRmD(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Dir);
End;

Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: PChar): Integer; cdecl;
    external FTPAPIDLL index 17;

Function FtpSite(Host, UserId, Passwd, Acct, SiteStr: String): Integer;
Var
  _Host, _UserId, _Passwd, _Acct, _SiteStr: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_SiteStr, Length(SiteStr)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_SiteStr, SiteStr);
  FtpSite:=FtpSite(_Host, _Userid, _Passwd, _Acct, _SiteStr);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_SiteStr, Length(SiteStr)+1);
End;

Function FtpSite(SiteStr: String): Integer;
Begin
  FtpSite:=FtpSite(ShortHost, ShortUserid, ShortPasswd, ShortAcct, SiteStr);
End;

Function FtpSys(Host, UserId, Passwd, Acct, Buf: PChar; BufLen: Integer): Integer; cdecl;
    external FTPAPIDLL index 18;

Function FtpSys(Host, UserId, Passwd, Acct: String; var Buf: String): Integer;
var
  _Buf: Array[0..255] of char;
Begin
  Host:=Host+#0;
  UserId:=UserId+#0;
  Passwd:=Passwd+#0;
  Acct:=Acct+#0;
  FtpSys:=FtpSys(@Host[1], @UserId[1], @Passwd[1], @Acct[1], @_Buf, SizeOf(Buf));
  Buf:=StrPas(@_Buf);
End;

Function FtpSys(var Buf: String): Integer;
Begin
  FtpSys:=FtpSys(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Buf);
End;

Function Ping(Addr: Longint; Len: Integer): Integer; cdecl;
    external FTPAPIDLL index 19;

Function Ftp_ErrNo: Integer; cdecl;
    external FTPAPIDLL index 21;

Function FtpVer(var Buf; BufLen: Integer): Integer; cdecl;
    external FTPAPIDLL index 23;

Function FtpVer(var Buf: String): Integer;
var
  T:array[0..255] of char;
begin
  FtpVer:=FtpVer(T, SizeOf(T));
  Buf:=StrPas(T);
end;

Function FtpTrcOn(FileSpec: PChar; Mode: Integer): Integer; cdecl;
    external FTPAPIDLL index 24;

Function FtpTrcOn(FileSpec: String; Mode: Integer): Integer; cdecl;
Begin
  FileSpec:=FileSpec+#0;
  FtpTrcOn:=FtpTrcOn(@FileSpec[1], Mode);
End;

Function FtpTrcOff: Integer; cdecl;
    external FTPAPIDLL index 25;

Function Keep_File_Date(LocalFile, RemoteFile: PChar): Boolean; cdecl;
    external FTPAPIDLL index 30;

Function Keep_File_Date(LocalFile, RemoteFile: String): Boolean;
Begin
  LocalFile:=LocalFile+#0;
  RemoteFile:=RemoteFile+#0;
  Keep_File_Date:=Keep_File_Date(@LocalFile[1], @RemoteFile[1]);
End;

Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: PChar; TransferType, Rest: Integer): Longint; cdecl;
    external FTPAPIDLL index 31;

Function FtpReStart(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
Var
  _Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode: PChar;
Begin
  GetMem(_Host, Length(Host)+1);
  GetMem(_UserId, Length(UserId)+1);
  GetMem(_Passwd, Length(Passwd)+1);
  GetMem(_Acct, Length(Acct)+1);
  GetMem(_Local, Length(Local)+1);
  GetMem(_Remote, Length(Remote)+1);
  GetMem(_Mode, Length(Mode)+1);
  StrPCopy(_Host, Host);
  StrPCopy(_UserId, UserId);
  StrPCopy(_Passwd, Passwd);
  StrPCopy(_Acct, Acct);
  StrPCopy(_Local, Local);
  StrPCopy(_Remote, Remote);
  StrPCopy(_Mode, Mode);
  FtpReStart:=FtpReStart(_Host, _UserId, _Passwd, _Acct, _Local, _Remote, _Mode, TransferType, Rest);
  FreeMem(_Host, Length(Host)+1);
  FreeMem(_UserId, Length(UserId)+1);
  FreeMem(_Passwd, Length(Passwd)+1);
  FreeMem(_Acct, Length(Acct)+1);
  FreeMem(_Local, Length(Local)+1);
  FreeMem(_Remote, Length(Remote)+1);
  FreeMem(_Mode, Length(Mode)+1);
End;

Function FtpReStart(Local, Remote, Mode: String; TransferType, Rest: Integer): Longint;
Begin
  FtpReStart:=FtpReStart(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, TransferType, Rest);
End;

Function FtpReStart(Local, Remote, Mode: String; Rest: Integer): Longint;
Begin
  FtpReStart:=FtpReStart(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, ShortTransferType, Rest);
End;

Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: Pchar; TransferType: Integer): Longint; cdecl;
    external FTPAPIDLL index 32;

Function FtpRemSize(Host, UserId, Passwd, Acct, Local, Remote, Mode: String; TransferType: Integer): Longint;
Begin
  Host:=Host+#0;
  UserId:=UserId+#0;
  Passwd:=Passwd+#0;
  Acct:=Acct+#0;
  Local:=Local+#0;
  Remote:=Remote+#0;
  Mode:=Mode+#0;
  FtpRemSize:=FtpRemSize(@Host[1], @UserId[1], @Passwd[1], @Acct[1], @Local[1], @Remote[1], @Mode[1], TransferType);
End;

Function FtpRemSize(Local, Remote, Mode: String; TransferType: Integer): Longint;
Begin
  FtpRemSize:=FtpRemSize(ShortHost, ShortUserId, ShortPasswd, ShortAcct, Local, Remote, Mode, TransferType);
End;

Function FtpRemSize(Local, Remote, Mode: String): Longint;
Begin
  FtpRemSize:=FtpRemSize(Local, Remote, Mode, ShortTransferType);
End;

Function FtpSetUser(Host, UserId, Passwd, Acct: String): Integer;
Begin
  ShortHost:=Host;
  ShortUserId:=UserId;
  ShortPasswd:=Passwd;
  ShortAcct:=Acct;
  FtpSetUser:=0;
  If (Host='') or (UserId='') then FtpSetUser:=-1;
End;

Function FtpSetBinary(TransferType: Integer): Integer;
Begin
  ShortTransferType:=TransferType;
  FtpSetBinary:=0;
End;

(* Undocumented functions follow
Function FtpXLate(Dig: Longint; St:PChar): Longint; cdecl;
                                                   external FTPAPIDLL index 22;
Procedure FtpXferWnd(var _hwnd: HWND); cdecl; external FTPAPIDLL index 26;
Procedure FtpSetConvertMode(var code: integer); cdecl;
                                                   external FTPAPIDLL index 27;
Procedure FtpSetEncodeMode(var code: integer); cdecl;
                                                   external FTPAPIDLL index 28;
Procedure FtpSetDecodeMode(var code: integer); cdecl;
                                                   external FTPAPIDLL index 29;

Absolutely no information about following functions:

var FtpErrNo: integer; cdecl; external FTPAPIDLL index 20; // seems to be a copy of ftp_errno
//³ 00033 ³ FTPQUOTEREPLY     // Seems to be direct command send (reply to ftpquote)
//³ 00034 ³ FtpSetActiveMode

*)

End.