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