summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-05 16:51:04 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-05 16:51:04 +0000
commit08b77389d8aac354da74e53412099f7fb60caa28 (patch)
tree4c6ff56ee13b6f5425bfd128f024e8f4f8a20e64 /src
parent39c0c0fdef116610245c43e825ce9ebeff11234d (diff)
removing gnunet-pseudonym, we're using GNS/gnunet-identity instead in the future
Diffstat (limited to 'src')
-rw-r--r--src/fs/Makefile.am23
-rw-r--r--src/fs/fs_pseudonym.c756
-rw-r--r--src/fs/gnunet-pseudonym.c353
-rw-r--r--src/fs/test_pseudonym.c223
-rw-r--r--src/include/gnunet_fs_service.h174
5 files changed, 0 insertions, 1529 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index ce70ff751..30a14e2c2 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -36,7 +36,6 @@ libgnunetfs_la_SOURCES = \
fs_file_information.c \
fs_getopt.c \
fs_list_indexed.c \
- fs_pseudonym.c \
fs_publish.c \
fs_publish_ksk.c \
fs_publish_ublock.c fs_publish_ublock.h \
@@ -80,7 +79,6 @@ bin_PROGRAMS = \
gnunet-directory \
gnunet-download \
gnunet-publish \
- gnunet-pseudonym \
gnunet-search \
gnunet-fs \
gnunet-unindex
@@ -153,17 +151,6 @@ gnunet_helper_fs_publish_LDADD = \
gnunet_helper_fs_publish_DEPENDENCIES = \
libgnunetfs.la
-gnunet_pseudonym_SOURCES = \
- gnunet-pseudonym.c
-gnunet_pseudonym_LDADD = \
- $(top_builddir)/src/identity/libgnunetidentity.la \
- $(top_builddir)/src/fs/libgnunetfs.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- -lextractor \
- $(GN_LIBINTL)
-gnunet_pseudonym_DEPENDENCIES = \
- libgnunetfs.la
-
gnunet_search_SOURCES = \
gnunet-search.c
gnunet_search_LDADD = \
@@ -256,7 +243,6 @@ check_PROGRAMS = \
test_fs_list_indexed \
test_fs_namespace \
test_fs_namespace_list_updateable \
- test_pseudonym \
test_fs_publish \
test_fs_publish_persistence \
test_fs_search \
@@ -303,7 +289,6 @@ TESTS = \
test_fs_list_indexed \
test_fs_namespace \
test_fs_namespace_list_updateable \
- test_pseudonym \
test_fs_publish \
test_fs_publish_persistence \
test_fs_search \
@@ -324,14 +309,6 @@ TESTS = \
endif
-test_pseudonym_SOURCES = \
- test_pseudonym.c
-test_pseudonym_LDADD = \
- -lgcrypt \
- $(top_builddir)/src/fs/libgnunetfs.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-
test_fs_directory_SOURCES = \
test_fs_directory.c
test_fs_directory_LDADD = \
diff --git a/src/fs/fs_pseudonym.c b/src/fs/fs_pseudonym.c
deleted file mode 100644
index 2600e51eb..000000000
--- a/src/fs/fs_pseudonym.c
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2003-2013 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- 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.
-*/
-/**
- * @file fs/fs_pseudonym.c
- * @brief pseudonym functions; these functions are about namespaces
- * managed by other users; we might want to eliminate this
- * entire API and instead manage pseudonyms only via GNS
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_fs_service.h"
-
-
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
-
-#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 "pseudonym" 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 "pseudonym" DIR_SEPARATOR_STR "names" DIR_SEPARATOR_STR
-
-
-/**
- * Configuration section we use.
- */
-#define GNUNET_CLIENT_SERVICE_NAME "fs"
-
-
-/* ************************* Disk operations (pseudonym data mgmt) **************** */
-
-/**
- * Registered callbacks for discovery of pseudonyms.
- */
-struct GNUNET_FS_Pseudonym_DiscoveryHandle
-{
- /**
- * This is a doubly linked list.
- */
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *next;
-
- /**
- * This is a doubly linked list.
- */
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *prev;
-
- /**
- * Function to call each time a pseudonym is discovered.
- */
- GNUNET_FS_PseudonymIterator callback;
-
- /**
- * Closure for callback.
- */
- void *callback_cls;
-};
-
-
-/**
- * Head of the linked list of functions to call when
- * new pseudonyms are added.
- */
-static struct GNUNET_FS_Pseudonym_DiscoveryHandle *disco_head;
-
-/**
- * Tail of the linked list of functions to call when
- * new pseudonyms are added.
- */
-static struct GNUNET_FS_Pseudonym_DiscoveryHandle *disco_tail;
-
-
-/**
- * Internal notification about new tracked URI.
- *
- * @param pseudonym public key of the pseudonym
- * @param md meta data to be written
- * @param rating rating of pseudonym
- */
-static void
-internal_notify (const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const struct GNUNET_CONTAINER_MetaData *md, int rating)
-{
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *pos;
-
- for (pos = disco_head; NULL != pos; pos = pos->next)
- pos->callback (pos->callback_cls, pseudonym, NULL, NULL, md, rating);
-}
-
-
-/**
- * Register callback to be invoked whenever we discover
- * a new pseudonym.
- * Will immediately call provided iterator callback for all
- * already discovered pseudonyms.
- *
- * @param cfg configuration to use
- * @param iterator iterator over pseudonym
- * @param iterator_cls point to a closure
- * @return registration handle
- */
-struct GNUNET_FS_Pseudonym_DiscoveryHandle *
-GNUNET_FS_pseudonym_discovery_callback_register (const struct
- GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FS_PseudonymIterator iterator,
- void *iterator_cls)
-{
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh;
-
- dh = GNUNET_new (struct GNUNET_FS_Pseudonym_DiscoveryHandle);
- dh->callback = iterator;
- dh->callback_cls = iterator_cls;
- GNUNET_CONTAINER_DLL_insert (disco_head, disco_tail, dh);
- GNUNET_FS_pseudonym_list_all (cfg, iterator, iterator_cls);
- return dh;
-}
-
-
-/**
- * Unregister pseudonym discovery callback.
- *
- * @param dh registration to unregister
- */
-void
-GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh)
-{
- GNUNET_CONTAINER_DLL_remove (disco_head, disco_tail, dh);
- GNUNET_free (dh);
-}
-
-
-/**
- * Get the filename (or directory name) for the given
- * pseudonym identifier and directory prefix.
- *
- * @param cfg configuration to use
- * @param prefix path components to append to the private directory name
- * @param pseudonym the pseudonym, can be NULL
- * @return filename of the pseudonym (if pseudonym != NULL) or directory with the data (if pseudonym == NULL)
- */
-static char *
-get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *prefix,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym)
-{
- struct GNUNET_CRYPTO_HashAsciiEncoded enc;
- struct GNUNET_HashCode psid;
-
- if (NULL != pseudonym)
- {
- GNUNET_CRYPTO_hash (pseudonym,
- sizeof (struct GNUNET_CRYPTO_EccPublicKey),
- &psid);
- GNUNET_CRYPTO_hash_to_enc (&psid, &enc);
- }
- return GNUNET_DISK_get_home_filename (cfg,
- GNUNET_CLIENT_SERVICE_NAME, prefix,
- (NULL == pseudonym)
- ? NULL
- : (const char *) &enc,
- NULL);
-}
-
-
-/**
- * Get the filename (or directory name) for the given
- * hash code and directory prefix.
- *
- * @param cfg configuration to use
- * @param prefix path components to append to the private directory name
- * @param hc some hash code
- * @return filename of the pseudonym (if hc != NULL) or directory with the data (if hc == NULL)
- */
-static char *
-get_data_filename_hash (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *prefix,
- const struct GNUNET_HashCode *hc)
-{
- struct GNUNET_CRYPTO_HashAsciiEncoded enc;
-
- if (NULL != hc)
- GNUNET_CRYPTO_hash_to_enc (hc, &enc);
- return GNUNET_DISK_get_home_filename (cfg,
- GNUNET_CLIENT_SERVICE_NAME, prefix,
- (NULL == hc)
- ? NULL
- : (const char *) &enc,
- NULL);
-}
-
-
-/**
- * Set the pseudonym metadata, rank and name.
- * Writes the pseudonym infomation into a file
- *
- * @param cfg overall configuration
- * @param pseudonym id of the pseudonym
- * @param name name to set. Must be the non-unique version of it.
- * May be NULL, in which case it erases pseudonym's name!
- * @param md metadata to set
- * May be NULL, in which case it erases pseudonym's metadata!
- * @param rank rank to assign
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- const struct GNUNET_CONTAINER_MetaData *md,
- int32_t rank)
-{
- char *fn;
- struct GNUNET_BIO_WriteHandle *fileW;
-
- fn = get_data_filename (cfg, PS_METADATA_DIR, pseudonym);
- if (NULL == (fileW = GNUNET_BIO_write_open (fn)))
- {
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- if ((GNUNET_OK != GNUNET_BIO_write (fileW, pseudonym,
- sizeof (struct GNUNET_CRYPTO_EccPublicKey))) ||
- (GNUNET_OK != GNUNET_BIO_write_int32 (fileW, rank)) ||
- (GNUNET_OK != GNUNET_BIO_write_string (fileW, name)) ||
- (GNUNET_OK != GNUNET_BIO_write_meta_data (fileW, md)))
- {
- (void) GNUNET_BIO_write_close (fileW);
- GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fn));
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK != GNUNET_BIO_write_close (fileW))
- {
- GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fn));
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- GNUNET_free (fn);
- /* create entry for pseudonym name in names */
- if (NULL != name)
- GNUNET_free_non_null (GNUNET_FS_pseudonym_name_uniquify (cfg, pseudonym,
- name, NULL));
- return GNUNET_OK;
-}
-
-
-/**
- * Read pseudonym infomation from a file
- *
- * @param cfg configuration to use
- * @param pseudonym hash code of a pseudonym
- * @param meta meta data to be read from a file
- * @param rank rank of a pseudonym
- * @param ns_name name of a pseudonym
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-static int
-read_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- struct GNUNET_CONTAINER_MetaData **meta,
- int32_t *rank,
- char **ns_name)
-{
- struct GNUNET_CRYPTO_EccPublicKey pd;
- char *fn;
- char *emsg;
- struct GNUNET_BIO_ReadHandle *fileR;
-
- fn = get_data_filename (cfg, PS_METADATA_DIR, pseudonym);
- if (GNUNET_YES !=
- GNUNET_DISK_file_test (fn))
- {
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- if (NULL == (fileR = GNUNET_BIO_read_open (fn)))
- {
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- emsg = NULL;
- *ns_name = NULL;
- if ( (GNUNET_OK != GNUNET_BIO_read (fileR, "pseudonym", &pd, sizeof (pd))) ||
- (0 != memcmp (&pd, pseudonym, sizeof (pd))) ||
- (GNUNET_OK != GNUNET_BIO_read_int32 (fileR, rank)) ||
- (GNUNET_OK !=
- GNUNET_BIO_read_string (fileR, "Read string error!", ns_name, 200)) ||
- (GNUNET_OK !=
- GNUNET_BIO_read_meta_data (fileR, "Read meta data error!", meta)) )
- {
- (void) GNUNET_BIO_read_close (fileR, &emsg);
- GNUNET_free_non_null (emsg);
- GNUNET_free_non_null (*ns_name);
- *ns_name = NULL;
- GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fn));
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK != GNUNET_BIO_read_close (fileR, &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;
- GNUNET_free_non_null (*ns_name);
- *ns_name = NULL;
- GNUNET_free_non_null (emsg);
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- GNUNET_free (fn);
- return GNUNET_OK;
-}
-
-
-/**
- * Return unique variant of the namespace name. Use it after
- * GNUNET_FS_pseudonym_get_info() to make sure that name is unique.
- *
- * @param cfg configuration
- * @param pseudonym public key of the pseudonym
- * @param name name to uniquify
- * @param suffix if not NULL, filled with the suffix value
- * @return NULL on failure (should never happen), name on success.
- * Free the name with GNUNET_free().
- */
-char *
-GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- unsigned int *suffix)
-{
- struct GNUNET_HashCode nh;
- struct GNUNET_CRYPTO_EccPublicKey pi;
- uint64_t len;
- char *fn;
- struct GNUNET_DISK_FileHandle *fh;
- unsigned int i;
- unsigned int idx;
- char *ret;
- struct stat sbuf;
-
- GNUNET_CRYPTO_hash (name, strlen (name), &nh);
- fn = get_data_filename_hash (cfg, PS_NAMES_DIR, &nh);
- len = 0;
- if (0 == STAT (fn, &sbuf))
- GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (fn, &len, GNUNET_YES, GNUNET_YES));
- 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 (struct GNUNET_CRYPTO_EccPublicKey)) &&
- (sizeof (struct GNUNET_CRYPTO_EccPublicKey) ==
- GNUNET_DISK_file_read (fh, &pi, sizeof (struct GNUNET_CRYPTO_EccPublicKey))))
- {
- if (0 == memcmp (&pi, pseudonym, sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
- {
- idx = i;
- break;
- }
- i++;
- len -= sizeof (struct GNUNET_HashCode);
- }
- if (-1 == idx)
- {
- idx = i;
- if (sizeof (struct GNUNET_CRYPTO_EccPublicKey) !=
- GNUNET_DISK_file_write (fh, pseudonym,
- sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "write", fn);
- }
- GNUNET_DISK_file_close (fh);
- ret = GNUNET_malloc (strlen (name) + 32);
- GNUNET_snprintf (ret, strlen (name) + 32, "%s-%u", name, idx);
- if (suffix != NULL)
- *suffix = idx;
- GNUNET_free (fn);
- return ret;
-}
-
-
-/**
- * Get namespace name, metadata and rank
- * This is a wrapper around internal read_info() call, and ensures that
- * returned data is not invalid (not NULL).
- *
- * @param cfg configuration
- * @param pseudonym public key of the pseudonym
- * @param ret_meta a location to store metadata pointer. NULL, if metadata
- * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy().
- * @param ret_rank a location to store rank. NULL, if rank not needed.
- * @param ret_name a location to store human-readable name. Name is not unique.
- * NULL, if name is not needed. Free with GNUNET_free().
- * @param name_is_a_dup is set to GNUNET_YES, if ret_name was filled with
- * a duplicate of a "no-name" placeholder
- * @return GNUNET_OK on success. GNUENT_SYSERR if the data was
- * unobtainable (in that case ret_* are filled with placeholders -
- * empty metadata container, rank -1 and a "no-name" name).
- */
-int
-GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- struct GNUNET_CONTAINER_MetaData **ret_meta,
- int32_t *ret_rank,
- char **ret_name,
- int *name_is_a_dup)
-{
- struct GNUNET_CONTAINER_MetaData *meta;
- char *name;
- int32_t rank = -1;
-
- meta = NULL;
- name = NULL;
- if (GNUNET_OK == read_info (cfg, pseudonym, &meta, &rank, &name))
- {
- if ((meta != NULL) && (name == NULL))
- name =
- GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METATYPE_PUBLISHER,
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METATYPE_SUMMARY,
- -1);
- if (ret_name != NULL)
- {
- if (name == NULL)
- {
- name = GNUNET_strdup (_("no-name"));
- if (name_is_a_dup != NULL)
- *name_is_a_dup = GNUNET_YES;
- }
- else if (name_is_a_dup != NULL)
- *name_is_a_dup = GNUNET_NO;
- *ret_name = name;
- }
- else if (name != NULL)
- GNUNET_free (name);
-
- if (ret_meta != NULL)
- {
- if (meta == NULL)
- meta = GNUNET_CONTAINER_meta_data_create ();
- *ret_meta = meta;
- }
- else if (meta != NULL)
- GNUNET_CONTAINER_meta_data_destroy (meta);
-
- if (ret_rank != NULL)
- *ret_rank = rank;
-
- return GNUNET_OK;
- }
- if (ret_name != NULL)
- *ret_name = GNUNET_strdup (_("no-name"));
- if (ret_meta != NULL)
- *ret_meta = GNUNET_CONTAINER_meta_data_create ();
- if (ret_rank != NULL)
- *ret_rank = -1;
- if (name_is_a_dup != NULL)
- *name_is_a_dup = GNUNET_YES;
- return GNUNET_SYSERR;
-}
-
-
-/**
- * Get the namespace ID belonging to the given namespace name.
- *
- * @param cfg configuration to use
- * @param ns_uname unique (!) human-readable name for the namespace
- * @param pseudonym set to public key of pseudonym based on 'ns_uname'
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *ns_uname,
- struct GNUNET_CRYPTO_EccPublicKey *pseudonym)
-{
- size_t slen;
- uint64_t len;
- unsigned int idx;
- char *name;
- struct GNUNET_HashCode nh;
- char *fn;
- struct GNUNET_DISK_FileHandle *fh;
-
- idx = -1;
- slen = strlen (ns_uname);
- while ((slen > 0) && (1 != SSCANF (&ns_uname[slen - 1], "-%u", &idx)))
- slen--;
- if (0 == slen)
- return GNUNET_SYSERR;
- name = GNUNET_strdup (ns_uname);
- name[slen - 1] = '\0';
-
- GNUNET_CRYPTO_hash (name, strlen (name), &nh);
- GNUNET_free (name);
- fn = get_data_filename_hash (cfg, PS_NAMES_DIR, &nh);
-
- if ((GNUNET_OK != GNUNET_DISK_file_test (fn) ||
- (GNUNET_OK != GNUNET_DISK_file_size (fn, &len, GNUNET_YES, GNUNET_YES))) ||
- ((idx + 1) * sizeof (struct GNUNET_CRYPTO_EccPublicKey) > len))
- {
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- 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);
- if (GNUNET_SYSERR ==
- GNUNET_DISK_file_seek (fh, idx * sizeof (struct GNUNET_CRYPTO_EccPublicKey),
- GNUNET_DISK_SEEK_SET))
- {
- GNUNET_DISK_file_close (fh);
- return GNUNET_SYSERR;
- }
- if (sizeof (struct GNUNET_CRYPTO_EccPublicKey) !=
- GNUNET_DISK_file_read (fh, pseudonym,
- sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
- {
- GNUNET_DISK_file_close (fh);
- return GNUNET_SYSERR;
- }
- GNUNET_DISK_file_close (fh);
- return GNUNET_OK;
-}
-
-
-/**
- * struct used to list the pseudonym
- */
-struct ListPseudonymClosure
-{
-
- /**
- * iterator over pseudonym
- */
- GNUNET_FS_PseudonymIterator iterator;
-
- /**
- * Closure for iterator.
- */
- void *iterator_cls;
-
- /**
- * Configuration to use.
- */
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-};
-
-
-
-/**
- * Helper function to list all available pseudonyms
- *
- * @param cls point to a struct ListPseudonymClosure
- * @param fullname name of pseudonym
- */
-static int
-list_pseudonym_helper (void *cls, const char *fullname)
-{
- struct ListPseudonymClosure *lpc = cls;
- struct GNUNET_CRYPTO_EccPublicKey pd;
- char *emsg;
- struct GNUNET_BIO_ReadHandle *fileR;
- int32_t rank;
- char *ns_name;
- struct GNUNET_CONTAINER_MetaData *meta;
- int ret;
- char *name_unique;
-
- if (NULL == (fileR = GNUNET_BIO_read_open (fullname)))
- return GNUNET_SYSERR;
- emsg = NULL;
- ns_name = NULL;
- if ( (GNUNET_OK != GNUNET_BIO_read (fileR, "pseudonym", &pd, sizeof (pd))) ||
- (GNUNET_OK != GNUNET_BIO_read_int32 (fileR, &rank)) ||
- (GNUNET_OK !=
- GNUNET_BIO_read_string (fileR, "Read string error!", &ns_name, 200)) ||
- (GNUNET_OK !=
- GNUNET_BIO_read_meta_data (fileR, "Read meta data error!", &meta)) )
- {
- (void) GNUNET_BIO_read_close (fileR, &emsg);
- GNUNET_free_non_null (emsg);
- GNUNET_free_non_null (ns_name);
- GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fullname));
- return GNUNET_SYSERR;
- }
- if (NULL == ns_name)
- ns_name = GNUNET_strdup (_("no-name"));
- if (GNUNET_OK != GNUNET_BIO_read_close (fileR, &emsg))
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to parse metadata about pseudonym from file `%s': %s\n"), fullname,
- emsg);
- GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fullname));
- GNUNET_CONTAINER_meta_data_destroy (meta);
- GNUNET_free (ns_name);
- GNUNET_free_non_null (emsg);
- return GNUNET_SYSERR;
- }
- ret = GNUNET_OK;
- name_unique = GNUNET_FS_pseudonym_name_uniquify (lpc->cfg, &pd, ns_name, NULL);
- if (NULL != lpc->iterator)
- ret = lpc->iterator (lpc->iterator_cls, &pd, ns_name, name_unique, meta, rank);
- GNUNET_free (ns_name);
- GNUNET_free_non_null (name_unique);
- GNUNET_CONTAINER_meta_data_destroy (meta);
- return ret;
-}
-
-
-/**
- * List all available pseudonyms.
- *
- * @param cfg overall configuration
- * @param iterator function to call for each pseudonym
- * @param iterator_cls closure for iterator
- * @return number of pseudonyms found
- */
-int
-GNUNET_FS_pseudonym_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FS_PseudonymIterator iterator,
- void *iterator_cls)
-{
- struct ListPseudonymClosure cls;
- char *fn;
- int ret;
-
- cls.iterator = iterator;
- cls.iterator_cls = iterator_cls;
- cls.cfg = cfg;
- fn = get_data_filename (cfg, PS_METADATA_DIR, NULL);
- GNUNET_assert (fn != NULL);
- GNUNET_DISK_directory_create (fn);
- ret = GNUNET_DISK_directory_scan (fn, &list_pseudonym_helper, &cls);
- GNUNET_free (fn);
- return ret;
-}
-
-
-/**
- * Change the rank of a pseudonym.
- *
- * @param cfg overall configuration
- * @param pseudonym the pseudonym
- * @param delta by how much should the rating be changed?
- * @return new rating of the pseudonym
- */
-int
-GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- int32_t delta)
-{
- struct GNUNET_CONTAINER_MetaData *meta;
- int ret;
- int32_t rank;
- char *name;
-
- name = NULL;
- ret = read_info (cfg, pseudonym, &meta, &rank, &name);
- if (ret == GNUNET_SYSERR)
- {
- rank = 0;
- meta = GNUNET_CONTAINER_meta_data_create ();
- }
- rank += delta;
- GNUNET_FS_pseudonym_set_info (cfg, pseudonym, name, meta, rank);
- GNUNET_CONTAINER_meta_data_destroy (meta);
- GNUNET_free_non_null (name);
- return rank;
-}
-
-
-/**
- * Add a pseudonym to the set of known pseudonyms.
- * For all pseudonym advertisements that we discover
- * FS should automatically call this function.
- *
- * @param cfg overall configuration
- * @param pseudonym the pseudonym to add
- * @param meta metadata for the pseudonym
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const struct GNUNET_CONTAINER_MetaData *meta)
-{
- char *name;
- int32_t rank;
- struct GNUNET_CONTAINER_MetaData *old;
- char *fn;
- struct stat sbuf;
- int ret;
-
- rank = 0;
- fn = get_data_filename (cfg, PS_METADATA_DIR, pseudonym);
- GNUNET_assert (fn != NULL);
-
- if ((0 == STAT (fn, &sbuf)) &&
- (GNUNET_OK == read_info (cfg, pseudonym, &old, &rank, &name)))
- {
- GNUNET_CONTAINER_meta_data_merge (old, meta);
- ret = GNUNET_FS_pseudonym_set_info (cfg, pseudonym, name, old, rank);
- GNUNET_CONTAINER_meta_data_destroy (old);
- GNUNET_free_non_null (name);
- }
- else
- {
- ret = GNUNET_FS_pseudonym_set_info (cfg, pseudonym, NULL, meta, rank);
- }
- GNUNET_free (fn);
- internal_notify (pseudonym, meta, rank);
- return ret;
-}
-
-
-/* end of fs_pseudonym.c */
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
deleted file mode 100644
index a9c6be623..000000000
--- a/src/fs/gnunet-pseudonym.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2001-2013 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- 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.
-*/
-/**
- * @file fs/gnunet-pseudonym.c
- * @brief manage GNUnet namespaces / pseudonyms
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_fs_service.h"
-#include "gnunet_identity_service.h"
-
-
-/**
- * -A option
- */
-static char *advertise_ns;
-
-/**
- * -k option
- */
-static struct GNUNET_FS_Uri *ksk_uri;
-
-/**
- * -m option.
- */
-static struct GNUNET_CONTAINER_MetaData *adv_metadata;
-
-/**
- * Our block options (-p, -r, -a).
- */
-static struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 };
-
-/**
- * -q option given.
- */
-static int no_remote_printing;
-
-/**
- * -r option.
- */
-static char *root_identifier;
-
-/**
- * -s option.
- */
-static char *rating_change;
-
-/**
- * Handle to fs service.
- */
-static struct GNUNET_FS_Handle *h;
-
-/**
- * Our configuration.
- */
-static const struct GNUNET_CONFIGURATION_Handle *cfg;
-
-/**
- * Handle to identity service.
- */
-static struct GNUNET_IDENTITY_Handle *identity;
-
-/**
- * Target namespace.
- */
-static struct GNUNET_IDENTITY_Ego *namespace;
-
-/**
- * URI to advertise.
- */
-static struct GNUNET_FS_Uri *sks_uri;
-
-/**
- * Global return value.
- */
-static int ret;
-
-
-/**
- * Progress callback given to FS.
- *
- * @param cls unused
- * @param info progress information, unused
- */
-static void *
-progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
-{
- return NULL;
-}
-
-
-/**
- * Output information about a pseudonym.
- *
- * @param cls closure
- * @param pseudonym hash code of public key of pseudonym
- * @param name name of the pseudonym (might be NULL)
- * @param unique_name unique name of the pseudonym (might be NULL)
- * @param md meta data known about the pseudonym
- * @param rating the local rating of the pseudonym
- * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
- */
-static int
-pseudo_printer (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md,
- int32_t rating)
-{
- char *id;
- char *unique_id;
- int getinfo_result;
-
- /* While we get a name from the caller, it might be NULL.
- * GNUNET_FS_pseudonym_get_info () never returns NULL.
- */
- getinfo_result = GNUNET_FS_pseudonym_get_info (cfg, pseudonym,
- NULL, NULL, &id, NULL);
- if (GNUNET_OK != getinfo_result)
- {
- GNUNET_break (0);
- return GNUNET_OK;
- }
- unique_id = GNUNET_FS_pseudonym_name_uniquify (cfg, pseudonym, id, NULL);
- GNUNET_free (id);
- FPRINTF (stdout,
- "%s (%d):\n",
- unique_id, rating);
- GNUNET_CONTAINER_meta_data_iterate (md, &EXTRACTOR_meta_data_print, stdout);
- FPRINTF (stdout,
- "%s",
- "\n");
- GNUNET_free (unique_id);
- return GNUNET_OK;
-}
-
-
-/**
- * Function called once advertising is finished.
- *
- * @param cls closure (NULL)
- * @param uri the advertised URI
- * @param emsg error message, NULL on success
- */
-static void
-post_advertising (void *cls,
- const struct GNUNET_FS_Uri *uri,
- const char *emsg)
-{
- if (emsg != NULL)
- {
- FPRINTF (stderr, "%s", emsg);
- ret = 1;
- }
- GNUNET_FS_stop (h);
- GNUNET_IDENTITY_disconnect (identity);
-}
-
-
-/**
- * Function called by identity service with known pseudonyms.
- *
- * @param cls closure, NULL
- * @param ego ego handle
- * @param ctx context for application to store data for this ego
- * (during the lifetime of this process, initially NULL)
- * @param name name assigned by the user for this ego,
- * NULL if the user just deleted the ego and it
- * must thus no longer be used
- */
-static void
-identity_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *name)
-{
- char *emsg;
- struct GNUNET_CRYPTO_EccPublicKey pub;
-
- if (NULL == ego)
- {
- if (NULL == namespace)
- {
- ret = 1;
- return;
- }
- if (NULL != root_identifier)
- {
- if (NULL == ksk_uri)
- {
- emsg = NULL;
- ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg);
- GNUNET_assert (NULL == emsg);
- }
- GNUNET_IDENTITY_ego_get_public_key (namespace,
- &pub);
- sks_uri = GNUNET_FS_uri_sks_create (&pub,
- root_identifier);
- GNUNET_FS_publish_ksk (h, ksk_uri, adv_metadata, sks_uri,
- &bo,
- GNUNET_FS_PUBLISH_OPTION_NONE,
- &post_advertising, NULL);
- GNUNET_FS_uri_destroy (sks_uri);
- return;
- }
- else
- {
- if (NULL != ksk_uri)
- FPRINTF (stderr, _("Option `%s' ignored\n"), "-k");
- if (NULL != advertise_ns)
- FPRINTF (stderr, _("Option `%s' ignored\n"), "-A");
- }
- return;
- }
- if (0 == strcmp (name, advertise_ns))
- namespace = ego;
-}
-
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param c configuration
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
-{
- struct GNUNET_CRYPTO_EccPublicKey nsid;
- char *set;
- int delta;
-
- cfg = c;
- h = GNUNET_FS_start (cfg, "gnunet-pseudonym", &progress_cb, NULL,
- GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
- if (NULL != rating_change)
- {
- set = rating_change;
- while ((*set != '\0') && (*set != ':'))
- set++;
- if (*set != ':')
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Invalid argument `%s'\n"),
- rating_change);
- }
- else
- {
- *set = '\0';
- delta = strtol (&set[1], NULL, /* no error handling yet */
- 10);
- if (GNUNET_OK == GNUNET_FS_pseudonym_name_to_id (cfg, rating_change, &nsid))
- {
- (void) GNUNET_FS_pseudonym_rank (cfg, &nsid, delta);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- ("Namespace `%s' unknown. Make sure you specify its numeric suffix, if any.\n"),
- rating_change);
- }
- }
- GNUNET_free (rating_change);
- rating_change = NULL;
- }
- if (0 == no_remote_printing)
- GNUNET_FS_pseudonym_list_all (cfg, &pseudo_printer, NULL);
-
- if (NULL != advertise_ns)
- identity = GNUNET_IDENTITY_connect (cfg,
- &identity_cb,
- NULL);
-}
-
-
-/**
- * The main function to manipulate GNUnet pseudonyms (and publish
- * to namespaces).
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc, char *const *argv)
-{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "anonymity", "LEVEL",
- gettext_noop ("set the desired LEVEL of sender-anonymity"),
- 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level},
- {'A', "advertise", "NAME",
- gettext_noop ("advertise namespace NAME"),
- 1, &GNUNET_GETOPT_set_string, &advertise_ns},
- {'k', "keyword", "VALUE",
- gettext_noop ("add an additional keyword for the advertisment"
- " (this option can be specified multiple times)"),
- 1, &GNUNET_FS_getopt_set_keywords, &ksk_uri},
- {'m', "meta", "TYPE:VALUE",
- gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
- 1, &GNUNET_FS_getopt_set_metadata, &adv_metadata},
- {'p', "priority", "PRIORITY",
- gettext_noop ("use the given PRIORITY for the advertisments"),
- 1, &GNUNET_GETOPT_set_uint, &bo.content_priority},
- {'q', "quiet", NULL,
- gettext_noop ("do not print names of remote namespaces"),
- 0, &GNUNET_GETOPT_set_one, &no_remote_printing},
- {'r', "replication", "LEVEL",
- gettext_noop ("set the desired replication LEVEL"),
- 1, &GNUNET_GETOPT_set_uint, &bo.replication_level},
- {'R', "root", "ID",
- gettext_noop ("specify ID of the root of the namespace"),
- 1, &GNUNET_GETOPT_set_string, &root_identifier},
- {'s', "set-rating", "ID:VALUE",
- gettext_noop ("change rating of namespace ID by VALUE"),
- 1, &GNUNET_GETOPT_set_string, &rating_change},
- GNUNET_GETOPT_OPTION_END
- };
- bo.expiration_time =
- GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
-
- ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-pseudonym [OPTIONS]",
- gettext_noop ("Manage GNUnet pseudonyms."),
- options, &run, NULL)) ? ret : 1;
- GNUNET_free ((void*) argv);
- return ret;
-}
-
-/* end of gnunet-pseudonym.c */
diff --git a/src/fs/test_pseudonym.c b/src/fs/test_pseudonym.c
deleted file mode 100644
index 56b9d9637..000000000
--- a/src/fs/test_pseudonym.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2005--2013 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- 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.
-*/
-
-/**
- * @file fs/test_pseudonym.c
- * @brief testcase for fs_pseudonym.c
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_fs_service.h"
-#include "gnunet_signatures.h"
-
-#define CHECK(a) do { if (!(a)) { ok = GNUNET_NO; GNUNET_break(0); goto FAILURE; } } while (0)
-
-static struct GNUNET_CONTAINER_MetaData *meta;
-
-static struct GNUNET_CRYPTO_EccPublicKey id1;
-
-
-static int
-iter (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name, const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int32_t rating)
-{
- int *ok = cls;
-
- if ((0 == memcmp (pseudonym, &id1, sizeof (struct GNUNET_CRYPTO_EccPublicKey))) &&
- (!GNUNET_CONTAINER_meta_data_test_equal (md, meta)))
- {
- *ok = GNUNET_NO;
- GNUNET_break (0);
- }
- return GNUNET_OK;
-}
-
-
-static int
-noti_callback (void *cls, const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name, const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int32_t rating)
-{
- int *ret = cls;
-
- (*ret)++;
- return GNUNET_OK;
-}
-
-
-static int
-fake_noti_callback (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKey * pseudonym,
- const char *name, const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int32_t rating)
-{
- int *ret = cls;
-
- (*ret)++;
- return GNUNET_OK;
-}
-
-
-static void
-create_pseu (struct GNUNET_CRYPTO_EccPublicKey *pseu)
-{
- struct GNUNET_CRYPTO_EccPrivateKey *ph;
-
- ph = GNUNET_CRYPTO_ecc_key_create ();
- GNUNET_CRYPTO_ecc_key_get_public (ph, pseu);
- GNUNET_free (ph);
-}
-
-
-/**
- * Testcase for meta data / ranking IO routines.
- */
-static int
-test_io ()
-{
- int ok;
- struct GNUNET_CRYPTO_EccPublicKey rid1;
- struct GNUNET_CRYPTO_EccPublicKey id2;
- struct GNUNET_CRYPTO_EccPublicKey rid2;
- struct GNUNET_CRYPTO_EccPublicKey fid;
- struct GNUNET_CRYPTO_EccPublicKey id3;
- int old;
- int newVal;
- struct GNUNET_CONFIGURATION_Handle *cfg;
- char *name1;
- char *name2;
- char *name3;
- char *name1_unique;
- char *name2_unique;
- char *noname;
- int noname_is_a_dup;
- int notiCount, fakenotiCount;
- static char m[1024 * 1024 * 10];
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh1;
- struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh2;
-
- memset (m, 'b', sizeof (m));
- m[sizeof (m) - 1] = '\0';
- GNUNET_log_setup ("test-pseudonym", "WARNING", NULL);
- ok = GNUNET_YES;
- (void) GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test");
- cfg = GNUNET_CONFIGURATION_create ();
- if (-1 == GNUNET_CONFIGURATION_parse (cfg, "test_pseudonym_data.conf"))
- {
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_break (0);
- return -1;
- }
- notiCount = 0;
- fakenotiCount = 0;
- dh1 = GNUNET_FS_pseudonym_discovery_callback_register (cfg, &fake_noti_callback,
- &fakenotiCount);
- dh2 = GNUNET_FS_pseudonym_discovery_callback_register (cfg, &noti_callback,
- &notiCount);
- GNUNET_FS_pseudonym_discovery_callback_unregister (dh1);
-
- /* ACTUAL TEST CODE */
- old = GNUNET_FS_pseudonym_list_all (cfg, NULL, NULL);
- meta = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- "test", strlen ("test") + 1);
- create_pseu (&id1);
- GNUNET_FS_pseudonym_add (cfg, &id1, meta);
- CHECK (notiCount == 1);
- GNUNET_FS_pseudonym_add (cfg, &id1, meta);
- CHECK (notiCount == 2);
- newVal = GNUNET_FS_pseudonym_list_all (cfg, &iter, &ok);
- CHECK (old < newVal);
- old = newVal;
- create_pseu (&id2);
- GNUNET_FS_pseudonym_add (cfg, &id2, meta);
- CHECK (notiCount == 3);
- newVal = GNUNET_FS_pseudonym_list_all (cfg, &iter, &ok);
- CHECK (old < newVal);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", m,
- strlen (m) + 1));
- create_pseu (&id3);
- GNUNET_FS_pseudonym_add (cfg, &id3, meta);
- GNUNET_FS_pseudonym_get_info (cfg, &id3, NULL, NULL, &name3, NULL);
- CHECK (name3 != NULL);
- GNUNET_FS_pseudonym_get_info (cfg, &id2, NULL, NULL, &name2, NULL);
- CHECK (name2 != NULL);
- GNUNET_FS_pseudonym_get_info (cfg, &id1, NULL, NULL, &name1, NULL);
- CHECK (name1 != NULL);
- CHECK (0 == strcmp (name1, name2));
- name1_unique = GNUNET_FS_pseudonym_name_uniquify (cfg, &id1, name1, NULL);
- name2_unique = GNUNET_FS_pseudonym_name_uniquify (cfg, &id2, name2, NULL);
- CHECK (0 != strcmp (name1_unique, name2_unique));
- CHECK (GNUNET_SYSERR == GNUNET_FS_pseudonym_name_to_id (cfg, "fake", &rid2));
- CHECK (GNUNET_SYSERR == GNUNET_FS_pseudonym_name_to_id (cfg, name2, &rid2));
- CHECK (GNUNET_SYSERR == GNUNET_FS_pseudonym_name_to_id (cfg, name1, &rid1));
- CHECK (GNUNET_OK == GNUNET_FS_pseudonym_name_to_id (cfg, name2_unique, &rid2));
- CHECK (GNUNET_OK == GNUNET_FS_pseudonym_name_to_id (cfg, name1_unique, &rid1));
- CHECK (0 == memcmp (&id1, &rid1, sizeof (struct GNUNET_CRYPTO_EccPublicKey)));
- CHECK (0 == memcmp (&id2, &rid2, sizeof (struct GNUNET_CRYPTO_EccPublicKey)));
-
- create_pseu (&fid);
- GNUNET_log_skip (1, GNUNET_NO);
- CHECK (0 == GNUNET_FS_pseudonym_rank (cfg, &fid, 0));
- GNUNET_log_skip (0, GNUNET_NO);
- CHECK (GNUNET_OK == GNUNET_FS_pseudonym_get_info (cfg, &fid, NULL, NULL, &noname, &noname_is_a_dup));
- CHECK (noname != NULL);
- CHECK (noname_is_a_dup == GNUNET_YES);
- CHECK (0 == GNUNET_FS_pseudonym_rank (cfg, &id1, 0));
- CHECK (5 == GNUNET_FS_pseudonym_rank (cfg, &id1, 5));
- CHECK (-5 == GNUNET_FS_pseudonym_rank (cfg, &id1, -10));
- CHECK (0 == GNUNET_FS_pseudonym_rank (cfg, &id1, 5));
- GNUNET_free (name1);
- GNUNET_free (name2);
- GNUNET_free (name1_unique);
- GNUNET_free (name2_unique);
- GNUNET_free (name3);
- GNUNET_free (noname);
- /* END OF TEST CODE */
-FAILURE:
- GNUNET_FS_pseudonym_discovery_callback_unregister (dh2);
- GNUNET_CONTAINER_meta_data_destroy (meta);
- GNUNET_CONFIGURATION_destroy (cfg);
- return (ok == GNUNET_YES) ? 0 : 1;
-}
-
-
-int
-main (int argc, char *argv[])
-{
- GNUNET_log_setup ("test-pseudonym", "WARNING", NULL);
- if (0 != test_io ())
- return 1;
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test"));
- return 0;
-}
-
-
-/* end of test_pseudoynm.c */
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index a49d8fb98..d60044732 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -93,180 +93,6 @@ typedef int (*GNUNET_FS_KeywordIterator) (void *cls, const char *keyword,
/**
- * Iterator over all known pseudonyms.
- *
- * @param cls closure
- * @param pseudonym public key of pseudonym
- * @param name name of the pseudonym (might be NULL)
- * @param unique_name unique name of the pseudonym (might be NULL)
- * @param md meta data known about the pseudonym
- * @param rating the local rating of the pseudonym
- * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
- */
-typedef int (*GNUNET_FS_PseudonymIterator) (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md,
- int32_t rating);
-
-
-/**
- * Change the rank of a pseudonym.
- *
- * @param cfg overall configuration
- * @param pseudonym identity of the pseudonym
- * @param delta by how much should the rating be changed?
- * @return new rating of the pseudonym
- */
-int
-GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- int32_t delta);
-
-
-/**
- * Add a pseudonym to the set of known pseudonyms.
- * For all pseudonym advertisements that we discover
- * FS should automatically call this function.
- *
- * @param cfg overall configuration
- * @param pseudonym the pseudonym identifier
- * @param meta metadata for the pseudonym
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const struct GNUNET_CONTAINER_MetaData *meta);
-
-
-/**
- * List all known pseudonyms.
- *
- * @param cfg overall configuration
- * @param iterator function to call for each pseudonym
- * @param iterator_cls closure for iterator
- * @return number of pseudonyms found
- */
-int
-GNUNET_FS_pseudonym_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FS_PseudonymIterator iterator,
- void *iterator_cls);
-
-
-/**
- * Handle for a discovery callback registration.
- */
-struct GNUNET_FS_Pseudonym_DiscoveryHandle;
-
-
-/**
- * Register callback to be invoked whenever we discover
- * a new pseudonym.
- *
- * @param cfg our configuration
- * @param iterator function to invoke on discovery
- * @param iterator_cls closure for iterator
- * @return registration handle
- */
-struct GNUNET_FS_Pseudonym_DiscoveryHandle *
-GNUNET_FS_pseudonym_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FS_PseudonymIterator iterator,
- void *iterator_cls);
-
-
-/**
- * Unregister pseudonym discovery callback.
- *
- * @param dh registration to unregister
- */
-void
-GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh);
-
-
-/**
- * Return unique variant of the pseudonym name. Use after
- * GNUNET_FS_pseudonym_id_to_name() to make sure that name is unique.
- *
- * @param cfg configuration
- * @param pseudonym cryptographic ID of the pseudonym
- * @param name name to uniquify
- * @param suffix if not NULL, filled with the suffix value
- * @return NULL on failure (should never happen), name on success.
- * Free the name with GNUNET_free().
- */
-char *
-GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- unsigned int *suffix);
-
-
-/**
- * Get pseudonym name, metadata and rank. This is a wrapper around
- * internal read_info() call, and ensures that returned data is not
- * invalid (not NULL). Writing back information returned by this
- * function will give a name "no-name" to pseudonyms that have no
- * name. This side-effect is unavoidable, but hardly harmful.
- *
- * @param cfg configuration
- * @param pseudonym cryptographic ID of the pseudonym
- * @param ret_meta a location to store metadata pointer. NULL, if metadata
- * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy().
- * @param ret_rank a location to store rank. NULL, if rank not needed.
- * @param ret_name a location to store human-readable name. Name is not unique.
- * NULL, if name is not needed. Free with GNUNET_free().
- * @param name_is_a_dup is set to #GNUNET_YES, if ret_name was filled with
- * a duplicate of a "no-name" placeholder
- * @return #GNUNET_OK on success. #GNUENT_SYSERR if the data was
- * unobtainable (in that case ret_* are filled with placeholders -
- * empty metadata container, rank -1 and a "no-name" name).
- */
-int
-GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- struct GNUNET_CONTAINER_MetaData **ret_meta,
- int32_t *ret_rank,
- char **ret_name,
- int *name_is_a_dup);
-
-
-/**
- * Get the pseudonym ID belonging to the given pseudonym name.
- *
- * @param cfg configuration to use
- * @param ns_uname unique (!) human-readable name for the pseudonym
- * @param pseudonym set to pseudonym ID based on 'ns_uname'
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *ns_uname,
- struct GNUNET_CRYPTO_EccPublicKey *pseudonym);
-
-
-/**
- * Set the pseudonym metadata, rank and name.
- *
- * @param cfg overall configuration
- * @param pseudonym id of the pseudonym
- * @param name name to set. Must be the non-unique version of it.
- * May be NULL, in which case it erases pseudonym's name!
- * @param md metadata to set
- * May be NULL, in which case it erases pseudonym's metadata!
- * @param rank rank to assign
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
- */
-int
-GNUNET_FS_pseudonym_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
- const char *name,
- const struct GNUNET_CONTAINER_MetaData *md,
- int32_t rank);
-
-
-/**
* Get a unique key from a URI. This is for putting URIs
* into HashMaps. The key may change between FS implementations.
*