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