1 /* liblouis Braille Translation and Back-Translation Library 2 3 Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by 4 The BRLTTY Team 5 6 Copyright (C) 2004, 2005, 2006, 2009 ViewPlus Technologies, Inc. 7 www.viewplus.com and JJB Software, Inc. www.jjb-software.com 8 9 liblouis is free software: you can redistribute it and/or modify it 10 under the terms of the GNU Lesser General Public License as 11 published by the Free Software Foundation, either version 3 of the 12 License, or (at your option) any later version. 13 14 liblouis is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this program. If not, see 21 <http://www.gnu.org/licenses/>. 22 23 Maintained by John J. Boyer john.boyer@abilitiessoft.com 24 */ 25 26 #ifndef __LIBLOUIS_H_ 27 #define __LIBLOUIS_H_ 28 #ifdef __cplusplus 29 extern "C" 30 { 31 #endif /* __cplusplus */ 32 33 #define widechar unsigned short int 34 #define formtype unsigned char 35 36 #ifdef _WIN32 37 #define EXPORT_CALL __stdcall 38 char *EXPORT_CALL lou_getProgramPath (); 39 #else 40 #define EXPORT_CALL 41 #endif 42 43 typedef enum 44 { 45 plain_text = 0, 46 italic = 1, 47 underline = 2, 48 bold = 4, 49 computer_braille = 8 50 } typeforms; 51 #define comp_emph_1 italic 52 #define comp_emph_2 underline 53 #define comp_emph_3 bold 54 55 typedef enum 56 { 57 noContractions = 1, 58 compbrlAtCursor = 2, 59 dotsIO = 4, 60 comp8Dots = 8, 61 pass1Only = 16, 62 compbrlLeftCursor = 32, 63 otherTrans = 64, 64 ucBrl = 128 65 } translationModes; 66 67 char *EXPORT_CALL lou_version (); 68 69 int EXPORT_CALL lou_charSize (); 70 71 /* Return the size of widechar */ 72 73 int EXPORT_CALL lou_translateString 74 (const char *tableList, 75 const widechar * inbuf, 76 int *inlen, 77 widechar * outbuf, int *outlen, formtype *typeform, char *spacing, 78 int 79 mode); 80 81 int EXPORT_CALL lou_translate (const char *tableList, const widechar 82 * inbuf, 83 int *inlen, widechar * outbuf, int *outlen, 84 formtype *typeform, char *spacing, 85 int *outputPos, int *inputPos, 86 int *cursorPos, int mode); 87 88 int EXPORT_CALL lou_translatePrehyphenated (const char *tableList, 89 const widechar * inbuf, 90 int *inlen, widechar * outbuf, 91 int *outlen, formtype 92 *typeform, 93 char *spacing, int *outputPos, 94 int *inputPos, int *cursorPos, 95 char *inputHyphens, 96 char *outputHyphens, int mode); 97 98 int EXPORT_CALL lou_hyphenate (const char *tableList, const widechar 99 * inbuf, int inlen, char *hyphens, int mode); 100 int EXPORT_CALL lou_dotsToChar (const char *tableList, widechar * inbuf, 101 widechar * outbuf, int length, int mode); 102 int EXPORT_CALL lou_charToDots (const char *tableList, const widechar 103 * inbuf, 104 widechar * outbuf, int length, int mode); 105 int EXPORT_CALL lou_backTranslateString (const char *tableList, 106 const widechar * inbuf, 107 int *inlen, 108 widechar * outbuf, 109 int *outlen, formtype 110 *typeform, char 111 *spacing, int mode); 112 113 int EXPORT_CALL lou_backTranslate (const char *tableList, const widechar 114 * inbuf, 115 int *inlen, widechar * outbuf, 116 int *outlen, formtype *typeform, 117 char *spacing, int *outputPos, 118 int *inputPos, int *cursorPos, int mode); 119 void EXPORT_CALL lou_logPrint (const char *format, ...); 120 /* Prints error messages to a file 121 @deprecated As of 2.6.0, applications using liblouis should implement 122 their own logging system. */ 123 124 void EXPORT_CALL lou_logFile (const char *filename); 125 /* Specifies the name of the file to be used by lou_logPrint. If it is 126 * not used, this file is stderr*/ 127 128 int EXPORT_CALL lou_readCharFromFile (const char *fileName, int *mode); 129 /*Read a character from a file, whether big-encian, little-endian or 130 * ASCII8, and return it as an integer. EOF at end of file. Mode = 1 on 131 * first call, any other value thereafter*/ 132 133 void EXPORT_CALL lou_logEnd (); 134 /* Closes the log file so it can be read by other functions. */ 135 136 void *EXPORT_CALL lou_getTable (const char *tableList); 137 /* This function checks a table for errors. If none are found it loads 138 * the table into memory and returns a pointer to it. if errors are found 139 * it returns a null pointer. It is called by lou_translateString and 140 * lou_backTranslateString and also by functions in liblouisxml 141 */ 142 143 void EXPORT_CALL lou_registerTableResolver (char ** (* resolver) (const char *table, const char *base)); 144 /* Register a new table resolver. Overrides the default resolver. */ 145 146 int EXPORT_CALL lou_compileString (const char *tableList, const char 147 *inString); 148 char *EXPORT_CALL lou_setDataPath (char *path); 149 /* Set the path used for searching for tables and liblouisutdml files. 150 * Overrides the installation path. */ 151 152 char *EXPORT_CALL lou_getDataPath (); 153 /* Get the path set in the previous function. */ 154 155 // char EXPORT_CALL * lou_getTablePaths (); 156 /* Get a list of paths actually used in seraching for tables */ 157 158 typedef void (*logcallback)(int level, const char *message); 159 void EXPORT_CALL lou_registerLogCallback(logcallback callback); 160 /* Register logging callbacks 161 * Set to NULL for default callback. 162 */ 163 164 typedef enum 165 { 166 LOG_ALL = -2147483647 - 1, 167 LOG_DEBUG = 10000, 168 LOG_INFO = 20000, 169 LOG_WARN = 30000, 170 LOG_ERROR = 40000, 171 LOG_FATAL = 50000, 172 LOG_OFF = 2147483647 173 } logLevels; 174 void EXPORT_CALL lou_setLogLevel(logLevels level); 175 /* Set the level for logging callback to be called at */ 176 void EXPORT_CALL lou_free (); 177 /* This function should be called at the end of 178 * the application to free all memory allocated by liblouis. */ 179 180 #ifdef __cplusplus 181 } 182 #endif /* __cplusplus */ 183 #endif /*LibLOUIS_H_ */ 184