WIP
This commit is contained in:
parent
e9b315f4ec
commit
be0bcdfd0c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,6 +4,3 @@
|
|||||||
[submodule "jansson"]
|
[submodule "jansson"]
|
||||||
path = jansson
|
path = jansson
|
||||||
url = https://github.com/akheron/jansson.git
|
url = https://github.com/akheron/jansson.git
|
||||||
[submodule "argparse"]
|
|
||||||
path = argparse
|
|
||||||
url = https://github.com/FooSoft/argparse
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(zero-epwing)
|
project(zero-epwing)
|
||||||
include_directories(eb)
|
include_directories(eb)
|
||||||
link_directories(eb/eb/.libs jansson/lib argparse)
|
link_directories(eb/eb/.libs jansson/lib)
|
||||||
add_executable(zero-epwing main.c book.c font.c convert.c hooks.c)
|
add_executable(zero-epwing main.c book.c font.c convert.c hooks.c)
|
||||||
target_link_libraries(zero-epwing libm.a libeb.a libm.a libz.a libjansson.a libargparse.a m)
|
target_link_libraries(zero-epwing libm.a libeb.a libm.a libz.a libjansson.a)
|
||||||
|
1
argparse
1
argparse
@ -1 +0,0 @@
|
|||||||
Subproject commit 1692ce12291a9d79cf6b425037a7d1a0e3c0aba5
|
|
64
main.c
64
main.c
@ -16,53 +16,53 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "argparse/argparse.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "book.h"
|
#include "book.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* Local types
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char dict_path[256];
|
|
||||||
char font_path[256];
|
|
||||||
int flags;
|
|
||||||
} Options;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entry point
|
* Entry point
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char* dict_path = NULL;
|
char* dict_path = NULL;
|
||||||
char* font_path = NULL;
|
char* font_path = NULL;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
struct argparse_option options[] = {
|
char c = 0;
|
||||||
OPT_HELP(),
|
while ((c = getopt(argc, argv, "f:d:pmst")) != -1) {
|
||||||
OPT_STRING('d', "dict", &dict_path, "dictionary resource to process", NULL, 0, 0),
|
switch (c) {
|
||||||
OPT_STRING('f', "font", &font_path, "font definition file for translation", NULL, 0, 0),
|
case 'f':
|
||||||
OPT_BOOLEAN('p', "pretty-print", &flags, "output pretty-printed JSON", NULL, 0, 0),
|
font_path = optarg;
|
||||||
OPT_BOOLEAN('m', "markup", &flags, "output formatting tags", 0, 0, 0),
|
break;
|
||||||
OPT_BOOLEAN('s', "positions", &flags, "output positional data", NULL, 0, 0),
|
case 'p':
|
||||||
OPT_BOOLEAN('t', "font-tags", &flags, "output missing font data tags", NULL, 0, 0),
|
flags |= FLAG_PRETTY_PRINT;
|
||||||
OPT_END()
|
break;
|
||||||
};
|
case 'm':
|
||||||
|
flags |= FLAG_HOOK_MARKUP;
|
||||||
struct argparse argparse;
|
break;
|
||||||
|
case 's':
|
||||||
argparse_init(&argparse, options, NULL, 0);
|
flags |= FLAG_POSITIONS;
|
||||||
argparse_parse(&argparse, argc, argv);
|
break;
|
||||||
|
case 't':
|
||||||
if (dict_path == NULL) {
|
flags |= FLAG_FONT_TAGS;
|
||||||
argparse_usage(&argparse);
|
break;
|
||||||
return 1;
|
default:
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind == argc) {
|
||||||
|
fprintf(stderr, "dictionary must be provided provided\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
dict_path = argv[optind];
|
||||||
|
|
||||||
Font_Context context;
|
Font_Context context;
|
||||||
if (!font_context_init(&context, font_path == 0 ? NULL : font_path)) {
|
if (!font_context_init(&context, font_path == 0 ? NULL : font_path)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user