rsh.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include <apt-pkg/hashes.h>
  13. #include <apt-pkg/acquire-method.h>
  14. #include <apt-pkg/fileutl.h>
  15. class RSHConn
  16. {
  17. char Buffer[1024*10];
  18. unsigned long Len;
  19. int WriteFd;
  20. int ReadFd;
  21. URI ServerName;
  22. // Private helper functions
  23. bool ReadLine(std::string &Text);
  24. public:
  25. pid_t Process;
  26. // Raw connection IO
  27. bool WriteMsg(std::string &Text,bool Sync,const char *Fmt,...);
  28. bool Connect(std::string Host, std::string User);
  29. bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
  30. // Connection control
  31. bool Open();
  32. void Close();
  33. // Query
  34. bool Size(const char *Path,unsigned long long &Size);
  35. bool ModTime(const char *Path, time_t &Time);
  36. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  37. Hashes &Hash,bool &Missing, unsigned long long Size);
  38. RSHConn(URI Srv);
  39. ~RSHConn();
  40. };
  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