From: Frank Lahm Date: Wed, 15 Aug 2012 18:01:38 +0000 (+0200) Subject: Start working on replying queries, add struct for storing query and a queue X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=607fad64594c86adb09993f6c5ce523b7f5312ed Start working on replying queries, add struct for storing query and a queue --- diff --git a/etc/afpd/spotlight.c b/etc/afpd/spotlight.c index a9688325..205a20e1 100644 --- a/etc/afpd/spotlight.c +++ b/etc/afpd/spotlight.c @@ -32,12 +32,13 @@ #include #include #include +#include #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; diff --git a/etc/afpd/spotlight.h b/etc/afpd/spotlight.h index b845a47c..197f9024 100644 --- a/etc/afpd/spotlight.h +++ b/etc/afpd/spotlight.h @@ -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);