rsh.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/// $Id: rsh.h,v 1.4 2002/11/09 23:33:26 doogie Exp $
  3. // $Id: rsh.h,v 1.4 2002/11/09 23:33:26 doogie Exp $
  4. /* ######################################################################
  5. RSH method - Transfer files via rsh compatible program
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef APT_RSH_H
  9. #define APT_RSH_H
  10. #include <string>
  11. #include <apt-pkg/strutl.h>
  12. class Hashes;
  13. class FileFd;
  14. class RSHConn
  15. {
  16. char Buffer[1024*10];
  17. unsigned long Len;
  18. int WriteFd;
  19. int ReadFd;
  20. URI ServerName;
  21. // Private helper functions
  22. bool ReadLine(std::string &Text);
  23. public:
  24. pid_t Process;
  25. // Raw connection IO
  26. bool WriteMsg(std::string &Text,bool Sync,const char *Fmt,...);
  27. bool Connect(std::string Host, std::string User);
  28. bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
  29. // Connection control
  30. bool Open();
  31. void Close();
  32. // Query
  33. bool Size(const char *Path,unsigned long long &Size);
  34. bool ModTime(const char *Path, time_t &Time);
  35. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  36. Hashes &Hash,bool &Missing, unsigned long long Size);
  37. RSHConn(URI Srv);
  38. ~RSHConn();
  39. };
  40. #include <apt-pkg/acquire-method.h>
  41. class RSHMethod : public pkgAcqMethod
  42. {
  43. virtual bool Fetch(FetchItem *Itm);
  44. virtual bool Configuration(std::string Message);
  45. RSHConn *Server;
  46. static std::string FailFile;
  47. static int FailFd;
  48. static time_t FailTime;
  49. static void SigTerm(int);
  50. public:
  51. RSHMethod();
  52. };
  53. #endif