Fixed incorrect usage of result (now object rather than scalar), thanks Michal Zygmun...
[pwlib.git] / src / ptclib / ftp.cxx
blobf355fa58930ddace692d1acdb2724e3be7e1ec56
1 /*
2 * ftp.cxx
4 * FTP ancestor class.
6 * Portable Windows Library
8 * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
26 * $Log$
27 * Revision 1.14 2002/11/06 22:47:24 robertj
28 * Fixed header comment (copyright etc)
30 * Revision 1.13 1998/11/30 04:50:46 robertj
31 * New directory structure
33 * Revision 1.12 1998/09/23 06:21:59 robertj
34 * Added open source copyright license.
36 * Revision 1.11 1998/01/26 05:20:30 robertj
37 * GNU Support.
39 * Revision 1.10 1997/07/14 11:47:09 robertj
40 * Added "const" to numerous variables.
42 * Revision 1.9 1996/09/14 13:09:26 robertj
43 * Major upgrade:
44 * rearranged sockets to help support IPX.
45 * added indirect channel class and moved all protocols to descend from it,
46 * separating the protocol from the low level byte transport.
48 * Revision 1.8 1996/05/30 10:04:46 robertj
49 * Fixed bug in breaking accept within FTP constructor returning wrong error code.
51 * Revision 1.7 1996/05/26 03:46:36 robertj
52 * Compatibility to GNU 2.7.x
54 * Revision 1.6 1996/05/23 09:56:27 robertj
55 * Changed FTP so can do passive/active mode on all data transfers.
57 * Revision 1.5 1996/03/31 09:01:20 robertj
58 * More FTP client implementation.
60 * Revision 1.4 1996/03/26 00:50:30 robertj
61 * FTP Client Implementation.
63 * Revision 1.3 1996/03/18 13:33:15 robertj
64 * Fixed incompatibilities to GNU compiler where PINDEX != int.
66 * Revision 1.2 1996/03/16 04:51:12 robertj
67 * Changed lastResponseCode to an integer.
69 * Revision 1.1 1996/03/04 12:12:51 robertj
70 * Initial revision
74 #ifdef __GNUC__
75 #pragma implementation "ftp.h"
76 #endif
78 #include <ptlib.h>
79 #include <ptlib/sockets.h>
80 #include <ptclib/ftp.h>
83 /////////////////////////////////////////////////////////
84 // File Transfer Protocol
86 static const char * const FTPCommands[PFTP::NumCommands] =
88 "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "QUIT", "REIN", "PORT", "PASV",
89 "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR",
90 "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST", "NLST", "SITE", "SYST",
91 "STAT", "HELP", "NOOP"
94 PFTP::PFTP()
95 : PInternetProtocol("ftp 21", NumCommands, FTPCommands)
100 BOOL PFTP::SendPORT(const PIPSocket::Address & addr, WORD port)
102 PString str(PString::Printf,
103 "%i,%i,%i,%i,%i,%i",
104 addr.Byte1(),
105 addr.Byte2(),
106 addr.Byte3(),
107 addr.Byte4(),
108 port/256,
109 port%256);
110 return ExecuteCommand(PORT, str)/100 == 2;
114 // End of File ///////////////////////////////////////////////////////////////