rsh.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. std::string const Prog;
  23. // Private helper functions
  24. bool ReadLine(std::string &Text);
  25. public:
  26. pid_t Process;
  27. // Raw connection IO
  28. bool WriteMsg(std::string &Text,bool Sync,const char *Fmt,...);
  29. bool Connect(std::string Host, std::string User);
  30. bool Connect(std::string Host, unsigned int Port, std::string User);
  31. bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
  32. // Connection control
  33. bool Open();
  34. void Close();
  35. // Query
  36. bool Size(const char *Path,unsigned long long &Size);
  37. bool ModTime(const char *Path, time_t &Time);
  38. bool Get(const char *Path,FileFd &To,unsigned long long Resume,
  39. Hashes &Hash,bool &Missing, unsigned long long Size);
  40. RSHConn(std::string const &Prog, URI Srv);
  41. ~RSHConn();
  42. };
  43. #include "aptmethod.h"
  44. class RSHMethod : public aptMethod
  45. {
  46. virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
  47. virtual bool Configuration(std::string Message) APT_OVERRIDE;
  48. RSHConn *Server;
  49. static std::string FailFile;
  50. static int FailFd;
  51. static time_t FailTime;
  52. static APT_NORETURN void SigTerm(int);
  53. public:
  54. explicit RSHMethod(std::string &&Prog);
  55. };
  56. #endif