| 45 | ****************************************************************************/ |
| 46 | |
| 47 | int main(int argc, char **argv, char **envp) |
| 48 | { |
| 49 | FILE *instream; |
| 50 | FILE *outstream; |
| 51 | const char *infile; |
| 52 | const char *outfile; |
| 53 | int tabsize = 8; |
| 54 | int tabmask = 7; |
| 55 | int newpos; |
| 56 | int pos; |
| 57 | int ret = 1; |
| 58 | int i; |
| 59 | |
| 60 | if (argc == 3) |
| 61 | { |
| 62 | infile = argv[1]; |
| 63 | outfile = argv[2]; |
| 64 | } |
| 65 | else if (argc == 4) |
| 66 | { |
| 67 | if (strcmp(argv[1], "-4") != 0) |
| 68 | { |
| 69 | fprintf(stderr, "ERROR: Unrecognized option\n"); |
| 70 | fprintf(stderr, "Usage: %s [-4] <source-file> <out-file>\n", |
| 71 | argv[0]); |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | tabsize = 4; |
| 76 | tabmask = 3; |
| 77 | infile = argv[2]; |
| 78 | outfile = argv[3]; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | fprintf(stderr, "ERROR: At least two arguments expected\n"); |
| 83 | fprintf(stderr, "Usage: %s [-4] <source-file> <out-file>\n", argv[0]); |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | /* Open the source file read-only */ |
| 88 | |
| 89 | instream = fopen(infile, "r"); |
| 90 | if (instream == NULL) |
| 91 | { |
| 92 | fprintf(stderr, "ERROR: Failed to open %s for reading\n", argv[1]); |
| 93 | return 1; |
| 94 | } |
| 95 | |
| 96 | /* Open the destination file write-only */ |
| 97 | |
| 98 | outstream = fopen(outfile, "w"); |
| 99 | if (outstream == NULL) |
| 100 | { |
| 101 | fprintf(stderr, "ERROR: Failed to open %s for reading\n", argv[2]); |
| 102 | goto errout_with_instream; |
| 103 | } |
| 104 | |