Upload files to "/"
This commit is contained in:
parent
188f3acc54
commit
89f4c53fba
14
cutecat.c
14
cutecat.c
@ -30,11 +30,11 @@ void OwO(char *buf, off_t len) {
|
||||
}
|
||||
|
||||
void PrintRainbow(char c, off_t i) {
|
||||
int red = sin(FREQ * i) * 127 + 128;
|
||||
int blue = sin(FREQ * i + 2 * M_PI / 3) * 127 + 128;
|
||||
int green = sin(FREQ * i + 4 * M_PI / 3) * 127 + 128;
|
||||
unsigned int red = sin(FREQ * i) * 127 + 128;
|
||||
unsigned int blue = sin(FREQ * i + 2 * M_PI / 3) * 127 + 128;
|
||||
unsigned int green = sin(FREQ * i + 4 * M_PI / 3) * 127 + 128;
|
||||
|
||||
printf("\033[38;2;%d;%d;%dm%c\033[0m", red, green, blue, c);
|
||||
printf("\033[38;2;%u;%u;%um%c\033[0m", red, green, blue, c);
|
||||
}
|
||||
|
||||
int cat(const char *path) {
|
||||
@ -50,13 +50,17 @@ int cat(const char *path) {
|
||||
|
||||
char buf[1025];
|
||||
off_t len = 0;
|
||||
off_t n_line = 0;
|
||||
|
||||
while ((len = read(fd, buf, sizeof(buf))) > 0) {
|
||||
OwO(buf, len);
|
||||
|
||||
for (off_t i = 0; i < len; i++) {
|
||||
if (buf[i] == '\n')
|
||||
n_line++;
|
||||
|
||||
if (!isspace(buf[i]) && !r_flag)
|
||||
PrintRainbow(buf[i], i);
|
||||
PrintRainbow(buf[i], len + n_line);
|
||||
|
||||
else
|
||||
putchar(buf[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user