You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
896 B

  1. #include <config.h>
  2. #include <apt-pkg/debfile.h>
  3. #include <apt-pkg/error.h>
  4. #include <apt-pkg/fileutl.h>
  5. #include <iostream>
  6. #include <string>
  7. #include <unistd.h>
  8. using namespace std;
  9. static bool 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. debDebFile::MemControlExtract Extract(Member);
  16. if (Extract.Read(Deb) == false)
  17. return false;
  18. if (Extract.Control == 0)
  19. return true;
  20. return write(STDOUT_FILENO,Extract.Control,Extract.Length) != -1;
  21. }
  22. int main(int argc, const char *argv[])
  23. {
  24. if (argc < 2)
  25. {
  26. cerr << "Need two arguments, a .deb and the control member" << endl;
  27. return 100;
  28. }
  29. if (ExtractMember(argv[1],argv[2]) == false)
  30. {
  31. _error->DumpErrors();
  32. return 100;
  33. }
  34. return 0;
  35. }