]> git.saurik.com Git - apt.git/blame_incremental - methods/ftp.h
tests: fail testsuccess if notices are shown, too
[apt.git] / methods / ftp.h
... / ...
CommitLineData
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 Acquire Method - This is the FTP acquire method for APT.
7
8 ##################################################################### */
9 /*}}}*/
10#ifndef APT_FTP_H
11#define APT_FTP_H
12
13#include <apt-pkg/acquire-method.h>
14#include <apt-pkg/strutl.h>
15#include "aptmethod.h"
16
17#include <sys/socket.h>
18#include <sys/types.h>
19#include <time.h>
20#include <string>
21
22class FTPConn
23{
24 char Buffer[1024*10];
25 unsigned long Len;
26 int ServerFd;
27 int DataFd;
28 int DataListenFd;
29 URI ServerName;
30 bool ForceExtended;
31 bool TryPassive;
32 bool Debug;
33
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
44 // Private helper functions
45 bool ReadLine(std::string &Text);
46 bool Login();
47 bool CreateDataFd();
48 bool Finalize();
49
50 public:
51
52 bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
53
54 // Raw connection IO
55 bool ReadResp(unsigned int &Ret,std::string &Text);
56 bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
57
58 // Connection control
59 bool Open(pkgAcqMethod *Owner);
60 void Close();
61 bool GoPasv();
62 bool ExtGoPasv();
63
64 // Query
65 bool Size(const char *Path,unsigned long long &Size);
66 bool ModTime(const char *Path, time_t &Time);
67 bool Get(const char *Path,FileFd &To,unsigned long long Resume,
68 Hashes &MD5,bool &Missing, unsigned long long MaximumSize,
69 pkgAcqMethod *Owner);
70
71 explicit FTPConn(URI Srv);
72 ~FTPConn();
73};
74
75class FtpMethod : public aptMethod
76{
77 virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
78 virtual bool Configuration(std::string Message) APT_OVERRIDE;
79
80 FTPConn *Server;
81
82 static std::string FailFile;
83 static int FailFd;
84 static time_t FailTime;
85 static APT_NORETURN void SigTerm(int);
86
87 public:
88
89 FtpMethod();
90};
91
92#endif