all repos — mgba @ 6d898542c765f4efc4a094c5ebd3f3465c36f417

mGBA Game Boy Advance Emulator

src/platform/test/tbl-fuzz-main.c (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "util/text-codec.h"
 7#include "util/vfs.h"
 8
 9int main(int argc, char** argv) {
10	struct TextCodec codec;
11	struct VFile* vf = VFileOpen(argv[1], O_RDONLY);
12	TextCodecLoadTBL(&codec, vf, true);
13	vf->close(vf);
14
15	vf = VFileOpen(argv[2], O_RDONLY);
16	struct TextCodecIterator iter;
17	TextCodecStartDecode(&codec, &iter);
18	uint8_t lineBuffer[128];
19	uint8_t c;
20	while (vf->read(vf, &c, 1) > 0) {
21		TextCodecAdvance(&iter, c, lineBuffer, sizeof(lineBuffer));
22	}
23	TextCodecFinish(&iter, lineBuffer, sizeof(lineBuffer));
24
25	TextCodecDeinit(&codec);
26	return 0;
27}
28