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