do not pollute namespace in the headers with using (Closes: #500198)
[ntk/apt.git] / methods / ftp.h
CommitLineData
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
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
13class FTPConn
14{
15 char Buffer[1024*10];
16 unsigned long Len;
17 int ServerFd;
18 int DataFd;
19 int DataListenFd;
20 URI ServerName;
b2e465d6 21 bool ForceExtended;
30b30ec1 22 bool TryPassive;
ce0ae89a 23 bool Debug;
30b30ec1 24
b2e465d6
AL
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
30b30ec1 35 // Private helper functions
8f3ba4e8 36 bool ReadLine(std::string &Text);
30b30ec1
AL
37 bool Login();
38 bool CreateDataFd();
39 bool Finalize();
40
41 public:
42
330463dd 43 bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
ce0ae89a 44
30b30ec1 45 // Raw connection IO
8f3ba4e8
DK
46 bool ReadResp(unsigned int &Ret,std::string &Text);
47 bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
30b30ec1
AL
48
49 // Connection control
ce0ae89a 50 bool Open(pkgAcqMethod *Owner);
30b30ec1
AL
51 void Close();
52 bool GoPasv();
b2e465d6 53 bool ExtGoPasv();
30b30ec1
AL
54
55 // Query
650faab0 56 bool Size(const char *Path,unsigned long long &Size);
30b30ec1 57 bool ModTime(const char *Path, time_t &Time);
650faab0 58 bool Get(const char *Path,FileFd &To,unsigned long long Resume,
63b1700f 59 Hashes &MD5,bool &Missing);
30b30ec1
AL
60
61 FTPConn(URI Srv);
62 ~FTPConn();
63};
64
ce0ae89a
AL
65class FtpMethod : public pkgAcqMethod
66{
67 virtual bool Fetch(FetchItem *Itm);
8f3ba4e8 68 virtual bool Configuration(std::string Message);
ce0ae89a
AL
69
70 FTPConn *Server;
71
8f3ba4e8 72 static std::string FailFile;
ce0ae89a
AL
73 static int FailFd;
74 static time_t FailTime;
75 static void SigTerm(int);
76
77 public:
78
79 FtpMethod();
80};
81
30b30ec1 82#endif