Switch to unified view

a/upmpd/upmpdutils.cxx b/upmpd/upmpdutils.cxx
...
...
42
42
43
#include "mpdcli.hxx"
43
#include "mpdcli.hxx"
44
#include "upmpdutils.hxx"
44
#include "upmpdutils.hxx"
45
#include "libupnpp/log.hxx"
45
#include "libupnpp/log.hxx"
46
#include "libupnpp/soaphelp.hxx"
46
#include "libupnpp/soaphelp.hxx"
47
#include "libupnpp/upnpavutils.hxx"
47
48
48
// Append system error string to input string
49
// Append system error string to input string
49
void catstrerror(string *reason, const char *what, int _errno)
50
void catstrerror(string *reason, const char *what, int _errno)
50
{
51
{
51
    if (!reason)
52
    if (!reason)
...
...
289
    int percent = floor(sqrt(vol * 10000.0));
290
    int percent = floor(sqrt(vol * 10000.0));
290
    if (percent < 0)    percent = 0;
291
    if (percent < 0)    percent = 0;
291
    if (percent > 100)  percent = 100;
292
    if (percent > 100)  percent = 100;
292
    return percent;
293
    return percent;
293
}
294
}
294
// Format duration in milliseconds into UPnP duration format
295
string upnpduration(int ms)
296
{
297
    int hours = ms / (3600 * 1000);
298
    ms -= hours * 3600 * 1000;
299
    int minutes = ms / (60 * 1000);
300
    ms -= minutes * 60 * 1000;
301
    int secs = ms / 1000;
302
    ms -= secs * 1000;
303
304
    char cbuf[100];
305
306
    // This is the format from the ref doc, but it appears that the
307
    // decimal part in the seconds field is an issue with some control
308
    // points. So drop it...
309
    //  sprintf(cbuf, "%d:%02d:%02d.%03d", hours, minutes, secs, ms);
310
    sprintf(cbuf, "%d:%02d:%02d", hours, minutes, secs);
311
    return cbuf;
312
}
313
314
// H:M:S to seconds
315
int upnpdurationtos(const string& dur)
316
{
317
    int hours, minutes, seconds;
318
    if (sscanf(dur.c_str(), "%d:%d:%d", &hours, &minutes, &seconds) != 3) {
319
  return 0;
320
    }
321
    return 3600 * hours + 60 * minutes + seconds;
322
}
323
295
324
// Get from ssl unordered_map, return empty string for non-existing
296
// Get from ssl unordered_map, return empty string for non-existing
325
// key (so this only works for data where this behaviour makes sense).
297
// key (so this only works for data where this behaviour makes sense).
326
const string& mapget(const unordered_map<string, string>& im, const string& k)
298
const string& mapget(const unordered_map<string, string>& im, const string& k)
327
{
299
{