* Make UPnPSearch using the "contains" keyword work properly with substring searches.

This commit is contained in:
Justin Maggard 2009-11-19 02:34:36 +00:00
parent 1549254753
commit 808fc6f459
2 changed files with 11 additions and 4 deletions

View File

@ -1122,7 +1122,7 @@ SearchContentDirectory(struct upnphttp * h, const char * action)
SearchCriteria = modifyString(SearchCriteria, "'", "'", 0);
SearchCriteria = modifyString(SearchCriteria, "object.", "", 0);
SearchCriteria = modifyString(SearchCriteria, "derivedfrom", "glob", 1);
SearchCriteria = modifyString(SearchCriteria, "contains", "glob", 1);
SearchCriteria = modifyString(SearchCriteria, "contains", "glob", 2);
SearchCriteria = modifyString(SearchCriteria, "dc:title", "d.TITLE", 0);
SearchCriteria = modifyString(SearchCriteria, "dc:creator", "d.CREATOR", 0);
SearchCriteria = modifyString(SearchCriteria, "upnp:class", "o.CLASS", 0);

13
utils.c
View File

@ -89,7 +89,7 @@ modifyString(char * string, const char * before, const char * after, short like)
oldlen = strlen(before);
newlen = strlen(after);
if( newlen > oldlen )
if( newlen+like > oldlen )
{
s = string;
while( (p = strstr(s, before)) )
@ -114,10 +114,17 @@ modifyString(char * string, const char * before, const char * after, short like)
while( isspace(*t) )
t++;
if( *t == '"' )
{
if( like == 2 )
{
memmove(t+2, t+1, strlen(t+1)+1);
*++t = '*';
}
while( *++t != '"' )
continue;
memmove(t+1, t, strlen(t)+1);
*t = '*';
memmove(t+1, t, strlen(t)+1);
*t = '*';
}
}
s = p + newlen;
}