-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
27 lines (23 loc) · 665 Bytes
/
utils.c
File metadata and controls
27 lines (23 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <string.h>
#include "utils.h"
void int8_to_char(const uint8_t *buffer, size_t buff_len, char *out) {
const char hex[] = "0123456789abcdef";
int i = 0;
int j = 0;
while (j < buff_len) {
out[i++] = hex[(buffer[j] >> 4) & 0xF];
out[i++] = hex[buffer[j] & 0xF];
j++;
}
out[i] = '\0';
}
void check_print(const char *expected, char *actual, const char *suffix) {
if (suffix)
printf("%s\n", suffix);
if (strcmp(expected, actual) != 0) {
printf("!!! MISMATCH !!!\nExpected: %s\nActual : %s\n", expected, actual);
} else {
printf("OK: %s\n", actual);
}
printf("\n");
}