(0 != strncmp (s, GNUNET_FS_URI_PREFIX GNUNET_FS_URI_SKS_INFIX,
pos) ) )
return NULL; /* not an SKS URI */
- if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1) ||
+ if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) ||
(s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '/') )
{
*emsg = GNUNET_strdup (_("Malformed SKS URI"));
struct GNUNET_FS_Uri *ret;
struct FileIdentifier fi;
unsigned int pos;
+ unsigned long long flen;
size_t slen;
char h1[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)];
char h2[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)];
&fi.chk.query)) ||
(1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
"%llu",
- &fi.file_length)))
+ &flen)) )
{
*emsg = GNUNET_strdup (_("Malformed CHK URI"));
return NULL;
}
- fi.file_length = GNUNET_htonll (fi.file_length);
+ fi.file_length = GNUNET_htonll (flen);
ret = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri));
ret->type = chk;
ret->data.chk = fi;
/**
* Convert string back to binary data.
*
- * @param input '\0'-terminated string
+ * @param input '\\0'-terminated string
* @param data where to write binary data
* @param size how much data should be converted
* @return number of characters processed from input,
bits = 0;
hbits = 0;
len = 0;
- pos = 0;
for (pos = 0; pos < size; pos++)
{
while (hbits < 8)
unsigned int pos;
unsigned int npos;
unsigned long long exptime;
+ unsigned long long flen;
struct GNUNET_TIME_Absolute et;
struct GNUNET_CRYPTO_RsaSignature sig;
struct LocUriAssembly ass;
&ass.fi.chk.query)) ||
(1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
"%llu",
- &ass.fi.file_length)) )
+ &flen)) )
{
*emsg = GNUNET_strdup (_("SKS URI malformed"));
return NULL;
}
- ass.fi.file_length = GNUNET_htonll (ass.fi.file_length);
+ ass.fi.file_length = GNUNET_htonll (flen);
npos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2;
while ((s[npos] != '\0') && (s[npos] != '.'))
}
+/**
+ * Obtain the expiration of the LOC URI.
+ *
+ * @param uri location URI to get the expiration from
+ * @return expiration time of the URI
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_FS_uri_loc_get_expiration (const struct GNUNET_FS_Uri *uri)
+{
+ GNUNET_assert (uri->type == loc);
+ return uri->data.loc.expirationTime;
+}
+
+
+
/**
* Obtain the URI of the content itself.
*
/**
* Construct a location URI (this peer will be used for the location).
*
- * @param baseURI content offered by the sender
+ * @param baseUri content offered by the sender
* @param cfg configuration information (used to find our hostkey)
* @param expiration_time how long will the content be offered?
* @return the location URI, NULL on error
}
+/**
+ * Create an SKS URI from a namespace and an identifier.
+ *
+ * @param ns namespace
+ * @param id identifier
+ * @param emsg where to store an error message
+ * @return an FS URI for the given namespace and identifier
+ */
+struct GNUNET_FS_Uri *
+GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns,
+ const char *id,
+ char **emsg)
+{
+ struct GNUNET_FS_Uri *ns_uri;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk;
+
+ ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
+ ns_uri->type = sks;
+ GNUNET_CRYPTO_rsa_key_get_public (ns->key,
+ &pk);
+ GNUNET_CRYPTO_hash (&pk,
+ sizeof (pk),
+ &ns_uri->data.sks.namespace);
+ ns_uri->data.sks.identifier = GNUNET_strdup (id);
+ return ns_uri;
+}
+
+
/**
* Canonicalize a keyword.
*
/* keep characters listed above without changes */
*wpos = *rpos;
wpos++;
+ break;
default:
/* replace characters listed above with '_' */
*wpos = '_';
struct GNUNET_FS_Uri *ret;
unsigned int i;
+ if (uri == NULL)
+ return NULL;
ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
memcpy (ret, uri, sizeof (struct GNUNET_FS_Uri));
switch (ret->type)
emsg = NULL;
if ( (argc == 1) &&
(strlen(argv[0]) > strlen(GNUNET_FS_URI_PREFIX)) &&
- (strncmp(argv[0], GNUNET_FS_URI_PREFIX, strlen(GNUNET_FS_URI_PREFIX)) ) &&
+ (0 == strncmp(argv[0], GNUNET_FS_URI_PREFIX, strlen(GNUNET_FS_URI_PREFIX)) ) &&
(NULL != (uri = GNUNET_FS_uri_parse(argv[0], &emsg)) ) )
return uri;
GNUNET_free_non_null (emsg);
* Adds it to the URI.
*
* @param cls URI to update
- * @param type type of the meta data
- * @param data value of the meta data
- * @return GNUNET_OK (always)
+ * @param plugin_name name of the plugin that produced this value;
+ * special values can be used (i.e. '<zlib>' for zlib being
+ * 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 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
+ * @param data_len number of bytes in data
+ * @return 0 (always)
*/
static int
gather_uri_data (void *cls,
- EXTRACTOR_KeywordType type,
- const char *data)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
struct GNUNET_FS_Uri *uri = cls;
char *nkword;
int j;
+ if ( (format != EXTRACTOR_METAFORMAT_UTF8) &&
+ (format != EXTRACTOR_METAFORMAT_C_STRING) )
+ return 0;
for (j = uri->data.ksk.keywordCount - 1; j >= 0; j--)
if (0 == strcmp (&uri->data.ksk.keywords[j][1], data))
return GNUNET_OK;
strcpy (nkword, " "); /* not mandatory */
strcat (nkword, data);
uri->data.ksk.keywords[uri->data.ksk.keywordCount++] = nkword;
- return GNUNET_OK;
+ return 0;
}
* Construct a keyword-URI from meta-data (take all entries
* in the meta-data and construct one large keyword URI
* that lists all keywords that can be found in the meta-data).
- * @deprecated
+ *
+ * @param md metadata to use
+ * @return NULL on error, otherwise a KSK URI
*/
struct GNUNET_FS_Uri *
GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData *md)
ret->data.ksk.keywords = NULL;
ret->data.ksk.keywords
= GNUNET_malloc (sizeof (char *) *
- GNUNET_CONTAINER_meta_data_get_contents (md, NULL, NULL));
- GNUNET_CONTAINER_meta_data_get_contents (md, &gather_uri_data, ret);
+ GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL));
+ GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret);
return ret;
}