Hi Slawomir, On Fri, Jan 13, 2012 at 12:48 PM, Slawomir Bochenski <lkslawek@xxxxxxxxx> wrote: > + switch (ap_defs[tago].type) { > + case APT_UINT8: > + if (hdr->len != 1) { > + DBG("Value of tag %s (%d) is %d bytes long " > + "instead of expected 1 byte - " > + "skipped!", ap_defs[tago].name, > + hdr->tag, hdr->len); > + break; > + } > + > + map_ap_set_u8(ap, hdr->tag, hdr->val[0]); > + > + break; > + case APT_UINT16: > + if (hdr->len != 2) { > + DBG("Value of tag %s (%d) is %d bytes long " > + "instead of expected 2 bytes - " > + "skipped!", ap_defs[tago].name, > + hdr->tag, hdr->len); > + break; > + } > + > + memcpy(&val16, hdr->val, sizeof(val16)); > + map_ap_set_u16(ap, hdr->tag, GUINT16_FROM_BE(val16)); > + > + break; > + case APT_UINT32: > + if (hdr->len != 4) { > + DBG("Value of tag %s (%d) is %d bytes long " > + "instead of expected 4 bytes - " > + "skipped!", ap_defs[tago].name, > + hdr->tag, hdr->len); > + break; > + } > + > + memcpy(&val32, hdr->val, sizeof(val32)); > + map_ap_set_u32(ap, hdr->tag, GUINT32_FROM_BE(val32)); > + > + break; > + case APT_STR: > + valstr = g_malloc0(hdr->len + 1); > + memcpy(valstr, hdr->val, hdr->len); > + map_ap_set_string(ap, hdr->tag, valstr); > + g_free(valstr); > + > + break; > + } Perhaps this parts can be integrated directly in their respective map_ap_set_* functions or if you are planing to reuse them not only for decoding then you can use dedicated decoder function e.g. map_ap_decode_u8. -- Luiz Augusto von Dentz ÿôèº{.nÇ+?·?®??+%?Ëÿ±éݶ¥?wÿº{.nÇ+?·¥?{±ý¹nzÚ(¶â?Ø^n?r¡ö¦zË?ëh?¨èÚ&£ûàz¿äz¹Þ?ú+?Ê+zf£¢·h??§~??Ûiÿÿï?êÿ?êçz_è®æj:+v?¨þ)ߣøm