netatalk: spotlight_marshalling.c File Reference

netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
spotlight_marshalling.c File Reference
`#include <errno.h>`
`#include <math.h>`
`#include <inttypes.h>`
`#include <limits.h>`
`#include <stdbool.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <strings.h>`
`#include <talloc.h>`
`#include <atalk/byteorder.h>`
`#include <atalk/dalloc.h>`
`#include <atalk/dsi.h>`
`#include <atalk/errchk.h>`
`#include <atalk/logger.h>`
`#include <atalk/netatalk_conf.h>`
`#include <atalk/spotlight.h>`
`#include <atalk/util.h>`
`#include <atalk/volume.h>`

## Macros
#define | MAX_SLQ_DAT (DSI_DATASIZ - 64)
#define | MAX_SLQ_TOC 8192
#define | SPOTLIGHT_TIME_DELTA 978307200 /* Diff from UNIX epoch to Spotlight epoch */
#define | SQ_TYPE_NULL 0x0000
#define | SQ_TYPE_COMPLEX 0x0200
#define | SQ_TYPE_INT64 0x8400
#define | SQ_TYPE_BOOL 0x0100
#define | SQ_TYPE_FLOAT 0x8500
#define | SQ_TYPE_DATA 0x0700
#define | SQ_TYPE_CNIDS 0x8700
#define | SQ_TYPE_UUID 0x0e00
#define | SQ_TYPE_DATE 0x8600
#define | SQ_TYPE_TOC 0x8800
#define | SQ_CPX_TYPE_ARRAY 0x0a00
#define | SQ_CPX_TYPE_STRING 0x0c00
#define | SQ_CPX_TYPE_UTF16_STRING 0x1c00
#define | SQ_CPX_TYPE_DICT 0x0d00
#define | SQ_CPX_TYPE_CNIDS 0x1a00
#define | SQ_CPX_TYPE_FILEMETA 0x1b00
#define | SUBQ_SAFETY_LIM 20
#define | SL_OFFSET_DELTA 16

## Functions
static int | sl_pack_loop (DALLOC_CTX *query, char *buf, int offset, char *toc_buf, int *toc_idx)
static int | sl_unpack_loop (DALLOC_CTX *query, const char *buf, int offset, uint count, size_t buf_len, const uint toc_offset, uint toc_count, const uint encoding, int depth)
static int | sl_unpack_cpx (DALLOC_CTX *query, const char *buf, const int offset, uint cpx_query_type, uint cpx_query_count, size_t buf_len, const uint toc_offset, uint toc_count, const uint encoding, int depth)
static int | sl_unpack_r (DALLOC_CTX *query, const char *buf, size_t buf_len, int depth)
static int | sivalc (char *buf, off_t off, off_t maxoff, uint32_t val)
static int | slvalc (char *buf, off_t off, off_t maxoff, uint64_t val)
static uint | spotlight_get_utf16_string_encoding (const char *buf, int offset, int query_length, uint encoding)
| Returns the UTF-16 string encoding, by checking the 2-byte byte order mark.
static uint64_t | sl_pack_tag (uint16_t type, uint16_t size_or_count, uint32_t val)
static int | sl_pack_float (double d, char *buf, int offset)
static int | sl_pack_uint64 (uint64_t u, char *buf, int offset)
static int | sl_pack_bool (sl_bool_t bl, char *buf, int offset)
static int | sl_pack_nil (char *buf, int offset)
static int | sl_pack_date (sl_time_t t, char *buf, int offset)
static int | sl_pack_uuid (sl_uuid_t *uuid, char *buf, int offset)
static int | sl_pack_CNID (sl_cnids_t *cnids, char *buf, int offset, char *toc_buf, int *toc_idx)
static int | sl_pack_array (sl_array_t *array, char *buf, int offset, char *toc_buf, int *toc_idx)
static int | sl_pack_dict (sl_array_t *dict, char *buf, int offset, char *toc_buf, int *toc_idx)
static int | sl_pack_filemeta (sl_filemeta_t *fm, 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)
static bool | sl_unpack_range_valid (size_t buf_len, int offset, size_t length)
static uint64_t | sl_unpack_uint64 (const char *buf, int offset, uint encoding)
static int | sl_unpack_uint64_checked (const char *buf, size_t buf_len, int offset, uint encoding, uint64_t *value)
static int | sl_unpack_count (uint64_t query_data64, int query_length, size_t element_size, int *count)
static int | sl_unpack_ints (DALLOC_CTX *query, const char *buf, int offset, int query_length, size_t buf_len, uint encoding)
static int | sl_unpack_date (DALLOC_CTX *query, const char *buf, int offset, int query_length, size_t buf_len, uint encoding)
static int | sl_unpack_uuid (DALLOC_CTX *query, const char *buf, int offset, int query_length, size_t buf_len, uint encoding)
static int | sl_unpack_floats (DALLOC_CTX *query, const char *buf, int offset, int query_length, size_t buf_len, uint encoding)
static int | sl_unpack_CNID (DALLOC_CTX *query, const char *buf, int offset, int length, size_t buf_len, uint encoding)
static const char * | spotlight_get_qtype_string (uint64_t query_type)
static const char * | spotlight_get_cpx_qtype_string (uint64_t cpx_query_type)
int | sl_pack (DALLOC_CTX *query, char *buf)
int | sl_unpack (DALLOC_CTX *query, const char *buf)
int | sl_unpack_len (DALLOC_CTX *query, const char *buf, size_t buf_len)

