nfsquota.c \
ofork.c \
quota.c \
+ spotlight.c \
status.c \
switch.c \
uam.c \
noinst_HEADERS = auth.h afp_config.h desktop.h directory.h fce_api_internal.h file.h \
filedir.h fork.h icon.h mangle.h misc.h status.h switch.h \
uam_auth.h uid.h unix.h volume.h hash.h acls.h acl_mappings.h extattrs.h \
- dircache.h afp_zeroconf.h afp_avahi.h afp_mdns.h dd.h
+ dircache.h afp_zeroconf.h afp_avahi.h afp_mdns.h
hash_SOURCES = hash.c
hash_CFLAGS = -DKAZLIB_TEST_MAIN -I$(top_srcdir)/include
fce_CFLAGS = -DFCE_TEST_MAIN -I$(top_srcdir)/include
fce_LDADD = $(top_builddir)/libatalk/libatalk.la
-spot_SOURCES = dd.c
+spot_SOURCES = spotlight.c
spot_CFLAGS = -DSPOT_TEST_MAIN
spot_LDADD = $(top_builddir)/libatalk/libatalk.la
+++ /dev/null
-/*
- 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 <string.h>
-#include <strings.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <inttypes.h>
-
-#include <atalk/errchk.h>
-#include <atalk/util.h>
-#include <atalk/logger.h>
-#include <atalk/talloc.h>
-#include <atalk/bstrlib.h>
-
-#include "dd.h"
-
-static const char *neststrings[] = {
- "",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "
-};
-
-int _dd_add_obj(dd_t *dd, void *talloc_chunk, void *obj, size_t size, int (*destructor)(void *))
-{
- AFP_ASSERT(talloc_chunk);
-
- if (destructor)
- talloc_set_destructor(talloc_chunk, destructor);
- if (dd->dd_talloc_array == NULL) {
- dd->dd_talloc_array = talloc_array(dd, void *, 1);
- } else {
- dd->dd_talloc_array = talloc_realloc(dd, dd->dd_talloc_array, void *, talloc_array_length(dd->dd_talloc_array) + 1);
- }
-
- memcpy(talloc_chunk, obj, size);
- dd->dd_talloc_array[talloc_array_length(dd->dd_talloc_array) - 1] = talloc_chunk;
-
- return 0;
-}
-
-static int dd_dump(dd_t *dd, int nestinglevel)
-{
- const char *type;
-
- printf("%sArray(#%d): {\n", neststrings[nestinglevel], 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")) {
- int64_t i;
- memcpy(&i, dd->dd_talloc_array[n], sizeof(int64_t));
- printf("%s%d:\t%" PRId64 "\n", neststrings[nestinglevel + 1], n, i);
- } else if (STRCMP(type, ==, "bstring")) {
- bstring b;
- memcpy(&b, dd->dd_talloc_array[n], sizeof(bstring));
- printf("%s%d:\t%s\n", neststrings[nestinglevel + 1], n, bdata(b));
- } else if (STRCMP(type, ==, "_Bool")) {
- bool bl;
- memcpy(&bl, dd->dd_talloc_array[n], sizeof(bool));
- printf("%s%d:\t%s\n", neststrings[nestinglevel + 1], n, bl ? "true" : "false");
- } else if (STRCMP(type, ==, "dd_t")) {
- dd_t *nested;
- memcpy(&nested, dd->dd_talloc_array[n], sizeof(dd_t *));
- dd_dump(nested, nestinglevel + 1);
- }
- }
- printf("%s}\n", neststrings[nestinglevel]);
-}
-
-static int bstring_destructor(void *bstr)
-{
- bdestroy(*(bstring *)bstr);
- return 0;
-}
-
-#ifdef SPOT_TEST_MAIN
-#include <stdarg.h>
-
-int main(int argc, char **argv)
-{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
- dd_t *dd = talloc_zero(mem_ctx, dd_t);
- int i;
-
- set_processname("spot");
- setuplog("default:info", "/dev/tty");
-
- LOG(logtype_default, log_info, "Start");
-
- i = 2;
- dd_add_obj(dd, &i, int64_t, NULL);
-
- bstring str = bfromcstr("hello world");
- dd_add_obj(dd, &str, bstring, bstring_destructor);
-
- bool b = true;
- dd_add_obj(dd, &b, bool, NULL);
-
- b = false;
- dd_add_obj(dd, &b, bool, NULL);
-
- i = 1;
- dd_add_obj(dd, &i, int64_t, NULL);
-
- /* add a nested array */
- dd_t *nested = talloc_zero(dd, dd_t);
- dd_add_obj(nested, &i, int64_t, NULL);
- dd_add_obj(nested, &str, bstring, bstring_destructor);
- dd_add_obj(dd, &nested, dd_t, NULL);
-
- dd_dump(dd, 0);
-
- talloc_free(mem_ctx);
- return 0;
-}
-#endif
+++ /dev/null
-/*
- 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 */
-
-#ifndef DD_H
-#define DD_H
-
-/* dynamic datastore */
-typedef struct {
- void **dd_talloc_array;
-} dd_t;
-
-#define dd_init(dd) (dd)->dd_talloc_array = NULL;
-
-#define dd_add_obj(dd, obj, type, destructor) \
- _dd_add_obj((dd), talloc((dd), type), (obj), sizeof(type), (destructor));
-
-#define dd_get_count(dd) talloc_array_length(dd->dd_talloc_array)
-
-extern int _dd_add_obj(dd_t *dd, void *talloc_chunk, void *obj, size_t size, int (*destructor)(void *));
-
-#endif /* DD_H */
--- /dev/null
+/*
+ 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 <string.h>
+#include <strings.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+#include <atalk/errchk.h>
+#include <atalk/util.h>
+#include <atalk/logger.h>
+#include <atalk/talloc.h>
+#include <atalk/bstrlib.h>
+
+#include "spotlight.h"
+
+#ifdef SPOT_TEST_MAIN
+
+static const char *neststrings[] = {
+ "",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " "
+};
+
+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));
+
+ 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")) {
+ int64_t i;
+ memcpy(&i, dd->dd_talloc_array[n], sizeof(int64_t));
+ printf("%s%d:\t%" PRId64 "\n", neststrings[nestinglevel + 1], n, i);
+ } else if (STRCMP(type, ==, "uint32_t")) {
+ uint32_t i;
+ memcpy(&i, dd->dd_talloc_array[n], sizeof(uint32_t));
+ printf("%s%d:\t%" PRIu32 "\n", neststrings[nestinglevel + 1], n, i);
+ } else if (STRCMP(type, ==, "char *")) {
+ char *s;
+ memcpy(&s, dd->dd_talloc_array[n], sizeof(char *));
+ printf("%s%d:\t%s\n", neststrings[nestinglevel + 1], n, s);
+ } else if (STRCMP(type, ==, "_Bool")) {
+ bool bl;
+ memcpy(&bl, dd->dd_talloc_array[n], sizeof(bool));
+ printf("%s%d:\t%s\n", neststrings[nestinglevel + 1], n, bl ? "true" : "false");
+ } else if (STRCMP(type, ==, "dd_t")) {
+ DALLOC_CTX *nested;
+ memcpy(&nested, dd->dd_talloc_array[n], sizeof(DALLOC_CTX *));
+ dd_dump(nested, nestinglevel + 1);
+ } else if (STRCMP(type, ==, "cnid_array_t")) {
+ cnid_array_t *cnids;
+ memcpy(&cnids, dd->dd_talloc_array[n], sizeof(cnid_array_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);
+ }
+ }
+ printf("%s}\n", neststrings[nestinglevel]);
+}
+
+#include <stdarg.h>
+
+int main(int argc, char **argv)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ DALLOC_CTX *dd = talloc_zero(mem_ctx, DALLOC_CTX);
+ int64_t i;
+
+ set_processname("spot");
+ setuplog("default:info", "/dev/tty");
+
+ LOG(logtype_default, log_info, "Start");
+
+ i = 2;
+ dalloc_add(dd, &i, int64_t);
+
+ i = 1;
+ dalloc_add(dd, &i, int64_t);
+
+
+ char *str = talloc_strdup(dd, "hello world");
+ dalloc_add(dd, &str, char *);
+
+ bool b = true;
+ dalloc_add(dd, &b, bool);
+
+ b = false;
+ dalloc_add(dd, &b, bool);
+
+
+ /* add a nested array */
+ DALLOC_CTX *nested = talloc_zero(dd, DALLOC_CTX);
+ i = 3;
+ dalloc_add(nested, &i, int64_t);
+ dalloc_add(dd, &nested, DALLOC_CTX);
+
+ /* test a CNID array */
+ uint32_t id = 16;
+ cnid_array_t *cnids = talloc_zero(dd, cnid_array_t);
+
+ cnids->ca_cnids = talloc_zero(cnids, DALLOC_CTX);
+
+ cnids->ca_unkn1 = 1;
+ cnids->ca_unkn2 = 2;
+
+ dalloc_add(cnids->ca_cnids, &id, uint32_t);
+ dalloc_add(dd, &cnids, cnid_array_t);
+
+ dd_dump(dd, 0);
+
+ talloc_free(mem_ctx);
+ return 0;
+}
+#endif
--- /dev/null
+/*
+ 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 */
+
+#ifndef SPOTLIGHT_H
+#define SPOTLIGHT_H
+
+#include <atalk/dalloc.h>
+
+typedef struct {
+ uint16_t ca_unkn1;
+ uint32_t ca_unkn2;
+ DALLOC_CTX *ca_cnids;
+} cnid_array_t;
+
+#endif /* SPOTLIGHT_H */
ftw.h \
dsi.h \
ldapconfig.h \
- talloc.h
+ talloc.h \
+ dalloc.h
--- /dev/null
+/*
+ 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 */
+
+#ifndef DALLOC_H
+#define DALLOC_H
+
+#include <atalk/talloc.h>
+
+/* dynamic datastore */
+typedef struct {
+ void **dd_talloc_array;
+} DALLOC_CTX;
+
+#define dalloc_add(dd, obj, type) \
+ dalloc_add_talloc_chunk((dd), talloc((dd), type), (obj), sizeof(type));
+
+#define dd_get_count(dd) talloc_array_length(dd->dd_talloc_array)
+
+extern int dalloc_add_talloc_chunk(DALLOC_CTX *dd, void *talloc_chunk, void *obj, size_t size);
+
+
+#endif /* DALLOC_H */
# Makefile.am for libatalk/talloc/
noinst_LTLIBRARIES = libtalloc.la
-libtalloc_la_SOURCES = talloc.c
+libtalloc_la_SOURCES = talloc.c dalloc.c
--- /dev/null
+/*
+ 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 <string.h>
+#include <strings.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+#include <atalk/errchk.h>
+#include <atalk/util.h>
+#include <atalk/logger.h>
+#include <atalk/talloc.h>
+#include <atalk/bstrlib.h>
+#include <atalk/dalloc.h>
+
+/* Use dalloc_add_obj() macro, not this function */
+int dalloc_add_talloc_chunk(DALLOC_CTX *dd, void *talloc_chunk, void *obj, size_t size)
+{
+ AFP_ASSERT(talloc_chunk);
+
+ dd->dd_talloc_array = talloc_realloc(dd, dd->dd_talloc_array, void *, talloc_array_length(dd->dd_talloc_array) + 1);
+ memcpy(talloc_chunk, obj, size);
+ dd->dd_talloc_array[talloc_array_length(dd->dd_talloc_array) - 1] = talloc_chunk;
+
+ return 0;
+}