| 53 | } |
| 54 | |
| 55 | int main(int argc, char **argv) |
| 56 | { |
| 57 | int buf_size = 0; |
| 58 | char *buf = NULL; |
| 59 | const char *outfilename = NULL, *infilename = NULL; |
| 60 | FILE *outfile = NULL, *infile = NULL; |
| 61 | const char *prompt = "=> "; |
| 62 | int count = 0, echo = 0; |
| 63 | int c; |
| 64 | |
| 65 | #define GROW_ARRAY() \ |
| 66 | do { \ |
| 67 | if (!av_dynarray2_add((void **)&buf, &buf_size, 1, NULL)) { \ |
| 68 | av_log(NULL, AV_LOG_ERROR, \ |
| 69 | "Memory allocation problem occurred\n"); \ |
| 70 | return 1; \ |
| 71 | } \ |
| 72 | } while (0) |
| 73 | |
| 74 | GROW_ARRAY(); |
| 75 | while ((c = getopt(argc, argv, "ehi:o:p:")) != -1) { |
| 76 | switch (c) { |
| 77 | case 'e': |
| 78 | echo = 1; |
| 79 | break; |
| 80 | case 'h': |
| 81 | usage(); |
| 82 | return 0; |
| 83 | case 'i': |
| 84 | infilename = optarg; |
| 85 | break; |
| 86 | case 'o': |
| 87 | outfilename = optarg; |
| 88 | break; |
| 89 | case 'p': |
| 90 | prompt = optarg; |
| 91 | break; |
| 92 | case '?': |
| 93 | return 1; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | if (!infilename || !strcmp(infilename, "-")) { |
| 98 | infilename = "stdin"; |
| 99 | infile = stdin; |
| 100 | } else { |
| 101 | infile = fopen(infilename, "r"); |
| 102 | } |
| 103 | if (!infile) { |
| 104 | fprintf(stderr, "Impossible to open input file '%s': %s\n", infilename, strerror(errno)); |
| 105 | return 1; |
| 106 | } |
| 107 | |
| 108 | if (!outfilename || !strcmp(outfilename, "-")) { |
| 109 | outfilename = "stdout"; |
| 110 | outfile = stdout; |
| 111 | } else { |
| 112 | outfile = fopen(outfilename, "w"); |
nothing calls this directly
no test coverage detected