]> git.saurik.com Git - apt.git/blame - test/interactive-helper/testdeb.cc
add test for Basic Authentication scheme
[apt.git] / test / interactive-helper / testdeb.cc
CommitLineData
453b82a3
DK
1#include <config.h>
2
b2e465d6
AL
3#include <apt-pkg/dirstream.h>
4#include <apt-pkg/debfile.h>
5#include <apt-pkg/error.h>
6#include <apt-pkg/extracttar.h>
453b82a3
DK
7#include <apt-pkg/arfile.h>
8#include <apt-pkg/fileutl.h>
9
10#include <iostream>
11#include <string>
b2e465d6
AL
12
13class NullStream : public pkgDirStream
14{
15 public:
65512241 16 virtual bool DoItem(Item &/*Itm*/, int &/*Fd*/) {return true;};
b2e465d6
AL
17};
18
c3ccac92 19static bool Test(const char *File)
b2e465d6
AL
20{
21 FileFd Fd(File,FileFd::ReadOnly);
22 debDebFile Deb(Fd);
23
24 if (_error->PendingError() == true)
25 return false;
26
27 // Get the archive member and positition the file
28 const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
29 if (Member == 0)
30 return false;
31
32 // Extract it.
9373b975 33 ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
b2e465d6
AL
34 NullStream Dir;
35 if (Tar.Go(Dir) == false)
36 return false;
37
38 return true;
39}
40
41int main(int argc, const char *argv[])
42{
65512241
DK
43 if (argc != 2) {
44 std::cout << "One parameter expected - given " << argc << std::endl;
45 return 100;
46 }
47
b2e465d6
AL
48 Test(argv[1]);
49 _error->DumpErrors();
50 return 0;
51}