source: projects/synaptic/trunk/common/rsources.h @ 280

Revision 280, 3.0 KB checked in by yasumichi, 13 years ago (diff)

first import

Line 
1/* rsource.h - access the sources.list file
2 *
3 * Copyright (c) 1999 Patrick Cole <z@amused.net>
4 *           (c) 2002 Synaptic development team     
5 *
6 * Author: Patrick Cole <z@amused.net>
7 *         Michael Vogt <mvo@debian.org>
8 *         Gustavo Niemeyer <niemeyer@conectiva.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */
25
26#ifndef _RSOURCES_H
27#define _RSOURCES_H
28
29#include <string>
30#include <list>
31
32using namespace std;
33
34class SourcesList {
35 public:
36   enum RecType {
37      Deb = 1 << 0,
38      DebSrc = 1 << 1,
39      Rpm = 1 << 2,
40      RpmSrc = 1 << 3,
41      Disabled = 1 << 4,
42      Comment = 1 << 5,
43      RpmDir = 1 << 6,
44      RpmSrcDir = 1 << 7,
45      Repomd = 1 << 8,
46      RepomdSrc = 1 << 9
47   };
48
49   struct SourceRecord {
50      unsigned int Type;
51      string VendorID;
52      string URI;
53      string Dist;
54      string *Sections;
55      unsigned short NumSections;
56      string Comment;
57      string SourceFile;
58
59      bool SetType(string);
60      string GetType();
61      bool SetURI(string);
62
63        SourceRecord():Type(0), Sections(0), NumSections(0) {
64      };
65      ~SourceRecord() {
66         if (Sections)
67            delete[]Sections;
68      };
69      SourceRecord &operator=(const SourceRecord &);
70   };
71
72   struct VendorRecord {
73      string VendorID;
74      string FingerPrint;
75      string Description;
76   };
77
78   list<SourceRecord *> SourceRecords;
79   list<VendorRecord *> VendorRecords;
80
81 private:
82   SourceRecord *AddSourceNode(SourceRecord &);
83   VendorRecord *AddVendorNode(VendorRecord &);
84
85 public:
86   SourceRecord *AddSource(RecType Type,
87                           string VendorID,
88                           string URI,
89                           string Dist,
90                           string *Sections,
91                           unsigned short count, string SourceFile);
92   SourceRecord *AddEmptySource();
93   void RemoveSource(SourceRecord *&);
94   void SwapSources( SourceRecord *&, SourceRecord *& );
95   bool ReadSourcePart(string listpath);
96   bool ReadSourceDir(string Dir);
97   bool ReadSources();
98   bool UpdateSources();
99
100   VendorRecord *AddVendor(string VendorID,
101                           string FingerPrint, string Description);
102   void RemoveVendor(VendorRecord *&);
103   bool ReadVendors();
104   bool UpdateVendors();
105
106   SourcesList() {
107   };
108   ~SourcesList();
109};
110
111ostream &operator <<(ostream &, const SourcesList::SourceRecord &);
112
113#endif
Note: See TracBrowser for help on using the repository browser.