ftp.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. FTP Acquire Method - This is the FTP acquire method for APT.
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef APT_FTP_H
  9. #define APT_FTP_H
  10. #include <apt-pkg/strutl.h>
  11. #include <sys/types.h>
  12. #include <time.h>
  13. #include <string>
  14. class FTPConn
  15. {
  16. char Buffer[1024*10];
  17. unsigned long Len;
  18. int ServerFd;
  19. int DataFd;
  20. int DataListenFd;
  21. URI ServerName;
  22. bool ForceExtended;
  23. bool TryPassive;
  24. bool Debug;
  25. struct addrinfo *PasvAddr;
  26. // Generic Peer Address
  27. struct sockaddr_storage PeerAddr;
  28. socklen_t PeerAddrLen;
  29. // Generic Server Address (us)
  30. struct sockaddr_storage ServerAddr;
  31. socklen_t ServerAddrLen;
  32. // Private helper functions
  33. bool ReadLine(std::string &Text);
  34. bool Login();
  35. bool CreateDataFd();
  36. bool Finalize();
  37. public:
  38. bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
  39. // Raw connection IO
  40. bool ReadResp(unsigned int &Ret,std::string &Text);
  41. bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
  42. // Connection control
  43. bool Open(pkgAcqMethod *Owner);
  44. void Close();
  45. bool GoPasv();
  46. bool ExtGoPasv();
  47. // Query
  48. bool Size(const char *Path,unsigned long long &Size);
  49. bool ModTime(const char *Path, time_t &Time);
  50. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  51. Hashes &MD5,bool &Missing, unsigned long long MaximumSize,
  52. pkgAcqMethod *Owner);
  53. FTPConn(URI Srv);
  54. ~FTPConn();
  55. };
  56. class FtpMethod : public pkgAcqMethod
  57. {
  58. virtual bool Fetch(FetchItem *Itm);
  59. virtual bool Configuration(std::string Message);
  60. FTPConn *Server;
  61. static std::string FailFile;
  62. static int FailFd;
  63. static time_t FailTime;
  64. static APT_NORETURN void SigTerm(int);
  65. public:
  66. FtpMethod();
  67. };
  68. #endif