2023-09-08 20:42:06 +00:00
|
|
|
#include <stdio.h>
|
2023-09-08 21:02:54 +00:00
|
|
|
#include <unistd.h> // read, isatty
|
2023-09-08 20:42:06 +00:00
|
|
|
|
2023-09-08 21:02:54 +00:00
|
|
|
// STDIN_FILENO
|
2023-09-08 21:07:49 +00:00
|
|
|
int process_fp(int filenum)
|
2023-09-08 21:02:54 +00:00
|
|
|
{
|
|
|
|
char buffer[1];
|
2023-09-08 21:07:49 +00:00
|
|
|
while (read(filenum, buffer, sizeof(buffer)) > 0) {
|
2023-09-08 21:02:54 +00:00
|
|
|
printf("%c", buffer[0]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2023-09-08 21:07:49 +00:00
|
|
|
if (!isatty(STDIN_FILENO)) {
|
2023-09-08 21:02:54 +00:00
|
|
|
return process_fp(STDIN_FILENO);
|
|
|
|
} else if(argc > 1){
|
|
|
|
printf("To do");
|
|
|
|
}
|
|
|
|
return 0;
|
2023-09-08 20:42:06 +00:00
|
|
|
}
|