db/upnp: pass unsigned integers to readDirSlice()

This commit is contained in:
Max Kellermann 2014-01-22 20:44:24 +01:00
parent 714056f157
commit f363788d76
2 changed files with 17 additions and 17 deletions

View File

@ -71,15 +71,15 @@ ReadResultTag(UPnPDirContent &dirbuf, IXML_Document *response, Error &error)
inline bool inline bool
ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl, ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
const char *objectId, int offset, const char *objectId, unsigned offset,
int count, UPnPDirContent &dirbuf, unsigned count, UPnPDirContent &dirbuf,
int *didreadp, int *totalp, unsigned &didreadp, unsigned &totalp,
Error &error) Error &error)
{ {
// Create request // Create request
char ofbuf[100], cntbuf[100]; char ofbuf[100], cntbuf[100];
sprintf(ofbuf, "%d", offset); sprintf(ofbuf, "%u", offset);
sprintf(cntbuf, "%d", count); sprintf(cntbuf, "%u", count);
// Some devices require an empty SortCriteria, else bad params // Some devices require an empty SortCriteria, else bad params
IXML_Document *request = IXML_Document *request =
MakeActionHelper("Browse", m_serviceType.c_str(), MakeActionHelper("Browse", m_serviceType.c_str(),
@ -112,7 +112,7 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
if (value != nullptr) if (value != nullptr)
didread = atoi(value); didread = atoi(value);
if (count == -1 || count == 0) { if (count == 0) {
// TODO: what's this? // TODO: what's this?
error.Set(upnp_domain, "got -1 or 0 entries"); error.Set(upnp_domain, "got -1 or 0 entries");
return false; return false;
@ -120,12 +120,12 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
value = ixmlwrap::getFirstElementValue(response, "TotalMatches"); value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
if (value != nullptr) if (value != nullptr)
*totalp = atoi(value); totalp = atoi(value);
if (!ReadResultTag(dirbuf, response, error)) if (!ReadResultTag(dirbuf, response, error))
return false; return false;
*didreadp = didread; didreadp = didread;
return true; return true;
} }
@ -135,13 +135,13 @@ ContentDirectoryService::readDir(UpnpClient_Handle handle,
UPnPDirContent &dirbuf, UPnPDirContent &dirbuf,
Error &error) Error &error)
{ {
int offset = 0; unsigned offset = 0;
int total = 1000;// Updated on first read. unsigned total = 1000;// Updated on first read.
while (offset < total) { while (offset < total) {
int count; unsigned count;
if (!readDirSlice(handle, objectId, offset, m_rdreqcnt, dirbuf, if (!readDirSlice(handle, objectId, offset, m_rdreqcnt, dirbuf,
&count, &total, error)) count, total, error))
return false; return false;
offset += count; offset += count;
@ -157,8 +157,8 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
UPnPDirContent &dirbuf, UPnPDirContent &dirbuf,
Error &error) Error &error)
{ {
int offset = 0; unsigned offset = 0;
int total = 1000;// Updated on first read. unsigned total = 1000;// Updated on first read.
while (offset < total) { while (offset < total) {
char ofbuf[100]; char ofbuf[100];

View File

@ -78,9 +78,9 @@ public:
Error &error); Error &error);
bool readDirSlice(UpnpClient_Handle handle, bool readDirSlice(UpnpClient_Handle handle,
const char *objectId, int offset, const char *objectId, unsigned offset,
int count, UPnPDirContent& dirbuf, unsigned count, UPnPDirContent& dirbuf,
int *didread, int *total, unsigned &didread, unsigned &total,
Error &error); Error &error);
/** Search the content directory service. /** Search the content directory service.