1 /* Copyright (c) 2013 - The libcangjie authors. 2 * 3 * This file is part of libcangjie. 4 * 5 * libcangjie is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * libcangjie is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with libcangjie. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef CANGJIE_H__ 20 #define CANGJIE_H__ 21 22 #include <stdint.h> 23 24 #include <sqlite3.h> 25 26 #include "cangjiecommon.h" 27 #include "cangjiecharlist.h" 28 #include "cangjieerrors.h" 29 30 31 CANGJIE_BEGIN_DECL 32 33 typedef enum CangjieVersion { 34 CANGJIE_VERSION_3 = 3, 35 CANGJIE_VERSION_5 = 5, 36 } CangjieVersion; 37 38 39 typedef enum CangjieFilter { 40 CANGJIE_FILTER_BIG5 = 1 << 0, 41 CANGJIE_FILTER_HKSCS = 1 << 1, 42 CANGJIE_FILTER_PUNCTUATION = 1 << 2, 43 CANGJIE_FILTER_CHINESE = 1 << 3, 44 CANGJIE_FILTER_ZHUYIN = 1 << 4, 45 CANGJIE_FILTER_KANJI = 1 << 5, 46 CANGJIE_FILTER_KATAKANA = 1 << 6, 47 CANGJIE_FILTER_HIRAGANA = 1 << 7, 48 CANGJIE_FILTER_SYMBOLS = 1 << 8, 49 } CangjieFilter; 50 51 52 typedef struct Cangjie { 53 uint32_t version; 54 uint32_t filter_flags; 55 56 sqlite3 *db; 57 char *cj_query; 58 char *shortcode_query; 59 } Cangjie; 60 61 CANGJIE_EXTERN int cangjie_new(Cangjie **cj, 62 CangjieVersion version, 63 CangjieFilter filter_flags); 64 65 CANGJIE_EXTERN int cangjie_get_characters(Cangjie *cj, 66 char *code, 67 CangjieCharList **l); 68 69 CANGJIE_EXTERN int cangjie_get_characters_by_shortcode(Cangjie *cj, 70 char *shortcode, 71 CangjieCharList **l); 72 73 CANGJIE_EXTERN int cangjie_get_radical(Cangjie *cj, 74 const char key, 75 char **radical); 76 77 CANGJIE_EXTERN int cangjie_is_input_key(Cangjie *cj, 78 const char key); 79 80 CANGJIE_EXTERN int cangjie_free(Cangjie *cj); 81 82 CANGJIE_END_DECL 83 84 #endif 85