netatalk  4.4.0dev
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 <glib.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/sparql_parser.h"

Data Structures

struct  slq_state_names

Macros

#define USE_LIST
#define MAX_SL_RESULTS   20

Functions

static char * tracker_to_unix_path (TALLOC_CTX *mem_ctx, const char *uri)
static int cnid_comp_fn (const void *p1, const void *p2)
static bool create_result_handle (slq_t *slq)
static bool add_filemeta (sl_array_t *reqinfo, sl_array_t *fm_array, const char *path, const struct stat *sp)
static char * tab_level (TALLOC_CTX *mem_ctx, int level)
static char * dd_dump (DALLOC_CTX *dd, int nestinglevel)
static int sl_createCNIDArray (slq_t *slq, const DALLOC_CTX *p)
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_tslq_for_ctx (uint64_t ctx1, uint64_t ctx2)
static void slq_destroy (slq_t *slq)
static void slq_cancel (slq_t *slq)
static int slq_free_cb (slq_t *slq)
static void slq_cancelled_cleanup (void)
static void slq_dump (void)
static void tracker_cursor_cb (GObject *object, GAsyncResult *res, gpointer user_data)
static void tracker_query_cb (GObject *object, GAsyncResult *res, gpointer user_data)
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 spotlight_init (AFPObj *obj)
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_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 )
static

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 _U_,
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 Tracker cursor 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_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

◆ 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

◆ slq_cancelled_add()

void slq_cancelled_add ( slq_t * slq)
static

Add a query to the list of active queries

◆ slq_cancelled_cleanup()

void slq_cancelled_cleanup ( void )
static

Free all cancelled queries

◆ slq_destroy()

void slq_destroy ( slq_t * slq)
static

Remove a query from the active queue and free it

◆ slq_dump()

void slq_dump ( void )
static

◆ slq_for_ctx()

slq_t * slq_for_ctx ( uint64_t ctx1,
uint64_t ctx2 )
static

◆ slq_free_cb()

int slq_free_cb ( slq_t * slq)
static

talloc destructor cb

◆ slq_remove()

void slq_remove ( slq_t * slq)
static

Remove a query from the active list

◆ spotlight_init()

int spotlight_init ( AFPObj * obj)

◆ tab_level()

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

◆ tracker_cursor_cb()

void tracker_cursor_cb ( GObject * object,
GAsyncResult * res,
gpointer user_data )
static

◆ tracker_query_cb()

void tracker_query_cb ( GObject * object,
GAsyncResult * res,
gpointer user_data )
static

◆ tracker_to_unix_path()

char * tracker_to_unix_path ( TALLOC_CTX * mem_ctx,
const char * uri )
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
Definition spotlight.h:81
@ SLQ_STATE_RUNNING
Definition spotlight.h:83
@ SLQ_STATE_CANCELLED
Definition spotlight.h:93
@ SLQ_STATE_DONE
Definition spotlight.h:89
@ SLQ_STATE_CANCEL_PENDING
Definition spotlight.h:91
@ SLQ_STATE_RESULTS
Definition spotlight.h:85
@ SLQ_STATE_FULL
Definition spotlight.h:87
@ SLQ_STATE_ERROR
Definition spotlight.h:95