$darkmode
netatalk  4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
spotlight.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2012 Frank Lahm <franklahm@gmail.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13*/
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif /* HAVE_CONFIG_H */
18
19#ifndef SPOTLIGHT_H
20#define SPOTLIGHT_H
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <stdint.h>
25
26#include <atalk/globals.h>
27#include <atalk/volume.h>
28#include <atalk/dalloc.h>
29
30/******************************************************************************
31 * Spotlight RPC and marshalling stuff
32 ******************************************************************************/
33
34/* FPSpotlightRPC subcommand codes */
35#define SPOTLIGHT_CMD_OPEN 1
36#define SPOTLIGHT_CMD_FLAGS 2
37#define SPOTLIGHT_CMD_RPC 3
38#define SPOTLIGHT_CMD_OPEN2 4
39
40/* Can be ored and used as flags */
41#define SL_ENC_LITTLE_ENDIAN 1
42#define SL_ENC_BIG_ENDIAN 2
43#define SL_ENC_UTF_16 4
44
48typedef int sl_nil_t;
49typedef bool sl_bool_t;
50typedef struct timeval sl_time_t;
51typedef struct {
52 char sl_uuid[16];
53} sl_uuid_t;
54typedef struct {
55 uint16_t ca_unkn1;
56 uint32_t ca_context;
58} sl_cnids_t;
60/******************************************************************************
61 * Some helper stuff dealing with queries
62 ******************************************************************************/
63
65typedef enum {
75
77typedef enum {
86
88struct sl_rslts {
92};
93
95typedef struct _slq_t {
99 const struct vol *slq_vol;
100 char *slq_scope;
101 time_t slq_time;
102 uint64_t slq_ctx1;
103 uint64_t slq_ctx2;
105 const char *slq_qstring;
106 uint64_t *slq_cnids;
113
114/******************************************************************************
115 * Pluggable search backend vtable
116 ******************************************************************************/
117
118typedef struct sl_backend_ops {
119 const char *sbo_name;
120
121 /* Called once globally when the first volume using this backend is opened. */
123
124 /* Called on afpd shutdown. */
126
127 /* Translate slq->slq_qstring into results.
128 * May be async (localsearch) or synchronous (cnid).
129 * On return slq_state must be SLQ_STATE_RUNNING or SLQ_STATE_DONE. */
130 int (*sbo_open_query)(slq_t *slq);
131
132 /* Fetch the next batch of results into slq->query_results.
133 * For async backends: pumps the event loop.
134 * For sync backends: no-op after sbo_open_query() already set SLQ_STATE_DONE. */
136
137 /* Cancel and clean up query state. */
138 void (*sbo_close_query)(slq_t *slq);
139
140 /* Optional incremental index update hook. */
142 const struct vol *vol,
143 sl_index_event_t event,
144 const char *path,
145 const char *oldpath);
147
148/******************************************************************************
149 * Function declarations
150 ******************************************************************************/
151
152extern int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_,
153 char *rbuf, size_t *rbuflen);
154extern int sl_index_event(const AFPObj *obj,
155 const struct vol *vol,
156 sl_index_event_t event,
157 const char *path,
158 const char *oldpath);
159extern int sl_pack(DALLOC_CTX *query, char *buf);
160extern int sl_unpack(DALLOC_CTX *query, const char *buf);
161extern int sl_unpack_len(DALLOC_CTX *query, const char *buf, size_t buf_len);
162extern void configure_spotlight_attributes(const char *attributes);
163
164#endif /* SPOTLIGHT_H */
static size_t rbuflen
Definition: afpfunc_helpers.c:45
static char rbuf[rbufsize]
Definition: afpfunc_helpers.c:44
static char buf[MAXPATHLEN+1]
Definition: afppasswd.c:113
static struct vol * vol
Definition: cmd_dbd_scanvol.c:50
static AFPObj obj
Definition: netatalk.c:69
void configure_spotlight_attributes(const char *attributes)
Definition: sparql_map.c:109
bool sl_bool_t
Definition: spotlight.h:49
int sl_unpack_len(DALLOC_CTX *query, const char *buf, size_t buf_len)
Definition: spotlight_marshalling.c:1244
int sl_pack(DALLOC_CTX *query, char *buf)
Definition: spotlight_marshalling.c:1163
DALLOC_CTX sl_array_t
Definition: spotlight.h:45
int sl_nil_t
Definition: spotlight.h:48
struct sl_backend_ops sl_backend_ops
struct timeval sl_time_t
Definition: spotlight.h:50
DALLOC_CTX sl_dict_t
Definition: spotlight.h:46
int sl_index_event(const AFPObj *obj, const struct vol *vol, sl_index_event_t event, const char *path, const char *oldpath)
Definition: spotlight.c:106
struct _slq_t slq_t
int sl_unpack(DALLOC_CTX *query, const char *buf)
Definition: spotlight_marshalling.c:1239
sl_index_event_t
Definition: spotlight.h:77
@ SL_INDEX_DIR_MOVE
Definition: spotlight.h:84
@ SL_INDEX_FILE_MOVE
Definition: spotlight.h:83
@ SL_INDEX_FILE_CREATE
Definition: spotlight.h:81
@ SL_INDEX_FILE_DELETE
Definition: spotlight.h:79
@ SL_INDEX_DIR_CREATE
Definition: spotlight.h:82
@ SL_INDEX_DIR_DELETE
Definition: spotlight.h:80
@ SL_INDEX_FILE_MODIFY
Definition: spotlight.h:78
DALLOC_CTX sl_filemeta_t
Definition: spotlight.h:47
int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition: spotlight.c:1403
slq_state_t
Definition: spotlight.h:65
@ SLQ_STATE_NEW
Definition: spotlight.h:66
@ SLQ_STATE_RUNNING
Definition: spotlight.h:67
@ SLQ_STATE_CANCELLED
Definition: spotlight.h:72
@ SLQ_STATE_DONE
Definition: spotlight.h:70
@ SLQ_STATE_CANCEL_PENDING
Definition: spotlight.h:71
@ SLQ_STATE_RESULTS
Definition: spotlight.h:68
@ SLQ_STATE_FULL
Definition: spotlight.h:69
@ SLQ_STATE_ERROR
Definition: spotlight.h:73
Definition: globals.h:166
Definition: dalloc.h:25
Definition: spotlight.h:95
uint64_t slq_ctx1
Definition: spotlight.h:102
AFPObj * slq_obj
Definition: spotlight.h:98
sl_array_t * slq_reqinfo
Definition: spotlight.h:104
bool slq_allow_expr
Definition: spotlight.h:109
uint64_t * slq_cnids
Definition: spotlight.h:106
const struct vol * slq_vol
Definition: spotlight.h:99
char * slq_scope
Definition: spotlight.h:100
struct sl_rslts * query_results
Definition: spotlight.h:111
slq_state_t slq_state
Definition: spotlight.h:97
time_t slq_time
Definition: spotlight.h:101
uint64_t slq_ctx2
Definition: spotlight.h:103
void * slq_backend_private
Definition: spotlight.h:108
const char * slq_qstring
Definition: spotlight.h:105
size_t slq_cnids_num
Definition: spotlight.h:107
struct list_head slq_list
Definition: spotlight.h:96
uint64_t slq_result_limit
Definition: spotlight.h:110
Definition: include/atalk/list.h:18
Definition: include/atalk/directory.h:123
Definition: spotlight.h:118
int(* sbo_open_query)(slq_t *slq)
Definition: spotlight.h:130
void(* sbo_close_query)(slq_t *slq)
Definition: spotlight.h:138
void(* sbo_close)(AFPObj *obj)
Definition: spotlight.h:125
int(* sbo_fetch_results)(slq_t *slq)
Definition: spotlight.h:135
const char * sbo_name
Definition: spotlight.h:119
int(* sbo_index_event)(const AFPObj *obj, const struct vol *vol, sl_index_event_t event, const char *path, const char *oldpath)
Definition: spotlight.h:141
int(* sbo_init)(AFPObj *obj)
Definition: spotlight.h:122
Definition: spotlight.h:54
DALLOC_CTX * ca_cnids
Definition: spotlight.h:57
uint32_t ca_context
Definition: spotlight.h:56
uint16_t ca_unkn1
Definition: spotlight.h:55
Definition: spotlight.h:88
int num_results
Definition: spotlight.h:89
sl_cnids_t * cnids
Definition: spotlight.h:90
sl_array_t * fm_array
Definition: spotlight.h:91
Definition: spotlight.h:51
Definition: include/atalk/volume.h:33