]>
git.saurik.com Git - apt.git/blob - apt-pkg/deb/debsrcrecords.cc
7a06e30b972b87a2a4515c43f767eece9b31e2b0
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: debsrcrecords.cc,v 1.3 1999/04/07 05:30:18 jgg Exp $
4 /* ######################################################################
6 Debian Source Package Records - Parser implementation for Debian style
9 ##################################################################### */
11 // Include Files /*{{{*/
13 #pragma implementation "apt-pkg/debsrcrecords.h"
16 #include <apt-pkg/debsrcrecords.h>
17 #include <apt-pkg/error.h>
18 #include <apt-pkg/strutl.h>
21 // SrcRecordParser::Binaries - Return the binaries field /*{{{*/
22 // ---------------------------------------------------------------------
23 /* This member parses the binaries field into a pair of class arrays and
24 returns a list of strings representing all of the components of the
25 binaries field. The returned array need not be freed and will be
26 reused by the next Binaries function call. */
27 const char **debSrcRecordParser::Binaries()
29 string Bins
= Sect
.FindS("Binary");
32 if (Bins
.empty() == true)
35 // Strip any leading spaces
36 string::const_iterator Start
= Bins
.begin();
37 for (; Start
!= Bins
.end() && isspace(*Start
) != 0; Start
++);
39 string::const_iterator Pos
= Start
;
40 while (Pos
!= Bins
.end())
42 // Skip to the next ','
43 for (; Pos
!= Bins
.end() && *Pos
!= ','; Pos
++);
46 string::const_iterator End
= Pos
;
47 for (; End
> Start
&& (End
[-1] == ',' || isspace(End
[-1]) != 0); End
--);
50 memcpy(Buf
,Start
,End
-Start
);
51 StaticBinList
[Bin
] = Buf
;
57 for (; Pos
!= Bins
.end() && (*Pos
== ',' || isspace(*Pos
) != 0); Pos
++);
61 StaticBinList
[Bin
] = 0;
65 // SrcRecordParser::Files - Return a list of files for this source /*{{{*/
66 // ---------------------------------------------------------------------
67 /* This parses the list of files and returns it, each file is required to have
68 a complete source package */
69 bool debSrcRecordParser::Files(vector
<pkgSrcRecords::File
> &List
)
71 List
.erase(List
.begin(),List
.end());
73 string Files
= Sect
.FindS("Files");
74 if (Files
.empty() == true)
77 // Stash the / terminated directory prefix
78 string Base
= Sect
.FindS("Directory");
79 if (Base
.empty() == false && Base
[Base
.length()-1] != '/')
82 // Iterate over the entire list grabbing each triplet
83 const char *C
= Files
.c_str();
86 pkgSrcRecords::File F
;
89 // Parse each of the elements
90 if (ParseQuoteWord(C
,F
.MD5Hash
) == false ||
91 ParseQuoteWord(C
,Size
) == false ||
92 ParseQuoteWord(C
,F
.Path
) == false)
93 return _error
->Error("Error parsing file record");
95 // Parse the size and append the directory
96 F
.Size
= atoi(Size
.c_str());
97 F
.Path
= Base
+ F
.Path
;