#include <ctype.h>#include <inttypes.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>#include <talloc.h>#include <atalk/cnid.h>#include <atalk/directory.h>#include <atalk/errchk.h>#include <atalk/globals.h>#include <atalk/logger.h>#include <atalk/spotlight.h>#include <atalk/util.h>#include <atalk/volume.h>#include "etc/spotlight/spotlight_private.h"Data Structures | |
| struct | sl_cnid_query |
Macros | |
| #define | SL_CNID_MAX_RESULTS 10000 |
| #define | SL_CNID_MIN_TERMLEN 3 |
| #define | SL_CNID_PAGE_SIZE 20 |
| #define | SL_CNID_MAX_DEPTH 64 |
Functions | |
| static int | cnid_comp_fn (const void *p1, const void *p2) |
| static char * | sl_cnid_extract_term (TALLOC_CTX *mem_ctx, const char *qstring) |
| Extract a filename search term from a Spotlight query string. | |
| static char * | sl_cnid_to_path (TALLOC_CTX *mem_ctx, const struct vol *vol, 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_open_query (slq_t *slq) |
| static int | sl_cnid_fetch_results (slq_t *slq) |
| static void | sl_cnid_close_query (slq_t *slq) |
Variables | |
| const sl_backend_ops | sl_cnid_ops |
| #define SL_CNID_MAX_DEPTH 64 |
| #define SL_CNID_MAX_RESULTS 10000 |
| #define SL_CNID_MIN_TERMLEN 3 |
| #define SL_CNID_PAGE_SIZE 20 |
|
static |
|
static |
|
static |
|
static |
Extract a filename search term from a Spotlight query string.
Handles the common macOS patterns: kMDItemFSName = "foo*"cd → "foo" kMDItemDisplayName = "*foo*"cd → "foo" _kMDItemFileName = "foo*"cd → "foo"
Returns a talloc-allocated copy of the extracted term, or NULL if the query does not contain a supported filename predicate.
|
static |
|
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
|
static |
|
static |
Reconstruct the full filesystem path for a CNID.
Walks the DID chain upward via repeated cnid_resolve() calls, prepending path components, until reaching DIRDID_ROOT (the volume root).
| mem_ctx | talloc context for the returned string |
| vol | volume whose CNID database to query |
| cnid | network-byte-order CNID (as returned by cnid_find) |
| const sl_backend_ops sl_cnid_ops |