1
This commit is contained in:
Alex Yatskov 2016-11-18 23:25:00 -08:00
parent 10cabbe554
commit 07021c4a5d
3 changed files with 15 additions and 1 deletions

View File

@ -221,5 +221,8 @@ static const EB_Hook s_hooks[] = {
*/
void hooks_install(EB_Hookset* hookset) {
(void)hookset;
const int count = sizeof(s_hooks) / sizeof(s_hooks[0]);
for (int i = 0; i < count; ++i) {
eb_set_hook(hookset, s_hooks + i);
}
}

View File

@ -19,5 +19,8 @@
#ifndef HOOKS_H
#define HOOKS_H
#include "eb/eb/eb.h"
void hooks_install(EB_Hookset* hookset);
#endif

8
main.c
View File

@ -23,8 +23,10 @@
#include "convert.h"
#include "util.h"
#include "hooks.h"
#include "eb/eb/eb.h"
#include "eb/text.h"
#include "eb/eb/error.h"
#define MAX_HITS 256
@ -96,9 +98,14 @@ static void export_book(const char path[], Book* book) {
EB_Book eb_book;
eb_initialize_book(&eb_book);
EB_Hookset eb_hookset;
eb_initialize_hookset(&eb_hookset);
hooks_install(&eb_hookset);
if ((error = eb_bind(&eb_book, path)) != EB_SUCCESS) {
fprintf(stderr, "Failed to bind book: %s\n", eb_error_message(error));
eb_finalize_book(&eb_book);
eb_finalize_hookset(&eb_hookset);
eb_finalize_library();
break;
}
@ -156,6 +163,7 @@ static void export_book(const char path[], Book* book) {
}
eb_finalize_book(&eb_book);
eb_finalize_hookset(&eb_hookset);
eb_finalize_library();
}
while(0);