init: add meson and simple termio program
crispy-caesus crispy@crispy-caesus.eu
Mon, 27 Apr 2026 20:56:53 +0200
2 files changed,
49 insertions(+),
0 deletions(-)
A
main.c
@@ -0,0 +1,42 @@
+#include <stdint.h> +#include <stdio.h> + +#include <termios.h> +#include <unistd.h> + +int main() { + + struct termios old, new; + + tcgetattr(STDIN_FILENO, &old); + + new = old; + + new.c_lflag &= ~(ECHO | ICANON); + new.c_cc[VMIN] = 0; // bytes read to return + new.c_cc[VTIME] = 0; // time before return + + tcsetattr(STDIN_FILENO, TCSANOW, &new); + + printf("Pressed characters:\n"); + + uint8_t run = 1; + + while (run) { + char buffer[10]; + uint16_t length = read(STDIN_FILENO, buffer, sizeof(buffer)); + if (length > 0) { + uint8_t i; + for (i = 0; i < length; i++) { + printf(" %d", buffer[i]); + if (buffer[i] == 'Q') + run = 0; + } + printf("\n"); + } + } + + tcsetattr(STDIN_FILENO, TCSANOW, &old); + + return 0; +}
A
meson.build
@@ -0,0 +1,7 @@
+project( + 'thing', + 'c', + default_options : + ['std=99'] + ) +executable('thing', 'main.c')