WIP
This commit is contained in:
parent
a842a7265e
commit
61ccf7d091
24
main.c
24
main.c
@ -133,16 +133,17 @@ static void export_subbook(EB_Book* book, Subbook* subbook_data) {
|
|||||||
|
|
||||||
static void export_book(const char path[], Book* book_data) {
|
static void export_book(const char path[], Book* book_data) {
|
||||||
do {
|
do {
|
||||||
if (eb_initialize_library() != EB_SUCCESS) {
|
EB_Error_Code error;
|
||||||
strcpy(book_data->error, "failed to initialize library");
|
if ((error = eb_initialize_library()) != EB_SUCCESS) {
|
||||||
|
strcpy(book_data->error, eb_error_message(error));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
EB_Book book;
|
EB_Book book;
|
||||||
eb_initialize_book(&book);
|
eb_initialize_book(&book);
|
||||||
|
|
||||||
if (eb_bind(&book, path) != EB_SUCCESS) {
|
if ((error = eb_bind(&book, path)) != EB_SUCCESS) {
|
||||||
strcpy(book_data->error, "failed to bind book to path");
|
strcpy(book_data->error, eb_error_message(error));
|
||||||
eb_finalize_book(&book);
|
eb_finalize_book(&book);
|
||||||
eb_finalize_library();
|
eb_finalize_library();
|
||||||
break;
|
break;
|
||||||
@ -182,24 +183,23 @@ static void export_book(const char path[], Book* book_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EB_Subbook_Code sub_codes[EB_MAX_SUBBOOKS];
|
EB_Subbook_Code sub_codes[EB_MAX_SUBBOOKS];
|
||||||
if (eb_subbook_list(&book, sub_codes, &book_data->subbook_count) != EB_SUCCESS) {
|
if ((error = eb_subbook_list(&book, sub_codes, &book_data->subbook_count)) == EB_SUCCESS) {
|
||||||
eb_finalize_book(&book);
|
|
||||||
eb_finalize_library();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (book_data->subbook_count > 0) {
|
if (book_data->subbook_count > 0) {
|
||||||
book_data->subbooks = calloc(book_data->subbook_count, sizeof(Subbook));
|
book_data->subbooks = calloc(book_data->subbook_count, sizeof(Subbook));
|
||||||
for (int i = 0; i < book_data->subbook_count; ++i) {
|
for (int i = 0; i < book_data->subbook_count; ++i) {
|
||||||
Subbook* subbook_data = book_data->subbooks + i;
|
Subbook* subbook_data = book_data->subbooks + i;
|
||||||
if (eb_set_subbook(&book, sub_codes[i]) == EB_SUCCESS) {
|
if ((error = eb_set_subbook(&book, sub_codes[i])) == EB_SUCCESS) {
|
||||||
export_subbook(&book, subbook_data);
|
export_subbook(&book, subbook_data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strcpy(subbook_data->error, "failed to set subbook");
|
strcpy(subbook_data->error, eb_error_message(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcpy(book_data->error, eb_error_message(error));
|
||||||
|
}
|
||||||
|
|
||||||
eb_finalize_book(&book);
|
eb_finalize_book(&book);
|
||||||
eb_finalize_library();
|
eb_finalize_library();
|
||||||
|
Loading…
Reference in New Issue
Block a user