netatalk 4.4.3
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
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 <stdint.h>
23#include <stdbool.h>
24
25#include <gio/gio.h>
26
27#ifdef HAVE_TRACKER3
28#include <tracker-sparql.h>
29#else
30#include <tinysparql.h>
31#endif
32
33#include <atalk/globals.h>
34#include <atalk/volume.h>
35#include <atalk/dalloc.h>
36
37/******************************************************************************
38 * Spotlight RPC and marshalling stuff
39 ******************************************************************************/
40
41/* FPSpotlightRPC subcommand codes */
42#define SPOTLIGHT_CMD_OPEN 1
43#define SPOTLIGHT_CMD_FLAGS 2
44#define SPOTLIGHT_CMD_RPC 3
45#define SPOTLIGHT_CMD_OPEN2 4
46
47/* Can be ored and used as flags */
48#define SL_ENC_LITTLE_ENDIAN 1
49#define SL_ENC_BIG_ENDIAN 2
50#define SL_ENC_UTF_16 4
51
52 typedef DALLOC_CTX sl_array_t;
53 typedef DALLOC_CTX sl_dict_t;
54 typedef DALLOC_CTX sl_filemeta_t;
55 typedef int sl_nil_t;
56 typedef bool sl_bool_t;
57 typedef struct timeval sl_time_t;
58 typedef struct {
59 char sl_uuid[16];
60} sl_uuid_t;
61 typedef struct {
62 uint16_t ca_unkn1;
63 uint32_t ca_context;
64 DALLOC_CTX *ca_cnids;
65} sl_cnids_t;
66
67/******************************************************************************
68 * Some helper stuff dealing with queries
69 ******************************************************************************/
70
72 typedef enum {
73 SLQ_STATE_NEW,
74 SLQ_STATE_RUNNING,
75 SLQ_STATE_RESULTS,
76 SLQ_STATE_FULL,
77 SLQ_STATE_DONE,
78 SLQ_STATE_CANCEL_PENDING,
79 SLQ_STATE_CANCELLED,
80 SLQ_STATE_ERROR
81} slq_state_t;
82
84 struct sl_rslts {
85 int num_results;
86 sl_cnids_t *cnids;
87 sl_array_t *fm_array;
88};
89
91 typedef struct _slq_t {
92 struct list_head slq_list;
93 slq_state_t slq_state;
94 AFPObj *slq_obj;
95 const struct vol *slq_vol;
96 char *slq_scope;
97 time_t slq_time;
98 uint64_t slq_ctx1;
99 uint64_t slq_ctx2;
100 sl_array_t *slq_reqinfo;
101 const char *slq_qstring;
102 uint64_t *slq_cnids;
103 size_t slq_cnids_num;
104 void *tracker_cursor;
105 bool slq_allow_expr;
106 uint64_t slq_result_limit;
107 struct sl_rslts *query_results;
108} slq_t;
109
110 struct sl_ctx {
111 TrackerSparqlConnection *tracker_con;
112 GCancellable *cancellable;
113 GMainLoop *mainloop;
114 slq_t *query_list;
115};
116
117/******************************************************************************
118 * Function declarations
119 ******************************************************************************/
120
121 extern int spotlight_init(AFPObj *obj);
122 extern int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_,
123 char *rbuf, size_t *rbuflen);
124 extern int sl_pack(DALLOC_CTX *query, char *buf);
125 extern int sl_unpack(DALLOC_CTX *query, const char *buf);
126 extern void configure_spotlight_attributes(const char *attributes);
127
128#endif /* SPOTLIGHT_H */
rbuflen
static size_t rbuflen
Definition afpfunc_helpers.c:45
rbuf
static char rbuf[rbufsize]
Definition afpfunc_helpers.c:44
buf
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:75
config.h
dalloc.h
globals.h
volume.h
obj
static AFPObj obj
Definition netatalk.c:62
configure_spotlight_attributes
void configure_spotlight_attributes(const char *attributes)
Definition sparql_map.c:107
sl_bool_t
bool sl_bool_t
Definition spotlight.h:56
spotlight_init
int spotlight_init(AFPObj *obj)
Definition spotlight.c:1309
sl_pack
int sl_pack(DALLOC_CTX *query, char *buf)
Definition spotlight_marshalling.c:904
sl_array_t
DALLOC_CTX sl_array_t
Definition spotlight.h:52
sl_nil_t
int sl_nil_t
Definition spotlight.h:55
sl_time_t
struct timeval sl_time_t
Definition spotlight.h:57
sl_dict_t
DALLOC_CTX sl_dict_t
Definition spotlight.h:53
slq_t
struct _slq_t slq_t
sl_unpack
int sl_unpack(DALLOC_CTX *query, const char *buf)
Definition spotlight_marshalling.c:957
sl_filemeta_t
DALLOC_CTX sl_filemeta_t
Definition spotlight.h:54
afp_spotlight_rpc
int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition spotlight.c:1364
slq_state_t
slq_state_t
Definition spotlight.h:72
SLQ_STATE_NEW
@ SLQ_STATE_NEW
Definition spotlight.h:73
SLQ_STATE_RUNNING
@ SLQ_STATE_RUNNING
Definition spotlight.h:74
SLQ_STATE_CANCELLED
@ SLQ_STATE_CANCELLED
Definition spotlight.h:79
SLQ_STATE_DONE
@ SLQ_STATE_DONE
Definition spotlight.h:77
SLQ_STATE_CANCEL_PENDING
@ SLQ_STATE_CANCEL_PENDING
Definition spotlight.h:78
SLQ_STATE_RESULTS
@ SLQ_STATE_RESULTS
Definition spotlight.h:75
SLQ_STATE_FULL
@ SLQ_STATE_FULL
Definition spotlight.h:76
SLQ_STATE_ERROR
@ SLQ_STATE_ERROR
Definition spotlight.h:80
AFPObj
Definition globals.h:158
DALLOC_CTX
Definition dalloc.h:25
_slq_t
Definition spotlight.h:91
_slq_t::slq_ctx1
uint64_t slq_ctx1
Definition spotlight.h:98
_slq_t::slq_obj
AFPObj * slq_obj
Definition spotlight.h:94
_slq_t::slq_reqinfo
sl_array_t * slq_reqinfo
Definition spotlight.h:100
_slq_t::slq_allow_expr
bool slq_allow_expr
Definition spotlight.h:105
_slq_t::slq_cnids
uint64_t * slq_cnids
Definition spotlight.h:102
_slq_t::slq_vol
const struct vol * slq_vol
Definition spotlight.h:95
_slq_t::slq_scope
char * slq_scope
Definition spotlight.h:96
_slq_t::query_results
struct sl_rslts * query_results
Definition spotlight.h:107
_slq_t::slq_state
slq_state_t slq_state
Definition spotlight.h:93
_slq_t::slq_time
time_t slq_time
Definition spotlight.h:97
_slq_t::slq_ctx2
uint64_t slq_ctx2
Definition spotlight.h:99
_slq_t::slq_qstring
const char * slq_qstring
Definition spotlight.h:101
_slq_t::slq_cnids_num
size_t slq_cnids_num
Definition spotlight.h:103
_slq_t::slq_list
struct list_head slq_list
Definition spotlight.h:92
_slq_t::tracker_cursor
void * tracker_cursor
Definition spotlight.h:104
_slq_t::slq_result_limit
uint64_t slq_result_limit
Definition spotlight.h:106
list_head
Definition include/atalk/list.h:18
sl_cnids_t
Definition spotlight.h:61
sl_cnids_t::ca_cnids
DALLOC_CTX * ca_cnids
Definition spotlight.h:64
sl_cnids_t::ca_context
uint32_t ca_context
Definition spotlight.h:63
sl_cnids_t::ca_unkn1
uint16_t ca_unkn1
Definition spotlight.h:62
sl_ctx
Definition spotlight.h:110
sl_ctx::query_list
slq_t * query_list
Definition spotlight.h:114
sl_ctx::cancellable
GCancellable * cancellable
Definition spotlight.h:112
sl_ctx::mainloop
GMainLoop * mainloop
Definition spotlight.h:113
sl_ctx::tracker_con
TrackerSparqlConnection * tracker_con
Definition spotlight.h:111
sl_rslts
Definition spotlight.h:84
sl_rslts::num_results
int num_results
Definition spotlight.h:85
sl_rslts::cnids
sl_cnids_t * cnids
Definition spotlight.h:86
sl_rslts::fm_array
sl_array_t * fm_array
Definition spotlight.h:87
sl_uuid_t
Definition spotlight.h:58
sl_uuid_t::sl_uuid
char sl_uuid[16]
Definition spotlight.h:59
vol
Definition include/atalk/volume.h:30