pkgsystem.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include<config.h>
  11. #include <apt-pkg/pkgsystem.h>
  12. #include <apt-pkg/macros.h>
  13. #include <cassert>
  14. #include <cstring>
  15. /*}}}*/
  16. pkgSystem *_system = 0;
  17. static pkgSystem *SysList[10];
  18. pkgSystem **pkgSystem::GlobalList = SysList;
  19. unsigned long pkgSystem::GlobalListLen = 0;
  20. // System::pkgSystem - Constructor /*{{{*/
  21. // ---------------------------------------------------------------------
  22. /* Add it to the global list.. */
  23. pkgSystem::pkgSystem(char const * const label, pkgVersioningSystem * const vs) :
  24. Label(label), VS(vs), d(NULL)
  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. APT_PURE 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. /*}}}*/
  42. pkgSystem::~pkgSystem() {}