Загрузить файлы в «/»

This commit is contained in:
2025-04-17 17:22:21 +00:00
parent 6e3949d8d7
commit c65297d7d2
3 changed files with 84 additions and 0 deletions

38
bbviewer.c Normal file
View File

@@ -0,0 +1,38 @@
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
void enableRawMode() {
struct termios tty;
tcgetattr(STDIN_FILENO, &tty);
tty.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &tty);
}
void disableRawMode() {
struct termios tty;
tcgetattr(STDIN_FILENO, &tty);
tty.c_lflag |= ICANON | ECHO;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &tty);
}
int main() {
enableRawMode();
char buf[3];
while (1) {
ssize_t n = read(STDIN_FILENO, buf, sizeof(buf));
if (n == 1 && buf[0] == 'q') break;
// Печатаем все полученные байты
printf("Read %zd bytes: ", n);
for (ssize_t i = 0; i < n; i++) {
printf("%d ", (unsigned char)buf[i]);
}
printf("\n");
fflush(stdout);
}
disableRawMode();
return 0;
}