int count = talloc_array_length(array->dd_talloc_array);
int octets = (offset + SL_OFFSET_DELTA) / 8;
- LOG(log_maxdebug, logtype_sl, "sl_pack_array: count: %d, offset:%d, octets: %d", count, offset, octets);
-
SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_ARRAY, octets, count));
SLVAL(buf, offset, sl_pack_tag(SQ_TYPE_COMPLEX, 1, *toc_idx + 1));
*toc_idx += 1;
static int sl_pack_filemeta(sl_filemeta_t *fm, char *buf, int offset, char *toc_buf, int *toc_idx)
{
int fmlen; /* lenght of filemeta */
- int saveoff = offset + 8;
+ int saveoff = offset;
SLVAL(buf, offset, sl_pack_tag(SQ_TYPE_COMPLEX, 1, *toc_idx + 1));
offset += 16;
fmlen = sl_pack(fm, buf + offset);
offset += fmlen;
- SLVAL(buf, saveoff, sl_pack_tag(SQ_TYPE_DATA, (fmlen / 8) + 1, 8 /* unknown meaning, but always 8 */));
+ SLVAL(buf, saveoff + 8, sl_pack_tag(SQ_TYPE_DATA, (fmlen / 8) + 1, 8 /* unknown meaning, but always 8 */));
- SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_FILEMETA, (offset + SL_OFFSET_DELTA) / 8, fmlen / 8));
+ SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_FILEMETA, (saveoff + SL_OFFSET_DELTA) / 8, fmlen / 8));
*toc_idx += 1;
return offset;
}
-static int sl_pack_string(char **string, char *buf, int offset, char *toc_buf, int *toc_idx)
+static int sl_pack_string(char *s, char *buf, int offset, char *toc_buf, int *toc_idx)
{
int len, octets, used_in_last_octet;
- char *s = *string;
len = strlen(s);
octets = (len / 8) + (len & 7 ? 1 : 0);
used_in_last_octet = 8 - (octets * 8 - len);
- LOG(log_maxdebug, logtype_sl, "sl_pack_string(\"%s\"): len: %d, octets: %d, used_in_last_octet: %d",
- s, len, octets, used_in_last_octet);
-
SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_STRING, (offset + SL_OFFSET_DELTA) / 8, used_in_last_octet));
SLVAL(buf, offset, sl_pack_tag(SQ_TYPE_COMPLEX, 1, *toc_idx + 1));
*toc_idx += 1;
offset = sl_pack_array(query->dd_talloc_array[n], buf, offset, toc_buf, toc_idx);
} else if (STRCMP(type, ==, "sl_dict_t")) {
offset = sl_pack_dict(query->dd_talloc_array[n], buf, offset, toc_buf, toc_idx);
+ } else if (STRCMP(type, ==, "sl_filemeta_t")) {
+ offset = sl_pack_filemeta(query->dd_talloc_array[n], buf, offset, toc_buf, toc_idx);
} else if (STRCMP(type, ==, "uint64_t")) {
uint64_t i;
memcpy(&i, query->dd_talloc_array[n], sizeof(uint64_t));
i = 0;
while (i++ < count) {
query_data64 = sl_unpack_uint64(buf, offset, encoding);
- dalloc_add(query, &query_data64, uint64_t);
+ dalloc_add_copy(query, &query_data64, uint64_t);
offset += 8;
}
query_data64 = sl_unpack_uint64(buf, offset, encoding) >> 24;
t.tv_sec = query_data64 - SPOTLIGHT_TIME_DELTA;
t.tv_usec = 0;
- dalloc_add(query, &t, sl_time_t);
+ dalloc_add_copy(query, &t, sl_time_t);
offset += 8;
}
i = 0;
while (i++ < count) {
memcpy(uuid.sl_uuid, buf + offset, 16);
- dalloc_add(query, &uuid, sl_uuid_t);
+ dalloc_add_copy(query, &uuid, sl_uuid_t);
offset += 16;
}
ieee_fp_union.w[1] = RIVAL(buf, offset);
#endif
}
- dalloc_add(query, &ieee_fp_union.d, double);
+ dalloc_add_copy(query, &ieee_fp_union.d, double);
offset += 8;
}
EC_INIT;
int count;
uint64_t query_data64;
- sl_cnids_t cnids;
+ sl_cnids_t *cnids;
- EC_NULL( cnids.ca_cnids = talloc_zero(query, DALLOC_CTX) );
+ EC_NULL( cnids = talloc_zero(query, sl_cnids_t) );
+ EC_NULL( cnids->ca_cnids = talloc_zero(cnids, DALLOC_CTX) );
if (length <= 16)
/* that's permitted, it's an empty array */
query_data64 = sl_unpack_uint64(buf, offset, encoding);
count = query_data64 & 0xffff;
- cnids.ca_unkn1 = (query_data64 & 0xffff0000) >> 16;
- cnids.ca_context = query_data64 >> 32;
+ cnids->ca_unkn1 = (query_data64 & 0xffff0000) >> 16;
+ cnids->ca_context = query_data64 >> 32;
offset += 8;
while (count --) {
query_data64 = sl_unpack_uint64(buf, offset, encoding);
- dalloc_add(cnids.ca_cnids, &query_data64, uint64_t);
+ dalloc_add_copy(cnids->ca_cnids, &query_data64, uint64_t);
offset += 8;
}
- dalloc_add(query, &cnids, sl_cnids_t);
+ dalloc_add(query, cnids, sl_cnids_t);
EC_CLEANUP:
EC_EXIT;
slen = qlen - 8 + used_in_last_block;
if (cpx_query_type == SQ_CPX_TYPE_STRING) {
- p = talloc_strndup(query, buf + offset + 8, slen);
+ p = dalloc_strndup(query, buf + offset + 8, slen);
} else {
unicode_encoding = spotlight_get_utf16_string_encoding(buf, offset + 8, slen, encoding);
mark_exists = (unicode_encoding & SL_ENC_UTF_16);
EC_NEG1( convert_string_allocate(CH_UCS2, CH_UTF8, buf + offset + (mark_exists ? 18 : 16), slen, &p) );
}
- dalloc_add(query, &p, char *);
+ dalloc_add(query, p, char *);
roffset += qlen;
break;
EC_FAIL;
nil = 0;
for (i = 0; i < subcount; i++)
- dalloc_add(query, &nil, sl_nil_t);
+ dalloc_add_copy(query, &nil, sl_nil_t);
offset += query_length;
count -= subcount;
break;
case SQ_TYPE_BOOL:
b = query_data64 >> 32;
- dalloc_add(query, &b, sl_bool_t);
+ dalloc_add_copy(query, &b, sl_bool_t);
offset += query_length;
count--;
break;