1 /* -*- C -*- 2 * Copyright (c) 1997-2006 Motoyuki Kasahara 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the project nor the names of its contributors 13 * may be used to endorse or promote products derived from this software 14 * without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef EB_TEXT_H 30 #define EB_TEXT_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/types.h> 37 38 #ifdef EB_BUILD_LIBRARY 39 #include "defs.h" 40 #else 41 #include <eb/defs.h> 42 #endif 43 44 /* 45 * Hook codes. 46 * (When you add or remove a hook, update EB_NUMER_OF_HOOKS in defs.h.) 47 */ 48 #define EB_HOOK_NULL -1 49 #define EB_HOOK_INITIALIZE 0 50 #define EB_HOOK_BEGIN_NARROW 1 51 #define EB_HOOK_END_NARROW 2 52 #define EB_HOOK_BEGIN_SUBSCRIPT 3 53 #define EB_HOOK_END_SUBSCRIPT 4 54 55 #define EB_HOOK_SET_INDENT 5 56 #define EB_HOOK_NEWLINE 6 57 #define EB_HOOK_BEGIN_SUPERSCRIPT 7 58 #define EB_HOOK_END_SUPERSCRIPT 8 59 #define EB_HOOK_BEGIN_NO_NEWLINE 9 60 61 #define EB_HOOK_END_NO_NEWLINE 10 62 #define EB_HOOK_BEGIN_EMPHASIS 11 63 #define EB_HOOK_END_EMPHASIS 12 64 #define EB_HOOK_BEGIN_CANDIDATE 13 65 #define EB_HOOK_END_CANDIDATE_GROUP 14 66 67 #define EB_HOOK_END_CANDIDATE_LEAF 15 68 #define EB_HOOK_BEGIN_REFERENCE 16 69 #define EB_HOOK_END_REFERENCE 17 70 #define EB_HOOK_BEGIN_KEYWORD 18 71 #define EB_HOOK_END_KEYWORD 19 72 73 #define EB_HOOK_NARROW_FONT 20 74 #define EB_HOOK_WIDE_FONT 21 75 #define EB_HOOK_ISO8859_1 22 76 #define EB_HOOK_NARROW_JISX0208 23 77 #define EB_HOOK_WIDE_JISX0208 24 78 79 #define EB_HOOK_GB2312 25 80 #define EB_HOOK_BEGIN_MONO_GRAPHIC 26 81 #define EB_HOOK_END_MONO_GRAPHIC 27 82 #define EB_HOOK_BEGIN_GRAY_GRAPHIC 28 83 #define EB_HOOK_END_GRAY_GRAPHIC 29 84 85 #define EB_HOOK_BEGIN_COLOR_BMP 30 86 #define EB_HOOK_BEGIN_COLOR_JPEG 31 87 #define EB_HOOK_BEGIN_IN_COLOR_BMP 32 88 #define EB_HOOK_BEGIN_IN_COLOR_JPEG 33 89 #define EB_HOOK_END_COLOR_GRAPHIC 34 90 91 #define EB_HOOK_END_IN_COLOR_GRAPHIC 35 92 #define EB_HOOK_BEGIN_WAVE 36 93 #define EB_HOOK_END_WAVE 37 94 #define EB_HOOK_BEGIN_MPEG 38 95 #define EB_HOOK_END_MPEG 39 96 97 #define EB_HOOK_BEGIN_GRAPHIC_REFERENCE 40 98 #define EB_HOOK_END_GRAPHIC_REFERENCE 41 99 #define EB_HOOK_GRAPHIC_REFERENCE 42 100 #define EB_HOOK_BEGIN_DECORATION 43 101 #define EB_HOOK_END_DECORATION 44 102 103 #define EB_HOOK_BEGIN_IMAGE_PAGE 45 104 #define EB_HOOK_END_IMAGE_PAGE 46 105 #define EB_HOOK_BEGIN_CLICKABLE_AREA 47 106 #define EB_HOOK_END_CLICKABLE_AREA 48 107 108 #define EB_HOOK_BEGIN_UNICODE 49 109 #define EB_HOOK_END_UNICODE 50 110 #define EB_HOOK_BEGIN_EBXAC_GAIJI 51 111 #define EB_HOOK_END_EBXAC_GAIJI 52 112 #define EB_HOOK_EBXAC_GAIJI 53 113 114 /* 115 * Function declarations. 116 */ 117 /* hook.c */ 118 void eb_initialize_hookset(EB_Hookset *hookset); 119 void eb_finalize_hookset(EB_Hookset *hookset); 120 EB_Error_Code eb_set_hook(EB_Hookset *hookset, const EB_Hook *hook); 121 EB_Error_Code eb_set_hooks(EB_Hookset *hookset, const EB_Hook *hook); 122 EB_Error_Code eb_hook_euc_to_ascii(EB_Book *book, EB_Appendix *appendix, 123 void *container, EB_Hook_Code hook_code, int argc, 124 const unsigned int *argv); 125 EB_Error_Code eb_hook_stop_code(EB_Book *book, EB_Appendix *appendix, 126 void *container, EB_Hook_Code hook_code, int argc, 127 const unsigned int *argv); 128 EB_Error_Code eb_hook_narrow_character_text(EB_Book *book, 129 EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, 130 const unsigned int *argv); 131 EB_Error_Code eb_hook_wide_character_text(EB_Book *book, 132 EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, 133 const unsigned int *argv); 134 EB_Error_Code eb_hook_newline(EB_Book *book, EB_Appendix *appendix, 135 void *container, EB_Hook_Code hook_code, int argc, 136 const unsigned int *argv); 137 EB_Error_Code eb_hook_empty(EB_Book *book, EB_Appendix *appendix, 138 void *container, EB_Hook_Code hook_code, int argc, 139 const unsigned int *argv); 140 141 /* readtext.c */ 142 EB_Error_Code eb_seek_text(EB_Book *book, const EB_Position *position); 143 EB_Error_Code eb_tell_text(EB_Book *book, EB_Position *position); 144 EB_Error_Code eb_read_text(EB_Book *book, EB_Appendix *appendix, 145 EB_Hookset *hookset, void *container, size_t text_max_length, char *text, 146 ssize_t *text_length); 147 EB_Error_Code eb_read_heading(EB_Book *book, EB_Appendix *appendix, 148 EB_Hookset *hookset, void *container, size_t text_max_length, char *text, 149 ssize_t *text_length); 150 EB_Error_Code eb_read_rawtext(EB_Book *book, size_t text_max_length, 151 char *text, ssize_t *text_length); 152 int eb_is_text_stopped(EB_Book *book); 153 EB_Error_Code eb_write_text_byte1(EB_Book *book, int byte1); 154 EB_Error_Code eb_write_text_byte2(EB_Book *book, int byte1, int byte2); 155 EB_Error_Code eb_write_text_string(EB_Book *book, const char *string); 156 EB_Error_Code eb_write_text(EB_Book *book, const char * stream, 157 size_t stream_length); 158 const char *eb_current_candidate(EB_Book *book); 159 EB_Error_Code eb_forward_text(EB_Book *book, EB_Appendix *appendix); 160 EB_Error_Code eb_backward_text(EB_Book *book, EB_Appendix *appendix); 161 162 #ifdef __cplusplus 163 } 164 #endif 165 166 #endif /* not EB_TEXT_H */ 167