1
This commit is contained in:
Alex Yatskov 2016-11-19 11:31:20 -08:00
parent 07021c4a5d
commit 29164873f4
4 changed files with 17 additions and 17 deletions

View File

@ -207,12 +207,12 @@ static const EB_Hook s_hooks[] = {
{ EB_HOOK_END_WAVE, HOOK_FUNC_NAME(end_wave) },
{ EB_HOOK_GB2312, HOOK_FUNC_NAME(gb2312) },
{ EB_HOOK_ISO8859_1, HOOK_FUNC_NAME(iso8859_1) },
{ EB_HOOK_NARROW_FONT, HOOK_FUNC_NAME(narrow_font) },
{ EB_HOOK_NARROW_JISX0208, HOOK_FUNC_NAME(narrow_jisx0208) },
/* { EB_HOOK_NARROW_FONT, HOOK_FUNC_NAME(narrow_font) }, */
/* { EB_HOOK_NARROW_JISX0208, HOOK_FUNC_NAME(narrow_jisx0208) }, */
{ EB_HOOK_NEWLINE, HOOK_FUNC_NAME(newline) },
{ EB_HOOK_SET_INDENT, HOOK_FUNC_NAME(set_indent) },
{ EB_HOOK_WIDE_FONT, HOOK_FUNC_NAME(wide_font) },
{ EB_HOOK_WIDE_JISX0208, HOOK_FUNC_NAME(wide_jisx0208) },
/* { EB_HOOK_WIDE_FONT, HOOK_FUNC_NAME(wide_font) }, */
/* { EB_HOOK_WIDE_JISX0208, HOOK_FUNC_NAME(wide_jisx0208) }, */
{ EB_HOOK_NULL, HOOK_FUNC_NAME(null) },
};

18
main.c
View File

@ -54,14 +54,14 @@ static void export_subbook_entries(EB_Book* eb_book, Subbook* subbook) {
}
Entry* entry = subbook->entries + subbook->entry_count++;
entry->heading = read_book_data(eb_book, &hit->heading, READ_MODE_HEADING);
entry->text = read_book_data(eb_book, &hit->text, READ_MODE_TEXT);
entry->heading = read_book_data(eb_book, eb_hookset, &hit->heading, READ_MODE_HEADING);
entry->text = read_book_data(eb_book, eb_hookset, &hit->text, READ_MODE_TEXT);
}
}
while (hit_count > 0);
}
static void export_subbook(EB_Book* eb_book, Subbook* subbook) {
static void export_subbook(EB_Book* eb_book, EB_Hookset* eb_hookset, Subbook* subbook) {
char title[EB_MAX_TITLE_LENGTH + 1];
if (eb_subbook_title(eb_book, title) == EB_SUCCESS) {
subbook->title = eucjp_to_utf8(title);
@ -70,20 +70,20 @@ static void export_subbook(EB_Book* eb_book, Subbook* subbook) {
if (eb_have_copyright(eb_book)) {
EB_Position position;
if (eb_copyright(eb_book, &position) == EB_SUCCESS) {
subbook->copyright = read_book_data(eb_book, &position, READ_MODE_TEXT);
subbook->copyright = read_book_data(eb_book, eb_hookset, &position, READ_MODE_TEXT);
}
}
if (eb_search_all_alphabet(eb_book) == EB_SUCCESS) {
export_subbook_entries(eb_book, subbook);
export_subbook_entries(eb_book, eb_hookset, subbook);
}
if (eb_search_all_kana(eb_book) == EB_SUCCESS) {
export_subbook_entries(eb_book, subbook);
export_subbook_entries(eb_book, eb_hookset, subbook);
}
if (eb_search_all_asis(eb_book) == EB_SUCCESS) {
export_subbook_entries(eb_book, subbook);
export_subbook_entries(eb_book, eb_hookset, subbook);
}
}
@ -150,7 +150,7 @@ static void export_book(const char path[], Book* book) {
for (int i = 0; i < book->subbook_count; ++i) {
Subbook* subbook = book->subbooks + i;
if ((error = eb_set_subbook(&eb_book, sub_codes[i])) == EB_SUCCESS) {
export_subbook(&eb_book, subbook);
export_subbook(&eb_book, &eb_hookset, subbook);
}
else {
fprintf(stderr, "Failed to set subbook: %s\n", eb_error_message(error));
@ -172,7 +172,7 @@ static void export_book(const char path[], Book* book) {
int main(int argc, char *argv[]) {
bool pretty_print = false;
char opt;
char opt = 0;
while ((opt = getopt(argc, argv, "p")) != -1) {
switch (opt) {
case 'p':

6
util.c
View File

@ -31,7 +31,7 @@
#define MAX_TEXT 1024
char* read_book_data(EB_Book* book, const EB_Position* position, ReadMode mode) {
char* read_book_data(EB_Book* book, EB_Hookset* hookset, const EB_Position* position, ReadMode mode) {
if (eb_seek_text(book, position) != EB_SUCCESS) {
return NULL;
}
@ -45,7 +45,7 @@ char* read_book_data(EB_Book* book, const EB_Position* position, ReadMode mode)
error = eb_read_text(
book,
NULL,
NULL,
hookset,
NULL,
MAX_TEXT - 1,
data,
@ -56,7 +56,7 @@ char* read_book_data(EB_Book* book, const EB_Position* position, ReadMode mode)
error = eb_read_heading(
book,
NULL,
NULL,
hookset,
NULL,
MAX_TEXT - 1,
data,

2
util.h
View File

@ -67,7 +67,7 @@ typedef enum {
READ_MODE_HEADING,
} ReadMode;
char* read_book_data(EB_Book* book, const EB_Position* position, ReadMode mode);
char* read_book_data(EB_Book* book, EB_Hookset* hookset, const EB_Position* position, ReadMode mode);
void free_book(Book* book);
void dump_book(Book* book, bool pretty_print, FILE* fp);