pkgsystem.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/policy.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()
  24. {
  25. assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
  26. SysList[GlobalListLen] = this;
  27. GlobalListLen++;
  28. }
  29. /*}}}*/
  30. // System::GetSystem - Get the named system /*{{{*/
  31. // ---------------------------------------------------------------------
  32. /* */
  33. pkgSystem *pkgSystem::GetSystem(const char *Label)
  34. {
  35. for (unsigned I = 0; I != GlobalListLen; I++)
  36. if (strcmp(SysList[I]->Label,Label) == 0)
  37. return SysList[I];
  38. return 0;
  39. }
  40. /*}}}*/