4#include <zypp-core/base/Logger.h>
5#include <zypp-core/base/IOStream.h>
6#include <zypp-core/Pathname.h>
7#include <zypp-core/fs/PathInfo.h>
9#include <zypp-curl/CurlConfig>
31 char *home = getenv(
"HOME");
33 curlrcFile = std::string( home ) + std::string(
"/.curlrc" );
36 curlrcFile = filename;
44 MIL <<
"Going to parse " << curlrcFile << endl;
49 WAR <<
"Not allowed to parse '" << curlrcFile
50 <<
"': dir/file owner: " << h_info.
owner() <<
"/" << c_info.
owner()
51 <<
", process uid: " << getuid()
52 <<
" (" << (!getlogin_r(buf, 31) ? buf :
"") <<
")" << std::endl;
57 std::ifstream inp(curlrcFile.
c_str());
78 const char * beg = line.c_str();
79 const char * cur = beg;
82#define ISSEP(x) (((x)=='=') || ((x) == ':') || isspace(x))
85 while (*cur && *cur ==
'-')
90 while (*cur && !
ISSEP(*cur))
93 std::string option(beg, cur - beg);
96 while (*cur &&
ISSEP(*cur))
104 std::string value(beg, cur - beg);
106 DBG <<
"GOT: " << option << endl;
111 if (value[0] ==
'\"')
114 std::string::size_type pos = value.rfind(
'\"');
116 pos == value.size() - 1 && pos > 1 && value[pos-1] !=
'\\';
117 value = value.substr(1,
118 cut_last ? value.size() - 2 : value.size() - 1);
122 while ((pos = value.find(
'\\', pos)) != std::string::npos)
125 if (pos == value.size() - 1)
127 value = value.erase(pos, 1);
134 value = value.replace(pos, 2,
"\t");
137 value = value.replace(pos, 2,
"\n");
140 value = value.replace(pos, 2,
"\r");
143 value = value.replace(pos, 2,
"\v");
146 value = value.erase(pos++, 1);
149 value = value.erase(pos, 1);
170 const std::string & option,
171 const std::string & value)
173 if (option ==
"proxy-user")
178 DBG <<
"Ignoring option " << option << endl;
Wrapper class for stat/lstat.
Pathname dirname() const
Return all but the last component od this path.
const char * c_str() const
String representation.
Simple lineparser: Traverse each line in a file.
bool next()
Advance to next line.
std::string trim(const std::string &s, const Trim trim_r)
Easy-to use interface to the ZYPP dependency resolver.