Print the help page.
.It d | \-display
Display all of our egos.
+.It v | \-verbose
+Be verbose, in particular outputs the public key of freshly created egos.
.It m | \-monitor
Run in monitor mode, listing all ouf our egos until CTRL-C is pressed.
Each ego is listed together with a unique pointer value; if egos are renamed, that pointer value remains the same; if egos are deleted, they are listed one more time with a name of "<null>".
*/
static int monitor;
+/**
+ * Was "verbose" specified?
+ */
+static unsigned int verbose;
+
/**
* -C option
*/
* Creation operation finished.
*
* @param cls pointer to operation handle
+ * @param pk private key of the ego, or NULL on error
* @param emsg error message, NULL on success
*/
static void
create_finished (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
const char *emsg)
{
struct GNUNET_IDENTITY_Operation **op = cls;
*op = NULL;
- if (NULL != emsg)
+ if (NULL == pk)
{
fprintf (stderr,
_("Failed to create ego: %s\n"),
emsg);
global_ret = 1;
}
+ else if (verbose)
+ {
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ char *pubs;
+
+ GNUNET_CRYPTO_ecdsa_key_get_public (pk,
+ &pub);
+ pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
+ fprintf (stdout,
+ "%s\n",
+ pubs);
+ GNUNET_free (pubs);
+ }
test_finished ();
}
"SUBSYSTEM",
gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
&set_subsystem),
-
+ GNUNET_GETOPT_option_verbose (&verbose),
GNUNET_GETOPT_OPTION_END
};
int res;
/**
* Continuation to invoke with the result of the transmission; @e cb
- * will be NULL in this case.
+ * and @e create_cont will be NULL in this case.
*/
GNUNET_IDENTITY_Continuation cont;
+ /**
+ * Continuation to invoke with the result of the transmission; @e cb
+ * and @a cb will be NULL in this case.
+ */
+ GNUNET_IDENTITY_CreateContinuation create_cont;
+
+ /**
+ * Private key to return to @e create_cont, or NULL.
+ */
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
+
/**
* Continuation to invoke with the result of the transmission for
- * 'get' operations (@e cont will be NULL in this case).
+ * 'get' operations (@e cont and @a create_cont will be NULL in this case).
*/
GNUNET_IDENTITY_Callback cb;
NULL,
NULL,
NULL);
+ else if (NULL != op->create_cont)
+ op->create_cont (op->cls,
+ NULL,
+ "Failed to communicate with the identity service");
+ GNUNET_free_non_null (op->pk);
GNUNET_free (op);
}
GNUNET_CONTAINER_multihashmap_iterate (h->egos,
str);
else if (NULL != op->cb)
op->cb (op->cls, NULL, NULL, NULL);
+ else if (NULL != op->create_cont)
+ op->create_cont (op->cls,
+ (NULL == str) ? op->pk : NULL,
+ str);
+ GNUNET_free_non_null (op->pk);
GNUNET_free (op);
}
struct GNUNET_IDENTITY_Operation *
GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
const char *name,
- GNUNET_IDENTITY_Continuation cont,
+ GNUNET_IDENTITY_CreateContinuation cont,
void *cont_cls)
{
struct GNUNET_IDENTITY_Operation *op;
}
op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
op->h = h;
- op->cont = cont;
+ op->create_cont = cont;
op->cls = cont_cls;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
h->op_tail,
crm->reserved = htons (0);
pk = GNUNET_CRYPTO_ecdsa_key_create ();
crm->private_key = *pk;
- GNUNET_free (pk);
+ op->pk = pk;
GNUNET_memcpy (&crm[1],
name,
slen);
{
op->cont = NULL;
op->cb = NULL;
+ op->create_cont = NULL;
+ if (NULL != op->pk)
+ {
+ GNUNET_free (op->pk);
+ op->pk = NULL;
+ }
}
GNUNET_CONTAINER_DLL_remove (h->op_head,
h->op_tail,
op);
+ GNUNET_free_non_null (op->pk);
GNUNET_free (op);
}
if (NULL != h->mq)
}
+/**
+ * Processing finished, when creating an ego.
+ *
+ * @param cls request handle
+ * @param private key of the ego, or NULL on error
+ * @param emsg error message
+ */
+static void
+do_finished_create (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
+ const char *emsg)
+{
+ struct RequestHandle *handle = cls;
+
+ (void) pk;
+ do_finished (handle,
+ emsg);
+}
+
+
/**
* Processing edit ego with EgoEntry ego_entry
*
json_decref (data_js);
handle->response_code = MHD_HTTP_CREATED;
handle->op = GNUNET_IDENTITY_create (handle->identity_handle, handle->name,
- &do_finished, handle);
+ &do_finished_create, handle);
}
/**
* Called with events about created ego.
*
* @param cls NULL
+ * @param pk private key of the ego, or NULL on error
* @param emsg error message
*/
static void
create_cb (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
const char *emsg)
{
+ GNUNET_assert (NULL != pk);
GNUNET_assert (NULL == emsg);
op = GNUNET_IDENTITY_rename (h,
"test-id",
* Called with events about created ego.
*
* @param cls NULL
+ * @param pk private key of the ego, or NULL on error
* @param emsg error message
*/
static void
create_cb (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
const char *emsg)
{
GNUNET_assert (NULL == emsg);
+ GNUNET_assert (NULL != pk);
op = NULL;
}
GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h);
+/**
+ * Function called once the requested operation has
+ * been completed.
+ *
+ * @param cls closure
+ * @param pk private key, NULL on error
+ * @param emsg error message, NULL on success
+ */
+typedef void
+(*GNUNET_IDENTITY_CreateContinuation)(void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
+ const char *emsg);
+
+
/**
* Create a new ego with the given name.
*
struct GNUNET_IDENTITY_Operation *
GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
const char *name,
- GNUNET_IDENTITY_Continuation cont,
+ GNUNET_IDENTITY_CreateContinuation cont,
void *cont_cls);