netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
spotlight.c File Reference
`#include <errno.h>`
`#include <inttypes.h>`
`#include <stdbool.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <strings.h>`
`#include <time.h>`
`#include <utime.h>`
`#include <talloc.h>`
`#include <atalk/byteorder.h>`
`#include <atalk/compat.h>`
`#include <atalk/dalloc.h>`
`#include <atalk/errchk.h>`
`#include <atalk/iniparser_util.h>`
`#include <atalk/list.h>`
`#include <atalk/logger.h>`
`#include <atalk/netatalk_conf.h>`
`#include <atalk/spotlight.h>`
`#include <atalk/util.h>`
`#include <atalk/volume.h>`
`#include "directory.h"`
`#include "etc/spotlight/spotlight_private.h"`

## Data Structures
struct | slq_state_names

## Macros
#define | USE_LIST
#define | MAX_SL_RESULTS 20
#define | MAX_SL_QUERY_IDLE_TIME_ACTIVE 60
#define | MAX_SL_QUERY_IDLE_TIME_TERMINAL 300

## Functions
static int | cnid_comp_fn (const void *p1, const void *p2)
static bool | create_result_handle (slq_t *slq)
static char * | tab_level (TALLOC_CTX *mem_ctx, int level)
int | sl_index_event (const AFPObj *obj, const struct vol *vol, sl_index_event_t event, const char *path, const char *oldpath)
static char * | dd_dump (DALLOC_CTX *dd, int nestinglevel)
static int | sl_createCNIDArray (slq_t *slq, const DALLOC_CTX *p)
bool | add_filemeta (sl_array_t *reqinfo, sl_array_t *fm_array, const char *path, const struct stat *sp)
| Add requested metadata for a query result element.
static bool | add_results (sl_array_t *array, slq_t *slq)
static | ATALK_LIST_HEAD (sl_queries)
static | ATALK_LIST_HEAD (sl_cancelled_queries)
static void | slq_add (slq_t *slq)
static void | slq_cancelled_add (slq_t *slq)
static void | slq_remove (slq_t *slq)
static slq_t * | slq_for_ctx (uint64_t ctx1, uint64_t ctx2)
static void | slq_destroy (slq_t *slq)
static void | slq_cancel (slq_t *slq)
static void | slq_cancelled_cleanup (void)
static void | slq_idle_cleanup (void)
static void | slq_dump (void)
static int | sl_rpc_fetchPropertiesForContext (const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *v)
static int | sl_rpc_openQuery (AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, struct vol *v)
static int | sl_rpc_fetchQueryResultsForContext (const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *v)
static int | sl_rpc_storeAttributesForOIDArray (const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *vol)
static int | sl_rpc_fetchAttributeNamesForOIDArray (const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *vol)
static int | sl_rpc_fetchAttributesForOIDArray (AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *vol)
static int | sl_rpc_closeQueryForContext (const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *v)
int | afp_spotlight_rpc (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)

## Variables
static struct slq_state_names | slq_state_names []

## Macro Definition Documentation

## ◆ MAX_SL_QUERY_IDLE_TIME_ACTIVE

#define MAX_SL_QUERY_IDLE_TIME_ACTIVE 60

## ◆ MAX_SL_QUERY_IDLE_TIME_TERMINAL

#define MAX_SL_QUERY_IDLE_TIME_TERMINAL 300

## ◆ MAX_SL_RESULTS

#define MAX_SL_RESULTS 20

## ◆ USE_LIST

#define USE_LIST

## Function Documentation

## ◆ add_filemeta()

bool add_filemeta | ( | sl_array_t * | reqinfo,
|  | sl_array_t * | fm_array,
|  | const char * | path,
|  | const struct stat * | sp )

Add requested metadata for a query result element.

This could be rewritten to something more sophisticated like querying metadata from Tracker.

If path or sp is NULL, simply add nil values for all attributes.

## ◆ add_results()

bool add_results | ( | sl_array_t * | array,
|  | slq_t * | slq )
| static

## ◆ afp_spotlight_rpc()

int afp_spotlight_rpc | ( | AFPObj * | obj,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )

## ◆ ATALK_LIST_HEAD() [1/2]

ATALK_LIST_HEAD | ( | sl_cancelled_queries |  | ) |
| static

## ◆ ATALK_LIST_HEAD() [2/2]

ATALK_LIST_HEAD | ( | sl_queries |  | ) |
| static

## ◆ cnid_comp_fn()

int cnid_comp_fn | ( | const void * | p1,
|  | const void * | p2 )
| static

## ◆ create_result_handle()

bool create_result_handle | ( | slq_t * | slq | ) |
| static

Allocate result handle used in the async search backend result handler for storing results

## ◆ dd_dump()

char * dd_dump | ( | DALLOC_CTX * | dd,
|  | int | nestinglevel )
| static

## ◆ sl_createCNIDArray()

