Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
7db98ffc | 3 | // $Id: indexfile.cc,v 1.2.2.1 2003/12/24 23:09:17 mdz Exp $ |
b2e465d6 AL |
4 | /* ###################################################################### |
5 | ||
6 | Index File - Abstraction for an index of archive/souce file. | |
7 | ||
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
10 | // Include Files /*{{{*/ | |
ea542140 DK |
11 | #include<config.h> |
12 | ||
b2e465d6 AL |
13 | #include <apt-pkg/indexfile.h> |
14 | #include <apt-pkg/error.h> | |
45df0ad2 | 15 | #include <apt-pkg/aptconfiguration.h> |
a52f938b OS |
16 | |
17 | #include <clocale> | |
4f333a8b | 18 | #include <cstring> |
b2e465d6 AL |
19 | /*}}}*/ |
20 | ||
21 | // Global list of Item supported | |
22 | static pkgIndexFile::Type *ItmList[10]; | |
23 | pkgIndexFile::Type **pkgIndexFile::Type::GlobalList = ItmList; | |
24 | unsigned long pkgIndexFile::Type::GlobalListLen = 0; | |
25 | ||
26 | // Type::Type - Constructor /*{{{*/ | |
27 | // --------------------------------------------------------------------- | |
28 | /* */ | |
29 | pkgIndexFile::Type::Type() | |
30 | { | |
31 | ItmList[GlobalListLen] = this; | |
32 | GlobalListLen++; | |
33 | } | |
34 | /*}}}*/ | |
35 | // Type::GetType - Locate the type by name /*{{{*/ | |
36 | // --------------------------------------------------------------------- | |
37 | /* */ | |
38 | pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type) | |
39 | { | |
40 | for (unsigned I = 0; I != GlobalListLen; I++) | |
41 | if (strcmp(GlobalList[I]->Label,Type) == 0) | |
42 | return GlobalList[I]; | |
43 | return 0; | |
44 | } | |
45 | /*}}}*/ | |
b2e465d6 AL |
46 | // IndexFile::ArchiveInfo - Stub /*{{{*/ |
47 | // --------------------------------------------------------------------- | |
48 | /* */ | |
49 | string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const | |
50 | { | |
51 | return string(); | |
52 | } | |
53 | /*}}}*/ | |
54 | // IndexFile::FindInCache - Stub /*{{{*/ | |
55 | // --------------------------------------------------------------------- | |
56 | /* */ | |
57 | pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const | |
58 | { | |
59 | return pkgCache::PkgFileIterator(Cache); | |
60 | } | |
61 | /*}}}*/ | |
62 | // IndexFile::SourceIndex - Stub /*{{{*/ | |
63 | // --------------------------------------------------------------------- | |
64 | /* */ | |
65 | string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record, | |
66 | pkgSrcRecords::File const &File) const | |
67 | { | |
68 | return string(); | |
69 | } | |
70 | /*}}}*/ | |
45df0ad2 | 71 | // IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/ |
a52f938b OS |
72 | // --------------------------------------------------------------------- |
73 | /* */ | |
45df0ad2 DK |
74 | bool pkgIndexFile::TranslationsAvailable() { |
75 | return (APT::Configuration::getLanguages().empty() != true); | |
a52f938b OS |
76 | } |
77 | /*}}}*/ | |
45df0ad2 | 78 | // IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/ |
a52f938b | 79 | // --------------------------------------------------------------------- |
45df0ad2 DK |
80 | /* No intern need for this method anymore as the check for correctness |
81 | is already done in getLanguages(). Note also that this check is | |
82 | rather bad (doesn't take three character like ast into account). | |
83 | TODO: Remove method with next API break */ | |
84 | __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *Lang) | |
a52f938b OS |
85 | { |
86 | if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_')) | |
87 | return true; | |
88 | ||
89 | if (strcmp(Lang,"C") != 0) | |
90 | _error->Warning("Wrong language code %s", Lang); | |
91 | ||
92 | return false; | |
93 | } | |
94 | /*}}}*/ | |
45df0ad2 | 95 | // IndexFile::LanguageCode - Return the Language Code /*{{{*/ |
a52f938b | 96 | // --------------------------------------------------------------------- |
45df0ad2 DK |
97 | /* As we have now possibly more than one LanguageCode this method is |
98 | supersided by a) private classmembers or b) getLanguages(). | |
99 | TODO: Remove method with next API break */ | |
100 | __attribute__ ((deprecated)) string pkgIndexFile::LanguageCode() { | |
101 | if (TranslationsAvailable() == false) | |
102 | return ""; | |
103 | return APT::Configuration::getLanguages()[0]; | |
a52f938b OS |
104 | } |
105 | /*}}}*/ |