#include #include #include main( int argc, char *argv[] ) { char eoi=' '; extern char *optarg; extern int optind,opterr,optopt; int opcion; unsigned char theError=0; while ( (opcion=getopt(argc,argv,"c:")) != EOF ) { switch(opcion) { case 'c': eoi = *optarg; break; default: theError ++; break; } } if ( theError != 0 ) { fprintf( stderr, "Usage: %s -c end_of_input\n", argv[0]); exit(-1); } /* * set raw mode */ setvbuf(stdin,NULL,_IONBF,(size_t)0); setvbuf(stdout,NULL,_IONBF,(size_t)0); /* * cat */ for( ; putchar(getchar())!=eoi; ) ; fflush(stdout); exit( 0 ); }