diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2023-08-07 18:12:05 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2023-08-07 18:12:05 +0200 |
commit | 140f9ac6d6ecd14a1ed3ee839ffe270a22ec993f (patch) | |
tree | a3e699f35bf3e1843b062e0bd954c70d6c98dc4f /src/messenger/messenger_api_message.c | |
parent | 182981a5dcb1285a8dc40f7661bbca96ffaa1df2 (diff) | |
download | gnunet-140f9ac6d6ecd14a1ed3ee839ffe270a22ec993f.tar.gz gnunet-140f9ac6d6ecd14a1ed3ee839ffe270a22ec993f.zip |
MESSENGER: Uncrustify
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/messenger_api_message.c')
-rw-r--r-- | src/messenger/messenger_api_message.c | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index 7b493f760..74b65bf71 100644 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -393,32 +393,32 @@ calc_padded_length (uint16_t length) | |||
393 | #define min(x, y) (x < y? x : y) | 393 | #define min(x, y) (x < y? x : y) |
394 | 394 | ||
395 | #define encode_step_ext(dst, offset, src, size) do { \ | 395 | #define encode_step_ext(dst, offset, src, size) do { \ |
396 | GNUNET_memcpy (dst + offset, src, size); \ | 396 | GNUNET_memcpy (dst + offset, src, size); \ |
397 | offset += size; \ | 397 | offset += size; \ |
398 | } while (0) | 398 | } while (0) |
399 | 399 | ||
400 | #define encode_step(dst, offset, src) do { \ | 400 | #define encode_step(dst, offset, src) do { \ |
401 | encode_step_ext (dst, offset, src, sizeof(*src)); \ | 401 | encode_step_ext (dst, offset, src, sizeof(*src)); \ |
402 | } while (0) | 402 | } while (0) |
403 | 403 | ||
404 | #define encode_step_key(dst, offset, src, length) do { \ | 404 | #define encode_step_key(dst, offset, src, length) do { \ |
405 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer ( \ | 405 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer ( \ |
406 | src, dst + offset, length - offset \ | 406 | src, dst + offset, length - offset \ |
407 | ); \ | 407 | ); \ |
408 | if (result < 0) \ | 408 | if (result < 0) \ |
409 | GNUNET_break (0); \ | 409 | GNUNET_break (0); \ |
410 | else \ | 410 | else \ |
411 | offset += result; \ | 411 | offset += result; \ |
412 | } while (0) | 412 | } while (0) |
413 | 413 | ||
414 | #define encode_step_signature(dst, offset, src, length) do { \ | 414 | #define encode_step_signature(dst, offset, src, length) do { \ |
415 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer ( \ | 415 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer ( \ |
416 | src, dst + offset, length - offset \ | 416 | src, dst + offset, length - offset \ |
417 | ); \ | 417 | ); \ |
418 | if (result < 0) \ | 418 | if (result < 0) \ |
419 | GNUNET_break (0); \ | 419 | GNUNET_break (0); \ |
420 | else \ | 420 | else \ |
421 | offset += result; \ | 421 | offset += result; \ |
422 | } while (0) | 422 | } while (0) |
423 | 423 | ||
424 | static void | 424 | static void |
@@ -568,30 +568,30 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, | |||
568 | 568 | ||
569 | 569 | ||
570 | #define decode_step_ext(src, offset, dst, size) do { \ | 570 | #define decode_step_ext(src, offset, dst, size) do { \ |
571 | GNUNET_memcpy (dst, src + offset, size); \ | 571 | GNUNET_memcpy (dst, src + offset, size); \ |
572 | offset += size; \ | 572 | offset += size; \ |
573 | } while (0) | 573 | } while (0) |
574 | 574 | ||
575 | #define decode_step(src, offset, dst) do { \ | 575 | #define decode_step(src, offset, dst) do { \ |
576 | decode_step_ext (src, offset, dst, sizeof(*dst)); \ | 576 | decode_step_ext (src, offset, dst, sizeof(*dst)); \ |
577 | } while (0) | 577 | } while (0) |
578 | 578 | ||
579 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ | 579 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ |
580 | dst = GNUNET_malloc (size + zero); \ | 580 | dst = GNUNET_malloc (size + zero); \ |
581 | if (zero) dst[size] = 0; \ | 581 | if (zero) dst[size] = 0; \ |
582 | decode_step_ext (src, offset, dst, size); \ | 582 | decode_step_ext (src, offset, dst, size); \ |
583 | } while (0) | 583 | } while (0) |
584 | 584 | ||
585 | #define decode_step_key(src, offset, dst, length) do { \ | 585 | #define decode_step_key(src, offset, dst, length) do { \ |
586 | enum GNUNET_GenericReturnValue result; \ | 586 | enum GNUNET_GenericReturnValue result; \ |
587 | size_t read; \ | 587 | size_t read; \ |
588 | result = GNUNET_IDENTITY_read_public_key_from_buffer ( \ | 588 | result = GNUNET_IDENTITY_read_public_key_from_buffer ( \ |
589 | src + offset, length - offset, dst, &read \ | 589 | src + offset, length - offset, dst, &read \ |
590 | ); \ | 590 | ); \ |
591 | if (GNUNET_SYSERR == result) \ | 591 | if (GNUNET_SYSERR == result) \ |
592 | GNUNET_break (0); \ | 592 | GNUNET_break (0); \ |
593 | else \ | 593 | else \ |
594 | offset += read; \ | 594 | offset += read; \ |
595 | } while (0) | 595 | } while (0) |
596 | 596 | ||
597 | static uint16_t | 597 | static uint16_t |
@@ -860,13 +860,15 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
860 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); | 860 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); |
861 | const uint16_t padded_length = calc_padded_length ( | 861 | const uint16_t padded_length = calc_padded_length ( |
862 | length + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | 862 | length + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES |
863 | ); | 863 | ); |
864 | 864 | ||
865 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; | 865 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; |
866 | message->body.privacy.data = GNUNET_malloc (padded_length); | 866 | message->body.privacy.data = GNUNET_malloc (padded_length); |
867 | message->body.privacy.length = padded_length; | 867 | message->body.privacy.length = padded_length; |
868 | 868 | ||
869 | const uint16_t encoded_length = padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES; | 869 | const uint16_t encoded_length = ( |
870 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | ||
871 | ); | ||
870 | 872 | ||
871 | encode_short_message (&shortened, encoded_length, message->body.privacy.data); | 873 | encode_short_message (&shortened, encoded_length, message->body.privacy.data); |
872 | 874 | ||
@@ -881,7 +883,7 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
881 | unfold_short_message (&shortened, message); | 883 | unfold_short_message (&shortened, message); |
882 | return GNUNET_NO; | 884 | return GNUNET_NO; |
883 | } | 885 | } |
884 | 886 | ||
885 | destroy_message_body (shortened.kind, &(shortened.body)); | 887 | destroy_message_body (shortened.kind, &(shortened.body)); |
886 | return GNUNET_YES; | 888 | return GNUNET_YES; |
887 | } | 889 | } |
@@ -897,12 +899,15 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
897 | 899 | ||
898 | if (padded_length < GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES) | 900 | if (padded_length < GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES) |
899 | { | 901 | { |
900 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Message length too short to decrypt!\n"); | 902 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
903 | "Message length too short to decrypt!\n"); | ||
901 | 904 | ||
902 | return GNUNET_NO; | 905 | return GNUNET_NO; |
903 | } | 906 | } |
904 | 907 | ||
905 | const uint16_t encoded_length = padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES; | 908 | const uint16_t encoded_length = ( |
909 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | ||
910 | ); | ||
906 | 911 | ||
907 | if (GNUNET_OK != GNUNET_IDENTITY_decrypt (message->body.privacy.data, | 912 | if (GNUNET_OK != GNUNET_IDENTITY_decrypt (message->body.privacy.data, |
908 | padded_length, | 913 | padded_length, |
@@ -914,7 +919,7 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
914 | 919 | ||
915 | return GNUNET_NO; | 920 | return GNUNET_NO; |
916 | } | 921 | } |
917 | 922 | ||
918 | struct GNUNET_MESSENGER_ShortMessage shortened; | 923 | struct GNUNET_MESSENGER_ShortMessage shortened; |
919 | 924 | ||
920 | if (GNUNET_YES != decode_short_message (&shortened, | 925 | if (GNUNET_YES != decode_short_message (&shortened, |