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/testbed-logger/gnunet-service-testbed-logger.c | 158 +++++++------- src/testbed-logger/test_testbed_logger_api.c | 228 ++++++++++----------- src/testbed-logger/testbed_logger_api.c | 174 ++++++++-------- 3 files changed, 281 insertions(+), 279 deletions(-) (limited to 'src/testbed-logger') diff --git a/src/testbed-logger/gnunet-service-testbed-logger.c b/src/testbed-logger/gnunet-service-testbed-logger.c index e2f71070b..4e0a3cd34 100644 --- a/src/testbed-logger/gnunet-service-testbed-logger.c +++ b/src/testbed-logger/gnunet-service-testbed-logger.c @@ -31,13 +31,13 @@ * Generic logging shorthand */ #define LOG(type, ...) \ - GNUNET_log(type, __VA_ARGS__) + GNUNET_log (type, __VA_ARGS__) /** * Debug logging shorthand */ #define LOG_DEBUG(...) \ - LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) + LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) /** * Handle for buffered writing. @@ -63,8 +63,8 @@ static int in_shutdown; * @return #GNUNET_OK (they are all always OK) */ static int -check_log_msg(void *cls, - const struct GNUNET_MessageHeader *msg) +check_log_msg (void *cls, + const struct GNUNET_MessageHeader *msg) { return GNUNET_OK; } @@ -77,17 +77,17 @@ check_log_msg(void *cls, * @param msg the actual message */ static void -handle_log_msg(void *cls, - const struct GNUNET_MessageHeader *msg) +handle_log_msg (void *cls, + const struct GNUNET_MessageHeader *msg) { struct GNUNET_SERVICE_Client *client = cls; uint16_t ms; - ms = ntohs(msg->size) - sizeof(struct GNUNET_MessageHeader); - GNUNET_BIO_write(bio, - &msg[1], - ms); - GNUNET_SERVICE_client_continue(client); + ms = ntohs (msg->size) - sizeof(struct GNUNET_MessageHeader); + GNUNET_BIO_write (bio, + &msg[1], + ms); + GNUNET_SERVICE_client_continue (client); } @@ -97,18 +97,18 @@ handle_log_msg(void *cls, * @param cls NULL */ static void -shutdown_task(void *cls) +shutdown_task (void *cls) { in_shutdown = GNUNET_YES; if (0 != nconn) - { - /* Delay shutdown if there are active connections */ - GNUNET_SCHEDULER_add_shutdown(&shutdown_task, - NULL); - return; - } - GNUNET_break(GNUNET_OK == - GNUNET_BIO_write_close(bio)); + { + /* Delay shutdown if there are active connections */ + GNUNET_SCHEDULER_add_shutdown (&shutdown_task, + NULL); + return; + } + GNUNET_break (GNUNET_OK == + GNUNET_BIO_write_close (bio)); } @@ -121,12 +121,12 @@ shutdown_task(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) { /* FIXME: is this really what we want here? */ - GNUNET_SERVICE_client_persist(c); + GNUNET_SERVICE_client_persist (c); nconn++; return c; } @@ -140,14 +140,14 @@ 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) { nconn--; if (GNUNET_YES == in_shutdown) - GNUNET_SCHEDULER_shutdown(); - GNUNET_assert(c == internal_cls); + GNUNET_SCHEDULER_shutdown (); + GNUNET_assert (c == internal_cls); } @@ -159,9 +159,9 @@ client_disconnect_cb(void *cls, * @param service the initialized service */ static void -logger_run(void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SERVICE_Handle *service) +logger_run (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_SERVICE_Handle *service) { char *dir; char *fn; @@ -170,48 +170,48 @@ logger_run(void *cls, pid_t pid; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename(cfg, - "TESTBED-LOGGER", - "DIR", - &dir)) - { - GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, - "TESTBED-LOGGER", - "DIR"); - GNUNET_SCHEDULER_shutdown(); - return; - } - pid = getpid(); - hname_len = GNUNET_OS_get_hostname_max_length(); - hname = GNUNET_malloc(hname_len); - if (0 != gethostname(hname, - hname_len)) - { - LOG(GNUNET_ERROR_TYPE_ERROR, - "Cannot get hostname. Exiting\n"); - GNUNET_free(hname); - GNUNET_free(dir); - GNUNET_SCHEDULER_shutdown(); - return; - } - GNUNET_asprintf(&fn, - "%s/%.*s_%jd.dat", - dir, - hname_len, - hname, - (intmax_t)pid); - GNUNET_free(hname); - GNUNET_free(dir); - if (NULL == (bio = GNUNET_BIO_write_open(fn))) - { - GNUNET_free(fn); - GNUNET_SCHEDULER_shutdown(); - return; - } - GNUNET_free(fn); - GNUNET_SCHEDULER_add_shutdown(&shutdown_task, - NULL); - LOG_DEBUG("TESTBED-LOGGER startup complete\n"); + GNUNET_CONFIGURATION_get_value_filename (cfg, + "TESTBED-LOGGER", + "DIR", + &dir)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "TESTBED-LOGGER", + "DIR"); + GNUNET_SCHEDULER_shutdown (); + return; + } + pid = getpid (); + hname_len = GNUNET_OS_get_hostname_max_length (); + hname = GNUNET_malloc (hname_len); + if (0 != gethostname (hname, + hname_len)) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + "Cannot get hostname. Exiting\n"); + GNUNET_free (hname); + GNUNET_free (dir); + GNUNET_SCHEDULER_shutdown (); + return; + } + GNUNET_asprintf (&fn, + "%s/%.*s_%jd.dat", + dir, + hname_len, + hname, + (intmax_t) pid); + GNUNET_free (hname); + GNUNET_free (dir); + if (NULL == (bio = GNUNET_BIO_write_open (fn))) + { + GNUNET_free (fn); + GNUNET_SCHEDULER_shutdown (); + return; + } + GNUNET_free (fn); + GNUNET_SCHEDULER_add_shutdown (&shutdown_task, + NULL); + LOG_DEBUG ("TESTBED-LOGGER startup complete\n"); } @@ -225,11 +225,11 @@ GNUNET_SERVICE_MAIN &client_connect_cb, &client_disconnect_cb, NULL, - GNUNET_MQ_hd_var_size(log_msg, - GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, - struct GNUNET_MessageHeader, - NULL), - GNUNET_MQ_handler_end()); + GNUNET_MQ_hd_var_size (log_msg, + GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_handler_end ()); /* end of gnunet-service-testbed-logger.c */ diff --git a/src/testbed-logger/test_testbed_logger_api.c b/src/testbed-logger/test_testbed_logger_api.c index 3d228cdb1..7496184c0 100644 --- a/src/testbed-logger/test_testbed_logger_api.c +++ b/src/testbed-logger/test_testbed_logger_api.c @@ -31,13 +31,13 @@ * Generic logging shortcut */ #define LOG(kind, ...) \ - GNUNET_log(kind, __VA_ARGS__) + GNUNET_log (kind, __VA_ARGS__) /** * Relative time seconds shorthand */ #define TIME_REL_SECS(sec) \ - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, sec) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) /** * Opaque handle for the logging service @@ -57,24 +57,24 @@ static struct GNUNET_SCHEDULER_Task *write_task; static int result; #define CANCEL_TASK(task) do { \ - if (NULL != task) \ - { \ - GNUNET_SCHEDULER_cancel(task); \ - task = NULL; \ - } \ - } while (0) + if (NULL != task) \ + { \ + GNUNET_SCHEDULER_cancel (task); \ + task = NULL; \ + } \ +} while (0) /** * shortcut to exit during failure */ #define FAIL_TEST(cond, ret) do { \ - if (!(cond)) { \ - GNUNET_break(0); \ - CANCEL_TASK(abort_task); \ - abort_task = GNUNET_SCHEDULER_add_now(&do_abort, NULL); \ - ret; \ - } \ - } while (0) + if (! (cond)) { \ + GNUNET_break (0); \ + CANCEL_TASK (abort_task); \ + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); \ + ret; \ + } \ +} while (0) /** @@ -84,24 +84,24 @@ static int result; * @param tc the task context */ static void -shutdown_now() +shutdown_now () { - CANCEL_TASK(abort_task); - CANCEL_TASK(write_task); - GNUNET_free_non_null(search_dir); + CANCEL_TASK (abort_task); + CANCEL_TASK (write_task); + GNUNET_free_non_null (search_dir); if (NULL != h) - GNUNET_TESTBED_LOGGER_disconnect(h); - GNUNET_SCHEDULER_shutdown(); + GNUNET_TESTBED_LOGGER_disconnect (h); + GNUNET_SCHEDULER_shutdown (); } static void -do_abort(void *cls) +do_abort (void *cls) { - LOG(GNUNET_ERROR_TYPE_WARNING, - "Aborting\n"); + LOG (GNUNET_ERROR_TYPE_WARNING, + "Aborting\n"); abort_task = NULL; - shutdown_now(); + shutdown_now (); } @@ -118,40 +118,40 @@ do_abort(void *cls) * #GNUNET_SYSERR to abort iteration with error! */ static int -iterator_cb(void *cls, - const char *filename) +iterator_cb (void *cls, + const char *filename) { const char *fn; size_t len; uint64_t fs; - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Iterator sees file %s\n", - filename); - len = strlen(filename); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Iterator sees file %s\n", + filename); + len = strlen (filename); fn = filename + len; - if (0 != strcasecmp(".dat", fn - 4)) + if (0 != strcasecmp (".dat", fn - 4)) return GNUNET_OK; if (GNUNET_OK != - GNUNET_DISK_file_size(filename, - &fs, - GNUNET_NO, - GNUNET_YES)) - { - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Failed to obtain file size for file %s\n", - filename); - return GNUNET_SYSERR; - } + GNUNET_DISK_file_size (filename, + &fs, + GNUNET_NO, + GNUNET_YES)) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Failed to obtain file size for file %s\n", + filename); + return GNUNET_SYSERR; + } if ((BSIZE * 2) != fs) - { - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Unexpected file size for file %s\n", - filename); - /* The file size should be equal to what we - have written */ - return GNUNET_SYSERR; - } + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Unexpected file size for file %s\n", + filename); + /* The file size should be equal to what we + have written */ + return GNUNET_SYSERR; + } result = GNUNET_OK; return GNUNET_OK; } @@ -165,52 +165,52 @@ iterator_cb(void *cls, * @param size the amount of data sent */ static void -flush_comp(void *cls, - size_t size) +flush_comp (void *cls, + size_t size) { - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Flush running\n"); - FAIL_TEST(&write_task == cls, - return ); - FAIL_TEST((BSIZE * 2) == size, - return ); - FAIL_TEST(GNUNET_OK == - GNUNET_TESTING_peer_stop(peer), - return ); - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Peer stopped, scanning %s\n", - search_dir); - FAIL_TEST(GNUNET_SYSERR != - GNUNET_DISK_directory_scan(search_dir, - &iterator_cb, - NULL), - return ); - shutdown_now(); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Flush running\n"); + FAIL_TEST (&write_task == cls, + return ); + FAIL_TEST ((BSIZE * 2) == size, + return ); + FAIL_TEST (GNUNET_OK == + GNUNET_TESTING_peer_stop (peer), + return ); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Peer stopped, scanning %s\n", + search_dir); + FAIL_TEST (GNUNET_SYSERR != + GNUNET_DISK_directory_scan (search_dir, + &iterator_cb, + NULL), + return ); + shutdown_now (); } static void -do_write(void *cls) +do_write (void *cls) { static int i; char buf[BSIZE]; write_task = NULL; - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Write task running\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Write task running\n"); if (0 == i) - write_task = GNUNET_SCHEDULER_add_delayed(TIME_REL_SECS(1), - &do_write, - NULL); - (void)memset(buf, i, BSIZE); - GNUNET_TESTBED_LOGGER_write(h, - buf, - BSIZE); + write_task = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (1), + &do_write, + NULL); + (void) memset (buf, i, BSIZE); + GNUNET_TESTBED_LOGGER_write (h, + buf, + BSIZE); if (0 == i++) return; - GNUNET_TESTBED_LOGGER_flush(h, - &flush_comp, - &write_task); + GNUNET_TESTBED_LOGGER_flush (h, + &flush_comp, + &write_task); } @@ -223,26 +223,26 @@ do_write(void *cls) * @param peer identity of the peer that was created */ static void -test_main(void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_TESTING_Peer *p) +test_main (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_TESTING_Peer *p) { - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Connecting to logger\n"); - FAIL_TEST(NULL != (h = GNUNET_TESTBED_LOGGER_connect(cfg)), - return ); - FAIL_TEST(GNUNET_OK == - GNUNET_CONFIGURATION_get_value_filename(cfg, - "testbed-logger", - "dir", - &search_dir), - return ); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Connecting to logger\n"); + FAIL_TEST (NULL != (h = GNUNET_TESTBED_LOGGER_connect (cfg)), + return ); + FAIL_TEST (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_filename (cfg, + "testbed-logger", + "dir", + &search_dir), + return ); peer = p; - write_task = GNUNET_SCHEDULER_add_now(&do_write, - NULL); - abort_task = GNUNET_SCHEDULER_add_delayed(TIME_REL_SECS(10), - &do_abort, - NULL); + write_task = GNUNET_SCHEDULER_add_now (&do_write, + NULL); + abort_task = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (10), + &do_abort, + NULL); } @@ -250,23 +250,23 @@ test_main(void *cls, * Main function */ int -main(int argc, char **argv) +main (int argc, char **argv) { int ret; result = GNUNET_SYSERR; - GNUNET_log_setup("test-testbed-logger-api", - "WARNING", - NULL); - GNUNET_break(GNUNET_OK == - GNUNET_DISK_directory_remove("/tmp/test-testbed")); - ret = GNUNET_TESTING_service_run("test-testbed-logger", - "testbed-logger", - "test_testbed_logger_api.conf", - &test_main, - NULL); - GNUNET_break(GNUNET_OK == - GNUNET_DISK_directory_remove("/tmp/test-testbed")); + GNUNET_log_setup ("test-testbed-logger-api", + "WARNING", + NULL); + GNUNET_break (GNUNET_OK == + GNUNET_DISK_directory_remove ("/tmp/test-testbed")); + ret = GNUNET_TESTING_service_run ("test-testbed-logger", + "testbed-logger", + "test_testbed_logger_api.conf", + &test_main, + NULL); + GNUNET_break (GNUNET_OK == + GNUNET_DISK_directory_remove ("/tmp/test-testbed")); if (0 != ret) return 1; if (GNUNET_OK != result) diff --git a/src/testbed-logger/testbed_logger_api.c b/src/testbed-logger/testbed_logger_api.c index 6e383e3c7..58f3d36ce 100644 --- a/src/testbed-logger/testbed_logger_api.c +++ b/src/testbed-logger/testbed_logger_api.c @@ -33,18 +33,20 @@ * Generic logging shorthand */ #define LOG(kind, ...) \ - GNUNET_log_from(kind, "testbed-logger-api", __VA_ARGS__) + GNUNET_log_from (kind, "testbed-logger-api", __VA_ARGS__) /** * The size of the buffer we fill before sending out the message */ -#define BUFFER_SIZE (GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GNUNET_MessageHeader)) +#define BUFFER_SIZE (GNUNET_MAX_MESSAGE_SIZE - sizeof(struct \ + GNUNET_MessageHeader)) /** * Connection handle for the logger service */ -struct GNUNET_TESTBED_LOGGER_Handle { +struct GNUNET_TESTBED_LOGGER_Handle +{ /** * Client connection */ @@ -98,7 +100,7 @@ struct GNUNET_TESTBED_LOGGER_Handle { * @param cls the logger handle */ static void -call_flush_completion(void *cls) +call_flush_completion (void *cls) { struct GNUNET_TESTBED_LOGGER_Handle *h = cls; GNUNET_TESTBED_LOGGER_FlushCompletion cb; @@ -113,7 +115,7 @@ call_flush_completion(void *cls) cb_cls = h->cb_cls; h->cb_cls = NULL; if (NULL != cb) - cb(cb_cls, bw); + cb (cb_cls, bw); } @@ -123,13 +125,13 @@ call_flush_completion(void *cls) * @param h logger handle */ static void -trigger_flush_notification(struct GNUNET_TESTBED_LOGGER_Handle *h) +trigger_flush_notification (struct GNUNET_TESTBED_LOGGER_Handle *h) { if (NULL != h->flush_completion_task) - GNUNET_SCHEDULER_cancel(h->flush_completion_task); + GNUNET_SCHEDULER_cancel (h->flush_completion_task); h->flush_completion_task - = GNUNET_SCHEDULER_add_now(&call_flush_completion, - h); + = GNUNET_SCHEDULER_add_now (&call_flush_completion, + h); } @@ -139,7 +141,7 @@ trigger_flush_notification(struct GNUNET_TESTBED_LOGGER_Handle *h) * @param h the logger handle */ static void -dispatch_buffer(struct GNUNET_TESTBED_LOGGER_Handle *h); +dispatch_buffer (struct GNUNET_TESTBED_LOGGER_Handle *h); /** @@ -148,19 +150,19 @@ dispatch_buffer(struct GNUNET_TESTBED_LOGGER_Handle *h); * @param cls our handle */ static void -notify_sent(void *cls) +notify_sent (void *cls) { struct GNUNET_TESTBED_LOGGER_Handle *h = cls; h->mq_len--; if ((0 == h->mq_len) && (NULL != h->cb)) - { - if (0 == h->buse) - trigger_flush_notification(h); - else - dispatch_buffer(h); - } + { + if (0 == h->buse) + trigger_flush_notification (h); + else + dispatch_buffer (h); + } } @@ -170,25 +172,25 @@ notify_sent(void *cls) * @param h the logger handle */ static void -dispatch_buffer(struct GNUNET_TESTBED_LOGGER_Handle *h) +dispatch_buffer (struct GNUNET_TESTBED_LOGGER_Handle *h) { struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope *env; - env = GNUNET_MQ_msg_extra(msg, - h->buse, - GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG); - GNUNET_memcpy(&msg[1], - h->buf, - h->buse); + env = GNUNET_MQ_msg_extra (msg, + h->buse, + GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG); + GNUNET_memcpy (&msg[1], + h->buf, + h->buse); h->bwrote += h->buse; h->buse = 0; h->mq_len++; - GNUNET_MQ_notify_sent(env, - ¬ify_sent, - h); - GNUNET_MQ_send(h->mq, - env); + GNUNET_MQ_notify_sent (env, + ¬ify_sent, + h); + GNUNET_MQ_send (h->mq, + env); } @@ -199,13 +201,13 @@ dispatch_buffer(struct GNUNET_TESTBED_LOGGER_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_TESTBED_LOGGER_Handle *h = cls; - GNUNET_break(0); - GNUNET_MQ_destroy(h->mq); + GNUNET_break (0); + GNUNET_MQ_destroy (h->mq); h->mq = NULL; } @@ -218,21 +220,21 @@ mq_error_handler(void *cls, * upon any error */ struct GNUNET_TESTBED_LOGGER_Handle * -GNUNET_TESTBED_LOGGER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_TESTBED_LOGGER_Handle *h; - h = GNUNET_new(struct GNUNET_TESTBED_LOGGER_Handle); - h->mq = GNUNET_CLIENT_connect(cfg, - "testbed-logger", - NULL, - &mq_error_handler, - h); + h = GNUNET_new (struct GNUNET_TESTBED_LOGGER_Handle); + h->mq = GNUNET_CLIENT_connect (cfg, + "testbed-logger", + NULL, + &mq_error_handler, + h); if (NULL == h->mq) - { - GNUNET_free(h); - return NULL; - } + { + GNUNET_free (h); + return NULL; + } return h; } @@ -243,23 +245,23 @@ GNUNET_TESTBED_LOGGER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) * @param h the logger handle */ void -GNUNET_TESTBED_LOGGER_disconnect(struct GNUNET_TESTBED_LOGGER_Handle *h) +GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h) { if (NULL != h->flush_completion_task) - { - GNUNET_SCHEDULER_cancel(h->flush_completion_task); - h->flush_completion_task = NULL; - } + { + GNUNET_SCHEDULER_cancel (h->flush_completion_task); + h->flush_completion_task = NULL; + } if (0 != h->mq_len) - LOG(GNUNET_ERROR_TYPE_WARNING, - "Disconnect lost %u logger message[s]\n", - h->mq_len); + LOG (GNUNET_ERROR_TYPE_WARNING, + "Disconnect lost %u logger message[s]\n", + h->mq_len); 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); } @@ -273,25 +275,25 @@ GNUNET_TESTBED_LOGGER_disconnect(struct GNUNET_TESTBED_LOGGER_Handle *h) * @param size how many bytes of @a data to send */ void -GNUNET_TESTBED_LOGGER_write(struct GNUNET_TESTBED_LOGGER_Handle *h, - const void *data, - size_t size) +GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h, + const void *data, + size_t size) { if (NULL == h->mq) return; while (0 != size) - { - size_t fit_size = GNUNET_MIN(size, - BUFFER_SIZE - h->buse); - GNUNET_memcpy(&h->buf[h->buse], - data, - fit_size); - h->buse += fit_size; - data += fit_size; - size -= fit_size; - if (0 != size) - dispatch_buffer(h); - } + { + size_t fit_size = GNUNET_MIN (size, + BUFFER_SIZE - h->buse); + GNUNET_memcpy (&h->buf[h->buse], + data, + fit_size); + h->buse += fit_size; + data += fit_size; + size -= fit_size; + if (0 != size) + dispatch_buffer (h); + } } @@ -303,20 +305,20 @@ GNUNET_TESTBED_LOGGER_write(struct GNUNET_TESTBED_LOGGER_Handle *h, * @param cb_cls the closure for the above callback */ void -GNUNET_TESTBED_LOGGER_flush(struct GNUNET_TESTBED_LOGGER_Handle *h, - GNUNET_TESTBED_LOGGER_FlushCompletion cb, - void *cb_cls) +GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h, + GNUNET_TESTBED_LOGGER_FlushCompletion cb, + void *cb_cls) { - GNUNET_assert(NULL == h->cb); + GNUNET_assert (NULL == h->cb); h->cb = cb; h->cb_cls = cb_cls; if ((NULL == h->mq) || (0 == h->buse)) - { - trigger_flush_notification(h); - return; - } - dispatch_buffer(h); + { + trigger_flush_notification (h); + return; + } + dispatch_buffer (h); } @@ -328,13 +330,13 @@ GNUNET_TESTBED_LOGGER_flush(struct GNUNET_TESTBED_LOGGER_Handle *h, * @param h the logger handle */ void -GNUNET_TESTBED_LOGGER_flush_cancel(struct GNUNET_TESTBED_LOGGER_Handle *h) +GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h) { if (NULL != h->flush_completion_task) - { - GNUNET_SCHEDULER_cancel(h->flush_completion_task); - h->flush_completion_task = NULL; - } + { + GNUNET_SCHEDULER_cancel (h->flush_completion_task); + h->flush_completion_task = NULL; + } h->cb = NULL; h->cb_cls = NULL; } -- cgit v1.2.3