3 * Author: Jan Vales (e0726236@student.tuwien.ac.at)
5 * Purpose: reimplementation of "cat"
6 * Usage: Usage: cat [opt]
7 * Output: prints stdin to stdout
20 /*Usage info, in case someone did something wrong*/
21 void usage(char **argv){
22 (void)fprintf(stderr,"%s Usage: mycat [opt]\n-E: replace newlines\n-T: replace Tabs\n-v: Print nonprintables (implies -E and -T)\n", argv[0]);
25 /* main program. reads input from stdin and prints requested stuff to stdout*/
26 int main(int argc, char **argv){
33 while((temp = getopt(argc, argv, "ETv")) != -1){
35 case 'E': isOptE = 1; break;
36 case 'T': isOptT = 1; break;
37 case 'v': isOptv = 1; break;
38 default: usage(argv); return 1;
46 if((isOptT | isOptv) & (c == '\t')){
47 (void)fprintf(stdout,"^I");
50 if((isOptE | isOptv) & (c == '\n')){
51 (void)fprintf(stdout,"$%c", c);
54 if(isOptv & (c >= 128)){
55 (void)fprintf(stdout,"M-");
58 if(isOptv & (c == 127)){
59 (void)fprintf(stdout,"^?");
62 if(isOptv & (c <= 32)){
63 (void)fprintf(stdout,"^%c", (c+64));
66 (void)fprintf(stdout,"%c", c);