|
| static int | cnid_comp_fn (const void *p1, const void *p2) |
| |
| static int | cnid32_comp_fn (const void *p1, const void *p2) |
| |
| static char * | sl_cnid_quoted_value (TALLOC_CTX *mem_ctx, const char *p, const char **endp) |
| | Extract the quoted value starting at or after p
|
| |
| static bool | sl_cnid_add_term (char **terms, int *count, char *term) |
| |
| static int | sl_cnid_extract_terms (TALLOC_CTX *mem_ctx, const char *qstring, char **terms, int max_terms) |
| | Extract all filename search terms from a Spotlight query.
|
| |
| static const char * | sl_dcache_get (struct sl_cnid_query *csq, cnid_t did) |
| |
| static void | sl_dcache_put (struct sl_cnid_query *csq, cnid_t did, const char *path) |
| |
| static char * | sl_cnid_to_path (TALLOC_CTX *mem_ctx, const struct vol *vol, struct sl_cnid_query *csq, cnid_t cnid) |
| | Reconstruct the full filesystem path for a CNID.
|
| |
| static int | sl_cnid_init (AFPObj *obj) |
| |
| static void | sl_cnid_close (AFPObj *obj) |
| |
| static int | sl_cnid_fill_results (slq_t *slq) |
| | Emit up to SL_CNID_PAGE_SIZE results from the private CNID buffer.
|
| |
| static int | sl_cnid_cap_for (uint64_t want, int nterms) |
| |
| static int | sl_cnid_collect (slq_t *slq, struct sl_cnid_query *csq, char **terms, int nterms, cnid_t scope_did) |
| | Search every term into the candidate buffer and deduplicate.
|
| |
| static bool | sl_cnid_scope_is_vol_root (const char *scope, const char *vol_path) |
| |
| static int | sl_cnid_open_query (slq_t *slq) |
| |
| static int | sl_cnid_fetch_results (slq_t *slq) |
| |
| static void | sl_cnid_close_query (slq_t *slq) |
| |
Search every term into the candidate buffer and deduplicate.
Finder joins one predicate per typed word with ||, so the terms are alternatives: one cnid_find() per term into the shared buffer, then a sort and unique pass because a name can match more than one term. Each call's slice is kept a multiple of CNID_FIND_MIN_RESULTS so the DBD pagination loop fills complete batches.
Restartable: count and the truncation flag are reset on entry so the caller can re-run against a grown buffer.
- Returns
- 0 on success, -1 when a backend search failed
| static int sl_cnid_extract_terms |
( |
TALLOC_CTX * |
mem_ctx, |
|
|
const char * |
qstring, |
|
|
char ** |
terms, |
|
|
int |
max_terms |
|
) |
| |
|
static |
Extract all filename search terms from a Spotlight query.
Handles the common macOS patterns: kMDItemFSName = "foo*"cd → "foo" kMDItemDisplayName = "*foo*"cd → "foo" _kMDItemFileName = "foo*"cd → "foo" *=="foo*"cdw → "foo"
Finder splits a multi-word search into one predicate per word joined with ||, so every extracted term contributes to the result set. Named filename attributes take precedence; the *== "any attribute" form is scanned only when no named attribute matched. Duplicate terms are collapsed.
- Returns
- the number of talloc'd terms stored in
terms
| static int sl_cnid_fill_results |
( |
slq_t * |
slq | ) |
|
|
static |
Emit up to SL_CNID_PAGE_SIZE results from the private CNID buffer.
Iterates over the remaining entries in csq->cnids[csq->pos..csq->count-1], resolving each CNID to a filesystem path and adding it to query_results. Stops after SL_CNID_PAGE_SIZE accepted results or when the buffer is exhausted, whichever comes first.
Sets slq_state to: SLQ_STATE_FULL — page is full, more results remain; client must poll SLQ_STATE_DONE — all results have been delivered SLQ_STATE_ERROR — add_filemeta() failed
- Returns
- 0 on success, -1 on error