From d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 8 Sep 2019 12:33:09 +0000 Subject: uncrustify as demanded. --- src/identity/identity_api.c | 605 ++++++++++++++++++++++---------------------- 1 file changed, 301 insertions(+), 304 deletions(-) (limited to 'src/identity/identity_api.c') diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index c463da641..530ee2d13 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -16,7 +16,7 @@ along with this program. If not, see . SPDX-License-Identifier: AGPL3.0-or-later -*/ + */ /** * @file identity/identity_api.c @@ -30,15 +30,13 @@ #include "gnunet_identity_service.h" #include "identity.h" -#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) +#define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) /** * Handle for an operation with the identity service. */ -struct GNUNET_IDENTITY_Operation -{ - +struct GNUNET_IDENTITY_Operation { /** * Main identity handle. */ @@ -93,8 +91,7 @@ struct GNUNET_IDENTITY_Operation /** * Handle for the service. */ -struct GNUNET_IDENTITY_Handle -{ +struct GNUNET_IDENTITY_Handle { /** * Configuration to use. */ @@ -154,7 +151,7 @@ struct GNUNET_IDENTITY_Handle * @return handle for the anonymous user, must not be freed */ const struct GNUNET_IDENTITY_Ego * -GNUNET_IDENTITY_ego_get_anonymous () +GNUNET_IDENTITY_ego_get_anonymous() { static struct GNUNET_IDENTITY_Ego anon; struct GNUNET_CRYPTO_EcdsaPublicKey pub; @@ -162,9 +159,9 @@ GNUNET_IDENTITY_ego_get_anonymous () if (NULL != anon.pk) return &anon; anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) - GNUNET_CRYPTO_ecdsa_key_get_anonymous (); - GNUNET_CRYPTO_ecdsa_key_get_public (anon.pk, &pub); - GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id); + GNUNET_CRYPTO_ecdsa_key_get_anonymous(); + GNUNET_CRYPTO_ecdsa_key_get_public(anon.pk, &pub); + GNUNET_CRYPTO_hash(&pub, sizeof(pub), &anon.id); return &anon; } @@ -175,7 +172,7 @@ GNUNET_IDENTITY_ego_get_anonymous () * @param cls handle to the identity service. */ static void -reconnect (void *cls); +reconnect(void *cls); /** @@ -187,18 +184,18 @@ reconnect (void *cls); * @return #GNUNET_OK (continue to iterate) */ static int -free_ego (void *cls, const struct GNUNET_HashCode *key, void *value) +free_ego(void *cls, const struct GNUNET_HashCode *key, void *value) { struct GNUNET_IDENTITY_Handle *h = cls; struct GNUNET_IDENTITY_Ego *ego = value; if (NULL != h->cb) - h->cb (h->cb_cls, ego, &ego->ctx, NULL); - GNUNET_free (ego->pk); - GNUNET_free (ego->name); - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (h->egos, key, value)); - GNUNET_free (ego); + h->cb(h->cb_cls, ego, &ego->ctx, NULL); + GNUNET_free(ego->pk); + GNUNET_free(ego->name); + GNUNET_assert(GNUNET_YES == + GNUNET_CONTAINER_multihashmap_remove(h->egos, key, value)); + GNUNET_free(ego); return GNUNET_OK; } @@ -209,38 +206,38 @@ free_ego (void *cls, const struct GNUNET_HashCode *key, void *value) * @param h transport service to reconnect */ static void -reschedule_connect (struct GNUNET_IDENTITY_Handle *h) +reschedule_connect(struct GNUNET_IDENTITY_Handle *h) { struct GNUNET_IDENTITY_Operation *op; - GNUNET_assert (NULL == h->reconnect_task); + GNUNET_assert(NULL == h->reconnect_task); if (NULL != h->mq) - { - GNUNET_MQ_destroy (h->mq); - h->mq = NULL; - } + { + GNUNET_MQ_destroy(h->mq); + h->mq = NULL; + } while (NULL != (op = h->op_head)) - { - GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); - if (NULL != op->cont) - op->cont (op->cls, "Error in communication with the identity service"); - else if (NULL != op->cb) - op->cb (op->cls, 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, &free_ego, h); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling task to reconnect to identity service in %s.\n", - GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES)); + { + GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); + if (NULL != op->cont) + op->cont(op->cls, "Error in communication with the identity service"); + else if (NULL != op->cb) + op->cb(op->cls, 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, &free_ego, h); + LOG(GNUNET_ERROR_TYPE_DEBUG, + "Scheduling task to reconnect to identity service in %s.\n", + GNUNET_STRINGS_relative_time_to_string(h->reconnect_delay, GNUNET_YES)); h->reconnect_task = - GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); - h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); + GNUNET_SCHEDULER_add_delayed(h->reconnect_delay, &reconnect, h); + h->reconnect_delay = GNUNET_TIME_STD_BACKOFF(h->reconnect_delay); } @@ -253,11 +250,11 @@ reschedule_connect (struct GNUNET_IDENTITY_Handle *h) * @param error error code */ static void -mq_error_handler (void *cls, enum GNUNET_MQ_Error error) +mq_error_handler(void *cls, enum GNUNET_MQ_Error error) { struct GNUNET_IDENTITY_Handle *h = cls; - reschedule_connect (h); + reschedule_connect(h); } @@ -270,10 +267,10 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) * @return #GNUNET_OK if the message is well-formed */ static int -check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) +check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) { - if (sizeof (*rcm) != htons (rcm->header.size)) - GNUNET_MQ_check_zero_termination (rcm); + if (sizeof(*rcm) != htons(rcm->header.size)) + GNUNET_MQ_check_zero_termination(rcm); return GNUNET_OK; } @@ -285,29 +282,29 @@ check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) * @param rcm result message received */ static void -handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) +handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) { struct GNUNET_IDENTITY_Handle *h = cls; struct GNUNET_IDENTITY_Operation *op; - uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm); - const char *str = (0 == size) ? NULL : (const char *) &rcm[1]; + uint16_t size = ntohs(rcm->header.size) - sizeof(*rcm); + const char *str = (0 == size) ? NULL : (const char *)&rcm[1]; op = h->op_head; if (NULL == op) - { - GNUNET_break (0); - reschedule_connect (h); - return; - } - GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + { + GNUNET_break(0); + reschedule_connect(h); + return; + } + GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); if (NULL != op->cont) - op->cont (op->cls, str); + op->cont(op->cls, str); else if (NULL != op->cb) - op->cb (op->cls, NULL, NULL, NULL); + 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); + op->create_cont(op->cls, (NULL == str) ? op->pk : NULL, str); + GNUNET_free_non_null(op->pk); + GNUNET_free(op); } @@ -319,18 +316,18 @@ handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) * @return #GNUNET_OK if the message is well-formed */ static int -check_identity_update (void *cls, const struct UpdateMessage *um) +check_identity_update(void *cls, const struct UpdateMessage *um) { - uint16_t size = ntohs (um->header.size); - uint16_t name_len = ntohs (um->name_len); - const char *str = (const char *) &um[1]; + uint16_t size = ntohs(um->header.size); + uint16_t name_len = ntohs(um->name_len); + const char *str = (const char *)&um[1]; - if ((size != name_len + sizeof (struct UpdateMessage)) || + if ((size != name_len + sizeof(struct UpdateMessage)) || ((0 != name_len) && ('\0' != str[name_len - 1]))) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } + { + GNUNET_break(0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -342,70 +339,70 @@ check_identity_update (void *cls, const struct UpdateMessage *um) * @param um message received */ static void -handle_identity_update (void *cls, const struct UpdateMessage *um) +handle_identity_update(void *cls, const struct UpdateMessage *um) { struct GNUNET_IDENTITY_Handle *h = cls; - uint16_t name_len = ntohs (um->name_len); - const char *str = (0 == name_len) ? NULL : (const char *) &um[1]; + uint16_t name_len = ntohs(um->name_len); + const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; struct GNUNET_CRYPTO_EcdsaPublicKey pub; struct GNUNET_HashCode id; struct GNUNET_IDENTITY_Ego *ego; - if (GNUNET_YES == ntohs (um->end_of_list)) - { - /* end of initial list of data */ - if (NULL != h->cb) - h->cb (h->cb_cls, NULL, NULL, NULL); - return; - } - GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub); - GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); - ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id); - if (NULL == ego) - { - /* ego was created */ - if (NULL == str) + if (GNUNET_YES == ntohs(um->end_of_list)) { - /* deletion of unknown ego? not allowed */ - GNUNET_break (0); - reschedule_connect (h); + /* end of initial list of data */ + if (NULL != h->cb) + h->cb(h->cb_cls, NULL, NULL, NULL); return; } - ego = GNUNET_new (struct GNUNET_IDENTITY_Ego); - ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); - *ego->pk = um->private_key; - ego->name = GNUNET_strdup (str); - ego->id = id; - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_put ( - h->egos, - &ego->id, - ego, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); - } + GNUNET_CRYPTO_ecdsa_key_get_public(&um->private_key, &pub); + GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); + ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); + if (NULL == ego) + { + /* ego was created */ + if (NULL == str) + { + /* deletion of unknown ego? not allowed */ + GNUNET_break(0); + reschedule_connect(h); + return; + } + ego = GNUNET_new(struct GNUNET_IDENTITY_Ego); + ego->pk = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); + *ego->pk = um->private_key; + ego->name = GNUNET_strdup(str); + ego->id = id; + GNUNET_assert(GNUNET_YES == + GNUNET_CONTAINER_multihashmap_put( + h->egos, + &ego->id, + ego, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + } if (NULL == str) - { - /* ego was deleted */ - GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (h->egos, + { + /* ego was deleted */ + GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(h->egos, &ego->id, ego)); - } + } else - { - /* ego changed name */ - GNUNET_free (ego->name); - ego->name = GNUNET_strdup (str); - } + { + /* ego changed name */ + GNUNET_free(ego->name); + ego->name = GNUNET_strdup(str); + } /* inform application about change */ if (NULL != h->cb) - h->cb (h->cb_cls, ego, &ego->ctx, str); + h->cb(h->cb_cls, ego, &ego->ctx, str); /* complete deletion */ if (NULL == str) - { - GNUNET_free (ego->pk); - GNUNET_free (ego->name); - GNUNET_free (ego); - } + { + GNUNET_free(ego->pk); + GNUNET_free(ego->name); + GNUNET_free(ego); + } } @@ -418,18 +415,18 @@ handle_identity_update (void *cls, const struct UpdateMessage *um) * @return #GNUNET_OK if the message is well-formed */ static int -check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) +check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) { - uint16_t size = ntohs (sdm->header.size) - sizeof (*sdm); - uint16_t name_len = ntohs (sdm->name_len); - const char *str = (const char *) &sdm[1]; + uint16_t size = ntohs(sdm->header.size) - sizeof(*sdm); + uint16_t name_len = ntohs(sdm->name_len); + const char *str = (const char *)&sdm[1]; if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1]))) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_break (0 == ntohs (sdm->reserved)); + { + GNUNET_break(0); + return GNUNET_SYSERR; + } + GNUNET_break(0 == ntohs(sdm->reserved)); return GNUNET_OK; } @@ -442,7 +439,7 @@ check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) * @param sdm message received */ static void -handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) +handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) { struct GNUNET_IDENTITY_Handle *h = cls; struct GNUNET_IDENTITY_Operation *op; @@ -450,28 +447,28 @@ handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) struct GNUNET_HashCode id; struct GNUNET_IDENTITY_Ego *ego; - GNUNET_CRYPTO_ecdsa_key_get_public (&sdm->private_key, &pub); - GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); - ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id); + GNUNET_CRYPTO_ecdsa_key_get_public(&sdm->private_key, &pub); + GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); + ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); if (NULL == ego) - { - GNUNET_break (0); - reschedule_connect (h); - return; - } + { + GNUNET_break(0); + reschedule_connect(h); + return; + } op = h->op_head; if (NULL == op) - { - GNUNET_break (0); - reschedule_connect (h); - return; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received SET_DEFAULT message from identity service\n"); - GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + { + GNUNET_break(0); + reschedule_connect(h); + return; + } + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "Received SET_DEFAULT message from identity service\n"); + GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); if (NULL != op->cb) - op->cb (op->cls, ego, &ego->ctx, ego->name); - GNUNET_free (op); + op->cb(op->cls, ego, &ego->ctx, ego->name); + GNUNET_free(op); } @@ -481,38 +478,38 @@ handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) * @param cls handle to the identity service. */ static void -reconnect (void *cls) +reconnect(void *cls) { struct GNUNET_IDENTITY_Handle *h = cls; struct GNUNET_MQ_MessageHandler handlers[] = - {GNUNET_MQ_hd_var_size (identity_result_code, - GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, - struct ResultCodeMessage, - h), - GNUNET_MQ_hd_var_size (identity_update, - GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, - struct UpdateMessage, - h), - GNUNET_MQ_hd_var_size (identity_set_default, - GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, - struct SetDefaultMessage, - h), - GNUNET_MQ_handler_end ()}; + { GNUNET_MQ_hd_var_size(identity_result_code, + GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, + struct ResultCodeMessage, + h), + GNUNET_MQ_hd_var_size(identity_update, + GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, + struct UpdateMessage, + h), + GNUNET_MQ_hd_var_size(identity_set_default, + GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, + struct SetDefaultMessage, + h), + GNUNET_MQ_handler_end() }; struct GNUNET_MQ_Envelope *env; struct GNUNET_MessageHeader *msg; h->reconnect_task = NULL; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); - GNUNET_assert (NULL == h->mq); + LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); + GNUNET_assert(NULL == h->mq); h->mq = - GNUNET_CLIENT_connect (h->cfg, "identity", handlers, &mq_error_handler, h); + GNUNET_CLIENT_connect(h->cfg, "identity", handlers, &mq_error_handler, h); if (NULL == h->mq) return; if (NULL != h->cb) - { - env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_IDENTITY_START); - GNUNET_MQ_send (h->mq, env); - } + { + env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_IDENTITY_START); + GNUNET_MQ_send(h->mq, env); + } } @@ -525,23 +522,23 @@ reconnect (void *cls) * @return handle to use */ struct GNUNET_IDENTITY_Handle * -GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_IDENTITY_Callback cb, - void *cb_cls) +GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, + GNUNET_IDENTITY_Callback cb, + void *cb_cls) { struct GNUNET_IDENTITY_Handle *h; - h = GNUNET_new (struct GNUNET_IDENTITY_Handle); + h = GNUNET_new(struct GNUNET_IDENTITY_Handle); h->cfg = cfg; h->cb = cb; h->cb_cls = cb_cls; - h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES); - reconnect (h); + h->egos = GNUNET_CONTAINER_multihashmap_create(16, GNUNET_YES); + reconnect(h); if (NULL == h->mq) - { - GNUNET_free (h); - return NULL; - } + { + GNUNET_free(h); + return NULL; + } return h; } @@ -553,7 +550,7 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, * @return associated ECC key, valid as long as the ego is valid */ const struct GNUNET_CRYPTO_EcdsaPrivateKey * -GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego) +GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego) { return ego->pk; } @@ -566,10 +563,10 @@ GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego) * @param pk set to ego's public key */ void -GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego, - struct GNUNET_CRYPTO_EcdsaPublicKey *pk) +GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, + struct GNUNET_CRYPTO_EcdsaPublicKey *pk) { - GNUNET_CRYPTO_ecdsa_key_get_public (ego->pk, pk); + GNUNET_CRYPTO_ecdsa_key_get_public(ego->pk, pk); } @@ -584,10 +581,10 @@ GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego, * @return handle to abort the operation */ struct GNUNET_IDENTITY_Operation * -GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, - const char *service_name, - GNUNET_IDENTITY_Callback cb, - void *cb_cls) +GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, + const char *service_name, + GNUNET_IDENTITY_Callback cb, + void *cb_cls) { struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MQ_Envelope *env; @@ -596,24 +593,24 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; - GNUNET_assert (NULL != h->cb); - slen = strlen (service_name) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_Operation); + GNUNET_assert(NULL != h->cb); + slen = strlen(service_name) + 1; + if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage)) + { + GNUNET_break(0); + return NULL; + } + op = GNUNET_new(struct GNUNET_IDENTITY_Operation); op->h = h; op->cb = cb; op->cls = cb_cls; - GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); env = - GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); - gdm->name_len = htons (slen); - gdm->reserved = htons (0); - GNUNET_memcpy (&gdm[1], service_name, slen); - GNUNET_MQ_send (h->mq, env); + GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); + gdm->name_len = htons(slen); + gdm->reserved = htons(0); + GNUNET_memcpy(&gdm[1], service_name, slen); + GNUNET_MQ_send(h->mq, env); return op; } @@ -629,11 +626,11 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, * @return handle to abort the operation */ struct GNUNET_IDENTITY_Operation * -GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, - const char *service_name, - struct GNUNET_IDENTITY_Ego *ego, - GNUNET_IDENTITY_Continuation cont, - void *cont_cls) +GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, + const char *service_name, + struct GNUNET_IDENTITY_Ego *ego, + GNUNET_IDENTITY_Continuation cont, + void *cont_cls) { struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MQ_Envelope *env; @@ -642,25 +639,25 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; - GNUNET_assert (NULL != h->cb); - slen = strlen (service_name) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_Operation); + GNUNET_assert(NULL != h->cb); + slen = strlen(service_name) + 1; + if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage)) + { + GNUNET_break(0); + return NULL; + } + op = GNUNET_new(struct GNUNET_IDENTITY_Operation); op->h = h; op->cont = cont; op->cls = cont_cls; - GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); env = - GNUNET_MQ_msg_extra (sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); - sdm->name_len = htons (slen); - sdm->reserved = htons (0); + GNUNET_MQ_msg_extra(sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); + sdm->name_len = htons(slen); + sdm->reserved = htons(0); sdm->private_key = *ego->pk; - GNUNET_memcpy (&sdm[1], service_name, slen); - GNUNET_MQ_send (h->mq, env); + GNUNET_memcpy(&sdm[1], service_name, slen); + GNUNET_MQ_send(h->mq, env); return op; } @@ -675,10 +672,10 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, * @return handle to abort the operation */ struct GNUNET_IDENTITY_Operation * -GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, - const char *name, - GNUNET_IDENTITY_CreateContinuation cont, - void *cont_cls) +GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, + const char *name, + GNUNET_IDENTITY_CreateContinuation cont, + void *cont_cls) { struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MQ_Envelope *env; @@ -688,25 +685,25 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; - slen = strlen (name) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage)) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_Operation); + slen = strlen(name) + 1; + if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage)) + { + GNUNET_break(0); + return NULL; + } + op = GNUNET_new(struct GNUNET_IDENTITY_Operation); op->h = h; op->create_cont = cont; op->cls = cont_cls; - GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); - env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); - crm->name_len = htons (slen); - crm->reserved = htons (0); - pk = GNUNET_CRYPTO_ecdsa_key_create (); + GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); + env = GNUNET_MQ_msg_extra(crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); + crm->name_len = htons(slen); + crm->reserved = htons(0); + pk = GNUNET_CRYPTO_ecdsa_key_create(); crm->private_key = *pk; op->pk = pk; - GNUNET_memcpy (&crm[1], name, slen); - GNUNET_MQ_send (h->mq, env); + GNUNET_memcpy(&crm[1], name, slen); + GNUNET_MQ_send(h->mq, env); return op; } @@ -722,11 +719,11 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, * @return handle to abort the operation */ struct GNUNET_IDENTITY_Operation * -GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, - const char *old_name, - const char *new_name, - GNUNET_IDENTITY_Continuation cb, - void *cb_cls) +GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, + const char *old_name, + const char *new_name, + GNUNET_IDENTITY_Continuation cb, + void *cb_cls) { struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MQ_Envelope *env; @@ -737,30 +734,30 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; - slen_old = strlen (old_name) + 1; - slen_new = strlen (new_name) + 1; + slen_old = strlen(old_name) + 1; + slen_new = strlen(new_name) + 1; if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) || (slen_new >= GNUNET_MAX_MESSAGE_SIZE) || (slen_old + slen_new >= - GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage))) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_Operation); + GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage))) + { + GNUNET_break(0); + return NULL; + } + op = GNUNET_new(struct GNUNET_IDENTITY_Operation); op->h = h; op->cont = cb; op->cls = cb_cls; - GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); - env = GNUNET_MQ_msg_extra (grm, - slen_old + slen_new, - GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); - grm->old_name_len = htons (slen_old); - grm->new_name_len = htons (slen_new); - dst = (char *) &grm[1]; - GNUNET_memcpy (dst, old_name, slen_old); - GNUNET_memcpy (&dst[slen_old], new_name, slen_new); - GNUNET_MQ_send (h->mq, env); + GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); + env = GNUNET_MQ_msg_extra(grm, + slen_old + slen_new, + GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); + grm->old_name_len = htons(slen_old); + grm->new_name_len = htons(slen_new); + dst = (char *)&grm[1]; + GNUNET_memcpy(dst, old_name, slen_old); + GNUNET_memcpy(&dst[slen_old], new_name, slen_new); + GNUNET_MQ_send(h->mq, env); return op; } @@ -775,10 +772,10 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, * @return handle to abort the operation */ struct GNUNET_IDENTITY_Operation * -GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, - const char *name, - GNUNET_IDENTITY_Continuation cb, - void *cb_cls) +GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, + const char *name, + GNUNET_IDENTITY_Continuation cb, + void *cb_cls) { struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MQ_Envelope *env; @@ -787,22 +784,22 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; - slen = strlen (name) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage)) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_Operation); + slen = strlen(name) + 1; + if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage)) + { + GNUNET_break(0); + return NULL; + } + op = GNUNET_new(struct GNUNET_IDENTITY_Operation); op->h = h; op->cont = cb; op->cls = cb_cls; - GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); - env = GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); - gdm->name_len = htons (slen); - gdm->reserved = htons (0); - GNUNET_memcpy (&gdm[1], name, slen); - GNUNET_MQ_send (h->mq, env); + GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); + env = GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); + gdm->name_len = htons(slen); + gdm->reserved = htons(0); + GNUNET_memcpy(&gdm[1], name, slen); + GNUNET_MQ_send(h->mq, env); return op; } @@ -816,16 +813,16 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, * @param op operation to cancel */ void -GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) +GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op) { op->cont = NULL; op->cb = NULL; op->create_cont = NULL; if (NULL != op->pk) - { - GNUNET_free (op->pk); - op->pk = NULL; - } + { + GNUNET_free(op->pk); + op->pk = NULL; + } } @@ -835,35 +832,35 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) * @param h handle to destroy */ void -GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) +GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h) { struct GNUNET_IDENTITY_Operation *op; - GNUNET_assert (NULL != h); + GNUNET_assert(NULL != h); if (h->reconnect_task != NULL) - { - GNUNET_SCHEDULER_cancel (h->reconnect_task); - h->reconnect_task = NULL; - } + { + GNUNET_SCHEDULER_cancel(h->reconnect_task); + h->reconnect_task = NULL; + } if (NULL != h->egos) - { - GNUNET_CONTAINER_multihashmap_iterate (h->egos, &free_ego, h); - GNUNET_CONTAINER_multihashmap_destroy (h->egos); - h->egos = NULL; - } + { + GNUNET_CONTAINER_multihashmap_iterate(h->egos, &free_ego, h); + GNUNET_CONTAINER_multihashmap_destroy(h->egos); + h->egos = NULL; + } while (NULL != (op = h->op_head)) - { - GNUNET_break (NULL == op->cont); - GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); - GNUNET_free_non_null (op->pk); - GNUNET_free (op); - } + { + GNUNET_break(NULL == op->cont); + GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); + GNUNET_free_non_null(op->pk); + GNUNET_free(op); + } if (NULL != h->mq) - { - GNUNET_MQ_destroy (h->mq); - h->mq = NULL; - } - GNUNET_free (h); + { + GNUNET_MQ_destroy(h->mq); + h->mq = NULL; + } + GNUNET_free(h); } /* end of identity_api.c */ -- cgit v1.2.3