diff options
Diffstat (limited to 'src/bplist.c')
| -rw-r--r-- | src/bplist.c | 27 | 
1 files changed, 25 insertions, 2 deletions
| diff --git a/src/bplist.c b/src/bplist.c index d1694b9..c4b2e13 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -212,6 +212,12 @@ static plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)      case sizeof(uint64_t):          memcpy(&data->intval, bnode, size);          data->intval = UINT_TO_HOST(&data->intval, size); +        data->length = sizeof(uint64_t); +        break; +    case 16: +        memcpy(&data->intval, bnode+8, sizeof(uint64_t)); +        data->intval = UINT_TO_HOST(&data->intval, sizeof(uint64_t)); +        data->length = size;          break;      default:          free(data); @@ -220,7 +226,6 @@ static plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)      *next_object = bnode + size;      data->type = PLIST_UINT; -    data->length = sizeof(uint64_t);      return node_create(NULL, data);  } @@ -833,6 +838,20 @@ static void write_int(bytearray_t * bplist, uint64_t val)      free(buff);  } +static void write_uint(bytearray_t * bplist, uint64_t val) +{ +    uint64_t size = 16; +    uint8_t *buff = NULL; + +    buff = (uint8_t *) malloc(sizeof(uint8_t) + size); +    buff[0] = BPLIST_UINT | 4; +    memset(buff + 1, '\0', 8); +    memcpy(buff + 9, &val, 8); +    byte_convert(buff + 9, 8); +    byte_array_append(bplist, buff, sizeof(uint8_t) + size); +    free(buff); +} +  static void write_real(bytearray_t * bplist, double val)  {      uint64_t size = get_real_bytes(val);	//cheat to know used space @@ -1143,7 +1162,11 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)              break;          case PLIST_UINT: -            write_int(bplist_buff, data->intval); +            if (data->length == 16) { +                write_uint(bplist_buff, data->intval); +            } else { +                write_int(bplist_buff, data->intval); +            }              break;          case PLIST_REAL: | 
