|
a/src/upmpdutils.cxx |
|
b/src/upmpdutils.cxx |
|
... |
|
... |
92 |
(void)strerror_r(_errno, errbuf, ERRBUFSZ);
|
92 |
(void)strerror_r(_errno, errbuf, ERRBUFSZ);
|
93 |
reason->append(errbuf);
|
93 |
reason->append(errbuf);
|
94 |
#endif
|
94 |
#endif
|
95 |
}
|
95 |
}
|
96 |
|
96 |
|
97 |
bool read_protocolinfo(const string& fn, string& out)
|
|
|
98 |
{
|
|
|
99 |
ifstream input;
|
|
|
100 |
input.open(fn, ios::in);
|
|
|
101 |
if (!input.is_open()) {
|
|
|
102 |
return false;
|
|
|
103 |
}
|
|
|
104 |
bool eof = false;
|
|
|
105 |
for (;;) {
|
|
|
106 |
string line;
|
|
|
107 |
getline(input, line);
|
|
|
108 |
if (!input.good()) {
|
|
|
109 |
if (input.bad()) {
|
|
|
110 |
return false;
|
|
|
111 |
}
|
|
|
112 |
// Must be eof ? But maybe we have a partial line which
|
|
|
113 |
// must be processed. This happens if the last line before
|
|
|
114 |
// eof ends with a backslash, or there is no final \n
|
|
|
115 |
eof = true;
|
|
|
116 |
}
|
|
|
117 |
trimstring(line, " \t\n\r");
|
|
|
118 |
if (line[0] == '#')
|
|
|
119 |
continue;
|
|
|
120 |
out += line;
|
|
|
121 |
if (eof)
|
|
|
122 |
break;
|
|
|
123 |
}
|
|
|
124 |
return true;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
bool file_to_string(const string &fn, string &data, string *reason)
|
97 |
bool file_to_string(const string &fn, string &data, string *reason)
|
128 |
{
|
98 |
{
|
129 |
const int RDBUFSZ = 4096;
|
99 |
const int RDBUFSZ = 4096;
|
130 |
bool ret = false;
|
100 |
bool ret = false;
|
131 |
int fd = -1;
|
101 |
int fd = -1;
|