debrecords.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: debrecords.cc,v 1.5 1999/02/22 03:30:06 jgg Exp $
  4. /* ######################################################################
  5. Debian Package Records - Parser for debian package records
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include Files /*{{{*/
  9. #ifdef __GNUG__
  10. #pragma implementation "apt-pkg/debrecords.h"
  11. #endif
  12. #include <apt-pkg/debrecords.h>
  13. #include <apt-pkg/error.h>
  14. /*}}}*/
  15. // RecordParser::debRecordParser - Constructor /*{{{*/
  16. // ---------------------------------------------------------------------
  17. /* */
  18. debRecordParser::debRecordParser(FileFd &File,pkgCache &Cache) :
  19. Tags(File,Cache.Head().MaxVerFileSize + 20)
  20. {
  21. }
  22. /*}}}*/
  23. // RecordParser::Jump - Jump to a specific record /*{{{*/
  24. // ---------------------------------------------------------------------
  25. /* */
  26. bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
  27. {
  28. return Tags.Jump(Section,Ver->Offset);
  29. }
  30. /*}}}*/
  31. // RecordParser::FindTag - Locate a tag and return a string /*{{{*/
  32. // ---------------------------------------------------------------------
  33. /* */
  34. string debRecordParser::FindTag(const char *Tag)
  35. {
  36. const char *Start;
  37. const char *Stop;
  38. if (Section.Find(Tag,Start,Stop) == false)
  39. return string();
  40. return string(Start,Stop - Start);
  41. }
  42. /*}}}*/
  43. // RecordParser::FileName - Return the archive filename on the site /*{{{*/
  44. // ---------------------------------------------------------------------
  45. /* */
  46. string debRecordParser::FileName()
  47. {
  48. return FindTag("Filename");
  49. }
  50. /*}}}*/
  51. // RecordParser::MD5Hash - Return the archive hash /*{{{*/
  52. // ---------------------------------------------------------------------
  53. /* */
  54. string debRecordParser::MD5Hash()
  55. {
  56. return FindTag("MD5sum");
  57. }
  58. /*}}}*/
  59. // RecordParser::Maintainer - Return the maintainer email /*{{{*/
  60. // ---------------------------------------------------------------------
  61. /* */
  62. string debRecordParser::Maintainer()
  63. {
  64. return FindTag("Maintainer");
  65. }
  66. /*}}}*/
  67. // RecordParser::ShortDesc - Return a 1 line description /*{{{*/
  68. // ---------------------------------------------------------------------
  69. /* */
  70. string debRecordParser::ShortDesc()
  71. {
  72. string Res = FindTag("Description");
  73. string::size_type Pos = Res.find('\n');
  74. if (Pos == string::npos)
  75. return Res;
  76. return string(Res,0,Pos);
  77. }
  78. /*}}}*/
  79. // RecordParser::LongDesc - Return a longer description /*{{{*/
  80. // ---------------------------------------------------------------------
  81. /* */
  82. string debRecordParser::LongDesc()
  83. {
  84. return FindTag("Description");
  85. }
  86. /*}}}*/