+ zone_private_key = strtok (line, ",");
+ if (NULL == zone_private_key)
+ break;
+ rvalue = strtok (NULL, ",");
+ if (NULL == rvalue)
+ break;
+ record_count = strtok (NULL, ",");
+ if (NULL == record_count)
+ break;
+ record_data_b64 = strtok (NULL, ",");
+ if (NULL == record_data_b64)
+ break;
+ label = strtok (NULL, ",");
+ if (NULL == label)
+ break;
+ line = strtok (NULL, "\n");
+ entry = GNUNET_new (struct FlatFileEntry);
+ {
+ unsigned long long ll;
+
+ if (1 != sscanf (rvalue,
+ "%llu",
+ &ll))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error parsing entry\n");
+ GNUNET_free (entry);
+ break;
+ }
+ entry->rvalue = (uint64_t) ll;
+ }
+ {
+ unsigned int ui;
+
+ if (1 != sscanf (record_count,
+ "%u",
+ &ui))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error parsing entry\n");
+ GNUNET_free (entry);
+ break;
+ }
+ entry->record_count = (uint32_t) ui;
+ }
+ entry->label = GNUNET_strdup (label);
+ record_data_size
+ = GNUNET_STRINGS_base64_decode (record_data_b64,
+ strlen (record_data_b64),
+ (void **) &record_data);
+ entry->record_data =
+ GNUNET_new_array (entry->record_count,
+ struct GNUNET_GNSRECORD_Data);
+ if (GNUNET_OK !=
+ GNUNET_GNSRECORD_records_deserialize (record_data_size,
+ record_data,
+ entry->record_count,
+ entry->record_data))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to deserialize record %s\n",
+ label);
+ GNUNET_free (entry->label);
+ GNUNET_free (entry);
+ GNUNET_free (record_data);
+ break;
+ }
+ GNUNET_free (record_data);
+
+ {
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key;
+
+ GNUNET_STRINGS_base64_decode (zone_private_key,
+ strlen (zone_private_key),
+ (void**)&private_key);
+ entry->private_key = *private_key;
+ GNUNET_free (private_key);
+ }
+
+ {
+ char *key;
+ size_t key_len;
+
+ key_len = strlen (label) + sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
+ key = GNUNET_malloc (strlen (label) + sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
+ GNUNET_memcpy (key,
+ label,
+ strlen (label));
+ GNUNET_memcpy (key+strlen(label),
+ &entry->private_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
+ GNUNET_CRYPTO_hash (key,
+ key_len,
+ &hkey);
+ GNUNET_free (key);
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONTAINER_multihashmap_put (plugin->hm,
+ &hkey,
+ entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_free (entry);
+ GNUNET_break (0);
+ }