EB_Error_Code QEb::setHook(const EB_Hook hook) { EB_Error_Code ecode = eb_set_hook(&hookset, &hook); if (ecode != EB_SUCCESS) dispError("eb_set_hooks", ecode); return ecode; }
/*------------------------------------------------------------------------ -- Name: init -- -- Description: -- Initialize EB Lib, set hooks, open the desired subbook. -- -- Parameters: -- None. -- -- Returns: -- None. -- ------------------------------------------------------------------------*/ static void init(void) { EB_Error_Code error_code; EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; FILE *out_file = NULL; int subbook_count; /* Blank the output file */ out_file = fopen(out_path, "w"); if(out_file == NULL) { fprintf(stderr, "Error: Could not open output file, \"%s\"\n", out_path); die(1); } fclose(out_file); /* Init EB Lib */ eb_initialize_library(); eb_initialize_book(&book); eb_initialize_hookset(&hookset); /* Set hooks */ eb_set_hook(&hookset, &hook_narrow_font); eb_set_hook(&hookset, &hook_wide_font); if(set_emphasis_hook) { eb_set_hook(&hookset, &hook_begin_emphasis); eb_set_hook(&hookset, &hook_end_emphasis); } if(set_keyword_hook) { eb_set_hook(&hookset, &hook_begin_keyword); eb_set_hook(&hookset, &hook_end_keyword); } if(set_reference_hook) { eb_set_hook(&hookset, &hook_begin_reference); eb_set_hook(&hookset, &hook_end_reference); } if(set_subscript_hook) { eb_set_hook(&hookset, &hook_begin_subscript); eb_set_hook(&hookset, &hook_end_subscript); } if(set_superscript_hook) { eb_set_hook(&hookset, &hook_begin_superscript); eb_set_hook(&hookset, &hook_end_superscript); } /* Open the EPWING book */ error_code = eb_bind(&book, book_path); if(error_code != EB_SUCCESS) { fprintf(stderr, "Error: Failed to bind the book, %s: %s\n", eb_error_message(error_code), book_path); die(1); } /* Get the subbook list */ error_code = eb_subbook_list(&book, subbook_list, &subbook_count); if(error_code != EB_SUCCESS) { fprintf(stderr, "Error: Failed to get the subbbook list, %s\n", eb_error_message(error_code)); die(1); } /* Get the subbook */ error_code = eb_set_subbook(&book, subbook_list[subbook_index]); if(error_code != EB_SUCCESS) { fprintf(stderr, "Error: Failed to set the current subbook, %s\n", eb_error_message(error_code)); die(1); } /* Get the subbook directory (the name only, not the full path) */ error_code = eb_subbook_directory(&book, subbook_directory); if(error_code != EB_SUCCESS) { fprintf(stderr, "Error: Failed to get the subbook directory: %s\n", eb_error_message(error_code)); die(1); } /* Set the font */ if (eb_set_font(&book, EB_FONT_16) < 0) { fprintf(stderr, "Error: Failed to set the font size: %s\n", eb_error_message(error_code)); die(1); } } /* init */