]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/spotlight.h
Use a linked list for the SL queries
[netatalk.git] / etc / afpd / spotlight.h
index b845a47c986319ff159a275706d2c2f12361a7f2..49a8fac063dd1d72204b617f7a8810b6751ada1c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <atalk/dalloc.h>
 #include <atalk/globals.h>
+#include <atalk/volume.h>
 
 /**************************************************************************************************
  * Spotlight module stuff
@@ -37,6 +38,7 @@ struct sl_module_export {
     int (*sl_mod_start_search)(void *);
     int (*sl_mod_fetch_result)(void *);
     int (*sl_mod_end_search)  (void *);
+    int (*sl_mod_error)       (void *);
 };
 
 extern int sl_mod_load(const char *path);
@@ -65,12 +67,43 @@ typedef bool           sl_bool_t;     /* a boolean, we avoid bool_t as it's a de
 typedef struct timeval sl_time_t;     /* a boolean, we avoid bool_t as it's a define for something else */
 typedef struct {
     char sl_uuid[16];
-}                      sl_uuid_t;     /* a UUID                                                         */
+}  sl_uuid_t;                         /* a UUID                                                         */
 typedef struct {
     uint16_t   ca_unkn1;
     uint32_t   ca_context;
     DALLOC_CTX *ca_cnids;
-}                      sl_cnids_t;    /* an array of CNID                                               */
+}  sl_cnids_t;                        /* an array of CNIDs                                              */
+
+/**************************************************************************************************
+ * Some helper stuff dealing with queries
+ **************************************************************************************************/
+
+/* Internal query state */
+typedef enum {
+    SLQ_STATE_NEW      = 1,           /* Query received from client                                     */
+    SLQ_STATE_RUNNING  = 2,           /* Query dispatched to Tracker                                    */
+    SLQ_STATE_DONE     = 3,           /* Tracker finished                                               */
+    SLQ_STATE_END      = 4            /* Query results returned to client                               */
+} slq_state_t;
+
+/* Internal query data structure */
+typedef struct _slq_t {
+    struct list_head slq_list;        /* queries are stored in a list                                   */
+    slq_state_t    slq_state;         /* State                                                          */
+    AFPObj         *slq_obj;          /* global AFPObj handle                                           */
+    const struct vol *slq_vol;        /* volume handle                                                  */
+    DALLOC_CTX     *slq_reply;        /* reply handle                                                   */
+    time_t         slq_time;          /* timestamp where we received this query                         */
+    uint64_t       slq_ctx1;          /* client context 1                                               */
+    uint64_t       slq_ctx2;          /* client context 2                                               */
+    const char     *slq_qstring;      /* the Spotlight query string                                     */
+    sl_array_t     *slq_reqinfo;      /* array with requested metadata                                  */
+    void           *slq_tracker_cursor; /* Tracker query result cursor                                  */
+} slq_t;
+
+/**************************************************************************************************
+ * Function declarations
+ **************************************************************************************************/
 
 extern int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen);
 extern int sl_pack(DALLOC_CTX *query, char *buf);