| 26 | } |
| 27 | |
| 28 | int main(int argc, const char* argv[]) |
| 29 | { |
| 30 | try |
| 31 | { |
| 32 | if (argc < 2) |
| 33 | syntax(); |
| 34 | |
| 35 | inputFile.open( |
| 36 | argv[1], std::ios::in | std::ios::out | std::ios::binary); |
| 37 | if (!inputFile.is_open()) |
| 38 | error("cannot open input file '{}'", argv[1]); |
| 39 | |
| 40 | uint8_t b1 = getbyte(0x015); |
| 41 | uint8_t b2 = getbyte(0x100); |
| 42 | if ((b1 == 0x58) && (b2 == 0x58)) |
| 43 | { |
| 44 | std::cerr << "Flipping from Brother to DOS.\n"; |
| 45 | putbyte(0x015, 0xf0); |
| 46 | putbyte(0x100, 0xf0); |
| 47 | } |
| 48 | else if ((b1 == 0xf0) && (b2 == 0xf0)) |
| 49 | { |
| 50 | std::cerr << "Flipping from DOS to Brother.\n"; |
| 51 | putbyte(0x015, 0x58); |
| 52 | putbyte(0x100, 0x58); |
| 53 | } |
| 54 | else |
| 55 | error("Unknown image format."); |
| 56 | |
| 57 | inputFile.close(); |
| 58 | return 0; |
| 59 | } |
| 60 | catch (const ErrorException& e) |
| 61 | { |
| 62 | e.print(); |
| 63 | exit(1); |
| 64 | } |
| 65 | } |