more FS coding
[oweals/gnunet.git] / src / fs / fs_uri.c
index 8e69a84258dacde68a56d945954b73a530927851..1c0686ed99d65b88f278893466c566615d99b5ac 100644 (file)
@@ -396,6 +396,7 @@ uri_chk_parse (const char *s, char **emsg)
   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)];
@@ -429,12 +430,12 @@ uri_chk_parse (const char *s, char **emsg)
                                               &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;
@@ -491,7 +492,6 @@ enc2bin (const char *input, void *data, size_t size)
   bits = 0;
   hbits = 0;
   len = 0;
-  pos = 0;
   for (pos = 0; pos < size; pos++)
     {
       while (hbits < 8)
@@ -544,6 +544,7 @@ uri_loc_parse (const char *s, char **emsg)
   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;
@@ -578,12 +579,12 @@ uri_loc_parse (const char *s, char **emsg)
                                                    &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] != '.'))
@@ -628,11 +629,11 @@ uri_loc_parse (const char *s, char **emsg)
       goto ERR;
     }
   ass.purpose.size = htonl(sizeof(struct LocUriAssembly));
-  ass.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT);
+  ass.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
   et.value = exptime;
   ass.exptime = GNUNET_TIME_absolute_hton (et);
   if (GNUNET_OK != 
-      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT,
+      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT,
                                &ass.purpose,
                                &sig,
                                &ass.peer))
@@ -847,7 +848,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
   GNUNET_free (keyfile);
   GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
   ass.purpose.size = htonl(sizeof(struct LocUriAssembly));
-  ass.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT);
+  ass.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
   ass.exptime = GNUNET_TIME_absolute_hton (expiration_time);
   ass.fi = baseUri->data.chk;
   ass.peer = my_public_key;
@@ -1193,7 +1194,7 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
   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);
@@ -1480,7 +1481,9 @@ gather_uri_data (void *cls,
  * 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)