ftp.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/// $Id: ftp.h,v 1.1 1999/03/15 06:01:00 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. struct sockaddr_in PasvAddr;
  19. struct sockaddr_in Peer;
  20. // Private helper functions
  21. bool ReadLine(string &Text);
  22. bool Login();
  23. bool CreateDataFd();
  24. bool Finalize();
  25. public:
  26. // Raw connection IO
  27. bool ReadResp(unsigned int &Ret,string &Text);
  28. bool WriteMsg(unsigned int &Ret,string &Text,const char *Fmt,...);
  29. // Connection control
  30. bool Open();
  31. void Close();
  32. bool GoPasv();
  33. // Query
  34. unsigned long Size(const char *Path);
  35. bool ModTime(const char *Path, time_t &Time);
  36. bool Get(const char *Path,FileFd &To,unsigned long Resume = 0);
  37. FTPConn(URI Srv);
  38. ~FTPConn();
  39. };
  40. #endif