Christian Egli | bbf00fd | 2009-11-12 10:02:23 +0000 | [diff] [blame] | 1 | /* liblouis Braille Translation and Back-Translation Library |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 2 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 3 | Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by The |
| 4 | BRLTTY Team |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 5 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 6 | Copyright (C) 2004, 2005, 2006 ViewPlus Technologies, Inc. www.viewplus.com |
| 7 | Copyright (C) 2004, 2005, 2006 JJB Software, Inc. www.jjb-software.com |
| 8 | Copyright (C) 2016 Mike Gray, American Printing House for the Blind |
| 9 | Copyright (C) 2016 Davy Kager, Dedicon |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 10 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 11 | This file is part of liblouis. |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 12 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 13 | liblouis is free software: you can redistribute it and/or modify it |
| 14 | under the terms of the GNU Lesser General Public License as published |
| 15 | by the Free Software Foundation, either version 2.1 of the License, or |
| 16 | (at your option) any later version. |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 17 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 18 | liblouis is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | Lesser General Public License for more details. |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 22 | |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 23 | You should have received a copy of the GNU Lesser General Public |
| 24 | License along with liblouis. If not, see <http://www.gnu.org/licenses/>. |
Christian Egli | f6ec6a5 | 2016-06-20 10:33:37 +0200 | [diff] [blame] | 25 | */ |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 26 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 27 | /** |
| 28 | * @file |
| 29 | * @brief Public API of liblouis |
| 30 | */ |
| 31 | |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 32 | #ifndef __LIBLOUIS_H_ |
| 33 | #define __LIBLOUIS_H_ |
| 34 | #ifdef __cplusplus |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 35 | extern "C" { |
| 36 | #endif /* __cplusplus */ |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 37 | |
Bert Frees | cde0fec | 2017-09-30 19:28:51 +0200 | [diff] [blame] | 38 | // clang-format interacts badly with @foo@ |
| 39 | // clang-format off |
Mike Gray | 509cee0 | 2015-08-12 19:52:06 -0400 | [diff] [blame] | 40 | typedef @WIDECHAR_TYPE@ widechar; |
Bert Frees | cde0fec | 2017-09-30 19:28:51 +0200 | [diff] [blame] | 41 | // clang-format on |
Mike Gray | 509cee0 | 2015-08-12 19:52:06 -0400 | [diff] [blame] | 42 | typedef unsigned short formtype; |
Eitan Isaacson | 84fd16c | 2008-05-29 17:38:24 +0000 | [diff] [blame] | 43 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 44 | #ifdef _MSC_VER |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 45 | #ifdef _EXPORTING |
| 46 | #define LIBLOUIS_API __declspec(dllexport) |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 47 | #else |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 48 | #define LIBLOUIS_API __declspec(dllimport) |
| 49 | #endif |
| 50 | #else |
| 51 | #define LIBLOUIS_API |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 52 | #endif |
Reiner Dolp | e8afe3c | 2017-04-21 09:51:05 +0100 | [diff] [blame] | 53 | |
| 54 | #ifdef __EMSCRIPTEN__ |
| 55 | #include "emscripten.h" |
| 56 | #define EXPORT_CALL EMSCRIPTEN_KEEPALIVE |
| 57 | #elif defined(_WIN32) |
James Teh | 115fb83 | 2009-02-14 00:47:32 +0000 | [diff] [blame] | 58 | #define EXPORT_CALL __stdcall |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 59 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 60 | char *EXPORT_CALL |
| 61 | lou_getProgramPath(void); |
James Teh | 115fb83 | 2009-02-14 00:47:32 +0000 | [diff] [blame] | 62 | #else |
| 63 | #define EXPORT_CALL |
| 64 | #endif |
| 65 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 66 | typedef enum { |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 67 | plain_text = 0x0000, |
| 68 | emph_1 = 0x0001, |
| 69 | emph_2 = 0x0002, |
| 70 | emph_3 = 0x0004, |
| 71 | emph_4 = 0x0008, |
| 72 | emph_5 = 0x0010, |
| 73 | emph_6 = 0x0020, |
| 74 | emph_7 = 0x0040, |
| 75 | emph_8 = 0x0080, |
| 76 | emph_9 = 0x0100, |
| 77 | emph_10 = 0x0200, |
| 78 | computer_braille = 0x0400, |
| 79 | no_translate = 0x0800, |
| 80 | no_contract = 0x1000, |
| 81 | // SYLLABLE_MARKER_1 0x2000, |
| 82 | // SYLLABLE_MARKER_1 0x4000 |
| 83 | // CAPSEMPH 0x4000 |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 84 | } typeforms; |
Dave Mielke | bdb0f5b | 2017-02-21 13:48:06 -0500 | [diff] [blame] | 85 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 86 | #define italic emph_1 |
Dave Mielke | bdb0f5b | 2017-02-21 13:48:06 -0500 | [diff] [blame] | 87 | #define underline emph_2 |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 88 | #define bold emph_3 |
Dave Mielke | bdb0f5b | 2017-02-21 13:48:06 -0500 | [diff] [blame] | 89 | |
| 90 | #define comp_emph_1 emph_1 |
| 91 | #define comp_emph_2 emph_2 |
| 92 | #define comp_emph_3 emph_3 |
| 93 | |
| 94 | #define EMPH_NAME_BOLD "bold" |
| 95 | #define EMPH_NAME_ITALIC "italic" |
| 96 | #define EMPH_NAME_UNDERLINE "underline" |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 97 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 98 | typedef enum { |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 99 | noContractions = 1, |
| 100 | compbrlAtCursor = 2, |
| 101 | dotsIO = 4, |
Christian Egli | 08084a6 | 2018-11-22 13:48:43 +0100 | [diff] [blame] | 102 | // for historic reasons 8 and 16 are free |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 103 | compbrlLeftCursor = 32, |
| 104 | ucBrl = 64, |
Dave Mielke | d227b78 | 2019-07-24 11:02:39 -0400 | [diff] [blame] | 105 | noUndefined = 128, |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 106 | partialTrans = 256 |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 107 | } translationModes; |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 108 | |
Dave Mielke | 4edf662 | 2019-07-24 15:48:48 -0400 | [diff] [blame] | 109 | #define noUndefinedDots noUndefined |
| 110 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 111 | LIBLOUIS_API |
Dave Mielke | 1362d52 | 2019-08-04 12:51:12 -0400 | [diff] [blame] | 112 | const char *EXPORT_CALL |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 113 | lou_version(void); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 114 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 115 | /** |
| 116 | * Return the size of widechar |
| 117 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 118 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 119 | int EXPORT_CALL |
| 120 | lou_charSize(void); |
John Boyer | 0452188 | 2010-07-05 13:29:41 +0000 | [diff] [blame] | 121 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 122 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 123 | int EXPORT_CALL |
| 124 | lou_translateString(const char *tableList, const widechar *inbuf, int *inlen, |
| 125 | widechar *outbuf, int *outlen, formtype *typeform, char *spacing, int mode); |
John Boyer | 0452188 | 2010-07-05 13:29:41 +0000 | [diff] [blame] | 126 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 127 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 128 | int EXPORT_CALL |
| 129 | lou_translate(const char *tableList, const widechar *inbuf, int *inlen, widechar *outbuf, |
| 130 | int *outlen, formtype *typeform, char *spacing, int *outputPos, int *inputPos, |
| 131 | int *cursorPos, int mode); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 132 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 133 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 134 | int EXPORT_CALL |
| 135 | lou_translatePrehyphenated(const char *tableList, const widechar *inbuf, int *inlen, |
| 136 | widechar *outbuf, int *outlen, formtype *typeform, char *spacing, int *outputPos, |
| 137 | int *inputPos, int *cursorPos, char *inputHyphens, char *outputHyphens, int mode); |
Bert Frees | b8e51e1 | 2012-10-22 12:34:30 +0000 | [diff] [blame] | 138 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 139 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 140 | int EXPORT_CALL |
| 141 | lou_hyphenate( |
| 142 | const char *tableList, const widechar *inbuf, int inlen, char *hyphens, int mode); |
Christian Egli | 64f6336 | 2018-05-25 16:02:26 +0200 | [diff] [blame] | 143 | |
| 144 | /** |
| 145 | * Convert a string of dot patterns to a string of chars |
| 146 | * |
| 147 | * @param[in] tableList comma separated list of braille tables |
| 148 | * @param[in] inbuf widechar string of dot patterns, either in liblouis format or Unicode |
| 149 | * braille |
| 150 | * @param[out] outbuf widechar string corresponding to the dot patterns in `inbuf` |
| 151 | * @param[in,out] length of both `inbuf` and `outbuf` |
| 152 | * @param[in] mode (deprecated) |
| 153 | * |
| 154 | * @return 1 on success and 0 on failure. |
| 155 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 156 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 157 | int EXPORT_CALL |
| 158 | lou_dotsToChar( |
| 159 | const char *tableList, widechar *inbuf, widechar *outbuf, int length, int mode); |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 160 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 161 | int EXPORT_CALL |
| 162 | lou_charToDots(const char *tableList, const widechar *inbuf, widechar *outbuf, int length, |
| 163 | int mode); |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 164 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 165 | int EXPORT_CALL |
| 166 | lou_backTranslateString(const char *tableList, const widechar *inbuf, int *inlen, |
| 167 | widechar *outbuf, int *outlen, formtype *typeform, char *spacing, int mode); |
Bert Frees | b8e51e1 | 2012-10-22 12:34:30 +0000 | [diff] [blame] | 168 | |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 169 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 170 | int EXPORT_CALL |
| 171 | lou_backTranslate(const char *tableList, const widechar *inbuf, int *inlen, |
| 172 | widechar *outbuf, int *outlen, formtype *typeform, char *spacing, int *outputPos, |
| 173 | int *inputPos, int *cursorPos, int mode); |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 174 | /** |
| 175 | * Print error messages to a file |
| 176 | * |
| 177 | * @deprecated As of 2.6.0, applications using liblouis should |
| 178 | * implement their own logging system. |
| 179 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 180 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 181 | void EXPORT_CALL |
| 182 | lou_logPrint(const char *format, ...); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 183 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 184 | /** |
| 185 | * Specify the name of the file to be used by lou_logPrint. |
| 186 | * |
| 187 | * If it is not used, this file is stderr |
Reiner Dolp | 555590e | 2017-03-09 20:31:09 +0000 | [diff] [blame] | 188 | * |
| 189 | * @deprecated As of 2.6.0, applications using liblouis should |
| 190 | * implement their own logging system. |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 191 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 192 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 193 | void EXPORT_CALL |
| 194 | lou_logFile(const char *filename); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 195 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 196 | /** |
Leonard de Ruijter | 7ba97d9 | 2018-09-07 17:04:56 +0200 | [diff] [blame] | 197 | * Read a character from a file, whether big-endian, little-endian or ASCII8 |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 198 | * |
| 199 | * and return it as an integer. EOF at end of file. Mode = 1 on first |
| 200 | * call, any other value thereafter |
| 201 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 202 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 203 | int EXPORT_CALL |
| 204 | lou_readCharFromFile(const char *fileName, int *mode); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 205 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 206 | /** |
| 207 | * Close the log file so it can be read by other functions. |
Reiner Dolp | 555590e | 2017-03-09 20:31:09 +0000 | [diff] [blame] | 208 | * |
| 209 | * @deprecated As of 2.6.0, applications using liblouis should |
| 210 | * implement their own logging system. |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 211 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 212 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 213 | void EXPORT_CALL |
| 214 | lou_logEnd(void); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 215 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 216 | /** |
| 217 | * Load and compile a translation table |
| 218 | * |
| 219 | * Check the table for errors. If none are found load the table into |
| 220 | * memory and return a pointer to it. If errors are found return a |
| 221 | * null pointer. It is called by lou_translateString() and |
| 222 | * lou_backTranslateString() and also by functions in liblouisutdml |
| 223 | * and by the tools. |
| 224 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 225 | LIBLOUIS_API |
Bert Frees | 47e6911 | 2019-08-22 13:09:36 +0200 | [diff] [blame] | 226 | const void *EXPORT_CALL |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 227 | lou_getTable(const char *tableList); |
John Boyer | 868abc5 | 2010-11-06 07:46:55 +0000 | [diff] [blame] | 228 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 229 | /** |
| 230 | * Check a translation table for errors. |
| 231 | * |
| 232 | * If no errors are found it load the table into memory and returns a |
| 233 | * non-zero value. Else the return value is 0. |
| 234 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 235 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 236 | int EXPORT_CALL |
| 237 | lou_checkTable(const char *tableList); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 238 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 239 | /** |
| 240 | * Register a new table resolver. Overrides the default resolver. */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 241 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 242 | void EXPORT_CALL |
Christian Egli | dd7b2fe | 2018-09-03 09:35:09 +0200 | [diff] [blame] | 243 | lou_registerTableResolver( |
| 244 | char **(EXPORT_CALL *resolver)(const char *table, const char *base)); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 245 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 246 | /** |
| 247 | * Compile a table entry on the fly at run-time |
| 248 | * |
| 249 | * This function enables you to compile a table entry on the fly at |
| 250 | * run-time. The new entry is added to tableList and remains in |
| 251 | * force until lou_free() is called. If tableList has not |
| 252 | * previously been loaded it is loaded and compiled. |
| 253 | * |
| 254 | * @param inString contains the table entry to be added. It may be |
| 255 | * anything valid. Error messages will be produced if it is invalid. |
| 256 | * |
| 257 | * @return 1 on success and 0 on failure. |
| 258 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 259 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 260 | int EXPORT_CALL |
| 261 | lou_compileString(const char *tableList, const char *inString); |
Bert Frees | dc97ef7 | 2014-02-10 14:26:09 +0000 | [diff] [blame] | 262 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 263 | /** |
Davy Kager | 511d91e | 2016-07-11 14:15:44 +0200 | [diff] [blame] | 264 | * Get the typeform bit for the named emphasis class. |
| 265 | * |
| 266 | * If the table defines the specified emphasis class the corresponding |
| 267 | * typeform is returned. Else the return value is 0. |
| 268 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 269 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 270 | formtype EXPORT_CALL |
| 271 | lou_getTypeformForEmphClass(const char *tableList, const char *emphClass); |
Davy Kager | 511d91e | 2016-07-11 14:15:44 +0200 | [diff] [blame] | 272 | |
| 273 | /** |
Dave Mielke | 15e99e0 | 2017-02-21 16:41:37 -0500 | [diff] [blame] | 274 | * Return the emphasis class names declared in tableList as a |
Dave Mielke | 412b5e0 | 2017-02-22 04:32:50 -0500 | [diff] [blame] | 275 | * NULL-terminated array of strings. The array is acquired with malloc() |
| 276 | * and should be released with free(). The strings must not be released, |
| 277 | * and are no longer valid after lou_free() has been called. |
Dave Mielke | 15e99e0 | 2017-02-21 16:41:37 -0500 | [diff] [blame] | 278 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 279 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 280 | char const **EXPORT_CALL |
| 281 | lou_getEmphClasses(const char *tableList); |
Dave Mielke | 15e99e0 | 2017-02-21 16:41:37 -0500 | [diff] [blame] | 282 | |
| 283 | /** |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 284 | * Set the path used for searching for tables and liblouisutdml files. |
| 285 | * |
Christian Egli | f432de3 | 2023-02-08 11:18:27 +0100 | [diff] [blame^] | 286 | * Overrides the installation path. Returns NULL if `path` is NULL or |
| 287 | * if the length of `path` is equal or longer than `MAXSTRING`. */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 288 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 289 | char *EXPORT_CALL |
| 290 | lou_setDataPath(const char *path); |
John Boyer | 4382c41 | 2012-06-20 16:15:13 +0000 | [diff] [blame] | 291 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 292 | /** |
| 293 | * Get the path set in the previous function. */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 294 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 295 | char *EXPORT_CALL |
| 296 | lou_getDataPath(void); |
John Boyer | 4382c41 | 2012-06-20 16:15:13 +0000 | [diff] [blame] | 297 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 298 | typedef enum { |
Christian Egli | 547815d | 2019-03-04 09:46:51 +0100 | [diff] [blame] | 299 | LOU_LOG_ALL = 0, |
| 300 | LOU_LOG_DEBUG = 10000, |
| 301 | LOU_LOG_INFO = 20000, |
| 302 | LOU_LOG_WARN = 30000, |
| 303 | LOU_LOG_ERROR = 40000, |
| 304 | LOU_LOG_FATAL = 50000, |
| 305 | LOU_LOG_OFF = 60000 |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 306 | } logLevels; |
| 307 | |
Christian Egli | ae25355 | 2019-11-18 13:11:53 +0100 | [diff] [blame] | 308 | typedef void(EXPORT_CALL *logcallback)(logLevels level, const char *message); |
Christian Egli | 46ac724 | 2016-07-14 11:48:07 +0200 | [diff] [blame] | 309 | |
| 310 | /** |
| 311 | * Register logging callbacks |
| 312 | * Set to NULL for default callback. |
| 313 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 314 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 315 | void EXPORT_CALL |
| 316 | lou_registerLogCallback(logcallback callback); |
Christian Egli | 46ac724 | 2016-07-14 11:48:07 +0200 | [diff] [blame] | 317 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 318 | /** |
| 319 | * Set the level for logging callback to be called at |
| 320 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 321 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 322 | void EXPORT_CALL |
| 323 | lou_setLogLevel(logLevels level); |
Bert Frees | 111e702 | 2015-02-10 12:57:05 +0100 | [diff] [blame] | 324 | |
Bert Frees | 6abe33d | 2019-08-07 22:52:47 +0200 | [diff] [blame] | 325 | typedef enum { LOU_ROW_BRAILLE = 0X2800 } LOU_UnicodeConstants; |
Dave Mielke | fca82cb | 2019-08-04 19:07:20 -0400 | [diff] [blame] | 326 | |
Christian Egli | 7092197 | 2019-06-04 16:33:10 +0200 | [diff] [blame] | 327 | /* ========================= Sort-of private API ========================= */ |
| 328 | |
| 329 | /** |
| 330 | * Definitions of braille dots |
| 331 | */ |
| 332 | typedef enum BrailleDots { |
Christian Egli | f04d3dc | 2022-01-13 10:57:30 +0100 | [diff] [blame] | 333 | LOU_DOT_1 = 0X01, /** dot 1 */ |
| 334 | LOU_DOT_2 = 0X02, /** dot 2 */ |
| 335 | LOU_DOT_3 = 0X04, /** dot 3 */ |
| 336 | LOU_DOT_4 = 0X08, /** dot 4 */ |
| 337 | LOU_DOT_5 = 0X10, /** dot 5 */ |
| 338 | LOU_DOT_6 = 0X20, /** dot 6 */ |
| 339 | LOU_DOT_7 = 0X40, /** dot 7 */ |
| 340 | LOU_DOT_8 = 0X80, /** dot 8 */ |
| 341 | LOU_DOT_9 = 0X100, /** virtual dot 9 */ |
| 342 | LOU_DOT_10 = 0X200, /** virtual dot A */ |
| 343 | LOU_DOT_11 = 0X400, /** virtual dot B */ |
| 344 | LOU_DOT_12 = 0X800, /** virtual dot C */ |
Christian Egli | 25a72e4 | 2019-06-04 16:53:16 +0200 | [diff] [blame] | 345 | LOU_DOT_13 = 0X1000, /** virtual dot D */ |
| 346 | LOU_DOT_14 = 0X2000, /** virtual dot E */ |
| 347 | LOU_DOT_15 = 0X4000, /** virtual dot F */ |
Christian Egli | f04d3dc | 2022-01-13 10:57:30 +0100 | [diff] [blame] | 348 | LOU_DOTS = 0X8000 /** if this bit is true, the widechar represents a dot pattern */ |
Christian Egli | 7092197 | 2019-06-04 16:33:10 +0200 | [diff] [blame] | 349 | } BrailleDots; |
| 350 | |
Christian Egli | 25a72e4 | 2019-06-04 16:53:16 +0200 | [diff] [blame] | 351 | /** |
Christian Egli | 56e879e | 2019-06-12 11:35:34 +0200 | [diff] [blame] | 352 | * A sentinel, used in liblouisutdml |
Christian Egli | 25a72e4 | 2019-06-04 16:53:16 +0200 | [diff] [blame] | 353 | */ |
Christian Egli | 7092197 | 2019-06-04 16:33:10 +0200 | [diff] [blame] | 354 | #define LOU_ENDSEGMENT 0xffff |
| 355 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 356 | /** |
| 357 | * Parse, analyze and index tables. |
| 358 | * |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 359 | * This function must be called prior to lou_findTable() and |
| 360 | * lou_listTables(). Table names must be provided as a NULL-terminated |
| 361 | * array of strings. Each table should resolve to exactly one file. An |
| 362 | * error message is given when a table contains invalid or duplicate |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 363 | * metadata fields. |
Bert Frees | 111e702 | 2015-02-10 12:57:05 +0100 | [diff] [blame] | 364 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 365 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 366 | void EXPORT_CALL |
| 367 | lou_indexTables(const char **tables); |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * Find the best match for a query. |
| 371 | * |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 372 | * Returns the name of the table, or NULL when no match can be |
| 373 | * found. If lou_indexTables() has not been previously called, the |
| 374 | * table search path specified with LOUIS_TABLEPATH will be indexed |
| 375 | * first. An error message is given when the query is invalid. Freeing |
| 376 | * the memory of the returned string is the responsibility of the |
| 377 | * caller. |
Bert Frees | 111e702 | 2015-02-10 12:57:05 +0100 | [diff] [blame] | 378 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 379 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 380 | char *EXPORT_CALL |
| 381 | lou_findTable(const char *query); |
Bert Frees | 111e702 | 2015-02-10 12:57:05 +0100 | [diff] [blame] | 382 | |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 383 | /** |
Bert Frees | 84f9dbf | 2017-11-12 22:38:01 +0100 | [diff] [blame] | 384 | * Find all matches for a query, best match first. |
| 385 | * |
| 386 | * Returns the names of the matched table as a NULL-terminated array |
| 387 | * of string. If lou_indexTables() has not been previously called, the |
| 388 | * table search path specified with LOUIS_TABLEPATH will be indexed |
| 389 | * first. An error message is given when the query is invalid. Freeing |
| 390 | * the memory of the returned array and strings is the responsibility |
| 391 | * of the caller. |
| 392 | */ |
| 393 | LIBLOUIS_API |
| 394 | char **EXPORT_CALL |
| 395 | lou_findTables(const char *query); |
| 396 | |
| 397 | /** |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 398 | * Read metadata from a file. |
| 399 | * |
Bert Frees | ed31526 | 2022-01-13 14:53:05 +0100 | [diff] [blame] | 400 | * Returns the value of the first occuring metadata field specified by |
| 401 | * `key' in `table', or NULL when the field does not exist. Freeing |
| 402 | * the memory of the returned string is the responsibility of the |
| 403 | * caller. |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 404 | */ |
| 405 | LIBLOUIS_API |
Dave Mielke | 94cd313 | 2019-08-03 21:54:45 -0400 | [diff] [blame] | 406 | char *EXPORT_CALL |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 407 | lou_getTableInfo(const char *table, const char *key); |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 408 | |
| 409 | /** |
| 410 | * List available tables. |
| 411 | * |
| 412 | * Returns the names of available tables as a NULL-terminated array of |
| 413 | * strings. Only tables that are discoverable, i.e. the have active |
| 414 | * metadata, are listed. If lou_indexTables() has not been previously |
| 415 | * called, the table search path specified with LOUIS_TABLEPATH will |
| 416 | * be indexed first. Freeing the memory of the returned array and |
| 417 | * strings is the responsibility of the caller. |
| 418 | */ |
| 419 | LIBLOUIS_API |
Dave Mielke | 94cd313 | 2019-08-03 21:54:45 -0400 | [diff] [blame] | 420 | char **EXPORT_CALL |
Christian Egli | e9462e7 | 2018-05-08 11:50:02 +0200 | [diff] [blame] | 421 | lou_listTables(void); |
Bert Frees | 0350ec0 | 2017-07-01 14:46:51 +0200 | [diff] [blame] | 422 | |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 423 | /** |
| 424 | * Free all memory allocated by liblouis. |
| 425 | * |
| 426 | * This function should be called at the end of the application to |
| 427 | * free all memory allocated by liblouis. |
| 428 | */ |
Davy Kager | 0eaa2bf | 2017-04-21 14:59:06 +0200 | [diff] [blame] | 429 | LIBLOUIS_API |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 430 | void EXPORT_CALL |
| 431 | lou_free(void); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 432 | |
| 433 | #ifdef __cplusplus |
| 434 | } |
Christian Egli | e190f58 | 2016-06-30 15:37:29 +0200 | [diff] [blame] | 435 | #endif /* __cplusplus */ |
| 436 | #endif /* __LIBLOUIS_H_ */ |