* fixed a problem when it comes to the cache rebuilding
[ntk/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 /*{{{*/
11#ifdef __GNUG__
12#pragma implementation "apt-pkg/indexfile.h"
13#endif
14
a52f938b 15#include <apt-pkg/configuration.h>
b2e465d6
AL
16#include <apt-pkg/indexfile.h>
17#include <apt-pkg/error.h>
a52f938b
OS
18
19#include <clocale>
b2e465d6
AL
20 /*}}}*/
21
22// Global list of Item supported
23static pkgIndexFile::Type *ItmList[10];
24pkgIndexFile::Type **pkgIndexFile::Type::GlobalList = ItmList;
25unsigned long pkgIndexFile::Type::GlobalListLen = 0;
26
27// Type::Type - Constructor /*{{{*/
28// ---------------------------------------------------------------------
29/* */
30pkgIndexFile::Type::Type()
31{
32 ItmList[GlobalListLen] = this;
33 GlobalListLen++;
34}
35 /*}}}*/
36// Type::GetType - Locate the type by name /*{{{*/
37// ---------------------------------------------------------------------
38/* */
39pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
40{
41 for (unsigned I = 0; I != GlobalListLen; I++)
42 if (strcmp(GlobalList[I]->Label,Type) == 0)
43 return GlobalList[I];
44 return 0;
45}
46 /*}}}*/
47
b2e465d6
AL
48// IndexFile::ArchiveInfo - Stub /*{{{*/
49// ---------------------------------------------------------------------
50/* */
51string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
52{
53 return string();
54}
55 /*}}}*/
56// IndexFile::FindInCache - Stub /*{{{*/
57// ---------------------------------------------------------------------
58/* */
59pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
60{
61 return pkgCache::PkgFileIterator(Cache);
62}
63 /*}}}*/
64// IndexFile::SourceIndex - Stub /*{{{*/
65// ---------------------------------------------------------------------
66/* */
67string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
68 pkgSrcRecords::File const &File) const
69{
70 return string();
71}
72 /*}}}*/
a52f938b
OS
73// IndexFile::UseTranslation - Check if will use Translation /*{{{*/
74// ---------------------------------------------------------------------
75/* */
76bool pkgIndexFile::UseTranslation()
77{
78 const string Translation = _config->Find("APT::Acquire::Translation");
79
80 if (Translation.compare("none") != 0)
81 return CheckLanguageCode(LanguageCode().c_str());
82 else
83 return false;
84}
85 /*}}}*/
86// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
87// ---------------------------------------------------------------------
88/* */
89bool pkgIndexFile::CheckLanguageCode(const char *Lang)
90{
91 if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
92 return true;
93
94 if (strcmp(Lang,"C") != 0)
95 _error->Warning("Wrong language code %s", Lang);
96
97 return false;
98}
99 /*}}}*/
100// IndexFile::LanguageCode - Return the Language Code /*{{{*/
101// ---------------------------------------------------------------------
102/* */
103string pkgIndexFile::LanguageCode()
104{
105 const string Translation = _config->Find("APT::Acquire::Translation");
106
107 if (Translation.compare("environment") == 0)
108 return std::setlocale(LC_ALL,NULL);
109 else
110 return Translation;
111}
112 /*}}}*/