main: refacto

This commit is contained in:
theBigBlase 2023-10-06 22:23:37 -04:00
parent 76ee7c2fab
commit 01353032b4

View file

@ -50,28 +50,26 @@ main(int argc, char *argv[])
free(res); free(res);
#endif #endif
printf("\n--- MSG ---\nas 0x: "); printf("\n--- MSG ---\n");
#ifdef TEST_ZERO
msg = 0;
printf("0x00000000\n");
#endif
#ifdef TEST_MAX #ifdef TEST_ZERO
msg = UINT32_MAX; msg = 0x00000000;
printf("0xffffffff\n");
#endif #endif
#ifdef TEST_MID #ifdef TEST_MID
printf("0x0000ffff\n");
/* is UINT16_MAX, but keeping this way for corrector convenience */ /* is UINT16_MAX, but keeping this way for corrector convenience */
msg = UINT32_MAX & UINT16_MAX; msg = 0x0000ffff;
#endif
#ifdef TEST_MAX
msg = 0xffffffff;
#endif #endif
#ifdef TEST_NAME #ifdef TEST_NAME
msg = *(uint32_t *)"bob"; msg = *(uint32_t *)"bob";
printf("%u\n", msg);
#endif #endif
printf("as 0x: %x\n", msg);
char *msg_char = uint32_to_char_arr(msg); char *msg_char = uint32_to_char_arr(msg);
printf("as char *: %s\nas uint32: %u\n", printf("as char *: %s\nas uint32: %u\n",
@ -125,21 +123,27 @@ gen()
static struct eve static struct eve
eve_shenanigans(struct eve str) eve_shenanigans(struct eve str)
{ {
#ifdef EVE_NAME #ifdef EVE_ZERO
uint32_t old_msg = str.msg; uint32_t old_msg = str.msg;
str.msg = *(uint32_t *)"eve"; str.msg = 0x00000000;
str.tag = str.tag ^ old_msg ^ str.msg; str.tag = str.tag ^ old_msg ^ str.msg;
#endif #endif
#ifdef EVE_ZERO #ifdef EVE_MID
uint32_t old_msg = str.msg; uint32_t old_msg = str.msg;
str.msg = 0; str.msg = 0x0000ffff;
str.tag = str.tag ^ old_msg ^ str.msg; str.tag = str.tag ^ old_msg ^ str.msg;
#endif #endif
#ifdef EVE_MAX #ifdef EVE_MAX
uint32_t old_msg = str.msg; uint32_t old_msg = str.msg;
str.msg = UINT32_MAX; str.msg = 0xffffffff;
str.tag = str.tag ^ old_msg ^ str.msg;
#endif
#ifdef EVE_NAME
uint32_t old_msg = str.msg;
str.msg = *(uint32_t *)"eve";
str.tag = str.tag ^ old_msg ^ str.msg; str.tag = str.tag ^ old_msg ^ str.msg;
#endif #endif