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