scratch.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <string>
  2. /*void basic_string<char,string_char_traits<char>,alloc>::Rep::release()
  3. {
  4. cout << "Release " << (void *)this << ' ' << ref << endl;
  5. if (--ref == 0) delete this;
  6. }
  7. basic_string<char,string_char_traits<char>,alloc>::~basic_string()
  8. {
  9. cout << "Destroy " << (void *)this << ',' << rep()->ref << endl;
  10. rep ()->release ();
  11. }*/
  12. #include <apt-pkg/tagfile.h>
  13. #include <apt-pkg/strutl.h>
  14. #include <apt-pkg/cachefile.h>
  15. #include <apt-pkg/pkgrecords.h>
  16. #include <apt-pkg/error.h>
  17. #include <apt-pkg/init.h>
  18. #include <signal.h>
  19. #include <stdio.h>
  20. #include <malloc.h>
  21. struct Rep
  22. {
  23. size_t len, res, ref;
  24. bool selfish;
  25. };
  26. int main(int argc,char *argv[])
  27. {
  28. pkgCacheFile Cache;
  29. OpProgress Prog;
  30. pkgInitialize(*_config);
  31. if (Cache.Open(Prog,false) == false)
  32. {
  33. _error->DumpErrors();
  34. return 0;
  35. }
  36. pkgRecords rec(*Cache);
  37. while (1)
  38. {
  39. pkgCache::VerIterator V = (*Cache)[Cache->PkgBegin()].CandidateVerIter(*Cache);
  40. pkgRecords::Parser &Parse = rec.Lookup(V.FileList());
  41. string Foo = Parse.ShortDesc();
  42. cout << (reinterpret_cast<Rep *>(Foo.begin()) - 1)[0].ref << endl;
  43. // cout << Foo << endl;
  44. // cout << rec.Lookup(V.FileList()).ShortDesc() << endl;
  45. malloc_stats();
  46. }
  47. #if 0
  48. URI U(argv[1]);
  49. cout << U.Access << endl;
  50. cout << U.User << endl;
  51. cout << U.Password << endl;
  52. cout << U.Host << endl;
  53. cout << U.Path << endl;
  54. cout << U.Port << endl;
  55. /*
  56. FileFd F(argv[1],FileFd::ReadOnly);
  57. pkgTagFile Reader(F);
  58. pkgTagSection Sect;
  59. while (Reader.Step(Sect) == true)
  60. {
  61. Sect.FindS("Package");
  62. Sect.FindS("Section");
  63. Sect.FindS("Version");
  64. Sect.FindI("Size");
  65. };*/
  66. #endif
  67. return 0;
  68. }