* Add some preliminary code for the eventual possibility of TiVo support.

This commit is contained in:
Justin Maggard
2009-02-23 23:10:27 +00:00
parent 10136482af
commit 2da2f6d4a1
23 changed files with 530 additions and 59 deletions

47
tivo_utils.c Normal file
View File

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