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