| 258 | enum class InputFormat { Auto, Raw, EscX, ZeroX, Hex, B64 }; |
| 259 | |
| 260 | InputFormat parse_input_format(const std::string& s) { |
| 261 | if (s == "auto") return InputFormat::Auto; |
| 262 | if (s == "raw" || s == "bin") return InputFormat::Raw; |
| 263 | if (s == "escape" || s == "escx" || s == "\\x" || s == "py") return InputFormat::EscX; |
| 264 | if (s == "0x" || s == "c") return InputFormat::ZeroX; |
| 265 | if (s == "hex") return InputFormat::Hex; |
| 266 | if (s == "b64" || s == "base64") return InputFormat::B64; |
| 267 | throw mkpivm::Error("unknown --input-format: " + s + ", expected auto|raw|escape|0x|hex|b64"); |
| 268 | } |
| 269 | |
| 270 | // decode input bytes. `forced` overrides auto-detect |
| 271 | std::vector<std::uint8_t> decode_input(std::vector<std::uint8_t> raw, InputFormat forced, const char** fmt_out) { |