Commit 95f8ce91 authored by JP Dinger's avatar JP Dinger

Remove another extra base64 decoder.

parent e3790d5a
...@@ -24,68 +24,10 @@ ...@@ -24,68 +24,10 @@
*/ */
#include "real.h" #include "real.h"
#include "vlc_strings.h"
#define BUFLEN 32000 #define BUFLEN 32000
/* static inline char *nl(char *data) {
* Decodes base64 strings (based upon b64 package)
*/
static char *b64_decode(const char *in, char *out, int *size) {
char dtable[256]; /* Encode / decode table */
int i,k;
unsigned int j;
for( i = 0; i < 256; i++ )
dtable[i] = 0x80;
for( i = 'A'; i <= 'Z'; i++ )
dtable[i] = 0 + (i - 'A');
for( i = 'a'; i <= 'z'; i++ )
dtable[i] = 26 + (i - 'a');
for( i = '0'; i <= '9'; i++ )
dtable[i] = 52 + (i - '0');
dtable['+'] = 62;
dtable['/'] = 63;
dtable['='] = 0;
k=0;
/*CONSTANTCONDITION*/
int in_len = strlen(in);
for (j=0; j < in_len; j+=4) {
char a[4], b[4];
for (i = 0; i < 4 && j + i < in_len; i++) {
int c = in[i+j];
if (dtable[c] & 0x80) {
printf("Illegal character '%c' in input.\n", c);
exit(1);
}
a[i] = (char) c;
b[i] = (char) dtable[c];
}
//xine_buffer_ensure_size(out, k+3);
out[k++] = (b[0] << 2) | (b[1] >> 4);
out[k++] = (b[1] << 4) | (b[2] >> 2);
out[k++] = (b[2] << 6) | b[3];
i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
if (i < 3) {
out[k]=0;
*size=k;
return out;
}
}
out[k]=0;
*size=k;
return out;
}
static char *nl(char *data) {
char *nlptr = (data) ? strchr(data,'\n') : NULL; char *nlptr = (data) ? strchr(data,'\n') : NULL;
return (nlptr) ? nlptr + 1 : NULL; return (nlptr) ? nlptr + 1 : NULL;
} }
...@@ -198,8 +140,9 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { ...@@ -198,8 +140,9 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
*data=nl(*data); *data=nl(*data);
} }
if(filter(*data,"a=OpaqueData:buffer;",&buf, BUFLEN)) { if(filter(*data,"a=OpaqueData:buffer;",&buf, BUFLEN)) {
decoded = b64_decode(buf, decoded, &(desc->mlti_data_size)); desc->mlti_data_size =
if ( decoded != NULL ) { vlc_b64_decode_binary_to_buffer(decoded, BUFLEN, buf );
if ( desc->mlti_data_size ) {
desc->mlti_data = malloc(desc->mlti_data_size); desc->mlti_data = malloc(desc->mlti_data_size);
memcpy(desc->mlti_data, decoded, desc->mlti_data_size); memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
handled=1; handled=1;
...@@ -281,33 +224,29 @@ sdpplin_t *sdpplin_parse(char *data) ...@@ -281,33 +224,29 @@ sdpplin_t *sdpplin_parse(char *data)
continue; continue;
} }
if(filter(data,"a=Title:buffer;",&buf, BUFLEN)) { if(filter(data,"a=Title:buffer;",&buf, BUFLEN)) {
decoded=b64_decode(buf, decoded, &len); desc->title=vlc_b64_decode(buf);
if ( decoded != NULL ) { if(desc->title) {
desc->title=strdup(decoded);
handled=1; handled=1;
data=nl(data); data=nl(data);
} }
} }
if(filter(data,"a=Author:buffer;",&buf, BUFLEN)) { if(filter(data,"a=Author:buffer;",&buf, BUFLEN)) {
decoded=b64_decode(buf, decoded, &len); desc->author=vlc_b64_decode(buf);
if ( decoded != NULL ) { if(desc->author) {
desc->author=strdup(decoded);
handled=1; handled=1;
data=nl(data); data=nl(data);
} }
} }
if(filter(data,"a=Copyright:buffer;",&buf, BUFLEN)) { if(filter(data,"a=Copyright:buffer;",&buf, BUFLEN)) {
decoded=b64_decode(buf, decoded, &len); desc->copyright=vlc_b64_decode(buf);
if ( decoded != NULL ) { if(desc->copyright) {
desc->copyright=strdup(decoded);
handled=1; handled=1;
data=nl(data); data=nl(data);
} }
} }
if(filter(data,"a=Abstract:buffer;",&buf, BUFLEN)) { if(filter(data,"a=Abstract:buffer;",&buf, BUFLEN)) {
decoded=b64_decode(buf, decoded, &len); desc->abstract=vlc_b64_decode(buf);
if ( decoded != NULL ) { if(desc->abstract) {
desc->abstract=strdup(decoded);
handled=1; handled=1;
data=nl(data); data=nl(data);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment