summaryrefslogtreecommitdiff
path: root/dpi/datauri.c
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2009-02-08 21:16:37 -0300
committerJorge Arellano Cid <jcid@dillo.org>2009-02-08 21:16:37 -0300
commit845493306279f446dbac9568a0a1e0f442e615dd (patch)
treedbf0a36e50a268b456760ce881a802d28979cc5f /dpi/datauri.c
parent283a7960e615b14c21b7ce757b0fcbe5c945bb95 (diff)
's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Diffstat (limited to 'dpi/datauri.c')
-rw-r--r--dpi/datauri.c113
1 files changed, 55 insertions, 58 deletions
diff --git a/dpi/datauri.c b/dpi/datauri.c
index 0165eba4..9d8fbcb7 100644
--- a/dpi/datauri.c
+++ b/dpi/datauri.c
@@ -39,63 +39,60 @@ static SockHandler *sh = NULL;
static int b64decode(unsigned char* str)
{
- unsigned char *cur, *start;
- int d, dlast, phase;
- unsigned char c;
- static int table[256] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
- 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
- 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
- -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
- 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
- };
-
- d = dlast = phase = 0;
- start = str;
- for (cur = str; *cur != '\0'; ++cur )
- {
- // jer: treat line endings as physical breaks.
- //if (*cur == '\n' || *cur == '\r'){phase = dlast = 0; continue;}
- d = table[(int)*cur];
- if(d != -1)
- {
- switch(phase)
- {
- case 0:
- ++phase;
- break;
- case 1:
- c = ((dlast << 2) | ((d & 0x30) >> 4));
- *str++ = c;
- ++phase;
- break;
- case 2:
- c = (((dlast & 0xf) << 4) | ((d & 0x3c) >> 2));
- *str++ = c;
- ++phase;
- break;
- case 3:
- c = (((dlast & 0x03 ) << 6) | d);
- *str++ = c;
- phase = 0;
- break;
- }
- dlast = d;
- }
- }
- *str = '\0';
- return str - start;
+ unsigned char *cur, *start;
+ int d, dlast, phase;
+ unsigned char c;
+ static int table[256] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
+ 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
+ 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
+ -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
+ 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
+ };
+
+ d = dlast = phase = 0;
+ start = str;
+ for (cur = str; *cur != '\0'; ++cur ) {
+ // jer: treat line endings as physical breaks.
+ //if (*cur == '\n' || *cur == '\r'){phase = dlast = 0; continue;}
+ d = table[(int)*cur];
+ if (d != -1) {
+ switch(phase) {
+ case 0:
+ ++phase;
+ break;
+ case 1:
+ c = ((dlast << 2) | ((d & 0x30) >> 4));
+ *str++ = c;
+ ++phase;
+ break;
+ case 2:
+ c = (((dlast & 0xf) << 4) | ((d & 0x3c) >> 2));
+ *str++ = c;
+ ++phase;
+ break;
+ case 3:
+ c = (((dlast & 0x03 ) << 6) | d);
+ *str++ = c;
+ phase = 0;
+ break;
+ }
+ dlast = d;
+ }
+ }
+ *str = '\0';
+ return str - start;
}
/* Modified from src/url.c --------------------------------------------------*/
@@ -113,7 +110,7 @@ static int Url_decode_hex_octet(const char *s)
hex[2] = 0;
hex_value = strtol(hex, &tail, 16);
if (tail - hex == 2)
- return hex_value;
+ return hex_value;
}
return -1;
}