]> arthur.barton.de Git - netatalk.git/commitdiff
Better dumping and example
authorFrank Lahm <franklahm@googlemail.com>
Thu, 14 Jun 2012 14:18:07 +0000 (16:18 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 15 Aug 2012 18:14:21 +0000 (20:14 +0200)
etc/afpd/spotlight.c
etc/afpd/spotlight.h

index 379f5a9adeef28c66da5565a2761ffe68991c381..11ea4b9c4c39944a8f9479fb856ae3e2d5f5954e 100644 (file)
@@ -356,9 +356,9 @@ static int spotlight_dissect_loop(DALLOC_CTX *query,
             subcount = query_data64 >> 32;
             if (subcount > 64)
                 EC_FAIL;
-            sl_nit_t nil = 0;
+            sl_nil_t nil = 0;
             for (i = 0; i < subcount; i++)
-                dalloc_add(query, &nil, sl_nit_t);
+                dalloc_add(query, &nil, sl_nil_t);
             count -= subcount;
             break;
         }
@@ -512,13 +512,17 @@ static int dd_dump(DALLOC_CTX *dd, int nestinglevel)
 {
     const char *type;
 
-    printf("%sArray(#%d): {\n", neststrings[nestinglevel], talloc_array_length(dd->dd_talloc_array));
+    printf("%s%s(#%d): {\n", neststrings[nestinglevel], talloc_get_name(dd), talloc_array_length(dd->dd_talloc_array));
 
     for (int n = 0; n < talloc_array_length(dd->dd_talloc_array); n++) {
 
         type = talloc_get_name(dd->dd_talloc_array[n]);
 
-        if (STRCMP(type, ==, "int64_t")) {
+        if (STRCMP(type, ==, "DALLOC_CTX")
+                   || STRCMP(type, ==, "sl_array_t")
+                   || STRCMP(type, ==, "sl_dict_t")) {
+            dd_dump(dd->dd_talloc_array[n], nestinglevel + 1);
+        } else if (STRCMP(type, ==, "int64_t")) {
             int64_t i;
             memcpy(&i, dd->dd_talloc_array[n], sizeof(int64_t));
             printf("%s%d:\t%" PRId64 "\n", neststrings[nestinglevel + 1], n, i);
@@ -534,17 +538,6 @@ static int dd_dump(DALLOC_CTX *dd, int nestinglevel)
             sl_bool_t bl;
             memcpy(&bl, dd->dd_talloc_array[n], sizeof(sl_bool_t));
             printf("%s%d:\t%s\n", neststrings[nestinglevel + 1], n, bl ? "true" : "false");
-        } else if (STRCMP(type, ==, "DALLOC_CTX")) {
-            DALLOC_CTX nested;
-            memcpy(&nested, dd->dd_talloc_array[n], sizeof(DALLOC_CTX));
-            dd_dump(&nested, nestinglevel + 1);
-        } else if (STRCMP(type, ==, "sl_cnids_t *")) {
-            sl_cnids_t *cnids;
-            memcpy(&cnids, dd->dd_talloc_array[n], sizeof(sl_cnids_t *));
-            printf("%s%d:\tunkn1: %" PRIu16 ", unkn2: %" PRIu32,
-                   neststrings[nestinglevel + 1], n, cnids->ca_unkn1, cnids->ca_unkn2);
-            if (cnids->ca_cnids)
-                dd_dump(cnids->ca_cnids, nestinglevel + 1);
         } else if (STRCMP(type, ==, "sl_cnids_t")) {
             sl_cnids_t cnids;
             memcpy(&cnids, dd->dd_talloc_array[n], sizeof(sl_cnids_t));
@@ -603,19 +596,21 @@ int main(int argc, char **argv)
     cnids->ca_unkn2 = 2;
 
     dalloc_add(cnids->ca_cnids, &id, uint32_t);
-    dalloc_add(dd, &cnids, sl_cnids_t *);
+    dalloc_add(dd, cnids, sl_cnids_t);
 
-    /* test an stack CNID array */
-    id = 17;
-    sl_cnids_t cnids2;
+    /* Now the Spotlight types */
+    sl_array_t *sl_arrary = talloc_zero(dd, sl_array_t);
+    i = 1234;
+    dalloc_add(sl_arrary, &i, int64_t);
 
-    cnids2.ca_cnids = talloc_zero(mem_ctx, DALLOC_CTX);
-    cnids2.ca_unkn1 = 3;
-    cnids2.ca_unkn2 = 4;
+    sl_dict_t *sl_dict = talloc_zero(dd, sl_dict_t);
+    i = 5678;
+    dalloc_add(sl_dict, &i, int64_t);
+    dalloc_add(sl_arrary, sl_dict, sl_dict_t);
 
-    dalloc_add(cnids2.ca_cnids, &id, uint32_t);
-    dalloc_add(dd, &cnids2, sl_cnids_t);
+    dalloc_add(dd, sl_arrary, sl_array_t);
 
+    /* Now dump the whole thing */
     dd_dump(dd, 0);
 
     talloc_free(mem_ctx);
index 14c719cfda6f8767a630b1bc33b4d21db1208998..23c8b745244fe2a76947ed3bb3189462e4064f04 100644 (file)
@@ -27,7 +27,7 @@
 typedef DALLOC_CTX     sl_array_t;    /* an array of elements                                           */
 typedef DALLOC_CTX     sl_dict_t;     /* an array of key/value elements                                 */
 typedef DALLOC_CTX     sl_filemeta_t; /* an array of elements                                           */
-typedef int            sl_nit_t;      /* a nil element                                                  */
+typedef int            sl_nil_t;      /* a nil element                                                  */
 typedef bool           sl_bool_t;     /* a boolean, we avoid bool_t as it's a define for something else */
 typedef struct timeval sl_time_t;     /* a boolean, we avoid bool_t as it's a define for something else */
 typedef struct {