/* * Copyright (C) 2016 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "util.h" #include "book.h" #include "font.h" /* * Entry point */ int main(int argc, char *argv[]) { const struct option options[] = { { "font-table", required_argument, NULL, 'f' }, { "pretty-print", no_argument, NULL, 'p' }, { "markup", no_argument, NULL, 'm' }, { "positions", no_argument, NULL, 's' }, { "font-tags", no_argument, NULL, 't' }, { NULL, 0, NULL, 0 }, }; char* dict_path = NULL; char* font_path = NULL; int flags = 0; int c = 0; while ((c = getopt_long(argc, argv, "f:d:pmst", options, NULL)) != -1) { switch (c) { case 'f': font_path = optarg; break; case 'p': flags |= FLAG_PRETTY_PRINT; break; case 'm': flags |= FLAG_HOOK_MARKUP; break; case 's': flags |= FLAG_POSITIONS; break; case 't': flags |= FLAG_FONT_TAGS; break; default: return 1; } } if (optind == argc) { fprintf(stderr, "%s: dictionary path must be provided provided\n", argv[0]); return 1; } dict_path = argv[optind]; Font_Context context; if (!font_context_init(&context, font_path == 0 ? NULL : font_path)) { return 1; } Book book; book_init(&book); const int success = book_import(&book, &context, dict_path, flags) && book_export(stdout, &book, flags); book_free(&book); font_context_destroy(&context); return success ? 0 : 1; }