2020-12-06 17:24:43 -05:00
|
|
|
#include <kernaux/printf.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
2020-12-06 17:32:49 -05:00
|
|
|
#include <stdio.h>
|
2020-12-06 17:24:43 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define BUFFER_SIZE 1024
|
|
|
|
|
|
|
|
static char buffer[BUFFER_SIZE];
|
|
|
|
static unsigned int buffer_index;
|
|
|
|
|
|
|
|
static void my_putchar(const char chr)
|
|
|
|
{
|
|
|
|
if (buffer_index >= BUFFER_SIZE) abort();
|
|
|
|
buffer[buffer_index++] = chr;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
memset(buffer, '\0', sizeof(buffer));
|
|
|
|
buffer_index = 0;
|
2020-12-06 19:22:52 -05:00
|
|
|
kernaux_printf(my_putchar, "Hello, %s! Session ID: %u.", "Alex", 123);
|
|
|
|
assert(strcmp(buffer, "Hello, Alex! Session ID: 123.") == 0);
|
2020-12-06 17:24:43 -05:00
|
|
|
|
2020-12-06 17:32:49 -05:00
|
|
|
printf("OK!\n");
|
|
|
|
|
2020-12-06 17:24:43 -05:00
|
|
|
return 0;
|
|
|
|
}
|