From 554deb2661f292d2d1dc6ed11b30d9a1eeae0ede Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 19 Dec 2020 18:44:07 +0100 Subject: adapt to GNUENT_DISK_fn_write API change --- src/social/gnunet-service-social.c | 652 ++++++++++++++++++++----------------- 1 file changed, 351 insertions(+), 301 deletions(-) diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index cda96e5..6fd2383 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c @@ -96,7 +96,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *apps_places; * Application subscriptions per place. * H(place_pub_key) -> H(app_id) */ -//static struct GNUNET_CONTAINER_MultiHashMap *places_apps; +// static struct GNUNET_CONTAINER_MultiHashMap *places_apps; /** * Connected applications. @@ -265,7 +265,8 @@ struct Place */ uint8_t is_host; - union { + union + { struct Host *host; struct Guest *guest; }; @@ -397,7 +398,8 @@ struct Application }; -struct Ego { +struct Ego +{ struct GNUNET_CRYPTO_EcdsaPrivateKey key; char *name; }; @@ -629,7 +631,7 @@ place_send_msg (const struct Place *plc, struct GNUNET_MQ_Envelope *env) { struct ClientListItem *cli = plc->clients_head; - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Sending message to clients of place.\n", plc); while (NULL != cli) @@ -649,14 +651,14 @@ static void place_send_leave_ack (struct Place *plc) { struct GNUNET_MQ_Envelope *env; - + for (struct ClientListItem *cli = plc->clients_head; NULL != cli; cli = cli->next) { env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), - env); + env); } } @@ -690,9 +692,9 @@ client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, if (0 < data_size) GNUNET_memcpy (&res[1], data, data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending result to client for operation #%" PRIu64 ": " + "%p Sending result to client for operation #%" PRIu64 ": " "%" PRId64 " (size: %u)\n", - client, GNUNET_ntohll (op_id), result_code, data_size); + client, GNUNET_ntohll (op_id), result_code, data_size); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); } @@ -706,7 +708,7 @@ client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client, struct Place *plc = &hst->place; env = GNUNET_MQ_msg (hack, - GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); + GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); hack->result_code = htonl (result); hack->max_message_id = GNUNET_htonll (plc->max_message_id); hack->place_pub_key = plc->pub_key; @@ -855,7 +857,8 @@ host_relay_message_part (struct Host *hst, GNUNET_CRYPTO_hash (nym_pub_key, sizeof (*nym_pub_key), &nym_pub_hash); struct MessageTransmitQueue * - tmit_msg = GNUNET_CONTAINER_multihashmap_get (hst->relay_msgs, &nym_pub_hash); + tmit_msg = GNUNET_CONTAINER_multihashmap_get (hst->relay_msgs, + &nym_pub_hash); uint16_t ptype = ntohs (pmsg->type); @@ -863,7 +866,7 @@ host_relay_message_part (struct Host *hst, { /* FIXME: last message was unfinished, cancel & remove from queue */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "FIXME: last message was unfinished.\n"); + "FIXME: last message was unfinished.\n"); } tmit_msg = psyc_transmit_queue_message (&hst->place, NULL, ntohs (pmsg->size), @@ -873,13 +876,13 @@ host_relay_message_part (struct Host *hst, { case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put - (hst->relay_msgs, &nym_pub_hash, tmit_msg, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + (hst->relay_msgs, &nym_pub_hash, tmit_msg, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); break; case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove - (hst->relay_msgs, &nym_pub_hash, tmit_msg)); + (hst->relay_msgs, &nym_pub_hash, tmit_msg)); break; } } @@ -898,7 +901,7 @@ place_recv_relay_method (void *cls, struct Place *plc = cls; if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) - && GNUNET_YES == plc->is_host) + && (GNUNET_YES == plc->is_host)) { struct Host *hst = cls; host_relay_message_part (hst, &meth->header, &msg->slave_pub_key); @@ -923,13 +926,14 @@ place_recv_relay_modifier (void *cls, struct Place *plc = cls; if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) - && GNUNET_YES == plc->is_host) + && (GNUNET_YES == plc->is_host)) { struct Host *hst = cls; host_relay_message_part (hst, pmsg, &msg->slave_pub_key); } } + /** * Received a data fragment to be relayed from a guest. */ @@ -944,7 +948,7 @@ place_recv_relay_data (void *cls, struct Place *plc = cls; if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) - && GNUNET_YES == plc->is_host) + && (GNUNET_YES == plc->is_host)) { struct Host *hst = cls; host_relay_message_part (hst, pmsg, &msg->slave_pub_key); @@ -965,7 +969,7 @@ place_recv_relay_eom (void *cls, struct Place *plc = cls; if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) - && GNUNET_YES == plc->is_host) + && (GNUNET_YES == plc->is_host)) { struct Host *hst = cls; host_relay_message_part (hst, pmsg, &msg->slave_pub_key); @@ -990,7 +994,8 @@ place_recv_save_method (void *cls, plc->file_offset = 0; plc->file_save = GNUNET_NO; - char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); + char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string ( + &plc->pub_key); char *filename = NULL; GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part", dir_social, DIR_SEPARATOR, @@ -1002,9 +1007,10 @@ place_recv_save_method (void *cls, /* save if does not already exist */ if (GNUNET_YES != GNUNET_DISK_file_test (filename)) { - if (0 == GNUNET_DISK_fn_write (filename, NULL, 0, - GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE)) + if (GNUNET_OK == + GNUNET_DISK_fn_write (filename, NULL, 0, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)) { plc->file_save = GNUNET_YES; } @@ -1034,7 +1040,8 @@ place_recv_save_data (void *cls, if (GNUNET_YES != plc->file_save) return; - char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); + char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string ( + &plc->pub_key); char *filename = NULL; GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part", dir_social, DIR_SEPARATOR, @@ -1055,7 +1062,8 @@ place_recv_save_data (void *cls, if (NULL != fh) { if (plc->file_offset != GNUNET_DISK_file_seek - (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) { + (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) + { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename); GNUNET_DISK_file_close (fh); GNUNET_free (filename); @@ -1090,7 +1098,8 @@ place_recv_save_eom (void *cls, if (GNUNET_YES != plc->file_save) return; - char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); + char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string ( + &plc->pub_key); char *fn = NULL; GNUNET_asprintf (&fn, "%s%c%s%c%s%c%" PRIu64, dir_social, DIR_SEPARATOR, @@ -1101,10 +1110,11 @@ place_recv_save_eom (void *cls, char *fn_part = NULL; GNUNET_asprintf (&fn_part, "%s.part", fn); - if (rename (fn_part, fn)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to rename %s into %s: %s (%d)\n", - fn_part, fn, strerror (errno), errno); + if (rename (fn_part, fn)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to rename %s into %s: %s (%d)\n", + fn_part, fn, strerror (errno), errno); } GNUNET_free (fn); @@ -1140,7 +1150,8 @@ place_add (const struct PlaceEnterRequest *ereq) .place_pub_key = ereq->place_pub_key, }; struct GNUNET_HashCode ego_place_pub_hash; - GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), &ego_place_pub_hash); + GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), + &ego_place_pub_hash); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash)); @@ -1151,7 +1162,9 @@ place_add (const struct PlaceEnterRequest *ereq) return GNUNET_NO; place_msg = GNUNET_copy_message (&ereq->header); - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places, &ego_place_pub_hash, place_msg, + if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places, + &ego_place_pub_hash, + place_msg, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) { GNUNET_break (0); @@ -1162,6 +1175,7 @@ place_add (const struct PlaceEnterRequest *ereq) return GNUNET_OK; } + /** * Add a place to the @e app_places hash map. * @@ -1191,7 +1205,8 @@ app_place_add (const char *app_id, .place_pub_key = ereq->place_pub_key, }; struct GNUNET_HashCode ego_place_pub_hash; - GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), &ego_place_pub_hash); + GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), + &ego_place_pub_hash); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash)); @@ -1205,7 +1220,8 @@ app_place_add (const char *app_id, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); } - if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (app_places, &ego_place_pub_hash)) + if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (app_places, + &ego_place_pub_hash)) return GNUNET_NO; if (GNUNET_SYSERR == place_add (ereq)) @@ -1213,7 +1229,8 @@ app_place_add (const char *app_id, return GNUNET_SYSERR; } - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, + if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, + &ego_place_pub_hash, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) { GNUNET_break (0); @@ -1243,19 +1260,20 @@ app_place_save (const char *app_id, if (NULL == dir_places) return GNUNET_SYSERR; - char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ereq->ego_pub_key); - char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&ereq->place_pub_key); + char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string ( + &ereq->ego_pub_key); + char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string ( + &ereq->place_pub_key); char *filename = NULL; GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%s", dir_social, DIR_SEPARATOR, "places", DIR_SEPARATOR, ego_pub_str, DIR_SEPARATOR, place_pub_str); - int ret = GNUNET_DISK_directory_create_for_file (filename); - if (GNUNET_OK != ret - || 0 > GNUNET_DISK_fn_write (filename, ereq, ntohs (ereq->header.size), - GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE)) + if (GNUNET_OK != + GNUNET_DISK_fn_write (filename, ereq, ntohs (ereq->header.size), + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)) { GNUNET_break (0); ret = GNUNET_SYSERR; @@ -1271,10 +1289,10 @@ app_place_save (const char *app_id, ego_pub_str, DIR_SEPARATOR, place_pub_str); ret = GNUNET_DISK_directory_create_for_file (filename); - if (GNUNET_OK != ret - || 0 > GNUNET_DISK_fn_write (filename, "", 0, - GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE)) + if ((GNUNET_OK != ret) + || (0 > GNUNET_DISK_fn_write (filename, "", 0, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE))) { GNUNET_break (0); ret = GNUNET_SYSERR; @@ -1298,7 +1316,8 @@ app_place_remove (const char *app_id, GNUNET_CRYPTO_hash (place_pub_key, sizeof (*place_pub_key), &place_pub_hash); char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key); - char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (place_pub_key); + char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string ( + place_pub_key); char *app_place_filename = NULL; GNUNET_asprintf (&app_place_filename, "%s%c" "%s%c" "%s%c" "%s%c" "%s", @@ -1406,7 +1425,7 @@ msg_proc_parse (const struct MsgProcRequest *mpreq, method_size, 1, method_prefix); - if (0 == offset || offset != method_size || *method_prefix == NULL) + if ((0 == offset) || (offset != method_size) || (*method_prefix == NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MsgProcRequest contains invalid method\n"); @@ -1425,44 +1444,44 @@ app_notify_place (const struct GNUNET_MessageHeader *msg, struct AppPlaceMessage *amsg; struct GNUNET_MQ_Envelope *env; uint16_t msg_size = ntohs (msg->size); - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Sending place notification of type %u to client.\n", client, ntohs (msg->type)); switch (ntohs (msg->type)) { case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: - { - struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; - if (msg_size < sizeof (struct HostEnterRequest)) - return; - env = GNUNET_MQ_msg (amsg, - GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); - // FIXME: also notify about not entered places - amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; - amsg->is_host = GNUNET_YES; - amsg->ego_pub_key = hreq->ego_pub_key; - amsg->place_pub_key = hreq->place_pub_key; - GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), - env); - break; - } + { + struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; + if (msg_size < sizeof (struct HostEnterRequest)) + return; + env = GNUNET_MQ_msg (amsg, + GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); + // FIXME: also notify about not entered places + amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; + amsg->is_host = GNUNET_YES; + amsg->ego_pub_key = hreq->ego_pub_key; + amsg->place_pub_key = hreq->place_pub_key; + GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), + env); + break; + } case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: - { - if (msg_size < sizeof (struct GuestEnterRequest)) - return; - struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; - env = GNUNET_MQ_msg (amsg, - GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); - // FIXME: also notify about not entered places - amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; - amsg->is_host = GNUNET_NO; - amsg->ego_pub_key = greq->ego_pub_key; - amsg->place_pub_key = greq->place_pub_key; - GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), - env); - break; - } + { + if (msg_size < sizeof (struct GuestEnterRequest)) + return; + struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; + env = GNUNET_MQ_msg (amsg, + GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); + // FIXME: also notify about not entered places + amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; + amsg->is_host = GNUNET_NO; + amsg->ego_pub_key = greq->ego_pub_key; + amsg->place_pub_key = greq->place_pub_key; + GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), + env); + break; + } default: return; } @@ -1518,7 +1537,8 @@ app_notify_ego_end (struct GNUNET_SERVICE_Client *client) int -app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) +app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, + void *value) { struct GNUNET_MessageHeader * msg = GNUNET_CONTAINER_multihashmap_get (places, key); @@ -1656,7 +1676,7 @@ handle_client_host_enter (void *cls, const char *app_id = NULL; uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], app_id_size, 1, &app_id); - if (0 == offset || offset != app_id_size || app_id == NULL) + if ((0 == offset) || (offset != app_id_size) || (app_id == NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "offset = %u, app_id_size = %u, app_id = %s\n", @@ -1673,7 +1693,8 @@ handle_client_host_enter (void *cls, struct GNUNET_CRYPTO_EddsaPublicKey empty_pub_key; memset (&empty_pub_key, 0, sizeof (empty_pub_key)); - if (0 == memcmp (&hreq->place_pub_key, &empty_pub_key, sizeof (empty_pub_key))) + if (0 == memcmp (&hreq->place_pub_key, &empty_pub_key, + sizeof (empty_pub_key))) { // no public key set: create new private key & save the place struct GNUNET_CRYPTO_EddsaPrivateKey * place_key = GNUNET_CRYPTO_eddsa_key_create (); @@ -1693,12 +1714,12 @@ handle_client_host_enter (void *cls, break; case GNUNET_NO: - { - plc = c->place = &hst->place; - plc->host = hst; - client_send_host_enter_ack (client, hst, GNUNET_OK); - break; - } + { + plc = c->place = &hst->place; + plc->host = hst; + client_send_host_enter_ack (client, hst, GNUNET_OK); + break; + } case GNUNET_SYSERR: ret = GNUNET_SYSERR; } @@ -1779,7 +1800,8 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) gst = GNUNET_new (struct Guest); new_guest = GNUNET_YES; } - else new_guest = GNUNET_NO; + else + new_guest = GNUNET_NO; if (NULL == gst->slave) { @@ -1853,15 +1875,17 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) if (NULL == plc_gst) { plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); - (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, + (void) GNUNET_CONTAINER_multihashmap_put (place_guests, + &plc->pub_key_hash, plc_gst, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); } if (GNUNET_YES == new_guest) { - (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, + (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, + gst, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } gst->slave @@ -1909,41 +1933,41 @@ client_guest_enter (struct Client *c, switch (guest_enter (greq, &gst)) { case GNUNET_YES: - { - plc = c->place = &gst->place; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "guest entered successfully to local place %s\n", - GNUNET_h2s (&plc->pub_key_hash)); - plc->guest = gst; - app_place_save (app_id, (const struct PlaceEnterRequest *) greq); - app_notify_place (&greq->header, client); - break; - } + { + plc = c->place = &gst->place; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "guest entered successfully to local place %s\n", + GNUNET_h2s (&plc->pub_key_hash)); + plc->guest = gst; + app_place_save (app_id, (const struct PlaceEnterRequest *) greq); + app_notify_place (&greq->header, client); + break; + } case GNUNET_NO: - { - plc = c->place = &gst->place; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "guest re-entered successfully to local place %s\n", - GNUNET_h2s (&plc->pub_key_hash)); - plc->guest = gst; - env = GNUNET_MQ_msg (result_msg, - GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); - result_msg->result_code = htonl (GNUNET_OK); - result_msg->max_message_id = GNUNET_htonll (plc->max_message_id); - GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), - env); - if (NULL != gst->join_dcsn) - { - env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header); + { + plc = c->place = &gst->place; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "guest re-entered successfully to local place %s\n", + GNUNET_h2s (&plc->pub_key_hash)); + plc->guest = gst; + env = GNUNET_MQ_msg (result_msg, + GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); + result_msg->result_code = htonl (GNUNET_OK); + result_msg->max_message_id = GNUNET_htonll (plc->max_message_id); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); + if (NULL != gst->join_dcsn) + { + env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header); + GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), + env); + } + break; } - break; - } case GNUNET_SYSERR: - { - return GNUNET_SYSERR; - } + { + return GNUNET_SYSERR; + } } struct ClientListItem *cli = GNUNET_new (struct ClientListItem); @@ -2008,7 +2032,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_PlaceData * rec = (const struct GNUNET_GNSRECORD_PlaceData *) rd->data; - if (0 == rd_count || rd->data_size < sizeof (*rec)) + if ((0 == rd_count) || (rd->data_size < sizeof (*rec))) { GNUNET_break (0); GNUNET_SERVICE_client_drop (c->client); @@ -2020,7 +2044,8 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, if (0 < relay_count) { - if (rd->data_size == sizeof (*rec) + relay_count * sizeof (struct GNUNET_PeerIdentity)) + if (rd->data_size == sizeof (*rec) + relay_count * sizeof (struct + GNUNET_PeerIdentity)) { relays = (struct GNUNET_PeerIdentity *) &rec[1]; } @@ -2037,7 +2062,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, if (NULL != gcls->join_msg) join_msg_size = ntohs (gcls->join_msg->size); uint16_t greq_size = sizeof (struct GuestEnterRequest) - + app_id_size + relay_size + join_msg_size; + + app_id_size + relay_size + join_msg_size; struct GuestEnterRequest *greq = GNUNET_malloc (greq_size); greq->header.size = htons (greq_size); greq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER); @@ -2099,13 +2124,13 @@ handle_client_guest_enter_by_name (void *cls, p += offset; remaining -= offset; - if (0 != offset && sizeof (*gcls->join_msg) <= remaining) + if ((0 != offset) && (sizeof (*gcls->join_msg) <= remaining)) { gcls->join_msg = GNUNET_copy_message ((struct GNUNET_MessageHeader *) p); remaining -= ntohs (gcls->join_msg->size); } - if (0 == offset || 0 != remaining) + if ((0 == offset) || (0 != remaining)) { if (NULL != gcls->join_msg) GNUNET_free (gcls->join_msg); @@ -2155,7 +2180,7 @@ handle_client_app_connect (void *cls, ssize_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); const char *app_id = NULL; uint16_t offset; - + if (app_id_size < 0) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -2167,12 +2192,12 @@ handle_client_app_connect (void *cls, offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1], (size_t) app_id_size, - 1, + 1, &app_id); - if (0 == offset || offset != app_id_size) + if ((0 == offset) || (offset != app_id_size)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "AppConnectRequest contains invalid app ID\n"); + "AppConnectRequest contains invalid app ID\n"); GNUNET_break (0); GNUNET_SERVICE_client_drop (client); return; @@ -2187,14 +2212,16 @@ handle_client_app_connect (void *cls, struct GNUNET_CONTAINER_MultiHashMap * app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash); if (NULL != app_places) - GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify, client); + GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify, + client); app_notify_place_end (client); struct ClientListItem *cli = GNUNET_new (struct ClientListItem); cli->client = client; struct Application *app = GNUNET_CONTAINER_multihashmap_get (apps, &app_id_hash); - if (NULL == app) { + if (NULL == app) + { app = GNUNET_malloc (sizeof (*app)); (void) GNUNET_CONTAINER_multihashmap_put (apps, &app_id_hash, app, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); @@ -2221,7 +2248,8 @@ handle_client_app_detach (void *cls, struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; - int ret = app_place_remove (c->app_id, &req->ego_pub_key, &req->place_pub_key); + int ret = app_place_remove (c->app_id, &req->ego_pub_key, + &req->place_pub_key); client_send_result (client, req->op_id, ret, NULL, 0); GNUNET_SERVICE_client_continue (client); @@ -2254,7 +2282,7 @@ handle_client_place_leave (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got leave request from %s for place %s", plc->is_host? "host" : "slave", - GNUNET_h2s (&plc->pub_key_hash)); + GNUNET_h2s (&plc->pub_key_hash)); if (NULL == plc) { GNUNET_break (0); @@ -2327,7 +2355,7 @@ handle_client_join_decision (void *cls, struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; struct Place *plc = c->place; - if (NULL == plc || GNUNET_YES != plc->is_host) + if ((NULL == plc) || (GNUNET_YES != plc->is_host)) { GNUNET_break (0); GNUNET_SERVICE_client_drop (client); @@ -2410,7 +2438,8 @@ psyc_transmit_queue_next_part (struct Place *plc, { if (NULL != tmit_frag->client) send_message_ack (plc, tmit_frag->client); - GNUNET_CONTAINER_DLL_remove (tmit_msg->frags_head, tmit_msg->frags_tail, tmit_frag); + GNUNET_CONTAINER_DLL_remove (tmit_msg->frags_head, tmit_msg->frags_tail, + tmit_frag); GNUNET_free (tmit_frag); tmit_frag = NULL; } @@ -2432,7 +2461,8 @@ static struct MessageTransmitQueue * psyc_transmit_queue_next_msg (struct Place *plc, struct MessageTransmitQueue *tmit_msg) { - GNUNET_CONTAINER_DLL_remove (plc->tmit_msgs_head, plc->tmit_msgs_tail, tmit_msg); + GNUNET_CONTAINER_DLL_remove (plc->tmit_msgs_head, plc->tmit_msgs_tail, + tmit_msg); GNUNET_free (tmit_msg); return plc->tmit_msgs_head; } @@ -2476,7 +2506,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data) if (*data_size < pdata_size) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p psyc_transmit_notify_data: buffer size too small for data.\n", plc); + "%p psyc_transmit_notify_data: buffer size too small for data.\n", + plc); *data_size = 0; return GNUNET_NO; } @@ -2506,7 +2537,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data) ret = GNUNET_SYSERR; } - if (GNUNET_SYSERR == ret && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL != ptype) + if ((GNUNET_SYSERR == ret) && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL != + ptype) ) { *data_size = 0; tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); @@ -2538,8 +2570,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data) } } - if (NULL == tmit_msg->frags_head - && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) + if ((NULL == tmit_msg->frags_head) + && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)) { /* Reached end of current message. */ tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); } @@ -2592,59 +2624,62 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data, switch (ptype) { case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: - { - if (NULL == oper) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%p psyc_transmit_notify_mod: oper is NULL.\n", plc); - ret = GNUNET_SYSERR; + if (NULL == oper) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%p psyc_transmit_notify_mod: oper is NULL.\n", plc); + ret = GNUNET_SYSERR; + break; + } + struct GNUNET_PSYC_MessageModifier * + pmod = (struct GNUNET_PSYC_MessageModifier *) tmit_frag->next_part; + uint16_t mod_size = ntohs (pmod->header.size) - sizeof (*pmod); + + if (*data_size < mod_size) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%p psyc_transmit_notify_mod: buffer size too small for data.\n", + plc); + *data_size = 0; + return GNUNET_NO; + } + + *full_value_size = ntohl (pmod->value_size); + *oper = pmod->oper; + *data_size = mod_size; + GNUNET_memcpy (data, &pmod[1], mod_size); + ret = GNUNET_NO; break; } - struct GNUNET_PSYC_MessageModifier * - pmod = (struct GNUNET_PSYC_MessageModifier *) tmit_frag->next_part; - uint16_t mod_size = ntohs (pmod->header.size) - sizeof (*pmod); - if (*data_size < mod_size) + case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: { + if (NULL != oper) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%p psyc_transmit_notify_mod: oper is not NULL.\n", plc); + ret = GNUNET_SYSERR; + break; + } + uint16_t mod_size = ntohs (pmsg->size) - sizeof (*pmsg); + if (*data_size < mod_size) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%p psyc_transmit_notify_mod: buffer size too small for data.\n", + plc); + *data_size = 0; + return GNUNET_NO; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p psyc_transmit_notify_mod: buffer size too small for data.\n", plc); - *data_size = 0; - return GNUNET_NO; - } - - *full_value_size = ntohl (pmod->value_size); - *oper = pmod->oper; - *data_size = mod_size; - GNUNET_memcpy (data, &pmod[1], mod_size); - ret = GNUNET_NO; - break; - } + "%p psyc_transmit_notify_mod: sending %u bytes.\n", plc, + mod_size); - case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: - { - if (NULL != oper) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%p psyc_transmit_notify_mod: oper is not NULL.\n", plc); - ret = GNUNET_SYSERR; + *data_size = mod_size; + GNUNET_memcpy (data, &pmsg[1], *data_size); + ret = GNUNET_NO; break; } - uint16_t mod_size = ntohs (pmsg->size) - sizeof (*pmsg); - if (*data_size < mod_size) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p psyc_transmit_notify_mod: buffer size too small for data.\n", plc); - *data_size = 0; - return GNUNET_NO; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p psyc_transmit_notify_mod: sending %u bytes.\n", plc, mod_size); - - *data_size = mod_size; - GNUNET_memcpy (data, &pmsg[1], *data_size); - ret = GNUNET_NO; - break; - } case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA: case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: @@ -2673,8 +2708,8 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data, if (GNUNET_YES != ret) psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag); - if (NULL == tmit_msg->frags_head - && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) + if ((NULL == tmit_msg->frags_head) + && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)) { /* Reached end of current message. */ tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); } @@ -2682,6 +2717,7 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data, return ret; } + /** * Callback for data transmission from a host to PSYC. */ @@ -2777,8 +2813,8 @@ psyc_transmit_queue_next_method (struct Place *plc) } struct GNUNET_MessageHeader *pmsg = tmit_frag->next_part; - if (NULL == pmsg - || GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD != ntohs (pmsg->type)) + if ((NULL == pmsg) + || (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD != ntohs (pmsg->type))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%p psyc_transmit_queue_next_method: unexpected message part of type %u.\n", @@ -2791,7 +2827,7 @@ psyc_transmit_queue_next_method (struct Place *plc) struct GNUNET_PSYC_MessageMethod * pmeth = (struct GNUNET_PSYC_MessageMethod *) GNUNET_copy_message (pmsg); - if (psize < sizeof (*pmeth) + 1 || '\0' != *((char *) pmeth + psize - 1)) + if ((psize < sizeof (*pmeth) + 1) || ('\0' != *((char *) pmeth + psize - 1))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%p psyc_transmit_queue_next_method: invalid method name.\n", @@ -2826,9 +2862,11 @@ psyc_master_transmit_message (struct Host *hst) hst->tmit_handle = (void *) &hst->tmit_handle; struct GNUNET_PSYC_MasterTransmitHandle * - tmit_handle = GNUNET_PSYC_master_transmit (hst->master, (const char *) &pmeth[1], + tmit_handle = GNUNET_PSYC_master_transmit (hst->master, (const + char *) &pmeth[1], &host_transmit_notify_mod, - &host_transmit_notify_data, hst, + &host_transmit_notify_data, + hst, pmeth->flags); if (NULL != hst->tmit_handle) hst->tmit_handle = tmit_handle; @@ -2859,10 +2897,12 @@ psyc_slave_transmit_message (struct Guest *gst) gst->tmit_handle = (void *) &gst->tmit_handle; struct GNUNET_PSYC_SlaveTransmitHandle * - tmit_handle = GNUNET_PSYC_slave_transmit (gst->slave, (const char *) &pmeth[1], - &guest_transmit_notify_mod, - &guest_transmit_notify_data, gst, - pmeth->flags); + tmit_handle = GNUNET_PSYC_slave_transmit (gst->slave, (const + char *) &pmeth[1], + &guest_transmit_notify_mod, + &guest_transmit_notify_data, + gst, + pmeth->flags); if (NULL != gst->tmit_handle) gst->tmit_handle = tmit_handle; GNUNET_free (pmeth); @@ -2909,7 +2949,8 @@ psyc_transmit_queue_message (struct Place *plc, if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == first_ptype) { tmit_msg = GNUNET_malloc (sizeof (*tmit_msg)); - GNUNET_CONTAINER_DLL_insert_tail (plc->tmit_msgs_head, plc->tmit_msgs_tail, tmit_msg); + GNUNET_CONTAINER_DLL_insert_tail (plc->tmit_msgs_head, plc->tmit_msgs_tail, + tmit_msg); } else if (NULL == tmit_msg) { @@ -2923,7 +2964,8 @@ psyc_transmit_queue_message (struct Place *plc, tmit_frag->client = client; tmit_frag->size = data_size; - GNUNET_CONTAINER_DLL_insert_tail (tmit_msg->frags_head, tmit_msg->frags_tail, tmit_frag); + GNUNET_CONTAINER_DLL_insert_tail (tmit_msg->frags_head, tmit_msg->frags_tail, + tmit_frag); tmit_msg->client = client; return tmit_msg; } @@ -2935,9 +2977,9 @@ psyc_transmit_queue_message (struct Place *plc, // * @param plc Place to send to. // * @param client Client the message originates from. // */ -//static void -//psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) -//{ +// static void +// psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) +// { // uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; // // struct GNUNET_MessageHeader msg; @@ -2948,7 +2990,7 @@ psyc_transmit_queue_message (struct Place *plc, // psyc_transmit_message (plc); // // /* FIXME: cleanup */ -//} +// } static int @@ -2981,7 +3023,8 @@ handle_client_psyc_message (void *cls, return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Received message of type %d from client.\n", plc, ntohs (msg->type)); + "%p Received message of type %d from client.\n", plc, ntohs ( + msg->type)); GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); if (GNUNET_YES != plc->is_ready) @@ -2995,8 +3038,8 @@ handle_client_psyc_message (void *cls, uint16_t size = ntohs (msg->size); uint16_t psize = size - sizeof (*msg); - if (psize < sizeof (struct GNUNET_MessageHeader) - || GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < psize) + if ((psize < sizeof (struct GNUNET_MessageHeader)) + || (GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < psize)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%p Received message with invalid payload size (%u) from client.\n", @@ -3051,7 +3094,8 @@ handle_client_psyc_message (void *cls, * A historic message arrived from PSYC. */ static void -psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) +psyc_recv_history_message (void *cls, const struct + GNUNET_PSYC_MessageHeader *msg) { struct OperationClosure *opcls = cls; struct Client *c = opcls->client; @@ -3103,7 +3147,8 @@ psyc_recv_history_result (void *cls, int64_t result, static int check_client_history_replay (void *cls, - const struct GNUNET_PSYC_HistoryRequestMessage *req) + const struct + GNUNET_PSYC_HistoryRequestMessage *req) { return GNUNET_OK; } @@ -3114,7 +3159,8 @@ check_client_history_replay (void *cls, */ static void handle_client_history_replay (void *cls, - const struct GNUNET_PSYC_HistoryRequestMessage *req) + const struct + GNUNET_PSYC_HistoryRequestMessage *req) { struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; @@ -3129,8 +3175,8 @@ handle_client_history_replay (void *cls, uint16_t size = ntohs (req->header.size); const char *method_prefix = (const char *) &req[1]; - if (size < sizeof (*req) + 1 - || '\0' != method_prefix[size - sizeof (*req) - 1]) + if ((size < sizeof (*req) + 1) + || ('\0' != method_prefix[size - sizeof (*req) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%p History replay #%" PRIu64 ": " @@ -3155,7 +3201,8 @@ handle_client_history_replay (void *cls, psyc_recv_history_result, opcls); else GNUNET_PSYC_channel_history_replay_latest (plc->channel, - GNUNET_ntohll (req->message_limit), + GNUNET_ntohll ( + req->message_limit), method_prefix, opcls->flags, psyc_recv_history_message, NULL, psyc_recv_history_result, opcls); @@ -3250,8 +3297,8 @@ handle_client_state_get (void *cls, "%p State get #%" PRIu64 ": %s\n", plc, GNUNET_ntohll (req->op_id), name); - if (size < sizeof (*req) + 1 - || '\0' != name[size - sizeof (*req) - 1]) + if ((size < sizeof (*req) + 1) + || ('\0' != name[size - sizeof (*req) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%p State get #%" PRIu64 ": " @@ -3269,19 +3316,19 @@ handle_client_state_get (void *cls, switch (ntohs (req->header.type)) { case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET: - GNUNET_PSYC_channel_state_get (plc->channel, name, - psyc_recv_state_var, - psyc_recv_state_result, opcls); - break; + GNUNET_PSYC_channel_state_get (plc->channel, name, + psyc_recv_state_var, + psyc_recv_state_result, opcls); + break; case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX: - GNUNET_PSYC_channel_state_get_prefix (plc->channel, name, - psyc_recv_state_var, - psyc_recv_state_result, opcls); - break; + GNUNET_PSYC_channel_state_get_prefix (plc->channel, name, + psyc_recv_state_var, + psyc_recv_state_result, opcls); + break; default: - GNUNET_assert (0); + GNUNET_assert (0); } GNUNET_SERVICE_client_continue (client); @@ -3335,7 +3382,7 @@ handle_client_zone_add_place (void *cls, relays = (const struct GNUNET_PeerIdentity *) p; uint16_t relay_size = ntohl (preq->relay_count) * sizeof (*relays); - if (0 == offset || remaining != relay_size) + if ((0 == offset) || (remaining != relay_size)) { GNUNET_break (0); client_send_result (client, preq->op_id, GNUNET_SYSERR, NULL, 0); @@ -3359,7 +3406,8 @@ handle_client_zone_add_place (void *cls, rd.data_size = sizeof (*rec) + relay_size; struct GNUNET_HashCode ego_pub_hash; - GNUNET_CRYPTO_hash (&preq->ego_pub_key, sizeof (preq->ego_pub_key), &ego_pub_hash); + GNUNET_CRYPTO_hash (&preq->ego_pub_key, sizeof (preq->ego_pub_key), + &ego_pub_hash); struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); if (NULL == ego) { @@ -3401,7 +3449,7 @@ handle_client_zone_add_nym (void *cls, const char *name = NULL; uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &nreq[1], name_size, 1, &name); - if (0 == offset || offset != name_size) + if ((0 == offset) || (offset != name_size)) { GNUNET_break (0); client_send_result (client, nreq->op_id, GNUNET_SYSERR, NULL, 0); @@ -3417,7 +3465,8 @@ handle_client_zone_add_nym (void *cls, rd.data_size = sizeof (nreq->nym_pub_key); struct GNUNET_HashCode ego_pub_hash; - GNUNET_CRYPTO_hash (&nreq->ego_pub_key, sizeof (nreq->ego_pub_key), &ego_pub_hash); + GNUNET_CRYPTO_hash (&nreq->ego_pub_key, sizeof (nreq->ego_pub_key), + &ego_pub_hash); struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); if (NULL == ego) { @@ -3444,7 +3493,7 @@ path_basename (const char *path) if (NULL != basename) basename++; - if (NULL == basename || '\0' == *basename) + if ((NULL == basename) || ('\0' == *basename)) return NULL; return basename; @@ -3479,9 +3528,9 @@ file_place_load (void *cls, const char *place_filename) place_pub_str); uint64_t file_size = 0; - if (GNUNET_OK != - GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES, GNUNET_YES) - || file_size < sizeof (struct PlaceEnterRequest)) + if ((GNUNET_OK != + GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES, GNUNET_YES)) + || (file_size < sizeof (struct PlaceEnterRequest))) { GNUNET_free (filename); return GNUNET_OK; @@ -3490,7 +3539,7 @@ file_place_load (void *cls, const char *place_filename) struct PlaceEnterRequest *ereq = GNUNET_malloc (file_size); ssize_t read_size = GNUNET_DISK_fn_read (filename, ereq, file_size); GNUNET_free (filename); - if (read_size < 0 || read_size < sizeof (*ereq)) + if ((read_size < 0) || (read_size < sizeof (*ereq))) { GNUNET_free (ereq); return GNUNET_OK; @@ -3558,6 +3607,7 @@ scan_app_ego_dir (void *cls, const char *dir_ego) return GNUNET_OK; } + /** * Read @e ego_pub_str entries in @a dir_app * @@ -3599,7 +3649,7 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, GNUNET_CRYPTO_hash (&ego_pub_key, sizeof (ego_pub_key), &ego_pub_hash); struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); - if (NULL == ego && NULL == name) + if ((NULL == ego) && (NULL == name)) { // an ego that is none of our business has been deleted return; @@ -3657,9 +3707,9 @@ run (void *cls, egos = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); - places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); - apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); - //places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); + places = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); + apps_places = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); + // places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); gns = GNUNET_GNS_connect (cfg); @@ -3690,71 +3740,71 @@ run (void *cls, * Define "main" method using service macro. */ GNUNET_SERVICE_MAIN -("social", - GNUNET_SERVICE_OPTION_NONE, - run, - client_notify_connect, - client_notify_disconnect, - NULL, - GNUNET_MQ_hd_var_size (client_host_enter, - GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, - struct HostEnterRequest, - NULL), - GNUNET_MQ_hd_var_size (client_guest_enter, - GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, - struct GuestEnterRequest, - NULL), - GNUNET_MQ_hd_var_size (client_guest_enter_by_name, - GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, - struct GuestEnterByNameRequest, - NULL), - GNUNET_MQ_hd_var_size (client_join_decision, - GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, - struct GNUNET_PSYC_JoinDecisionMessage, - NULL), - GNUNET_MQ_hd_var_size (client_psyc_message, - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, - struct GNUNET_MessageHeader, - NULL), - GNUNET_MQ_hd_var_size (client_history_replay, - GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, - struct GNUNET_PSYC_HistoryRequestMessage, - NULL), - GNUNET_MQ_hd_var_size (client_state_get, - GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, - struct GNUNET_PSYC_StateRequestMessage, - NULL), - GNUNET_MQ_hd_var_size (client_state_get_prefix, - GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, - struct GNUNET_PSYC_StateRequestMessage, - NULL), - GNUNET_MQ_hd_var_size (client_zone_add_place, - GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, - struct ZoneAddPlaceRequest, - NULL), - GNUNET_MQ_hd_var_size (client_zone_add_nym, - GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, - struct ZoneAddNymRequest, - NULL), - GNUNET_MQ_hd_var_size (client_app_connect, - GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, - struct AppConnectRequest, - NULL), - GNUNET_MQ_hd_fixed_size (client_app_detach, - GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, - struct AppDetachRequest, - NULL), - GNUNET_MQ_hd_fixed_size (client_place_leave, - GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, - struct GNUNET_MessageHeader, - NULL), - GNUNET_MQ_hd_var_size (client_msg_proc_set, - GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, - struct MsgProcRequest, - NULL), - GNUNET_MQ_hd_fixed_size (client_msg_proc_clear, - GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, - struct GNUNET_MessageHeader, - NULL)); + ("social", + GNUNET_SERVICE_OPTION_NONE, + run, + client_notify_connect, + client_notify_disconnect, + NULL, + GNUNET_MQ_hd_var_size (client_host_enter, + GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, + struct HostEnterRequest, + NULL), + GNUNET_MQ_hd_var_size (client_guest_enter, + GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, + struct GuestEnterRequest, + NULL), + GNUNET_MQ_hd_var_size (client_guest_enter_by_name, + GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, + struct GuestEnterByNameRequest, + NULL), + GNUNET_MQ_hd_var_size (client_join_decision, + GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, + struct GNUNET_PSYC_JoinDecisionMessage, + NULL), + GNUNET_MQ_hd_var_size (client_psyc_message, + GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_hd_var_size (client_history_replay, + GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, + struct GNUNET_PSYC_HistoryRequestMessage, + NULL), + GNUNET_MQ_hd_var_size (client_state_get, + GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, + struct GNUNET_PSYC_StateRequestMessage, + NULL), + GNUNET_MQ_hd_var_size (client_state_get_prefix, + GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, + struct GNUNET_PSYC_StateRequestMessage, + NULL), + GNUNET_MQ_hd_var_size (client_zone_add_place, + GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, + struct ZoneAddPlaceRequest, + NULL), + GNUNET_MQ_hd_var_size (client_zone_add_nym, + GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, + struct ZoneAddNymRequest, + NULL), + GNUNET_MQ_hd_var_size (client_app_connect, + GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, + struct AppConnectRequest, + NULL), + GNUNET_MQ_hd_fixed_size (client_app_detach, + GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, + struct AppDetachRequest, + NULL), + GNUNET_MQ_hd_fixed_size (client_place_leave, + GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_hd_var_size (client_msg_proc_set, + GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, + struct MsgProcRequest, + NULL), + GNUNET_MQ_hd_fixed_size (client_msg_proc_clear, + GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, + struct GNUNET_MessageHeader, + NULL)); /* end of gnunet-service-social.c */ -- cgit v1.2.3