#include "gnunet_pseudonym_lib.h"
#include "gnunet_bio_lib.h"
-/**
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+
+#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
+
+/**
* Name of the directory which stores meta data for pseudonym
*/
#define PS_METADATA_DIR DIR_SEPARATOR_STR "data" DIR_SEPARATOR_STR "pseudonyms" DIR_SEPARATOR_STR "metadata" DIR_SEPARATOR_STR
-/**
+/**
* Name of the directory which stores names for pseudonyms
*/
#define PS_NAMES_DIR DIR_SEPARATOR_STR "data" DIR_SEPARATOR_STR "pseudonyms" DIR_SEPARATOR_STR "names" DIR_SEPARATOR_STR
-/**
+/**
+ * Configuration section we use.
+ */
+#define GNUNET_CLIENT_SERVICE_NAME "client"
+
+
+
+/**
* Registered callbacks for discovery of pseudonyms.
*/
struct DiscoveryCallback
{
- /**
+ /**
* This is a linked list.
*/
struct DiscoveryCallback *next;
- /**
+ /**
* Function to call each time a pseudonym is discovered.
*/
GNUNET_PSEUDONYM_Iterator callback;
- /**
+ /**
* Closure for callback.
*/
void *closure;
};
-/**
- * Head of the linked list of functions to call when
+/**
+ * Head of the linked list of functions to call when
* new pseudonyms are added.
*/
static struct DiscoveryCallback *head;
*/
int
GNUNET_PSEUDONYM_discovery_callback_register (const struct
- GNUNET_CONFIGURATION_Handle
- *cfg,
+ GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_PSEUDONYM_Iterator
iterator, void *closure)
{
* @return filename of the pseudonym (if psid != NULL) or directory with the data (if psid == NULL)
*/
static char *
-get_data_filename (const struct GNUNET_CONFIGURATION_Handle
- *cfg, const char *prefix, const GNUNET_HashCode * psid)
+get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *prefix, const GNUNET_HashCode * psid)
{
struct GNUNET_CRYPTO_HashAsciiEncoded enc;
if (psid != NULL)
GNUNET_CRYPTO_hash_to_enc (psid, &enc);
- return GNUNET_DISK_get_home_filename (cfg,
- GNUNET_CLIENT_SERVICE_NAME,
- prefix,
+ return GNUNET_DISK_get_home_filename (cfg, GNUNET_CLIENT_SERVICE_NAME, prefix,
(psid ==
NULL) ? NULL : (const char *) &enc,
NULL);
static int
read_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
const GNUNET_HashCode * nsid,
- struct GNUNET_CONTAINER_MetaData **meta,
- int32_t * ranking, char **ns_name)
+ struct GNUNET_CONTAINER_MetaData **meta, int32_t * ranking,
+ char **ns_name)
{
char *fn;
char *emsg;
}
if (GNUNET_OK != GNUNET_BIO_read_close (fileR, &emsg))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("Failed to parse metadata about pseudonym from file `%s': %s\n"),
- fn, emsg);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to parse metadata about pseudonym from file `%s': %s\n"), fn,
+ emsg);
GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fn));
GNUNET_CONTAINER_meta_data_destroy (*meta);
*meta = NULL;
/**
* Return the unique, human readable name for the given namespace.
*
- * @param cfg configuration
+ * @param cfg configuration
* @param nsid cryptographic ID of the namespace
* @return NULL on failure (should never happen)
*/
if (GNUNET_OK == read_info (cfg, nsid, &meta, rank, &name))
{
if ((meta != NULL) && (name == NULL))
- name = GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METATYPE_PUBLISHER,
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METATYPE_SUMMARY,
- -1);
+ name =
+ GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METATYPE_PUBLISHER,
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METATYPE_SUMMARY,
+ -1);
if (meta != NULL)
{
GNUNET_CONTAINER_meta_data_destroy (meta);
len = 0;
if (0 == STAT (fn, &sbuf))
GNUNET_DISK_file_size (fn, &len, GNUNET_YES);
- fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE
- | GNUNET_DISK_OPEN_READWRITE,
+ fh = GNUNET_DISK_file_open (fn,
+ GNUNET_DISK_OPEN_CREATE |
+ GNUNET_DISK_OPEN_READWRITE,
GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE);
i = 0;
idx = -1;
while ((len >= sizeof (GNUNET_HashCode)) &&
- (sizeof (GNUNET_HashCode)
- == GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode))))
+ (sizeof (GNUNET_HashCode) ==
+ GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode))))
{
if (0 == memcmp (&nh, nsid, sizeof (GNUNET_HashCode)))
{
idx = i;
if (sizeof (GNUNET_HashCode) !=
GNUNET_DISK_file_write (fh, nsid, sizeof (GNUNET_HashCode)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "write", fn);
}
GNUNET_DISK_file_close (fh);
ret = GNUNET_malloc (strlen (name) + 32);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
- fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE
- | GNUNET_DISK_OPEN_READWRITE,
+ fh = GNUNET_DISK_file_open (fn,
+ GNUNET_DISK_OPEN_CREATE |
+ GNUNET_DISK_OPEN_READWRITE,
GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE);
GNUNET_free (fn);
/**
* List all available pseudonyms.
*
- * @param cfg overall configuration
+ * @param cfg overall configuration
* @param iterator function to call for each pseudonym
* @param closure closure for iterator
* @return number of pseudonyms found