]> arthur.barton.de Git - netatalk.git/commitdiff
Work on fixing filemeta handling
authorFrank Lahm <franklahm@googlemail.com>
Tue, 25 Sep 2012 09:34:44 +0000 (11:34 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 25 Sep 2012 09:34:44 +0000 (11:34 +0200)
etc/afpd/spotlight.c
etc/afpd/spotlight_marshalling.c

index d83b757121498abfdfb0a5e883409f031c1c7d0e..a57a15f45ad7eaee7f9720b9088ddbd099b1b631 100644 (file)
@@ -65,6 +65,7 @@ static int dd_dump(DALLOC_CTX *dd, int nestinglevel)
 
         if (STRCMP(type, ==, "DALLOC_CTX")
                    || STRCMP(type, ==, "sl_array_t")
+                   || STRCMP(type, ==, "sl_filemeta_t")
                    || STRCMP(type, ==, "sl_dict_t")) {
             dd_dump(dd->dd_talloc_array[n], nestinglevel + 1);
         } else if (STRCMP(type, ==, "uint64_t")) {
@@ -79,13 +80,15 @@ static int dd_dump(DALLOC_CTX *dd, int nestinglevel)
             sl_bool_t bl;
             memcpy(&bl, dd->dd_talloc_array[n], sizeof(sl_bool_t));
             LOG(log_debug, logtype_sl, "%sbool: %s", neststrings[nestinglevel + 1], bl ? "true" : "false");
+        } else if (STRCMP(type, ==, "sl_nil_t")) {
+            LOG(log_debug, logtype_sl, "%snil", neststrings[nestinglevel + 1]);
         } else if (STRCMP(type, ==, "sl_cnids_t")) {
             sl_cnids_t cnids;
             memcpy(&cnids, dd->dd_talloc_array[n], sizeof(sl_cnids_t));
             LOG(log_debug, logtype_sl, "%sCNIDs: unkn1: 0x%" PRIx16 ", unkn2: 0x%" PRIx32,
                    neststrings[nestinglevel + 1], cnids.ca_unkn1, cnids.ca_context);
             if (cnids.ca_cnids)
-                dd_dump(cnids.ca_cnids, nestinglevel + 1);
+                dd_dump(cnids.ca_cnids, nestinglevel + 2);
         }
     }
     LOG(log_debug, logtype_sl, "%s}", neststrings[nestinglevel]);
@@ -461,7 +464,6 @@ int main(int argc, char **argv)
     EC_NULL_LOG (int2 = dalloc_get(dd, "DALLOC_CTX", 6, "uint64_t", 1) );
     LOG(log_debug, logtype_sl, "ctx1: 0x%" PRIx64 ", ctx2: 0x%" PRIx64, *int1, *int2);
 
-#if 0
     /* now parse a real spotlight packet */
     if (argc > 1) {
         char ibuf[8192];
@@ -480,7 +482,6 @@ int main(int argc, char **argv)
         /* Now dump the whole thing */
         dd_dump(query, 0);
     }
-#endif
 
 #if 0
     /* packing  */
index 4b4a9b9650944db199cff88f448ce1874ef75c27..b74b4f9c925fd40f7a6a2c198b8d2f160c88f863 100644 (file)
@@ -166,7 +166,7 @@ static int sl_pack_CNID(sl_cnids_t *cnids, char *buf, int offset, char *toc_buf,
     int cnid_count = talloc_array_length(cnids->ca_cnids);
     uint64_t id;
 
-    SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_CNIDS, (offset + SL_OFFSET_DELTA) / 8, cnid_count));
+    SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_CNIDS, (offset + SL_OFFSET_DELTA) / 8, 0 /* cnid_count */));
     SLVAL(buf, offset, sl_pack_tag(SQ_TYPE_COMPLEX, 1, *toc_idx + 1));
     *toc_idx += 1;
     offset += 8;
@@ -217,6 +217,25 @@ static int sl_pack_dict(sl_array_t *dict, char *buf, int offset, char *toc_buf,
     return offset;
 }
 
+static int sl_pack_filemeta(sl_filemeta_t *fm, char *buf, int offset, char *toc_buf, int *toc_idx)
+{
+    int fmlen;                  /* lenght of filemeta */
+    int saveoff = offset + 8;
+
+    SLVAL(buf, offset, sl_pack_tag(SQ_TYPE_COMPLEX, 1, *toc_idx + 1));
+    offset += 16;
+
+    fmlen = sl_pack(fm, buf + offset);
+    offset += fmlen;
+
+    SLVAL(buf, saveoff, sl_pack_tag(SQ_TYPE_DATA, (fmlen / 8) + 1, 8 /* unknown meaning, but always 8 */));
+
+    SLVAL(toc_buf, *toc_idx * 8, sl_pack_tag(SQ_CPX_TYPE_FILEMETA, (offset + SL_OFFSET_DELTA) / 8, fmlen / 8));
+    *toc_idx += 1;
+
+    return offset;
+}
+
 static int sl_pack_string(char **string, char *buf, int offset, char *toc_buf, int *toc_idx)
 {
     int len, octets, used_in_last_octet;
@@ -488,14 +507,15 @@ static int sl_unpack_cpx(DALLOC_CTX *query,
     uint8_t mark_exists;
     char *p;
     int qlen, used_in_last_block, slen;
-    sl_array_t *sl_arrary;
+    sl_array_t *sl_array;
     sl_dict_t *sl_dict;
+    sl_filemeta_t *sl_fm;
 
     switch (cpx_query_type) {
     case SQ_CPX_TYPE_ARRAY:
-        sl_arrary = talloc_zero(query, sl_array_t);
-        EC_NEG1_LOG( roffset = sl_unpack_loop(sl_arrary, buf, offset, cpx_query_count, toc_offset, encoding) );
-        dalloc_add(query, sl_arrary, sl_array_t);
+        sl_array = talloc_zero(query, sl_array_t);
+        EC_NEG1_LOG( roffset = sl_unpack_loop(sl_array, buf, offset, cpx_query_count, toc_offset, encoding) );
+        dalloc_add(query, sl_array, sl_array_t);
         break;
 
     case SQ_CPX_TYPE_DICT:
@@ -530,7 +550,9 @@ static int sl_unpack_cpx(DALLOC_CTX *query,
         if (qlen <= 8) {
             EC_FAIL_LOG("SQ_CPX_TYPE_FILEMETA: query_length <= 8: %d", qlen);
         } else {
-            EC_NEG1_LOG( sl_unpack(query, buf + offset + 8) );
+            sl_fm = talloc_zero(query, sl_filemeta_t);
+            EC_NEG1_LOG( sl_unpack(sl_fm, buf + offset + 8) );
+            dalloc_add(query, sl_fm, sl_filemeta_t);
         }
         roffset += qlen;
         break;