access _config via GET requests in the webserver
[ntk/apt.git] / test / interactive-helper / extract-control.cc
CommitLineData
b2e465d6
AL
1#include <apt-pkg/debfile.h>
2#include <apt-pkg/error.h>
472ff00e 3#include <apt-pkg/fileutl.h>
b2e465d6
AL
4
5#include <iostream>
6#include <unistd.h>
7
5a8748f1
AL
8using namespace std;
9
b2e465d6
AL
10bool ExtractMember(const char *File,const char *Member)
11{
12 FileFd Fd(File,FileFd::ReadOnly);
13 debDebFile Deb(Fd);
14 if(_error->PendingError() == true)
15 return false;
16
17 debDebFile::MemControlExtract Extract(Member);
18 if (Extract.Read(Deb) == false)
19 return false;
20
21 if (Extract.Control == 0)
22 return true;
23
fca97516 24 return write(STDOUT_FILENO,Extract.Control,Extract.Length) != -1;
b2e465d6
AL
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}