ptr<pub3::expr_t> msgpack_t::unpack_fix_map () { u_int8_t b; bool ok = get_byte (&b); assert (ok); // Strip off the top bit u_int8_t n = b ^ (0x80); return unpack_map (n); }
ptr<pub3::expr_t> msgpack_t::unpack_map16 () { consume_byte (); u_int16_t n; bool ok = unpack_int (&n); ptr<pub3::expr_t> ret; if (ok) { ret = unpack_map (n); } return ret; }
bool UNPACK_VALUE(serial_context *ser_cont, as_val **value) { int32_t type = READ_CHAR(ser_cont->fd, ser_cont->line_no, ser_cont->col_no, ser_cont->bytes); if (type == EOF) { err("Error while reading value type"); return false; } switch (type) { case 0xc0: // nil return unpack_nil(ser_cont, value); case 0xc3: // boolean true return unpack_boolean(ser_cont, true, value); case 0xc2: // boolean false return unpack_boolean(ser_cont, false, value); case 0xca: { // float float tmp; return extract_float(ser_cont, &tmp) && unpack_double(ser_cont, tmp, value); } case 0xcb: { // double double tmp; return extract_double(ser_cont, &tmp) && unpack_double(ser_cont, tmp, value); } case 0xd0: { // signed 8 bit integer int8_t tmp; return extract_uint8(ser_cont, (uint8_t *)&tmp) && unpack_integer(ser_cont, tmp, value); } case 0xcc: { // unsigned 8 bit integer uint8_t tmp; return extract_uint8(ser_cont, &tmp) && unpack_integer(ser_cont, tmp, value); } case 0xd1: { // signed 16 bit integer int16_t tmp; return extract_uint16(ser_cont, (uint16_t *)&tmp) && unpack_integer(ser_cont, tmp, value); } case 0xcd: { // unsigned 16 bit integer uint16_t tmp; return extract_uint16(ser_cont, &tmp) && unpack_integer(ser_cont, tmp, value); } case 0xd2: { // signed 32 bit integer int32_t tmp; return extract_uint32(ser_cont, (uint32_t *)&tmp) && unpack_integer(ser_cont, tmp, value); } case 0xce: { // unsigned 32 bit integer uint32_t tmp; return extract_uint32(ser_cont, &tmp) && unpack_integer(ser_cont, tmp, value); } case 0xd3: { // signed 64 bit integer int64_t tmp; return extract_uint64(ser_cont, (uint64_t *)&tmp) && unpack_integer(ser_cont, tmp, value); } case 0xcf: { // unsigned 64 bit integer uint64_t tmp; return extract_uint64(ser_cont, &tmp) && unpack_integer(ser_cont, (int64_t)tmp, value); } case 0xc4: case 0xd9: { // raw bytes with 8 bit header uint8_t size; return extract_uint8(ser_cont, &size) && unpack_blob(ser_cont, size, value); } case 0xc5: case 0xda: { // raw bytes with 16 bit header uint16_t size; return extract_uint16(ser_cont, &size) && unpack_blob(ser_cont, size, value); } case 0xc6: case 0xdb: { // raw bytes with 32 bit header uint32_t size; return extract_uint32(ser_cont, &size) && unpack_blob(ser_cont, size, value); } case 0xdc: { // list with 16 bit header uint16_t size; return extract_uint16(ser_cont, &size) && unpack_list(ser_cont, size, value); } case 0xdd: { // list with 32 bit header uint32_t size; return extract_uint32(ser_cont, &size) && unpack_list(ser_cont, size, value); } case 0xde: { // map with 16 bit header uint16_t size; return extract_uint16(ser_cont, &size) && unpack_map(ser_cont, size, value); } case 0xdf: { // map with 32 bit header uint32_t size; return extract_uint32(ser_cont, &size) && unpack_map(ser_cont, size, value); } default: if ((type & 0xe0) == 0xa0) { // raw bytes with 8 bit combined header return unpack_blob(ser_cont, type & 0x1f, value); } if ((type & 0xf0) == 0x80) { // map with 8 bit combined header return unpack_map(ser_cont, type & 0x0f, value); } if ((type & 0xf0) == 0x90) { // list with 8 bit combined header return unpack_list(ser_cont, type & 0x0f, value); } if (type < 0x80) { // 8 bit combined unsigned integer return unpack_integer(ser_cont, type, value); } if (type >= 0xe0) { // 8 bit combined signed integer return unpack_integer(ser_cont, type - 0xe0 - 32, value); } return false; } }