More fixes
[ntk/apt.git] / methods / ftp.h
CommitLineData
30b30ec1 1// -*- mode: cpp; mode: fold -*-
ce0ae89a 2// Description /*{{{*/// $Id: ftp.h,v 1.2 1999/03/15 07:20:41 jgg Exp $
30b30ec1
AL
3/* ######################################################################
4
5 FTP Aquire Method - This is the FTP aquire method for APT.
6
7 ##################################################################### */
8 /*}}}*/
9#ifndef APT_FTP_H
10#define APT_FTP_H
11
12class FTPConn
13{
14 char Buffer[1024*10];
15 unsigned long Len;
16 int ServerFd;
17 int DataFd;
18 int DataListenFd;
19 URI ServerName;
20 bool TryPassive;
ce0ae89a 21 bool Debug;
30b30ec1
AL
22
23 struct sockaddr_in PasvAddr;
24 struct sockaddr_in Peer;
25
26 // Private helper functions
27 bool ReadLine(string &Text);
28 bool Login();
29 bool CreateDataFd();
30 bool Finalize();
31
32 public:
33
ce0ae89a
AL
34 bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
35
30b30ec1
AL
36 // Raw connection IO
37 bool ReadResp(unsigned int &Ret,string &Text);
38 bool WriteMsg(unsigned int &Ret,string &Text,const char *Fmt,...);
39
40 // Connection control
ce0ae89a 41 bool Open(pkgAcqMethod *Owner);
30b30ec1
AL
42 void Close();
43 bool GoPasv();
44
45 // Query
ce0ae89a 46 bool Size(const char *Path,unsigned long &Size);
30b30ec1 47 bool ModTime(const char *Path, time_t &Time);
ce0ae89a
AL
48 bool Get(const char *Path,FileFd &To,unsigned long Resume,
49 MD5Summation &MD5,bool &Missing);
30b30ec1
AL
50
51 FTPConn(URI Srv);
52 ~FTPConn();
53};
54
ce0ae89a
AL
55class FtpMethod : public pkgAcqMethod
56{
57 virtual bool Fetch(FetchItem *Itm);
58 virtual bool Configuration(string Message);
59
60 FTPConn *Server;
61
62 static string FailFile;
63 static int FailFd;
64 static time_t FailTime;
65 static void SigTerm(int);
66
67 public:
68
69 FtpMethod();
70};
71
30b30ec1 72#endif