I need handle control characters in my program.
this code is a simple pipe:
Code:
#include <stdio.h>
void mypipe( FILE *fd)
{
char *buf;
size_t linesize = 0;
while ( ! feof (fd) )
{
getline (&buf , &linesize , fd);
fputs( buf , stdout );
fflush(stdout);
}
fclose(fd);
}
int main(int argc, char *argv[])
{
mypipe(stdin);
return 0;
}
for example if I run this command:
ls --color | ./mypipe
colored text will be display. how can I Ignore escape sequences?