rsh.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <time.h>
  12. #include <apt-pkg/strutl.h>
  13. class Hashes;
  14. class FileFd;
  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 Connect(std::string Host, unsigned int Port, std::string User);
  30. bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
  31. // Connection control
  32. bool Open();
  33. void Close();
  34. // Query
  35. bool Size(const char *Path,unsigned long long &Size);
  36. bool ModTime(const char *Path, time_t &Time);
  37. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  38. Hashes &Hash,bool &Missing, unsigned long long Size);
  39. explicit RSHConn(URI Srv);
  40. ~RSHConn();
  41. };
  42. #include <apt-pkg/acquire-method.h>
  43. #include "aptmethod.h"
  44. class RSHMethod : public aptMethod
  45. {
  46. std::string const Prog;
  47. virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
  48. virtual bool Configuration(std::string Message) APT_OVERRIDE;
  49. RSHConn *Server;
  50. static std::string FailFile;
  51. static int FailFd;
  52. static time_t FailTime;
  53. static APT_NORETURN void SigTerm(int);
  54. public:
  55. explicit RSHMethod(std::string const &Prog);
  56. };
  57. #endif