1
/***************************************************************************
2
* Copyright (C) 2012~2012 by Yichao Yu *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program 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 General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#ifndef _PINYIN_ENHANCE_MAP_H
22
#define _PINYIN_ENHANCE_MAP_H
24
#define PYENHANCE_MAP_BLANK " \t\b\r\n"
28
typedef struct _PyEnhanceMapWord PyEnhanceMapWord;
29
struct _PyEnhanceMapWord {
30
PyEnhanceMapWord *next;
33
py_enhance_map_word(const PyEnhanceMapWord *word)
35
return ((void*)(intptr_t)word) + sizeof(PyEnhanceMapWord);
38
typedef struct _PyEnhanceMap PyEnhanceMap;
39
struct _PyEnhanceMap {
40
PyEnhanceMapWord *words;
44
static inline PyEnhanceMap*
45
py_enhance_map_next(PyEnhanceMap *map)
47
return (PyEnhanceMap*)map->hh.next;
51
py_enhance_map_key(PyEnhanceMap *map)
53
return (void*)map + sizeof(PyEnhanceMap);
55
void PinyinEnhanceMapAdd(PyEnhanceMap **map, FcitxMemoryPool *pool,
56
const char *key, unsigned int key_l,
57
const char *word, unsigned int word_l);
58
PyEnhanceMapWord *PinyinEnhanceMapGet(PyEnhanceMap *map,
59
const char *key, unsigned int key_l);
61
PinyinEnhanceMapClear(PyEnhanceMap **map, FcitxMemoryPool *pool)
64
if (fcitx_likely(pool)) {
65
fcitx_memory_pool_clear(pool);
68
void PinyinEnhanceMapLoad(PyEnhanceMap **map, FcitxMemoryPool *pool, FILE *fp);
70
#endif /* _PINYIN_ENHANCE_MAP_H */