static void write_unicode(GByteArray * bplist, gunichar2 * val, uint64_t size) { uint64_t i = 0; uint64_t size2 = size * sizeof(gunichar2); uint8_t *buff = (uint8_t *) malloc(size2); memcpy(buff, val, size2); for (i = 0; i < size; i++) byte_convert(buff + i * sizeof(gunichar2), sizeof(gunichar2)); write_raw_data(bplist, BPLIST_UNICODE, buff, size); }
int parse_dnskey(unsigned char *data, unsigned short data_len, char *output_buf, size_t output_buf_size) { unsigned short flags = parse_to_ushort(data); unsigned char protocol = *(data + 2); unsigned char algorithm = *(data + 3); int i = 0; int taken = 0; while (i < data_len - 4) { taken += write_raw_data(output_buf, output_buf_size, data + i + 4); ++i; } taken += write_endl(output_buf, output_buf_size); return taken; }
int parse_default(unsigned char *data, unsigned short data_len, char *output_buf, size_t output_buf_size) { int i = 0; if (data_len == 0) { return; } int taken = 0; while (i < data_len) { taken += write_raw_data(output_buf, output_buf_size, data + i); ++i; } taken += write_endl(output_buf, output_buf_size); return taken; }
int son_write_data(son_t * h, const char * key, const void * v, son_size_t size){ return write_raw_data(h, key, SON_DATA, v, size); }
int son_write_null(son_t * h, const char * key){ return write_raw_data(h, key, SON_NULL, 0, 0); }
int son_write_false(son_t * h, const char * key){ return write_raw_data(h, key, SON_FALSE, 0, 0); }
int son_write_true(son_t * h, const char * key){ return write_raw_data(h, key, SON_TRUE, 0, 0); }
int son_write_float(son_t * h, const char * key, float v){ return write_raw_data(h, key, SON_FLOAT, &v, sizeof(float)); }
int son_write_unum(son_t * h, const char * key, u32 v){ return write_raw_data(h, key, SON_NUMBER_U32, &v, sizeof(v)); }
int son_write_str(son_t * h, const char * key, const char * v){ //add one to the string length so that the zero terminator is saved return write_raw_data(h, key, SON_STRING, v, strlen(v)+1); }
static void write_string(GByteArray * bplist, char *val) { uint64_t size = strlen(val); write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size); }
static void write_data(GByteArray * bplist, uint8_t * val, uint64_t size) { write_raw_data(bplist, BPLIST_DATA, val, size); }