## Macro Definition Documentation

## ◆ MAX_SLQ_DAT

#define MAX_SLQ_DAT (DSI_DATASIZ - 64)

## ◆ MAX_SLQ_TOC

#define MAX_SLQ_TOC 8192

## ◆ SL_OFFSET_DELTA

#define SL_OFFSET_DELTA 16

## ◆ SPOTLIGHT_TIME_DELTA

#define SPOTLIGHT_TIME_DELTA 978307200 /* Diff from UNIX epoch to Spotlight epoch */

## ◆ SQ_CPX_TYPE_ARRAY

#define SQ_CPX_TYPE_ARRAY 0x0a00

## ◆ SQ_CPX_TYPE_CNIDS

#define SQ_CPX_TYPE_CNIDS 0x1a00

## ◆ SQ_CPX_TYPE_DICT

#define SQ_CPX_TYPE_DICT 0x0d00

## ◆ SQ_CPX_TYPE_FILEMETA

#define SQ_CPX_TYPE_FILEMETA 0x1b00

## ◆ SQ_CPX_TYPE_STRING

#define SQ_CPX_TYPE_STRING 0x0c00

## ◆ SQ_CPX_TYPE_UTF16_STRING

#define SQ_CPX_TYPE_UTF16_STRING 0x1c00

## ◆ SQ_TYPE_BOOL

#define SQ_TYPE_BOOL 0x0100

## ◆ SQ_TYPE_CNIDS

#define SQ_TYPE_CNIDS 0x8700

## ◆ SQ_TYPE_COMPLEX

#define SQ_TYPE_COMPLEX 0x0200

## ◆ SQ_TYPE_DATA

#define SQ_TYPE_DATA 0x0700

## ◆ SQ_TYPE_DATE

#define SQ_TYPE_DATE 0x8600

## ◆ SQ_TYPE_FLOAT

#define SQ_TYPE_FLOAT 0x8500

## ◆ SQ_TYPE_INT64

#define SQ_TYPE_INT64 0x8400

## ◆ SQ_TYPE_NULL

#define SQ_TYPE_NULL 0x0000

## ◆ SQ_TYPE_TOC

#define SQ_TYPE_TOC 0x8800

## ◆ SQ_TYPE_UUID

#define SQ_TYPE_UUID 0x0e00

## ◆ SUBQ_SAFETY_LIM

#define SUBQ_SAFETY_LIM 20

## Function Documentation

## ◆ sivalc()

int sivalc | ( | char * | buf,
|  | off_t | off,
|  | off_t | maxoff,
|  | uint32_t | val )
| static

## ◆ sl_pack()

int sl_pack | ( | DALLOC_CTX * | query,
|  | char * | buf )

## ◆ sl_pack_array()

