16 #define MAX_TICK_ELAPSE 0x7FFFFFFF // Maximum elapse time you can set
29 static const int8_t MimeBase64[] = {
30 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
31 'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
32 'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
33 'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
34 'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
35 'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
36 'w',
'x',
'y',
'z',
'0',
'1',
'2',
'3',
37 '4',
'5',
'6',
'7',
'8',
'9',
'+',
'/'
41 static int32_t DecodeMimeBase64[256] = {
42 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
43 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
44 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
45 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
46 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
47 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
48 -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
49 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
50 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
51 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
52 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
53 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
54 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
55 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
56 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
57 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
88 while(*adbl && (*adbl)->
time <= time) {
89 adbl = &(*adbl)->
next;
125 if( (cb == NULL || (cb != NULL && ((*adbl)->cb == cb))) &&
126 (arg == -1 || (arg >= 0 && ((*adbl)->arg == arg))) )
130 DBGA(
"Del: CB(%p),ARG(%d)", (
void*)aptr->
cb, aptr->
arg);
133 }
else adbl = &(*adbl)->
next;
157 if( (cb == NULL || (cb != NULL && ((*adbl)->cb == cb))) &&
158 (arg == -1 || (arg >= 0 && ((*adbl)->arg == arg))) )
160 DBGA(
"Chk: CB(%p),ARG(%d)", (
void*)(*adbl)->cb, (*adbl)->arg);
163 adbl = &(*adbl)->
next;
208 for(i=0; i<255; i++) {
211 if(dgt == 0)
return len;
234 if(method == NULL || str == NULL || *str == 0)
238 if(!method((
int)*str))
return RET_NOK;
290 uint8_t *tp = (uint8_t*)buf;
292 uint16_t line = len / 0x10;
293 uint16_t left = len % 0x10;
296 LOG(
"===========================================================");
297 LOG(
"-ADDR----0--1--2--3--4--5--6--7----8--9--A--B--C--D--E--F--");
298 for(i=0; i<line; i++) {
299 LOGA(
"0x%04x %02x %02x %02x %02x %02x %02x %02x %02x"
300 " %02x %02x %02x %02x %02x %02x %02x %02x", 0x10*i,
301 tp[0x10*i+0x0], tp[0x10*i+0x1], tp[0x10*i+0x2], tp[0x10*i+0x3],
302 tp[0x10*i+0x4], tp[0x10*i+0x5], tp[0x10*i+0x6], tp[0x10*i+0x7],
303 tp[0x10*i+0x8], tp[0x10*i+0x9], tp[0x10*i+0xA], tp[0x10*i+0xB],
304 tp[0x10*i+0xC], tp[0x10*i+0xD], tp[0x10*i+0xE], tp[0x10*i+0xF]);
307 LOGFA(
"0x%04x ", 0x10*line);
308 for(i=0; i<left; i++)
LOGFA(
"%02x ", tp[0x10*line + i]);
311 LOG(
"===========================================================");
322 uint16_t sum, tsum, i, j;
328 for(i = 0; i < j; i++) {
341 sum = ~(sum + (lsum >> 16));
343 return (uint16_t)sum;
369 int32_t space_idx = 0, phase;
370 int32_t d, prev_d = 0;
376 for ( cp = text; *cp !=
'\0'; ++cp ) {
377 d = DecodeMimeBase64[(int32_t) *cp];
384 c = ( ( prev_d << 2 ) | ( ( d & 0x30 ) >> 4 ) );
385 if ( space_idx < numBytes )
386 dst[space_idx++] = c;
390 c = ( ( ( prev_d & 0xf ) << 4 ) | ( ( d & 0x3c ) >> 2 ) );
391 if ( space_idx < numBytes )
392 dst[space_idx++] = c;
396 c = ( ( ( prev_d & 0x03 ) << 6 ) | d );
397 if ( space_idx < numBytes )
398 dst[space_idx++] = c;
420 uint8_t input[3] = {0,0,0};
421 uint8_t output[4] = {0,0,0,0};
425 plen = text + numBytes - 1;
428 for (i = 0, p = text;p <= plen; i++, p++) {
432 if (index == 2 || p == plen) {
433 output[0] = ((input[0] & 0xFC) >> 2);
434 output[1] = ((input[0] & 0x3) << 4) | ((input[1] & 0xF0) >> 4);
435 output[2] = ((input[1] & 0xF) << 2) | ((input[2] & 0xC0) >> 6);
436 output[3] = (input[2] & 0x3F);
438 encodedText[j++] = MimeBase64[output[0]];
439 encodedText[j++] = MimeBase64[output[1]];
440 encodedText[j++] = index == 0?
'=' : MimeBase64[output[2]];
441 encodedText[j++] = index < 2?
'=' : MimeBase64[output[3]];
443 input[0] = input[1] = input[2] = 0;
447 encodedText[j] =
'\0';
454 #ifdef USE_FULL_ASSERT
461 void assert_failed(uint8_t* file, uint32_t line)