-change vpn wire data format
[oweals/gnunet.git] / src / include / gnunet_pseudonym_lib.h
index bde98ef8ff7e8caa87ef1b010454cffc0181b20d..6ec51b6783c512c9ddf8d1af5d1f6de37d79dda8 100644 (file)
@@ -44,12 +44,16 @@ extern "C"
  *
  * @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
  */
 typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls,
-                                          const GNUNET_HashCode * pseudonym,
+                                          const struct GNUNET_HashCode * pseudonym,
+                                          const char *name,
+                                          const char *unique_name,
                                           const struct GNUNET_CONTAINER_MetaData
                                           * md, int rating);
 
@@ -63,7 +67,7 @@ typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls,
  */
 int
 GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                       const GNUNET_HashCode * nsid, int delta);
+                       const struct GNUNET_HashCode * nsid, int delta);
 
 /**
  * Add a pseudonym to the set of known pseudonyms.
@@ -76,7 +80,7 @@ GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
  */
 void
 GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                      const GNUNET_HashCode * id,
+                      const struct GNUNET_HashCode * id,
                       const struct GNUNET_CONTAINER_MetaData *meta);
 
 
@@ -110,22 +114,76 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator
                                                 iterator, void *closure);
 
 /**
- * Return the unique, human readable name for the given pseudonym.
+ * Return unique variant of the namespace name.
+ * Use after GNUNET_PSEUDONYM_id_to_name() to make sure
+ * that name is unique.
  *
- * @return NULL on failure (should never happen)
+ * @param cfg configuration
+ * @param nsid cryptographic ID of the namespace
+ * @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_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             const GNUNET_HashCode * pseudo);
+GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg,
+    const struct GNUNET_HashCode * nsid, const char *name, unsigned int *suffix);
 
 /**
- * Get the pseudonym ID belonging to the given human readable name.
+ * 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).
+ * 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.
  *
- * @return GNUNET_OK on success
+ * @param cfg configuration
+ * @param nsid cryptographic ID of the namespace
+ * @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_PSEUDONYM_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
+    const struct GNUNET_HashCode * nsid, struct GNUNET_CONTAINER_MetaData **ret_meta,
+    int32_t *ret_rank, char **ret_name, int *name_is_a_dup);
+
+
+/**
+ * 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 nsid set to namespace ID based on 'ns_uname'
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int
 GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             const char *hname, GNUNET_HashCode * psid);
+    const char *ns_uname, struct GNUNET_HashCode * nsid);
+
+/**
+ * Set the pseudonym metadata, rank and name.
+ *
+ * @param cfg overall configuration
+ * @param nsid 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_PSEUDONYM_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
+    const struct GNUNET_HashCode * nsid, const char *name,
+    const struct GNUNET_CONTAINER_MetaData *md, int rank);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */