]> git.saurik.com Git - apt.git/blame - test/extract-control.cc
Doc updates
[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
7bool ExtractMember(const char *File,const char *Member)
8{
9 FileFd Fd(File,FileFd::ReadOnly);
10 debDebFile Deb(Fd);
11 if(_error->PendingError() == true)
12 return false;
13
14 debDebFile::MemControlExtract Extract(Member);
15 if (Extract.Read(Deb) == false)
16 return false;
17
18 if (Extract.Control == 0)
19 return true;
20
21 write(STDOUT_FILENO,Extract.Control,Extract.Length);
22 return true;
23}
24
25int main(int argc, const char *argv[])
26{
27 if (argc < 2)
28 {
29 cerr << "Need two arguments, a .deb and the control member" << endl;
30 return 100;
31 }
32
33 if (ExtractMember(argv[1],argv[2]) == false)
34 {
35 _error->DumpErrors();
36 return 100;
37 }
38
39 return 0;
40}