diff --git a/book.c b/book.c index e5f1314..0e520d2 100644 --- a/book.c +++ b/book.c @@ -128,10 +128,10 @@ static void subbook_undupe(Book_Subbook* subbook) { Book_Entry* entry = subbook->entries + i; Page* page = pages + entry->text.page; - bool found = false; + int found = 0; for (int j = 0; j < page->offset_count; ++j) { if (entry->text.offset == page->offsets[j]){ - found = true; + found = 1; break; } } @@ -325,7 +325,7 @@ void book_free(Book* book) { memset(book, 0, sizeof(Book)); } -bool book_export(FILE* fp, const Book* book, int flags) { +int book_export(FILE* fp, const Book* book, int flags) { json_t* book_json = json_object(); book_encode(book_json, book, flags); @@ -340,11 +340,11 @@ bool book_export(FILE* fp, const Book* book, int flags) { } -bool book_import(Book* book, const Font_Context* context, const char path[], int flags) { +int book_import(Book* book, const Font_Context* context, const char path[], int flags) { EB_Error_Code error; if ((error = eb_initialize_library()) != EB_SUCCESS) { fprintf(stderr, "Failed to initialize library: %s\n", eb_error_message(error)); - return false; + return 0; } EB_Book eb_book; @@ -359,7 +359,7 @@ bool book_import(Book* book, const Font_Context* context, const char path[], int eb_finalize_book(&eb_book); eb_finalize_hookset(&eb_hookset); eb_finalize_library(); - return false; + return 0; } EB_Character_Code char_code; @@ -425,5 +425,5 @@ bool book_import(Book* book, const Font_Context* context, const char path[], int eb_finalize_library(); book_undupe(book); - return true; + return 1; } diff --git a/book.h b/book.h index fee7fb2..30e6f38 100644 --- a/book.h +++ b/book.h @@ -20,7 +20,6 @@ #define BOOK_H #include -#include #include "font.h" @@ -60,7 +59,7 @@ typedef struct { void book_init(Book* book); void book_free(Book* book); -bool book_import(Book* book, const Font_Context* context, const char path[], int flags); -bool book_export(FILE* fp, const Book* book, int flags); +int book_import(Book* book, const Font_Context* context, const char path[], int flags); +int book_export(FILE* fp, const Book* book, int flags); #endif /* BOOK_H */ diff --git a/font.c b/font.c index 17aea2d..1d2bcd9 100644 --- a/font.c +++ b/font.c @@ -16,9 +16,8 @@ * along with this program. If not, see . */ -#include -#include #include +#include #include "jansson/include/jansson.h" @@ -50,7 +49,7 @@ static char nibble_to_ascii(int n) { return n <= 0x0f ? hex[n] : 0; } -static bool is_ascii_nibble(char c) { +static int is_ascii_nibble(char c) { return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); } @@ -202,11 +201,11 @@ void font_stub_encode(char output[], int size, int code, const Font_Table* table void font_stub_decode(char output[], int size, const char input[]) { const char* ptr_in = input; char* ptr_out = output; - bool decode = false; + int decode = 0; while (*ptr_in != 0 && ptr_out - output < size - 1) { if (strncmp(ptr_in, "{#", 2) == 0) { - decode = true; + decode = 1; ptr_in += 2; } @@ -222,7 +221,7 @@ void font_stub_decode(char output[], int size, const char input[]) { } if (high_ascii == '}') { - decode = false; + decode = 0; --ptr_in; } else { @@ -239,23 +238,23 @@ void font_stub_decode(char output[], int size, const char input[]) { *ptr_out = 0; } -bool font_context_init(Font_Context* context, const char path[]) { +int font_context_init(Font_Context* context, const char path[]) { context->table_count = 0; context->tables = NULL; if (path == NULL) { - return true; + return 1; } json_t* table_array_json = json_load_file(path, 0, NULL); if (table_array_json == NULL) { fprintf(stderr, "Failed to load font file %s\n", path); - return false; + return 0; } parse_table_array(context, table_array_json); json_decref(table_array_json); - return true; + return 1; } void font_context_destroy(Font_Context* context) { diff --git a/font.h b/font.h index af3f5af..47a0905 100644 --- a/font.h +++ b/font.h @@ -19,8 +19,6 @@ #ifndef FONT_H #define FONT_H -#include - /* * Constants */ @@ -59,7 +57,7 @@ typedef enum { * Functions */ -bool font_context_init(Font_Context* context, const char path[]); +int font_context_init(Font_Context* context, const char path[]); void font_context_destroy(Font_Context* context); const Font_Table* font_table_select(const Font_Context* context, const char name[]); diff --git a/main.c b/main.c index f5b66f9..a99b192 100644 --- a/main.c +++ b/main.c @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include #include #include @@ -80,7 +79,7 @@ int main(int argc, char *argv[]) { Book book; book_init(&book); - const bool success = + const int success = book_import(&book, &context, dict_path, flags) && book_export(stdout, &book, flags);