rsh.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/// $Id: rsh.h,v 1.3 2001/03/06 07:15:29 jgg Exp $
  3. // $Id: rsh.h,v 1.3 2001/03/06 07:15:29 jgg 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(string &Text);
  24. public:
  25. int Process;
  26. // Raw connection IO
  27. bool WriteMsg(string &Text,bool Sync,const char *Fmt,...);
  28. bool Connect(string Host, string User);
  29. bool Comp(URI Other) {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 &Size);
  35. bool ModTime(const char *Path, time_t &Time);
  36. bool Get(const char *Path,FileFd &To,unsigned long Resume,
  37. Hashes &Hash,bool &Missing, unsigned long Size);
  38. RSHConn(URI Srv);
  39. ~RSHConn();
  40. };
  41. class RSHMethod : public pkgAcqMethod
  42. {
  43. virtual bool Fetch(FetchItem *Itm);
  44. RSHConn *Server;
  45. static string FailFile;
  46. static int FailFd;
  47. static time_t FailTime;
  48. static void SigTerm(int);
  49. public:
  50. RSHMethod();
  51. };
  52. #endif