]> git.saurik.com Git - apt.git/blame - methods/ftp.h
* apt-pkg/acquire-item.cc:
[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
AL
35 // Private helper functions
36 bool ReadLine(string &Text);
37 bool Login();
38 bool CreateDataFd();
39 bool Finalize();
40
41 public:
42
ce0ae89a
AL
43 bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
44
30b30ec1
AL
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
ce0ae89a 50 bool Open(pkgAcqMethod *Owner);
30b30ec1
AL
51 void Close();
52 bool GoPasv();
b2e465d6 53 bool ExtGoPasv();
30b30ec1
AL
54
55 // Query
ce0ae89a 56 bool Size(const char *Path,unsigned long &Size);
30b30ec1 57 bool ModTime(const char *Path, time_t &Time);
ce0ae89a 58 bool Get(const char *Path,FileFd &To,unsigned 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);
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
30b30ec1 82#endif