From c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Oct 2019 15:09:28 +0200 Subject: global reindent, now with uncrustify hook enabled --- src/regex/gnunet-service-regex.c | 297 ++++++++++++++++++++------------------- 1 file changed, 150 insertions(+), 147 deletions(-) (limited to 'src/regex/gnunet-service-regex.c') diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index 90ea91780..19250d427 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c @@ -33,7 +33,8 @@ /** * Information about one of our clients. */ -struct ClientEntry { +struct ClientEntry +{ /** * Queue for transmissions to @e client. */ @@ -88,14 +89,14 @@ static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; * @param cls unused */ static void -cleanup_task(void *cls) +cleanup_task (void *cls) { - GNUNET_DHT_disconnect(dht); + GNUNET_DHT_disconnect (dht); dht = NULL; - GNUNET_STATISTICS_destroy(stats, - GNUNET_NO); + GNUNET_STATISTICS_destroy (stats, + GNUNET_NO); stats = NULL; - GNUNET_free(my_private_key); + GNUNET_free (my_private_key); my_private_key = NULL; } @@ -107,14 +108,14 @@ cleanup_task(void *cls) * announcement */ static void -reannounce(void *cls) +reannounce (void *cls) { struct ClientEntry *ce = cls; - REGEX_INTERNAL_reannounce(ce->ah); - ce->refresh_task = GNUNET_SCHEDULER_add_delayed(ce->frequency, - &reannounce, - ce); + REGEX_INTERNAL_reannounce (ce->ah); + ce->refresh_task = GNUNET_SCHEDULER_add_delayed (ce->frequency, + &reannounce, + ce); } @@ -126,18 +127,18 @@ reannounce(void *cls) * @return #GNUNET_OK if @am is well-formed */ static int -check_announce(void *cls, - const struct AnnounceMessage *am) +check_announce (void *cls, + const struct AnnounceMessage *am) { struct ClientEntry *ce = cls; - GNUNET_MQ_check_zero_termination(am); + GNUNET_MQ_check_zero_termination (am); if (NULL != ce->ah) - { - /* only one announcement per client allowed */ - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + /* only one announcement per client allowed */ + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -149,36 +150,36 @@ check_announce(void *cls, * @param am the actual message */ static void -handle_announce(void *cls, - const struct AnnounceMessage *am) +handle_announce (void *cls, + const struct AnnounceMessage *am) { struct ClientEntry *ce = cls; const char *regex; - regex = (const char *)&am[1]; - ce->frequency = GNUNET_TIME_relative_ntoh(am->refresh_delay); - ce->refresh_task = GNUNET_SCHEDULER_add_delayed(ce->frequency, - &reannounce, - ce); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Starting to announce regex `%s' every %s\n", - regex, - GNUNET_STRINGS_relative_time_to_string(ce->frequency, - GNUNET_NO)); - ce->ah = REGEX_INTERNAL_announce(dht, - my_private_key, - regex, - ntohs(am->compression), - stats); + regex = (const char *) &am[1]; + ce->frequency = GNUNET_TIME_relative_ntoh (am->refresh_delay); + ce->refresh_task = GNUNET_SCHEDULER_add_delayed (ce->frequency, + &reannounce, + ce); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Starting to announce regex `%s' every %s\n", + regex, + GNUNET_STRINGS_relative_time_to_string (ce->frequency, + GNUNET_NO)); + ce->ah = REGEX_INTERNAL_announce (dht, + my_private_key, + regex, + ntohs (am->compression), + stats); if (NULL == ce->ah) - { - GNUNET_break(0); - GNUNET_SCHEDULER_cancel(ce->refresh_task); - ce->refresh_task = NULL; - GNUNET_SERVICE_client_drop(ce->client); - return; - } - GNUNET_SERVICE_client_continue(ce->client); + { + GNUNET_break (0); + GNUNET_SCHEDULER_cancel (ce->refresh_task); + ce->refresh_task = NULL; + GNUNET_SERVICE_client_drop (ce->client); + return; + } + GNUNET_SERVICE_client_continue (ce->client); } @@ -193,12 +194,12 @@ handle_announce(void *cls, * @param put_path_length Length of the @a put_path. */ static void -handle_search_result(void *cls, - const struct GNUNET_PeerIdentity *id, - const struct GNUNET_PeerIdentity *get_path, - unsigned int get_path_length, - const struct GNUNET_PeerIdentity *put_path, - unsigned int put_path_length) +handle_search_result (void *cls, + const struct GNUNET_PeerIdentity *id, + const struct GNUNET_PeerIdentity *get_path, + unsigned int get_path_length, + const struct GNUNET_PeerIdentity *put_path, + unsigned int put_path_length) { struct ClientEntry *ce = cls; struct GNUNET_MQ_Envelope *env; @@ -208,28 +209,30 @@ handle_search_result(void *cls, if ((get_path_length >= 65536) || (put_path_length >= 65536) || - ((get_path_length + put_path_length) * sizeof(struct GNUNET_PeerIdentity)) - + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) - { - GNUNET_break(0); - return; - } - size = (get_path_length + put_path_length) * sizeof(struct GNUNET_PeerIdentity); - env = GNUNET_MQ_msg_extra(result, - size, - GNUNET_MESSAGE_TYPE_REGEX_RESULT); - result->get_path_length = htons((uint16_t)get_path_length); - result->put_path_length = htons((uint16_t)put_path_length); + ( ((get_path_length + put_path_length) * sizeof(struct + GNUNET_PeerIdentity)) + + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ) + { + GNUNET_break (0); + return; + } + size = (get_path_length + put_path_length) * sizeof(struct + GNUNET_PeerIdentity); + env = GNUNET_MQ_msg_extra (result, + size, + GNUNET_MESSAGE_TYPE_REGEX_RESULT); + result->get_path_length = htons ((uint16_t) get_path_length); + result->put_path_length = htons ((uint16_t) put_path_length); result->id = *id; gp = &result->id; - GNUNET_memcpy(&gp[1], - get_path, - get_path_length * sizeof(struct GNUNET_PeerIdentity)); - GNUNET_memcpy(&gp[1 + get_path_length], - put_path, - put_path_length * sizeof(struct GNUNET_PeerIdentity)); - GNUNET_MQ_send(ce->mq, - env); + GNUNET_memcpy (&gp[1], + get_path, + get_path_length * sizeof(struct GNUNET_PeerIdentity)); + GNUNET_memcpy (&gp[1 + get_path_length], + put_path, + put_path_length * sizeof(struct GNUNET_PeerIdentity)); + GNUNET_MQ_send (ce->mq, + env); } @@ -240,26 +243,26 @@ handle_search_result(void *cls, * @param message the actual message */ static int -check_search(void *cls, - const struct RegexSearchMessage *sm) +check_search (void *cls, + const struct RegexSearchMessage *sm) { struct ClientEntry *ce = cls; const char *string; uint16_t size; - size = ntohs(sm->header.size) - sizeof(*sm); - string = (const char *)&sm[1]; + size = ntohs (sm->header.size) - sizeof(*sm); + string = (const char *) &sm[1]; if ('\0' != string[size - 1]) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } if (NULL != ce->sh) - { - /* only one search allowed per client */ - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + /* only one search allowed per client */ + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -271,28 +274,28 @@ check_search(void *cls, * @param message the actual message */ static void -handle_search(void *cls, - const struct RegexSearchMessage *sm) +handle_search (void *cls, + const struct RegexSearchMessage *sm) { struct ClientEntry *ce = cls; const char *string; - string = (const char *)&sm[1]; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Starting to search for `%s'\n", - string); - ce->sh = REGEX_INTERNAL_search(dht, - string, - &handle_search_result, - ce, - stats); + string = (const char *) &sm[1]; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Starting to search for `%s'\n", + string); + ce->sh = REGEX_INTERNAL_search (dht, + string, + &handle_search_result, + ce, + stats); if (NULL == ce->sh) - { - GNUNET_break(0); - GNUNET_SERVICE_client_drop(ce->client); - return; - } - GNUNET_SERVICE_client_continue(ce->client); + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (ce->client); + return; + } + GNUNET_SERVICE_client_continue (ce->client); } @@ -304,27 +307,27 @@ handle_search(void *cls, * @param service the initialized service */ static void -run(void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SERVICE_Handle *service) +run (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_SERVICE_Handle *service) { - my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration(cfg); + my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); if (NULL == my_private_key) - { - GNUNET_SCHEDULER_shutdown(); - return; - } - dht = GNUNET_DHT_connect(cfg, 1024); + { + GNUNET_SCHEDULER_shutdown (); + return; + } + dht = GNUNET_DHT_connect (cfg, 1024); if (NULL == dht) - { - GNUNET_free(my_private_key); - my_private_key = NULL; - GNUNET_SCHEDULER_shutdown(); - return; - } - GNUNET_SCHEDULER_add_shutdown(&cleanup_task, - NULL); - stats = GNUNET_STATISTICS_create("regex", cfg); + { + GNUNET_free (my_private_key); + my_private_key = NULL; + GNUNET_SCHEDULER_shutdown (); + return; + } + GNUNET_SCHEDULER_add_shutdown (&cleanup_task, + NULL); + stats = GNUNET_STATISTICS_create ("regex", cfg); } @@ -337,13 +340,13 @@ run(void *cls, * @return @a c */ static void * -client_connect_cb(void *cls, - struct GNUNET_SERVICE_Client *c, - struct GNUNET_MQ_Handle *mq) +client_connect_cb (void *cls, + struct GNUNET_SERVICE_Client *c, + struct GNUNET_MQ_Handle *mq) { struct ClientEntry *ce; - ce = GNUNET_new(struct ClientEntry); + ce = GNUNET_new (struct ClientEntry); ce->client = c; ce->mq = mq; return ce; @@ -358,28 +361,28 @@ client_connect_cb(void *cls, * @param internal_cls should be equal to @a c */ static void -client_disconnect_cb(void *cls, - struct GNUNET_SERVICE_Client *c, - void *internal_cls) +client_disconnect_cb (void *cls, + struct GNUNET_SERVICE_Client *c, + void *internal_cls) { struct ClientEntry *ce = internal_cls; if (NULL != ce->refresh_task) - { - GNUNET_SCHEDULER_cancel(ce->refresh_task); - ce->refresh_task = NULL; - } + { + GNUNET_SCHEDULER_cancel (ce->refresh_task); + ce->refresh_task = NULL; + } if (NULL != ce->ah) - { - REGEX_INTERNAL_announce_cancel(ce->ah); - ce->ah = NULL; - } + { + REGEX_INTERNAL_announce_cancel (ce->ah); + ce->ah = NULL; + } if (NULL != ce->sh) - { - REGEX_INTERNAL_search_cancel(ce->sh); - ce->sh = NULL; - } - GNUNET_free(ce); + { + REGEX_INTERNAL_search_cancel (ce->sh); + ce->sh = NULL; + } + GNUNET_free (ce); } @@ -393,15 +396,15 @@ GNUNET_SERVICE_MAIN &client_connect_cb, &client_disconnect_cb, NULL, - GNUNET_MQ_hd_var_size(announce, - GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, - struct AnnounceMessage, - NULL), - GNUNET_MQ_hd_var_size(search, - GNUNET_MESSAGE_TYPE_REGEX_SEARCH, - struct RegexSearchMessage, - NULL), - GNUNET_MQ_handler_end()); + GNUNET_MQ_hd_var_size (announce, + GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, + struct AnnounceMessage, + NULL), + GNUNET_MQ_hd_var_size (search, + GNUNET_MESSAGE_TYPE_REGEX_SEARCH, + struct RegexSearchMessage, + NULL), + GNUNET_MQ_handler_end ()); /* end of gnunet-service-regex.c */ -- cgit v1.2.3