add CLI option to decode SJIS

This commit is contained in:
Martin Michelsen
2022-05-18 23:58:21 -07:00
parent 43723887bb
commit 0837234e4f
+12
View File
@@ -277,6 +277,7 @@ enum class Behavior {
DECRYPT_DATA, DECRYPT_DATA,
ENCRYPT_DATA, ENCRYPT_DATA,
DECODE_QUEST_FILE, DECODE_QUEST_FILE,
DECODE_SJIS,
}; };
enum class EncryptionType { enum class EncryptionType {
@@ -304,6 +305,8 @@ int main(int argc, char** argv) {
behavior = Behavior::DECRYPT_DATA; behavior = Behavior::DECRYPT_DATA;
} else if (!strcmp(argv[x], "--encrypt-data")) { } else if (!strcmp(argv[x], "--encrypt-data")) {
behavior = Behavior::ENCRYPT_DATA; behavior = Behavior::ENCRYPT_DATA;
} else if (!strcmp(argv[x], "--decode-sjis")) {
behavior = Behavior::DECODE_SJIS;
} else if (!strncmp(argv[x], "--decode-gci=", 13)) { } else if (!strncmp(argv[x], "--decode-gci=", 13)) {
behavior = Behavior::DECODE_QUEST_FILE; behavior = Behavior::DECODE_QUEST_FILE;
quest_file_type = QuestFileFormat::GCI; quest_file_type = QuestFileFormat::GCI;
@@ -384,6 +387,15 @@ int main(int argc, char** argv) {
} }
return 0; return 0;
} else if (behavior == Behavior::DECODE_SJIS) {
string data = read_all(stdin);
if (parse_data) {
data = parse_data_string(data);
}
auto decoded = decode_sjis(data);
print_data(stderr, decoded.data(), decoded.size() * sizeof(decoded[0]));
return 0;
} }
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);