int sl_createCNIDArray | ( | slq_t * | slq,
|  | const DALLOC_CTX * | p )
| static

## ◆ sl_index_event()

int sl_index_event | ( | const AFPObj * | obj,
|  | const struct vol * | vol,
|  | sl_index_event_t | event,
|  | const char * | path,
|  | const char * | oldpath )

## ◆ sl_rpc_closeQueryForContext()

int sl_rpc_closeQueryForContext | ( | const AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | v )
| static

## ◆ sl_rpc_fetchAttributeNamesForOIDArray()

int sl_rpc_fetchAttributeNamesForOIDArray | ( | const AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | vol )
| static

## ◆ sl_rpc_fetchAttributesForOIDArray()

int sl_rpc_fetchAttributesForOIDArray | ( | AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | vol )
| static

## ◆ sl_rpc_fetchPropertiesForContext()

int sl_rpc_fetchPropertiesForContext | ( | const AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | v )
| static

Return true if any currently-open volume uses the localsearch backend

## ◆ sl_rpc_fetchQueryResultsForContext()

int sl_rpc_fetchQueryResultsForContext | ( | const AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | v )
| static

## ◆ sl_rpc_openQuery()

int sl_rpc_openQuery | ( | AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | struct vol * | v )
| static

## ◆ sl_rpc_storeAttributesForOIDArray()

int sl_rpc_storeAttributesForOIDArray | ( | const AFPObj * | obj,
|  | const DALLOC_CTX * | query,
|  | DALLOC_CTX * | reply,
|  | const struct vol * | vol )
| static

## ◆ slq_add()

void slq_add | ( | slq_t * | slq | ) |
| static

Add a query to the list of active queries

## ◆ slq_cancel()

void slq_cancel | ( | slq_t * | slq | ) |
| static

Cancel a query (move to cancelled list; backend cleanup deferred)

## ◆ slq_cancelled_add()

void slq_cancelled_add | ( | slq_t * | slq | ) |
| static

Add a query to the list of cancelled queries

## ◆ slq_cancelled_cleanup()

void slq_cancelled_cleanup | ( | void |  | ) |
| static

Free all fully-cancelled queries

## ◆ slq_destroy()

void slq_destroy | ( | slq_t * | slq | ) |
| static

Invoke the backend close_query hook then free the slq

## ◆ slq_dump()

void slq_dump | ( | void |  | ) |
| static

## ◆ slq_for_ctx()

slq_t * slq_for_ctx | ( | uint64_t | ctx1,
|  | uint64_t | ctx2 )
| static

## ◆ slq_idle_cleanup()

void slq_idle_cleanup | ( | void |  | ) |
| static

Cancel or destroy queries idle longer than MAX_SL_QUERY_IDLE_TIME

## ◆ slq_remove()

void slq_remove | ( | slq_t * | slq | ) |
| static

Remove a query from the active list

Uses pointer identity rather than ctx-value comparison so that a query that was never enqueued (e.g. openQuery failure before slq_add()) cannot accidentally remove an unrelated active query whose ctx IDs happen to match the zero-initialized or partially-parsed values.

## ◆ tab_level()

char * tab_level | ( | TALLOC_CTX * | mem_ctx,
|  | int | level )
| static

## Variable Documentation

## ◆ slq_state_names

struct slq_state_names slq_state_names[]
| static

Initial value:
= {
{SLQ_STATE_NEW, "SLQ_STATE_NEW"},
{SLQ_STATE_RUNNING, "SLQ_STATE_RUNNING"},
{SLQ_STATE_RESULTS, "SLQ_STATE_RESULTS"},
{SLQ_STATE_FULL, "SLQ_STATE_FULL"},
{SLQ_STATE_DONE, "SLQ_STATE_DONE"},
{SLQ_STATE_CANCEL_PENDING, "SLQ_STATE_CANCEL_PENDING"},
{SLQ_STATE_CANCELLED, "SLQ_STATE_CANCELLED"},
{SLQ_STATE_ERROR, "SLQ_STATE_ERROR"}
}
SLQ_STATE_NEW
@ SLQ_STATE_NEW
Definition spotlight.h:66
SLQ_STATE_RUNNING
@ SLQ_STATE_RUNNING
Definition spotlight.h:67
SLQ_STATE_CANCELLED
@ SLQ_STATE_CANCELLED
Definition spotlight.h:72
SLQ_STATE_DONE
@ SLQ_STATE_DONE
Definition spotlight.h:70
SLQ_STATE_CANCEL_PENDING
@ SLQ_STATE_CANCEL_PENDING
Definition spotlight.h:71
SLQ_STATE_RESULTS
@ SLQ_STATE_RESULTS
Definition spotlight.h:68
SLQ_STATE_FULL
@ SLQ_STATE_FULL
Definition spotlight.h:69
SLQ_STATE_ERROR
@ SLQ_STATE_ERROR
Definition spotlight.h:73