struct message * decode_ary_message(char * msg) { char *lptr = seekString(msg,CRLF); long length = asciiBytes2long(lptr); struct message * m = calloc(length,sizeof(struct message)); msg = msg+LENGTH_CRLF+(int)strlen(lptr); int i=0; for(;i<(int)length;i++) { if(msg[0] == INTEGER_MARKER) { m[i] = *decode_int_message(++msg); msg = msg+LENGTH_CRLF+getNumLength(*(int*)(m[i].data)); }else if(msg[0] == STRING_MARKER) { m[i] = *decode_ary_message(++msg); msg = msg+2*LENGTH_CRLF+strlen((char*)m[i].data)+getNumLength(m[1].capacity); } } m[i].data = NULL; free(lptr); return m; }
static uint32_t getCigarStringLength(uint8_t const * D, uint32_t ncigar) { uint32_t length = 0; uint32_t i; #if 0 static char const * opc = "MIDNSHP=X???????"; #endif for ( i = 0; i < ncigar; ++i, D+=4 ) { uint32_t const oppair = decodeUInt(D,4); uint32_t const len = (oppair>>4)&((1ul <<28)-1); #if 0 uint32_t const op = oppair & 0xF; uint8_t const c = op[opc]; #endif length += (1+getNumLength(len,10)); } return length; }