]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/spotlight.h
197f90246fab651bf2cc846a6909b0bdbdc629fd
[netatalk.git] / etc / afpd / spotlight.h
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 <atalk/dalloc.h>
26 #include <atalk/globals.h>
27
28 /**************************************************************************************************
29  * Spotlight module stuff
30  **************************************************************************************************/
31
32 #define SL_MODULE_VERSION 1
33
34 struct sl_module_export {
35     int sl_mod_version;
36     int (*sl_mod_init)        (void *);
37     int (*sl_mod_start_search)(void *);
38     int (*sl_mod_fetch_result)(void *);
39     int (*sl_mod_end_search)  (void *);
40 };
41
42 extern int sl_mod_load(const char *path);
43
44
45 /**************************************************************************************************
46  * Spotlight RPC and marshalling stuff
47  **************************************************************************************************/
48
49 /* FPSpotlightRPC subcommand codes */
50 #define SPOTLIGHT_CMD_OPEN    1
51 #define SPOTLIGHT_CMD_FLAGS   2
52 #define SPOTLIGHT_CMD_RPC     3
53 #define SPOTLIGHT_CMD_OPEN2   4
54
55 /* Can be ored and used as flags */
56 #define SL_ENC_LITTLE_ENDIAN 1
57 #define SL_ENC_BIG_ENDIAN    2
58 #define SL_ENC_UTF_16        4
59
60 typedef DALLOC_CTX     sl_array_t;    /* an array of elements                                           */
61 typedef DALLOC_CTX     sl_dict_t;     /* an array of key/value elements                                 */
62 typedef DALLOC_CTX     sl_filemeta_t; /* contains one sl_array_t                                        */
63 typedef int            sl_nil_t;      /* a nil element                                                  */
64 typedef bool           sl_bool_t;     /* a boolean, we avoid bool_t as it's a define for something else */
65 typedef struct timeval sl_time_t;     /* a boolean, we avoid bool_t as it's a define for something else */
66 typedef struct {
67     char sl_uuid[16];
68 }                      sl_uuid_t;     /* a UUID                                                         */
69 typedef struct {
70     uint16_t   ca_unkn1;
71     uint32_t   ca_context;
72     DALLOC_CTX *ca_cnids;
73 }                      sl_cnids_t;    /* an array of CNID                                               */
74
75 /**************************************************************************************************
76  * Some helper stuff dealing with queries
77  **************************************************************************************************/
78
79 typedef struct {
80     time_t slq_time;            /* timestamp where we received this query */
81     uint64_t slq_ctx1;          /* client context 1 */
82     uint64_t slq_ctx2;          /* client context 2 */
83     DALLOC_CTX *slq_query;      /* the complete query as unmarshalled in openQuery */
84     const char *sql_qstring;    /* the Spotlight query string */
85     DALLOC_CTX *slq_reqinfo;    /* array with requested metadata */
86 } slq_t;
87
88 /**************************************************************************************************
89  * Function declarations
90  **************************************************************************************************/
91
92 extern int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen);
93 extern int sl_pack(DALLOC_CTX *query, char *buf);
94 extern int sl_unpack(DALLOC_CTX *query, const char *buf);
95
96 #endif /* SPOTLIGHT_H */