/*
This file is part of GNUnet.
- (C) 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2003, 2004, 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.
*/
/**
*/
#include "platform.h"
#include "gnunet_fs_service.h"
-#include "fs.h"
+#include "fs_api.h"
/**
* String that is used to indicate that a file
* Does the meta-data claim that this is a directory?
* Checks if the mime-type is that of a GNUnet directory.
*
- * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
- * we have no mime-type information (treat as 'GNUNET_NO')
+ * @return #GNUNET_YES if it is, #GNUNET_NO if it is not, #GNUNET_SYSERR if
+ * we have no mime-type information (treat as #GNUNET_NO)
*/
int
-GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
- *md)
+GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData *md)
{
char *mime;
int ret;
if (NULL == md)
return GNUNET_SYSERR;
- mime =
- GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
- if (mime == NULL)
+ mime = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
+ if (NULL == mime)
return GNUNET_SYSERR;
- ret = (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : GNUNET_NO;
+ ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : GNUNET_NO;
GNUNET_free (mime);
return ret;
}
/**
* Set the MIMETYPE information for the given
* metadata to "application/gnunet-directory".
- *
+ *
* @param md metadata to add mimetype to
*/
void
* used in the main libextractor library and yielding
* meta data).
* @param type libextractor-type describing the meta data
- * @param format basic format information about data
+ * @param format basic format information about data
* @param data_mime_type mime-type of data (not of the original file);
* can be NULL (if mime-type is not known)
* @param data actual meta-data found
if (data_len > 0)
{
gfdc->data = GNUNET_malloc (data_len);
- memcpy (gfdc->data, data, data_len);
+ GNUNET_memcpy (gfdc->data, data, data_len);
}
return 1;
}
if ((offset == 0) &&
((size < 8 + sizeof (uint32_t)) ||
(0 != memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8))))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("MAGIC mismatch. This is not a GNUnet directory.\n"));
return GNUNET_SYSERR;
- }
pos = offset;
if (offset == 0)
{
- memcpy (&mdSize, &cdata[8], sizeof (uint32_t));
+ GNUNET_memcpy (&mdSize, &cdata[8], sizeof (uint32_t));
mdSize = ntohl (mdSize);
if (mdSize > size - 8 - sizeof (uint32_t))
{
return GNUNET_NO; /* illegal in directory! */
}
- memcpy (&mdSize, &cdata[pos], sizeof (uint32_t));
+ GNUNET_memcpy (&mdSize, &cdata[pos], sizeof (uint32_t));
mdSize = ntohl (mdSize);
pos += sizeof (uint32_t);
if (pos + mdSize > size)
/**
* Create a directory builder.
- *
+ *
* @param mdir metadata for the directory
*/
struct GNUNET_FS_DirectoryBuilder *
{
struct GNUNET_FS_DirectoryBuilder *ret;
- ret = GNUNET_malloc (sizeof (struct GNUNET_FS_DirectoryBuilder));
+ ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
if (mdir != NULL)
ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir);
else
/**
* Add an entry to a directory.
- *
+ *
* @param bld directory to extend
* @param uri uri of the entry (must not be a KSK)
* @param md metadata of the entry
e = GNUNET_malloc (sizeof (struct BuilderEntry) + slen + mds +
sizeof (uint32_t));
ser = (char *) &e[1];
- memcpy (ser, uris, slen);
+ GNUNET_memcpy (ser, uris, slen);
GNUNET_free (uris);
sptr = &ser[slen + sizeof (uint32_t)];
ret =
else
mds = ret;
big = htonl (mds);
- memcpy (&ser[slen], &big, sizeof (uint32_t));
+ GNUNET_memcpy (&ser[slen], &big, sizeof (uint32_t));
e->len = slen + sizeof (uint32_t) + mds;
e->next = bld->head;
bld->head = e;
return GNUNET_SYSERR;
}
*rdata = data;
- memcpy (data, GNUNET_DIRECTORY_MAGIC, strlen (GNUNET_DIRECTORY_MAGIC));
+ GNUNET_memcpy (data, GNUNET_DIRECTORY_MAGIC, strlen (GNUNET_DIRECTORY_MAGIC));
off = strlen (GNUNET_DIRECTORY_MAGIC);
sptr = &data[off + sizeof (uint32_t)];
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
GNUNET_assert (ret != -1);
big = htonl (ret);
- memcpy (&data[off], &big, sizeof (uint32_t));
+ GNUNET_memcpy (&data[off], &big, sizeof (uint32_t));
off += sizeof (uint32_t) + ret;
for (j = 0; j < bld->count; j++)
{
psize = off;
off += sizes[i];
off = do_align (psize, off);
- memcpy (&data[off - sizes[i]], &(bes[i])[1], sizes[i]);
+ GNUNET_memcpy (&data[off - sizes[i]], &(bes[i])[1], sizes[i]);
GNUNET_free (bes[i]);
}
GNUNET_free_non_null (sizes);