|
a/upmpd/upmpdutils.cxx |
|
b/upmpd/upmpdutils.cxx |
|
... |
|
... |
314 |
<< "</res>"
|
314 |
<< "</res>"
|
315 |
<< "</item></DIDL-Lite>";
|
315 |
<< "</item></DIDL-Lite>";
|
316 |
return ss.str();
|
316 |
return ss.str();
|
317 |
}
|
317 |
}
|
318 |
|
318 |
|
319 |
bool sleepms(int ms)
|
|
|
320 |
{
|
|
|
321 |
struct timespec duration;
|
|
|
322 |
duration.tv_sec = ms/1000;
|
|
|
323 |
ms -= 1000 * duration.tv_sec;
|
|
|
324 |
duration.tv_nsec = ms * 1000 * 1000;
|
|
|
325 |
if (nanosleep(&duration, 0))
|
|
|
326 |
return false;
|
|
|
327 |
return true;
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
// Substitute regular expression
|
319 |
// Substitute regular expression
|
331 |
// The c++11 regex package does not seem really ready from prime time
|
320 |
// The c++11 regex package does not seem really ready from prime time
|
332 |
// (Tried on gcc + libstdc++ 4.7.2-5 on Debian, with little
|
321 |
// (Tried on gcc + libstdc++ 4.7.2-5 on Debian, with little
|
333 |
// joy). So...:
|
322 |
// joy). So...:
|
334 |
string regsub1(const string& sexp, const string& input, const string& repl)
|
323 |
string regsub1(const string& sexp, const string& input, const string& repl)
|
|
... |
|
... |
346 |
}
|
335 |
}
|
347 |
|
336 |
|
348 |
if ((err = regexec(&expr, input.c_str(), 10, pmatch, 0))) {
|
337 |
if ((err = regexec(&expr, input.c_str(), 10, pmatch, 0))) {
|
349 |
regerror(err, &expr, errbuf, ERRSIZE);
|
338 |
regerror(err, &expr, errbuf, ERRSIZE);
|
350 |
cerr << "upmpd: regsub1: regcomp() failed: " << errbuf << endl;
|
339 |
cerr << "upmpd: regsub1: regcomp() failed: " << errbuf << endl;
|
|
|
340 |
regfree(&expr);
|
351 |
return string();
|
341 |
return string();
|
352 |
}
|
342 |
}
|
353 |
if (pmatch[0].rm_so == -1) {
|
343 |
if (pmatch[0].rm_so == -1) {
|
354 |
// No match
|
344 |
// No match
|
|
|
345 |
regfree(&expr);
|
355 |
return input;
|
346 |
return input;
|
356 |
}
|
347 |
}
|
357 |
string out = input.substr(0, pmatch[0].rm_so);
|
348 |
string out = input.substr(0, pmatch[0].rm_so);
|
358 |
out += repl;
|
349 |
out += repl;
|
359 |
out += input.substr(pmatch[0].rm_eo);
|
350 |
out += input.substr(pmatch[0].rm_eo);
|
|
|
351 |
regfree(&expr);
|
360 |
return out;
|
352 |
return out;
|
361 |
}
|
353 |
}
|