init commit

This commit is contained in:
2025-04-13 21:48:15 +03:00
commit 23255e9121
192 changed files with 12200 additions and 0 deletions
Executable
+34
View File
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <string.h>
int
main(int argc, char **argv)
{
int file = open(argv[1], O_RDONLY);
int file_out = open("tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666);
dup2(file, 0);
dup2(file_out, 1);
char buf[101];
while (fgets(buf, 100, stdin) != NULL) {
for (int i = 0; i < strlen(buf); i++) {
if (!strncmp(buf + i, "begin", 5)) {
printf("{");
i += 4;
} else if (!strncmp(buf + i, "end", 3)) {
printf("}");
i += 2;
} else {
printf("%c", buf[i]);
}
}
}
rename("tmp", argv[1]);
return 0;
}