]> git.saurik.com Git - apt.git/blame - test/extract-control.cc
add config setting for User-Agent in http and https to the Acquire group,
[apt.git] / test / extract-control.cc
CommitLineData
b2e465d6
AL
1#include <apt-pkg/debfile.h>
2#include <apt-pkg/error.h>
3
4#include <iostream>
5#include <unistd.h>
6
5a8748f1
AL
7using namespace std;
8
b2e465d6
AL
9bool 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
27int 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}