int sl_pack_array | ( | sl_array_t * | array,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_bool()

int sl_pack_bool | ( | sl_bool_t | bl,
|  | char * | buf,
|  | int | offset )
| static

## ◆ sl_pack_CNID()

int sl_pack_CNID | ( | sl_cnids_t * | cnids,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_date()

int sl_pack_date | ( | sl_time_t | t,
|  | char * | buf,
|  | int | offset )
| static

## ◆ sl_pack_dict()

int sl_pack_dict | ( | sl_array_t * | dict,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_filemeta()

int sl_pack_filemeta | ( | sl_filemeta_t * | fm,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_float()

int sl_pack_float | ( | double | d,
|  | char * | buf,
|  | int | offset )
| static

## ◆ sl_pack_loop()

int sl_pack_loop | ( | DALLOC_CTX * | query,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_nil()

int sl_pack_nil | ( | char * | buf,
|  | int | offset )
| static

## ◆ sl_pack_string()

int sl_pack_string | ( | char * | s,
|  | char * | buf,
|  | int | offset,
|  | char * | toc_buf,
|  | int * | toc_idx )
| static

## ◆ sl_pack_tag()

uint64_t sl_pack_tag | ( | uint16_t | type,
|  | uint16_t | size_or_count,
|  | uint32_t | val )
| static

## ◆ sl_pack_uint64()

int sl_pack_uint64 | ( | uint64_t | u,
|  | char * | buf,
|  | int | offset )
| static

## ◆ sl_pack_uuid()

int sl_pack_uuid | ( | sl_uuid_t * | uuid,
|  | char * | buf,
|  | int | offset )
| static

## ◆ sl_unpack()

int sl_unpack | ( | DALLOC_CTX * | query,
|  | const char * | buf )

## ◆ sl_unpack_CNID()

int sl_unpack_CNID | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | int | length,
|  | size_t | buf_len,
|  | uint | encoding )
| static

## ◆ sl_unpack_count()

int sl_unpack_count | ( | uint64_t | query_data64,
|  | int | query_length,
|  | size_t | element_size,
|  | int * | count )
| static

## ◆ sl_unpack_cpx()

int sl_unpack_cpx | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | const int | offset,
|  | uint | cpx_query_type,
|  | uint | cpx_query_count,
|  | size_t | buf_len,
|  | const uint | toc_offset,
|  | uint | toc_count,
|  | const uint | encoding,
|  | int | depth )
| static

## ◆ sl_unpack_date()

int sl_unpack_date | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | int | query_length,
|  | size_t | buf_len,
|  | uint | encoding )
| static

## ◆ sl_unpack_floats()

int sl_unpack_floats | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | int | query_length,
|  | size_t | buf_len,
|  | uint | encoding )
| static

## ◆ sl_unpack_ints()

int sl_unpack_ints | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | int | query_length,
|  | size_t | buf_len,
|  | uint | encoding )
| static

## ◆ sl_unpack_len()

int sl_unpack_len | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | size_t | buf_len )

## ◆ sl_unpack_loop()

int sl_unpack_loop | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | uint | count,
|  | size_t | buf_len,
|  | const uint | toc_offset,
|  | uint | toc_count,
|  | const uint | encoding,
|  | int | depth )
| static

## ◆ sl_unpack_r()

int sl_unpack_r | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | size_t | buf_len,
|  | int | depth )
| static

## ◆ sl_unpack_range_valid()

bool sl_unpack_range_valid | ( | size_t | buf_len,
|  | int | offset,
|  | size_t | length )
| static

## ◆ sl_unpack_uint64()

uint64_t sl_unpack_uint64 | ( | const char * | buf,
|  | int | offset,
|  | uint | encoding )
| static

## ◆ sl_unpack_uint64_checked()

int sl_unpack_uint64_checked | ( | const char * | buf,
|  | size_t | buf_len,
|  | int | offset,
|  | uint | encoding,
|  | uint64_t * | value )
| static

## ◆ sl_unpack_uuid()

int sl_unpack_uuid | ( | DALLOC_CTX * | query,
|  | const char * | buf,
|  | int | offset,
|  | int | query_length,
|  | size_t | buf_len,
|  | uint | encoding )
| static

## ◆ slvalc()

int slvalc | ( | char * | buf,
|  | off_t | off,
|  | off_t | maxoff,
|  | uint64_t | val )
| static

## ◆ spotlight_get_cpx_qtype_string()

const char * spotlight_get_cpx_qtype_string | ( | uint64_t | cpx_query_type | ) |
| static

## ◆ spotlight_get_qtype_string()

const char * spotlight_get_qtype_string | ( | uint64_t | query_type | ) |
| static

## ◆ spotlight_get_utf16_string_encoding()

uint spotlight_get_utf16_string_encoding | ( | const char * | buf,
|  | int | offset,
|  | int | query_length,
|  | uint | encoding )
| static

Returns the UTF-16 string encoding, by checking the 2-byte byte order mark.

Returns
  If there is no byte order mark, -1 is returned.