debrecords.cc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: debrecords.cc,v 1.3 1998/11/13 04:23:37 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) : Tags(File,4*1024)
  19. {
  20. }
  21. /*}}}*/
  22. // RecordParser::Jump - Jump to a specific record /*{{{*/
  23. // ---------------------------------------------------------------------
  24. /* */
  25. bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
  26. {
  27. return Tags.Jump(Section,Ver->Offset);
  28. }
  29. /*}}}*/
  30. // RecordParser::FindTag - Locate a tag and return a string /*{{{*/
  31. // ---------------------------------------------------------------------
  32. /* */
  33. string debRecordParser::FindTag(const char *Tag)
  34. {
  35. const char *Start;
  36. const char *Stop;
  37. if (Section.Find(Tag,Start,Stop) == false)
  38. return string();
  39. return string(Start,Stop - Start);
  40. }
  41. /*}}}*/
  42. // RecordParser::FileName - Return the archive filename on the site /*{{{*/
  43. // ---------------------------------------------------------------------
  44. /* */
  45. string debRecordParser::FileName()
  46. {
  47. return FindTag("Filename");
  48. }
  49. /*}}}*/
  50. // RecordParser::MD5Hash - Return the archive hash /*{{{*/
  51. // ---------------------------------------------------------------------
  52. /* */
  53. string debRecordParser::MD5Hash()
  54. {
  55. return FindTag("MD5sum");
  56. }
  57. /*}}}*/
  58. // RecordParser::Maintainer - Return the maintainer email /*{{{*/
  59. // ---------------------------------------------------------------------
  60. /* */
  61. string debRecordParser::Maintainer()
  62. {
  63. return FindTag("Maintainer");
  64. }
  65. /*}}}*/
  66. // RecordParser::ShortDesc - Return a 1 line description /*{{{*/
  67. // ---------------------------------------------------------------------
  68. /* */
  69. string debRecordParser::ShortDesc()
  70. {
  71. string Res = FindTag("Description");
  72. string::size_type Pos = Res.find('\n');
  73. if (Pos == string::npos)
  74. return Res;
  75. return string(Res,0,Pos);
  76. }
  77. /*}}}*/
  78. // RecordParser::LongDesc - Return a longer description /*{{{*/
  79. // ---------------------------------------------------------------------
  80. /* */
  81. string debRecordParser::LongDesc()
  82. {
  83. return string();
  84. }
  85. /*}}}*/