ftp.h 1.9 KB

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