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