acquire-worker.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-worker.h,v 1.5 1998/10/26 07:11:46 jgg Exp $
  4. /* ######################################################################
  5. Acquire Worker - Worker process manager
  6. Each worker class is associated with exaclty one subprocess.
  7. ##################################################################### */
  8. /*}}}*/
  9. #ifndef PKGLIB_ACQUIRE_WORKER_H
  10. #define PKGLIB_ACQUIRE_WORKER_H
  11. #include <apt-pkg/acquire.h>
  12. #include <apt-pkg/configuration.h>
  13. #ifdef __GNUG__
  14. #pragma interface "apt-pkg/acquire-worker.h"
  15. #endif
  16. // Interfacing to the method process
  17. class pkgAcquire::Worker
  18. {
  19. friend pkgAcquire;
  20. protected:
  21. friend Queue;
  22. /* Linked list starting at a Queue and a linked list starting
  23. at Acquire */
  24. Worker *NextQueue;
  25. Worker *NextAcquire;
  26. // The access association
  27. Queue *OwnerQ;
  28. MethodConfig *Config;
  29. string Access;
  30. // This is the subprocess IPC setup
  31. pid_t Process;
  32. int InFd;
  33. int OutFd;
  34. bool InReady;
  35. bool OutReady;
  36. // Various internal things
  37. bool Debug;
  38. vector<string> MessageQueue;
  39. string OutQueue;
  40. // Private constructor helper
  41. void Construct();
  42. // Message handling things
  43. bool ReadMessages();
  44. bool RunMessages();
  45. bool InFdReady();
  46. bool OutFdReady();
  47. // The message handlers
  48. bool Capabilities(string Message);
  49. bool SendConfiguration();
  50. bool MethodFailure();
  51. public:
  52. // The curent method state
  53. pkgAcquire::Queue::QItem *CurrentItem;
  54. string Status;
  55. unsigned long CurrentSize;
  56. unsigned long TotalSize;
  57. // Load the method and do the startup
  58. bool QueueItem(pkgAcquire::Queue::QItem *Item);
  59. bool Start();
  60. Worker(Queue *OwnerQ,MethodConfig *Config);
  61. Worker(MethodConfig *Config);
  62. ~Worker();
  63. };
  64. bool pkgInjectConfiguration(string &Message,Configuration &Cnf);
  65. #endif