]> git.saurik.com Git - apt.git/blame - methods/ftp.h
edsp: dump: support dumping into compressed file
[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
1e3f4083 6 FTP Acquire Method - This is the FTP acquire method for APT.
30b30ec1
AL
7
8 ##################################################################### */
9 /*}}}*/
10#ifndef APT_FTP_H
11#define APT_FTP_H
12
3b302846 13#include <apt-pkg/acquire-method.h>
472ff00e 14#include <apt-pkg/strutl.h>
23e64f6d 15#include "aptmethod.h"
472ff00e 16
3b302846 17#include <sys/socket.h>
453b82a3
DK
18#include <sys/types.h>
19#include <time.h>
472ff00e
DK
20#include <string>
21
30b30ec1
AL
22class FTPConn
23{
24 char Buffer[1024*10];
25 unsigned long Len;
26 int ServerFd;
27 int DataFd;
28 int DataListenFd;
29 URI ServerName;
b2e465d6 30 bool ForceExtended;
30b30ec1 31 bool TryPassive;
ce0ae89a 32 bool Debug;
30b30ec1 33
b2e465d6
AL
34 struct addrinfo *PasvAddr;
35
36 // Generic Peer Address
37 struct sockaddr_storage PeerAddr;
38 socklen_t PeerAddrLen;
39
40 // Generic Server Address (us)
41 struct sockaddr_storage ServerAddr;
42 socklen_t ServerAddrLen;
43
30b30ec1 44 // Private helper functions
8f3ba4e8 45 bool ReadLine(std::string &Text);
30b30ec1
AL
46 bool Login();
47 bool CreateDataFd();
48 bool Finalize();
49
50 public:
51
330463dd 52 bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
ce0ae89a 53
30b30ec1 54 // Raw connection IO
8f3ba4e8
DK
55 bool ReadResp(unsigned int &Ret,std::string &Text);
56 bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
30b30ec1
AL
57
58 // Connection control
ce0ae89a 59 bool Open(pkgAcqMethod *Owner);
30b30ec1
AL
60 void Close();
61 bool GoPasv();
b2e465d6 62 bool ExtGoPasv();
30b30ec1
AL
63
64 // Query
650faab0 65 bool Size(const char *Path,unsigned long long &Size);
30b30ec1 66 bool ModTime(const char *Path, time_t &Time);
650faab0 67 bool Get(const char *Path,FileFd &To,unsigned long long Resume,
ee279506
MV
68 Hashes &MD5,bool &Missing, unsigned long long MaximumSize,
69 pkgAcqMethod *Owner);
30b30ec1 70
258b9e51 71 explicit FTPConn(URI Srv);
30b30ec1
AL
72 ~FTPConn();
73};
74
23e64f6d 75class FtpMethod : public aptMethod
ce0ae89a 76{
3b302846
DK
77 virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
78 virtual bool Configuration(std::string Message) APT_OVERRIDE;
ce0ae89a
AL
79
80 FTPConn *Server;
81
8f3ba4e8 82 static std::string FailFile;
ce0ae89a
AL
83 static int FailFd;
84 static time_t FailTime;
a02db58f 85 static APT_NORETURN void SigTerm(int);
ce0ae89a
AL
86
87 public:
88
89 FtpMethod();
90};
91
30b30ec1 92#endif