]> arthur.barton.de Git - netatalk.git/commitdiff
Start working on replying queries, add struct for storing query and a queue
authorFrank Lahm <franklahm@googlemail.com>
Wed, 15 Aug 2012 18:01:38 +0000 (20:01 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 15 Aug 2012 18:15:11 +0000 (20:15 +0200)
etc/afpd/spotlight.c
etc/afpd/spotlight.h

index a96883251034a24a15321b1e2086ba90e792f842..205a20e18b4c4e5ea9ae1ebb8b52105bfffd90a7 100644 (file)
 #include <atalk/byteorder.h>
 #include <atalk/netatalk_conf.h>
 #include <atalk/volume.h>
+#include <atalk/queue.h>
 
 #include "spotlight.h"
 
-void *sl_module;
-struct sl_module_export *sl_module_export;
-
+static void *sl_module;
+static struct sl_module_export *sl_module_export;
+static q_t *sl_queries;
 
 /* Helper functions and stuff */
 static const char *neststrings[] = {
@@ -153,6 +154,8 @@ static int sl_rpc_openQuery(const AFPObj *obj, const DALLOC_CTX *query, DALLOC_C
 
     LOG(log_debug, logtype_sl, "sl_rpc_openQuery: %s", *sl_query);
 
+    enqueue(sl_queries, query);
+
 EC_CLEANUP:
     EC_EXIT;
 }
@@ -165,6 +168,8 @@ int sl_mod_load(const char *path)
 {
     EC_INIT;
 
+    sl_queries = queue_init();
+
     if ((sl_module = mod_open(path)) == NULL) {
         LOG(log_error, logtype_sl, "sl_mod_load(%s): failed to load: %s", path, mod_error());
         EC_FAIL;
index b845a47c986319ff159a275706d2c2f12361a7f2..197f90246fab651bf2cc846a6909b0bdbdc629fd 100644 (file)
@@ -72,6 +72,23 @@ typedef struct {
     DALLOC_CTX *ca_cnids;
 }                      sl_cnids_t;    /* an array of CNID                                               */
 
+/**************************************************************************************************
+ * Some helper stuff dealing with queries
+ **************************************************************************************************/
+
+typedef struct {
+    time_t slq_time;            /* timestamp where we received this query */
+    uint64_t slq_ctx1;          /* client context 1 */
+    uint64_t slq_ctx2;          /* client context 2 */
+    DALLOC_CTX *slq_query;      /* the complete query as unmarshalled in openQuery */
+    const char *sql_qstring;    /* the Spotlight query string */
+    DALLOC_CTX *slq_reqinfo;    /* array with requested metadata */
+} 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);
 extern int sl_unpack(DALLOC_CTX *query, const char *buf);