/*
This file is part of GNUnet.
- (C) 2005, 2006, 2009 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2005, 2006, 2009 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
-
/**
* @file fs/test_fs_directory.c
* @brief Test for fs_directory.c
* @author Christian Grothoff
*/
-
#include "platform.h"
+#if HAVE_EXTRACTOR_H
#include <extractor.h>
+#endif
#include "gnunet_util_lib.h"
#include "gnunet_fs_service.h"
-#include "fs.h"
+#include "fs_api.h"
#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); return 1; }
};
static void
-processor (void *cls,
- const char *filename,
- const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *md,
- size_t length, const void *data)
+processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
+ const struct GNUNET_CONTAINER_MetaData *md, size_t length,
+ const void *data)
{
struct PCLS *p = cls;
int i;
return; /* ignore directory's meta data */
for (i = 0; i < p->max; i++)
{
- if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i],
- md) &&
+ if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], md) &&
GNUNET_FS_uri_test_equal (p->uri[i], uri))
{
p->pos++;
return;
}
}
- fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__);
+ FPRINTF (stderr, "Error at %s:%d\n", __FILE__, __LINE__);
}
static int
char txt[128];
int ret = 0;
struct GNUNET_TIME_Absolute start;
- char *s;
+ const char *s;
cls.max = i;
uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i);
mds = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_MetaData *) * i);
meta = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_insert (meta,
- "<test>",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
+ GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
"A title", strlen ("A title") + 1);
- GNUNET_CONTAINER_meta_data_insert (meta,
- "<test>",
+ GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
"An author", strlen ("An author") + 1);
for (p = 0; p < i; p++)
{
for (q = 0; q <= p; q++)
{
GNUNET_snprintf (txt, sizeof (txt), "%u -- %u\n", p, q);
- GNUNET_CONTAINER_meta_data_insert (mds[p],
- "<test>",
+ GNUNET_CONTAINER_meta_data_insert (mds[p], "<test>",
+#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
q % EXTRACTOR_metatype_get_max (),
+#else
+ q % 128,
+#endif
EXTRACTOR_METAFORMAT_UTF8,
"text/plain", txt, strlen (txt) + 1);
}
- GNUNET_snprintf (uri,
- sizeof (uri),
+ GNUNET_snprintf (uri, sizeof (uri),
"gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
p);
emsg = NULL;
GNUNET_FS_directory_builder_add (db, uris[p], mds[p], NULL);
GNUNET_FS_directory_builder_finish (db, &dlen, (void **) &data);
s = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration
- (start));
- fprintf (stdout,
+ (start),
+ GNUNET_YES);
+ FPRINTF (stdout,
"Creating directory with %u entires and total size %llu took %s\n",
i, (unsigned long long) dlen, s);
- GNUNET_free (s);
if (i < 100)
{
cls.pos = 0;