]> git.saurik.com Git - apt-legacy.git/blob - test/extract-control.cc
Fix compilation of http when embedding into Cydia.
[apt-legacy.git] / test / extract-control.cc
1 #include <apt-pkg/debfile.h>
2 #include <apt-pkg/error.h>
3
4 #include <iostream>
5 #include <unistd.h>
6
7 using namespace std;
8
9 bool ExtractMember(const char *File,const char *Member)
10 {
11 FileFd Fd(File,FileFd::ReadOnly);
12 debDebFile Deb(Fd);
13 if(_error->PendingError() == true)
14 return false;
15
16 debDebFile::MemControlExtract Extract(Member);
17 if (Extract.Read(Deb) == false)
18 return false;
19
20 if (Extract.Control == 0)
21 return true;
22
23 write(STDOUT_FILENO,Extract.Control,Extract.Length);
24 return true;
25 }
26
27 int main(int argc, const char *argv[])
28 {
29 if (argc < 2)
30 {
31 cerr << "Need two arguments, a .deb and the control member" << endl;
32 return 100;
33 }
34
35 if (ExtractMember(argv[1],argv[2]) == false)
36 {
37 _error->DumpErrors();
38 return 100;
39 }
40
41 return 0;
42 }