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