ftp.h 1.6 KB

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