]> git.saurik.com Git - apt.git/blame - apt-pkg/indexfile.cc
test/integration/test-ubuntu-bug-346386-apt-get-update-paywall: use downloadfile()
[apt.git] / apt-pkg / indexfile.cc
CommitLineData
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>
453b82a3
DK
16#include <apt-pkg/pkgcache.h>
17#include <apt-pkg/cacheiterators.h>
18#include <apt-pkg/srcrecords.h>
19#include <apt-pkg/macros.h>
a52f938b 20
453b82a3
DK
21#include <string>
22#include <vector>
a52f938b 23#include <clocale>
4f333a8b 24#include <cstring>
b2e465d6
AL
25 /*}}}*/
26
27// Global list of Item supported
28static pkgIndexFile::Type *ItmList[10];
29pkgIndexFile::Type **pkgIndexFile::Type::GlobalList = ItmList;
30unsigned long pkgIndexFile::Type::GlobalListLen = 0;
31
32// Type::Type - Constructor /*{{{*/
33// ---------------------------------------------------------------------
34/* */
35pkgIndexFile::Type::Type()
36{
37 ItmList[GlobalListLen] = this;
dd688285
DK
38 GlobalListLen++;
39 Label = NULL;
b2e465d6
AL
40}
41 /*}}}*/
42// Type::GetType - Locate the type by name /*{{{*/
43// ---------------------------------------------------------------------
44/* */
45pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
46{
47 for (unsigned I = 0; I != GlobalListLen; I++)
48 if (strcmp(GlobalList[I]->Label,Type) == 0)
49 return GlobalList[I];
50 return 0;
51}
52 /*}}}*/
b2e465d6
AL
53// IndexFile::ArchiveInfo - Stub /*{{{*/
54// ---------------------------------------------------------------------
55/* */
65512241 56std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator /*Ver*/) const
b2e465d6 57{
8f3ba4e8 58 return std::string();
b2e465d6
AL
59}
60 /*}}}*/
61// IndexFile::FindInCache - Stub /*{{{*/
62// ---------------------------------------------------------------------
63/* */
64pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
65{
66 return pkgCache::PkgFileIterator(Cache);
67}
68 /*}}}*/
69// IndexFile::SourceIndex - Stub /*{{{*/
70// ---------------------------------------------------------------------
71/* */
65512241
DK
72std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &/*Record*/,
73 pkgSrcRecords::File const &/*File*/) const
b2e465d6 74{
8f3ba4e8 75 return std::string();
b2e465d6
AL
76}
77 /*}}}*/
45df0ad2 78// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
a52f938b
OS
79// ---------------------------------------------------------------------
80/* */
45df0ad2
DK
81bool pkgIndexFile::TranslationsAvailable() {
82 return (APT::Configuration::getLanguages().empty() != true);
a52f938b
OS
83}
84 /*}}}*/
45df0ad2 85// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
a52f938b 86// ---------------------------------------------------------------------
45df0ad2
DK
87/* No intern need for this method anymore as the check for correctness
88 is already done in getLanguages(). Note also that this check is
89 rather bad (doesn't take three character like ast into account).
90 TODO: Remove method with next API break */
453b82a3 91APT_DEPRECATED bool pkgIndexFile::CheckLanguageCode(const char *Lang)
a52f938b
OS
92{
93 if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
94 return true;
95
96 if (strcmp(Lang,"C") != 0)
97 _error->Warning("Wrong language code %s", Lang);
98
99 return false;
100}
101 /*}}}*/
45df0ad2 102// IndexFile::LanguageCode - Return the Language Code /*{{{*/
a52f938b 103// ---------------------------------------------------------------------
45df0ad2
DK
104/* As we have now possibly more than one LanguageCode this method is
105 supersided by a) private classmembers or b) getLanguages().
106 TODO: Remove method with next API break */
453b82a3 107APT_DEPRECATED std::string pkgIndexFile::LanguageCode() {
45df0ad2
DK
108 if (TranslationsAvailable() == false)
109 return "";
110 return APT::Configuration::getLanguages()[0];
a52f938b
OS
111}
112 /*}}}*/