]> arthur.barton.de Git - netatalk.git/commitdiff
Spotlight module
authorFrank Lahm <franklahm@gmail.com>
Mon, 16 Jul 2012 08:51:50 +0000 (10:51 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 15 Aug 2012 18:14:22 +0000 (20:14 +0200)
etc/afpd/spotlight.c
etc/afpd/spotlight_module.c [new file with mode: 0644]
include/atalk/dalloc.h
libatalk/talloc/dalloc.c

index dc607a077ae215fd23e1f386fe7e7d8ed9cfd458..a96883251034a24a15321b1e2086ba90e792f842 100644 (file)
@@ -147,6 +147,12 @@ EC_CLEANUP:
 static int sl_rpc_openQuery(const AFPObj *obj, const DALLOC_CTX *query, DALLOC_CTX *reply, const struct vol *v)
 {
     EC_INIT;
+
+    char **sl_query;
+    EC_NULL_LOG( sl_query = dalloc_value_for_key(query, "DALLOC_CTX", 0, "DALLOC_CTX", 1, "kMDQueryString") );
+
+    LOG(log_debug, logtype_sl, "sl_rpc_openQuery: %s", *sl_query);
+
 EC_CLEANUP:
     EC_EXIT;
 }
@@ -232,6 +238,7 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_
         EC_NULL( reply = talloc_zero(tmp_ctx, DALLOC_CTX) );
 
         EC_NEG1_LOG( sl_unpack(query, ibuf + 22) );
+        dd_dump(query, 0);
 
         char **cmd;
         EC_NULL_LOG( cmd = dalloc_get(query, "DALLOC_CTX", 0, "DALLOC_CTX", 0, "char *", 0) );
diff --git a/etc/afpd/spotlight_module.c b/etc/afpd/spotlight_module.c
new file mode 100644 (file)
index 0000000..13aa830
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+  Copyright (c) 2012 Frank Lahm <franklahm@gmail.com>
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <atalk/util.h>
+#include <atalk/errchk.h>
+#include <atalk/logger.h>
+
+#include "spotlight.h"
+
+int sl_mod_init(void *p)
+{
+    EC_INIT;
+
+    const char *msg = p;
+
+    LOG(log_note, logtype_sl, "sl_mod_init: %s", msg);
+
+EC_CLEANUP:
+    EC_EXIT;
+}
+
+struct sl_module_export sl_mod = {
+    SL_MODULE_VERSION,
+    sl_mod_init,
+    NULL,
+    NULL,
+    NULL
+};
index 70d8db59478f46f4b478f2887c13bb18f5632fd6..51ebf02b47700b5540d0647c9489c2ef8a821b5c 100644 (file)
@@ -26,11 +26,11 @@ typedef struct {
     void **dd_talloc_array;
 } DALLOC_CTX;
 
-#define dalloc_add(d, obj, type) dalloc_add_talloc_chunk((d), talloc((d), type), (obj), sizeof(type));
-
 /* Use dalloc_add() macro, not this function */
 extern int dalloc_add_talloc_chunk(DALLOC_CTX *dd, void *talloc_chunk, void *obj, size_t size);
 
-extern void *dalloc_get(DALLOC_CTX *d, ...);
+#define dalloc_add(d, obj, type) dalloc_add_talloc_chunk((d), talloc((d), type), (obj), sizeof(type));
+extern void *dalloc_get(const DALLOC_CTX *d, ...);
+extern void *dalloc_value_for_key(const DALLOC_CTX *d, ...);
 
 #endif  /* DALLOC_H */
index 2390d108ebc9c438d6ece5ecace1aa1b8bc61875..70c75e3b53e0a23f5ab1fde019c31a3e78f33137 100644 (file)
@@ -43,7 +43,7 @@ int dalloc_add_talloc_chunk(DALLOC_CTX *dd, void *talloc_chunk, void *obj, size_
     return 0;
 }
 
-void *dalloc_get(DALLOC_CTX *d, ...)
+void *dalloc_get(const DALLOC_CTX *d, ...)
 {
     EC_INIT;
     void *p = NULL;
@@ -77,3 +77,41 @@ EC_CLEANUP:
         p = NULL;
     return p;
 }
+
+void *dalloc_value_for_key(const DALLOC_CTX *d, ...)
+{
+    EC_INIT;
+    void *p = NULL;
+    va_list args;
+    const char *type;
+    int elem;
+    const char *elemtype;
+    char *s;
+
+    va_start(args, d);
+    type = va_arg(args, const char *);
+
+    if (STRCMP(type, !=, "DALLOC_CTX"))
+        EC_FAIL;
+
+    while (STRCMP(type, ==, "DALLOC_CTX")) {
+        elem = va_arg(args, int);
+        AFP_ASSERT(elem < talloc_array_length(d->dd_talloc_array));
+        d = d->dd_talloc_array[elem];
+        type = va_arg(args, const char *);
+    }
+
+    for (elem = 0; elem + 1 < talloc_array_length(d->dd_talloc_array); elem += 2) {
+        memcpy(&s, d->dd_talloc_array[elem], sizeof(char *));
+        if (STRCMP(s, ==, type)) {
+            p = d->dd_talloc_array[elem + 1];
+            break;
+        }            
+    }
+    va_end(args);
+
+EC_CLEANUP:
+    if (ret != 0)
+        p = NULL;
+    return p;
+}