ftp.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <string>
  12. class 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 ForceExtended;
  21. bool TryPassive;
  22. bool Debug;
  23. struct addrinfo *PasvAddr;
  24. // Generic Peer Address
  25. struct sockaddr_storage PeerAddr;
  26. socklen_t PeerAddrLen;
  27. // Generic Server Address (us)
  28. struct sockaddr_storage ServerAddr;
  29. socklen_t ServerAddrLen;
  30. // Private helper functions
  31. bool ReadLine(std::string &Text);
  32. bool Login();
  33. bool CreateDataFd();
  34. bool Finalize();
  35. public:
  36. bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
  37. // Raw connection IO
  38. bool ReadResp(unsigned int &Ret,std::string &Text);
  39. bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
  40. // Connection control
  41. bool Open(pkgAcqMethod *Owner);
  42. void Close();
  43. bool GoPasv();
  44. bool ExtGoPasv();
  45. // Query
  46. bool Size(const char *Path,unsigned long long &Size);
  47. bool ModTime(const char *Path, time_t &Time);
  48. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  49. Hashes &MD5,bool &Missing);
  50. FTPConn(URI Srv);
  51. ~FTPConn();
  52. };
  53. class FtpMethod : public pkgAcqMethod
  54. {
  55. virtual bool Fetch(FetchItem *Itm);
  56. virtual bool Configuration(std::string Message);
  57. FTPConn *Server;
  58. static std::string FailFile;
  59. static int FailFd;
  60. static time_t FailTime;
  61. static void SigTerm(int);
  62. public:
  63. FtpMethod();
  64. };
  65. #endif