2020-12-12 06:33:20 +00:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
2020-02-12 05:30:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
FILE *in_file;
|
|
|
|
int i, error = 0, eof_reached = 0;
|
|
|
|
char c, c_temp;
|
|
|
|
|
|
|
|
for(i = 1; i < argc; i++) {
|
|
|
|
if(argv[i][0] == '-' && argv[i][1] == '\0')
|
|
|
|
in_file = stdin;
|
|
|
|
else {
|
|
|
|
in_file = fopen(argv[i], "r");
|
|
|
|
if(in_file == NULL) {
|
2020-12-13 15:17:40 +00:00
|
|
|
fprintf(stderr, "Cannot find file %s\n", argv[i]);
|
|
|
|
error = 1;
|
|
|
|
continue;
|
2020-02-12 05:30:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
eof_reached = 0;
|
|
|
|
while(!eof_reached) {
|
|
|
|
c = fgetc(in_file);
|
|
|
|
switch(c) {
|
|
|
|
case '1': printf("\f"); break;
|
|
|
|
case '0': printf("\n"); break;
|
|
|
|
case '+': printf("\r"); break;
|
|
|
|
case EOF: eof_reached = 1; continue;
|
|
|
|
}
|
|
|
|
for(c_temp = fgetc(in_file); c_temp != '\n'; c_temp = fgetc(in_file)) {
|
2020-12-13 15:17:40 +00:00
|
|
|
if(c_temp == EOF) {
|
|
|
|
eof_reached = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("%c", c_temp);
|
2020-02-12 05:30:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(error)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|