apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ftp.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  FTP Acquire Method - This is the FTP acquire method for APT.
6 
7  ##################################################################### */
8  /*}}}*/
9 #ifndef APT_FTP_H
10 #define APT_FTP_H
11 
12 #include "aptmethod.h"
13 #include "connect.h"
14 #include <apt-pkg/strutl.h>
15 
16 #include <string>
17 #include <sys/socket.h>
18 #include <sys/types.h>
19 #include <time.h>
20 
21 class FTPConn
22 {
23  char Buffer[1024*10];
24  unsigned long Len;
25  std::unique_ptr<MethodFd> ServerFd;
26  int DataFd;
30  bool TryPassive;
31  bool Debug;
32 
33  struct addrinfo *PasvAddr;
34 
35  // Generic Peer Address
37  socklen_t PeerAddrLen;
38 
39  // Generic Server Address (us)
41  socklen_t ServerAddrLen;
42 
43  // Private helper functions
44  bool ReadLine(std::string &Text);
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  ResultState Open(aptMethod *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  explicit FTPConn(URI Srv);
71  ~FTPConn();
72 };
73 
75 {
76  virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
77  virtual bool Configuration(std::string Message) APT_OVERRIDE;
78 
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
ResultState
Definition: aptmethod.h:35
Definition: ftp.h:22
struct sockaddr_storage ServerAddr
Definition: ftp.h:40
ResultState Open(aptMethod *Owner)
Definition: ftp.cc:112
socklen_t PeerAddrLen
Definition: ftp.h:37
bool Comp(URI Other)
Definition: ftp.h:51
bool Finalize()
Definition: ftp.cc:859
~FTPConn()
Definition: ftp.cc:87
bool ReadLine(std::string &Text)
Definition: ftp.cc:341
bool GoPasv()
Definition: ftp.cc:506
URI ServerName
Definition: ftp.h:28
ResultState Login()
Definition: ftp.cc:202
std::unique_ptr< MethodFd > ServerFd
Definition: ftp.h:25
bool Get(const char *Path, FileFd &To, unsigned long long Resume, Hashes &MD5, bool &Missing, unsigned long long MaximumSize, pkgAcqMethod *Owner)
Definition: ftp.cc:890
bool TryPassive
Definition: ftp.h:30
bool ReadResp(unsigned int &Ret, std::string &Text)
Definition: ftp.cc:393
bool ExtGoPasv()
Definition: ftp.cc:591
void Close()
Definition: ftp.cc:95
bool Size(const char *Path, unsigned long long &Size)
Definition: ftp.cc:679
bool CreateDataFd()
Definition: ftp.cc:719
FTPConn(URI Srv)
Definition: ftp.cc:74
unsigned long Len
Definition: ftp.h:24
struct sockaddr_storage PeerAddr
Definition: ftp.h:36
int DataListenFd
Definition: ftp.h:27
int DataFd
Definition: ftp.h:26
struct addrinfo * PasvAddr
Definition: ftp.h:33
bool ForceExtended
Definition: ftp.h:29
char Buffer[1024 *10]
Definition: ftp.h:23
socklen_t ServerAddrLen
Definition: ftp.h:41
bool WriteMsg(unsigned int &Ret, std::string &Text, const char *Fmt,...)
Definition: ftp.cc:461
bool Debug
Definition: ftp.h:31
bool ModTime(const char *Path, time_t &Time)
Definition: ftp.cc:700
Definition: fileutl.h:39
Definition: ftp.h:75
virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE
Definition: ftp.cc:1038
FtpMethod()
Definition: ftp.cc:991
static time_t FailTime
Definition: ftp.h:83
static APT_NORETURN void SigTerm(int)
Definition: ftp.cc:1005
FTPConn * Server
Definition: ftp.h:79
virtual bool Configuration(std::string Message) APT_OVERRIDE
Definition: ftp.cc:1025
static int FailFd
Definition: ftp.h:82
static std::string FailFile
Definition: ftp.h:81
Definition: hashes.h:170
Definition: strutl.h:193
unsigned int Port
Definition: strutl.h:203
std::string User
Definition: strutl.h:199
std::string Host
Definition: strutl.h:201
std::string Password
Definition: strutl.h:200
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_NORETURN
Definition: macros.h:57
#define sockaddr_storage
Definition: rfc2553emu.h:104
#define addrinfo
Definition: rfc2553emu.h:52