]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/spotlight.c
Spotlight module
[netatalk.git] / etc / afpd / spotlight.c
index 8eb26a7eb7fddea7b0626a6d525ac0e9a8d6ebbe..dc607a077ae215fd23e1f386fe7e7d8ed9cfd458 100644 (file)
@@ -35,6 +35,9 @@
 
 #include "spotlight.h"
 
+void *sl_module;
+struct sl_module_export *sl_module_export;
+
 
 /* Helper functions and stuff */
 static const char *neststrings[] = {
@@ -148,6 +151,30 @@ EC_CLEANUP:
     EC_EXIT;
 }
 
+/**************************************************************************************************
+ * Spotlight module functions
+ **************************************************************************************************/
+
+int sl_mod_load(const char *path)
+{
+    EC_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;
+    }
+
+    if ((sl_module_export = mod_symbol(sl_module, "sl_mod")) == NULL) {
+        LOG(log_error, logtype_sl, "sl_mod_load(%s): mod_symbol error for symbol %s", path, "sl_mod");
+        EC_FAIL;
+    }
+
+    sl_module_export->sl_mod_init("test");
+   
+EC_CLEANUP:
+    EC_EXIT;
+}
+
 /**************************************************************************************************
  * AFP functions
  **************************************************************************************************/
@@ -204,16 +231,11 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_
         DALLOC_CTX *reply;
         EC_NULL( reply = talloc_zero(tmp_ctx, DALLOC_CTX) );
 
-        ret = sl_unpack(query, ibuf + 22);
-        dd_dump(query, 0);
-        if (ret != 0) {
-            LOG(log_error, logtype_sl, "sl_unpack");
-            EC_FAIL;
-        }
+        EC_NEG1_LOG( sl_unpack(query, ibuf + 22) );
+
         char **cmd;
         EC_NULL_LOG( cmd = dalloc_get(query, "DALLOC_CTX", 0, "DALLOC_CTX", 0, "char *", 0) );
 
-
         if (STRCMP(*cmd, ==, "fetchPropertiesForContext:")) {
             EC_ZERO_LOG( sl_rpc_fetchPropertiesForContext(obj, query, reply, vol) );
         } else if (STRCMP(*cmd, ==, "openQueryWithParams:forContext:")) {
@@ -225,19 +247,15 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_
             }
         }
 
-        /* Spotlight RPC status code ? 0 in all traces, we use 0xffffffff for an error, never seen from Apple */
-        if (ret == 0)
-            memset(rbuf, 0, 4);
-        else
-            memset(rbuf, 0xff, 4);
+        dd_dump(reply, 0);
+
+        memset(rbuf, 0, 4);
         *rbuflen += 4;
 
         int len;
         EC_NEG1_LOG( len = sl_pack(reply, rbuf + 4) );
         *rbuflen += len;
 
-        dd_dump(reply, 0);
-
         break;
     }
     }