pkgsystem.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
  4. /* ######################################################################
  5. System - Abstraction for running on different systems.
  6. Basic general structure..
  7. ##################################################################### */
  8. /*}}}*/
  9. // Include Files /*{{{*/
  10. #ifdef __GNUG__
  11. #pragma implementation "apt-pkg/pkgsystem.h"
  12. #endif
  13. #include <apt-pkg/pkgsystem.h>
  14. #include <apt-pkg/policy.h>
  15. #include <cassert>
  16. /*}}}*/
  17. pkgSystem *_system = 0;
  18. static pkgSystem *SysList[10];
  19. pkgSystem **pkgSystem::GlobalList = SysList;
  20. unsigned long pkgSystem::GlobalListLen = 0;
  21. // System::pkgSystem - Constructor /*{{{*/
  22. // ---------------------------------------------------------------------
  23. /* Add it to the global list.. */
  24. pkgSystem::pkgSystem()
  25. {
  26. assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
  27. SysList[GlobalListLen] = this;
  28. GlobalListLen++;
  29. }
  30. /*}}}*/
  31. // System::GetSystem - Get the named system /*{{{*/
  32. // ---------------------------------------------------------------------
  33. /* */
  34. pkgSystem *pkgSystem::GetSystem(const char *Label)
  35. {
  36. for (unsigned I = 0; I != GlobalListLen; I++)
  37. if (strcmp(SysList[I]->Label,Label) == 0)
  38. return SysList[I];
  39. return 0;
  40. }
  41. /*}}}*/