libzypp
12.16.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
User data as transaction id
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
media
misc
parser
plaindir
susetags
ws
xml
yum
HistoryLogReader.cc
HistoryLogReader.h
IniDict.cc
IniDict.h
IniParser.cc
IniParser.h
ParseException.cc
ParseException.h
ParserProgress.h
ProductFileReader.cc
ProductFileReader.h
RepoFileReader.cc
RepoFileReader.h
RepoindexFileReader.cc
RepoindexFileReader.h
ServiceFileReader.cc
ServiceFileReader.h
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
RepoFileReader.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <iostream>
13
#include "
zypp/base/Logger.h
"
14
#include "
zypp/base/String.h
"
15
#include "
zypp/base/Regex.h
"
16
#include "
zypp/base/InputStream.h
"
17
#include "
zypp/base/UserRequestException.h
"
18
19
#include "
zypp/parser/IniDict.h
"
20
#include "
zypp/parser/RepoFileReader.h
"
21
22
using
std::endl;
23
using
zypp::parser::IniDict
;
24
26
namespace
zypp
27
{
28
29
namespace
parser
30
{
31
36
static
void
repositories_in_stream
(
const
InputStream
&is,
37
const
RepoFileReader::ProcessRepo
&callback,
38
const
ProgressData::ReceiverFnc
&progress )
39
{
40
parser::IniDict
dict(is);
41
for
(
parser::IniDict::section_const_iterator
its = dict.
sectionsBegin
();
42
its != dict.
sectionsEnd
();
43
++its )
44
{
45
RepoInfo
info;
46
info.
setAlias
(*its);
47
Url
url
;
48
49
for
(
IniDict::entry_const_iterator
it = dict.
entriesBegin
(*its);
50
it != dict.
entriesEnd
(*its);
51
++it )
52
{
53
//MIL << (*it).first << endl;
54
if
(it->first ==
"name"
)
55
info.
setName
(it-> second);
56
else
if
( it->first ==
"enabled"
)
57
info.
setEnabled
(
str::strToTrue
( it->second ) );
58
else
if
( it->first ==
"priority"
)
59
info.
setPriority
( str::strtonum<unsigned>( it->second ) );
60
else
if
( it->first ==
"baseurl"
&& !it->second.empty())
61
url = it->second;
62
else
if ( it->first ==
"path"
)
63
info.
setPath
( Pathname(it->second) );
64
else
if
( it->first ==
"type"
)
65
info.
setType
(
repo::RepoType
(it->second));
66
else
if
( it->first ==
"autorefresh"
)
67
info.
setAutorefresh
(
str::strToTrue
( it->second ) );
68
else
if
( it->first ==
"mirrorlist"
&& !it->second.empty())
69
info.
setMirrorListUrl
(
Url
(it->second));
70
else
if
( it->first ==
"gpgkey"
&& !it->second.empty())
71
{
72
std::vector<std::string> keys;
73
str::split
( it->second, std::back_inserter(keys) );
74
if
( ! keys.empty() )
75
info.
setGpgKeyUrl
(
Url
(*keys.begin()) );
76
}
77
else
if
( it->first ==
"gpgcheck"
)
78
info.
setGpgCheck
(
str::strToTrue
( it->second ) );
79
else
if
( it->first ==
"keeppackages"
)
80
info.
setKeepPackages
(
str::strToTrue
( it->second ) );
81
else
if
( it->first ==
"service"
)
82
info.
setService
( it->second );
83
else
if
( it->first ==
"proxy"
)
84
{
85
if
(it->second !=
"_none_"
)
86
{
87
str::regex
ex(
"^(.*):([0-9]+)$"
);
88
str::smatch
what;
89
if
(
str::regex_match
(it->second, what, ex)){
90
url.
setQueryParam
(
"proxy"
, what[1]);
91
url.
setQueryParam
(
"proxyport"
, what[2]);
92
}
93
}
94
}
else
95
ERR
<<
"Unknown attribute in ["
<< *its <<
"]: "
<< it->second <<
" ignored"
<< endl;
96
}
97
if
(url.
isValid
())
98
info.
addBaseUrl
(url);
99
info.
setFilepath
(is.
path
());
100
MIL
<< info << endl;
101
// add it to the list.
102
callback(info);
103
//if (!progress.tick())
104
// ZYPP_THROW(AbortRequestException());
105
}
106
}
107
109
//
110
// CLASS NAME : RepoFileReader
111
//
113
114
RepoFileReader::RepoFileReader
(
const
Pathname & repo_file,
115
const
ProcessRepo
& callback,
116
const
ProgressData::ReceiverFnc
&progress )
117
: _callback(callback)
118
{
119
repositories_in_stream
(
InputStream
(repo_file),
_callback
, progress);
120
}
121
122
RepoFileReader::RepoFileReader
(
const
InputStream
&is,
123
const
ProcessRepo
& callback,
124
const
ProgressData::ReceiverFnc
&progress )
125
: _callback(callback)
126
{
127
repositories_in_stream
(is,
_callback
, progress);
128
}
129
130
RepoFileReader::~RepoFileReader
()
131
{}
132
133
134
std::ostream &
operator<<
( std::ostream & str,
const
RepoFileReader
& obj )
135
{
136
return
str;
137
}
138
140
}
// namespace parser
143
}
// namespace zypp
zypp
parser
RepoFileReader.cc
Generated by
1.8.2