1
zero-epwing/main.c

64 lines
1.7 KiB
C
Raw Normal View History

2016-10-31 16:04:15 +00:00
/*
* Copyright (C) 2016 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
2016-11-21 02:23:50 +00:00
#include <stdlib.h>
2016-11-03 03:37:11 +00:00
#include <getopt.h>
2016-11-01 02:32:40 +00:00
2016-11-21 02:23:50 +00:00
#include "book.h"
2016-11-20 03:40:29 +00:00
#include "gaiji.h"
2016-10-30 00:38:50 +00:00
2016-11-19 20:23:06 +00:00
/*
* Entry point
*/
2016-10-30 01:27:05 +00:00
int main(int argc, char *argv[]) {
2016-11-03 03:37:11 +00:00
bool pretty_print = false;
2016-11-21 02:54:57 +00:00
bool markup = false;
2016-11-03 03:37:11 +00:00
2016-11-19 19:31:20 +00:00
char opt = 0;
2016-11-21 03:00:59 +00:00
while ((opt = getopt(argc, argv, "pm")) != -1) {
2016-11-03 03:37:11 +00:00
switch (opt) {
case 'p':
pretty_print = true;
break;
2016-11-21 02:54:57 +00:00
case 'm':
markup = true;
break;
2016-11-03 03:37:11 +00:00
default:
exit(EXIT_FAILURE);
break;
}
2016-10-30 01:27:05 +00:00
}
2016-11-03 03:37:11 +00:00
if (optind >= argc) {
fprintf(stderr, "Usage: %s [-p] dictionary_path\n", argv[0]);
exit(EXIT_FAILURE);
2016-11-03 03:06:40 +00:00
}
2016-11-03 03:37:11 +00:00
2016-11-22 06:15:47 +00:00
Gaiji_Context context;
gaiji_context_init(&context, "gaiji.json");
2016-11-03 03:37:11 +00:00
Book book = {};
2016-11-22 06:31:01 +00:00
book_export(&book, &context, argv[optind], markup);
2016-11-21 02:23:50 +00:00
book_dump(&book, pretty_print, stdout);
book_free(&book);
2016-11-03 03:37:11 +00:00
2016-11-22 06:15:47 +00:00
gaiji_context_destroy(&context);
2016-11-03 03:37:11 +00:00
return 0;
2016-10-29 23:58:09 +00:00
}