* Many changes for TiVo support. It actually [kinda] works. :)

This commit is contained in:
Justin Maggard
2009-03-13 08:39:37 +00:00
parent 3ae378cdc9
commit 7a2e3ae67a
17 changed files with 713 additions and 543 deletions

View File

@ -1,29 +1,31 @@
#include "config.h"
#ifdef ENABLE_TIVO
#ifdef TIVO_SUPPORT
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* This function stolen from byRequest */
/* This function based on byRequest */
char *
decodeString(const char * string)
decodeString(char * string, int inplace)
{
if( !string )
return NULL;
int alloc = (int)strlen(string)+1;
char *ns = malloc(alloc);
char *ns;
unsigned char in;
int strindex=0;
long hex;
if( !ns )
return NULL;
if( !inplace )
{
if( !(ns = malloc(alloc)) )
return NULL;
}
while(--alloc > 0)
{
in = *string;
if(('%' == in) && isxdigit(string[1]) && isxdigit(string[2]))
if((in == '%') && isxdigit(string[1]) && isxdigit(string[2]))
{
/* this is two hexadecimal digits following a '%' */
char hexstr[3];
@ -35,14 +37,29 @@ decodeString(const char * string)
hex = strtol(hexstr, &ptr, 16);
in = (unsigned char)hex; /* this long is never bigger than 255 anyway */
string+=2;
if( inplace )
{
*string = in;
memmove(string+1, string+3, alloc-2);
}
else
{
string+=2;
}
alloc-=2;
}
ns[strindex++] = in;
if( !inplace )
ns[strindex++] = in;
string++;
}
ns[strindex]=0; /* terminate it */
return ns;
if( inplace )
{
return string;
}
else
{
ns[strindex] = '\0'; /* terminate it */
return ns;
}
}
#endif