]>
Commit | Line | Data |
---|---|---|
30b30ec1 | 1 | // -*- mode: cpp; mode: fold -*- |
63b1700f AL |
2 | // Description /*{{{*/// $Id: ftp.h,v 1.4 2001/03/06 07:15:29 jgg Exp $ |
3 | // $Id: ftp.h,v 1.4 2001/03/06 07:15:29 jgg Exp $ | |
30b30ec1 AL |
4 | /* ###################################################################### |
5 | ||
1e3f4083 | 6 | FTP Acquire Method - This is the FTP acquire method for APT. |
30b30ec1 AL |
7 | |
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
10 | #ifndef APT_FTP_H | |
11 | #define APT_FTP_H | |
12 | ||
472ff00e DK |
13 | #include <apt-pkg/strutl.h> |
14 | ||
453b82a3 DK |
15 | #include <sys/types.h> |
16 | #include <time.h> | |
472ff00e DK |
17 | #include <string> |
18 | ||
30b30ec1 AL |
19 | class FTPConn |
20 | { | |
21 | char Buffer[1024*10]; | |
22 | unsigned long Len; | |
23 | int ServerFd; | |
24 | int DataFd; | |
25 | int DataListenFd; | |
26 | URI ServerName; | |
b2e465d6 | 27 | bool ForceExtended; |
30b30ec1 | 28 | bool TryPassive; |
ce0ae89a | 29 | bool Debug; |
30b30ec1 | 30 | |
b2e465d6 AL |
31 | struct addrinfo *PasvAddr; |
32 | ||
33 | // Generic Peer Address | |
34 | struct sockaddr_storage PeerAddr; | |
35 | socklen_t PeerAddrLen; | |
36 | ||
37 | // Generic Server Address (us) | |
38 | struct sockaddr_storage ServerAddr; | |
39 | socklen_t ServerAddrLen; | |
40 | ||
30b30ec1 | 41 | // Private helper functions |
8f3ba4e8 | 42 | bool ReadLine(std::string &Text); |
30b30ec1 AL |
43 | bool Login(); |
44 | bool CreateDataFd(); | |
45 | bool Finalize(); | |
46 | ||
47 | public: | |
48 | ||
330463dd | 49 | bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; }; |
ce0ae89a | 50 | |
30b30ec1 | 51 | // Raw connection IO |
8f3ba4e8 DK |
52 | bool ReadResp(unsigned int &Ret,std::string &Text); |
53 | bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...); | |
30b30ec1 AL |
54 | |
55 | // Connection control | |
ce0ae89a | 56 | bool Open(pkgAcqMethod *Owner); |
30b30ec1 AL |
57 | void Close(); |
58 | bool GoPasv(); | |
b2e465d6 | 59 | bool ExtGoPasv(); |
30b30ec1 AL |
60 | |
61 | // Query | |
650faab0 | 62 | bool Size(const char *Path,unsigned long long &Size); |
30b30ec1 | 63 | bool ModTime(const char *Path, time_t &Time); |
650faab0 | 64 | bool Get(const char *Path,FileFd &To,unsigned long long Resume, |
63b1700f | 65 | Hashes &MD5,bool &Missing); |
30b30ec1 AL |
66 | |
67 | FTPConn(URI Srv); | |
68 | ~FTPConn(); | |
69 | }; | |
70 | ||
ce0ae89a AL |
71 | class FtpMethod : public pkgAcqMethod |
72 | { | |
73 | virtual bool Fetch(FetchItem *Itm); | |
8f3ba4e8 | 74 | virtual bool Configuration(std::string Message); |
ce0ae89a AL |
75 | |
76 | FTPConn *Server; | |
77 | ||
8f3ba4e8 | 78 | static std::string FailFile; |
ce0ae89a AL |
79 | static int FailFd; |
80 | static time_t FailTime; | |
a02db58f | 81 | static APT_NORETURN void SigTerm(int); |
ce0ae89a AL |
82 | |
83 | public: | |
84 | ||
85 | FtpMethod(); | |
86 | }; | |
87 | ||
30b30ec1 | 88 | #endif |