int main(int argc, char *argv[]) { //char input_filename[1024]; char *input_filename; FILE *input, *output; if (argc != 3) { printf("Usage: %s <input filename> <output filename>\n" "Restore <output filename> from <input filename>\n\n", argv[0]); exit(1); } //strcpy(input_filename, argv[1]); //strcat(input_filename, ".rp"); input_filename = argv[1]; input = fopen(input_filename, "rb"); output = fopen(argv[2], "w"); if (input == NULL || output == NULL) { printf("File open error.\n"); exit(1); } DecodeCFG(input, output); fclose(input); fclose(output); exit(0); }
int main(int argc, char *argv[]) { FILE *input, *output; if (argc != 3) { printf("usage: %s target_enc_file output_txt_file\n", argv[0]); puts("argument error."); exit(1); } input = fopen(argv[1], "rb"); output = fopen(argv[2], "w"); if (input == NULL || output == NULL) { printf("File open error.\n"); exit(1); } DecodeCFG(input, output); fclose(input); fclose(output); exit(0); }
// decode用のmain関数 int main(int argc, char *argv[]) { //char input_filename[1024]; char *input_filename, *output_filename, *dict_filename; FILE *input, *output, *dictfile; IBITFS input_stream, dict_stream; int result; /* オプションの解析 */ while ((result = getopt(argc, argv, "r:w:d:")) != -1) { switch (result) { case 'r': input_filename = optarg; break; case 'w': output_filename = optarg; break; case 'd': dict_filename = optarg; break; case '?': help(argv); break; } } // 必要なオプションがそろっているかを確認する if (!(input_filename && output_filename && dict_filename)) { help(argv); } // 圧縮データファイルをオープンする input = fopen(input_filename, "rb"); if (input == NULL) { puts("Input file open error at the beginning."); exit(1); } // 出力用ファイルをオープンする output = fopen(output_filename, "wb"); if (output == NULL) { puts("Output file open error at the beginning."); exit(1); } // 辞書ファイルをオープンする dictfile = fopen(dict_filename, "rb"); if (!dictfile) { puts("Dictionary file open error at the beginning."); exit(EXIT_FAILURE); } ibitfs_init(&input_stream, input); ibitfs_init(&dict_stream, dictfile); DecodeCFG(output, &input_stream, &dict_stream); ibitfs_finalize(&input_stream); ibitfs_finalize(&dict_stream); fclose(input); fclose(output); exit(0); }