Open Chinese Convert  0.4.3
A project for conversion between Traditional and Simplified Chinese
/usr/src/RPM/BUILD/opencc-0.4.3/src/common.h
00001 /*
00002  * Open Chinese Convert
00003  *
00004  * Copyright 2010-2013 BYVoid <byvoid@byvoid.com>
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *      http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #ifndef __COMMON_H_
00020 #define __COMMON_H_
00021 
00022 #include <assert.h>
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <string.h>
00026 #include <stddef.h>
00027 
00028 #include "opencc_types.h"
00029 
00030 #define INFINITY_INT ((~0U) >> 1)
00031 
00032 #ifdef ENABLE_GETTEXT
00033 # include <libintl.h>
00034 # include <locale.h>
00035 # define _(STRING) dgettext(PACKAGE_NAME, STRING)
00036 #else // ENABLE_GETTEXT
00037 # define _(STRING) STRING
00038 #endif // ENABLE_GETTEXT
00039 
00040 #ifndef PKGDATADIR
00041 #define PKGDATADIR ""
00042 #endif
00043 
00044 struct SConfig;
00045 struct SConverter;
00046 struct SDict;
00047 struct SDictGroup;
00048 struct SDictChain;
00049 struct SDictMeta;
00050 
00051 typedef struct SConfig Config;
00052 typedef struct SConverter Converter;
00053 typedef struct SDict Dict;
00054 typedef struct SDictGroup DictGroup;
00055 typedef struct SDictChain DictChain;
00056 typedef struct SDictMeta DictMeta;
00057 
00058 struct SDict {
00059   opencc_dictionary_type type;
00060   Dict* dict;
00061 };
00062 
00063 #define DICTIONARY_MAX_COUNT 128
00064 struct SDictGroup {
00065   DictChain* dict_chain;
00066   size_t count;
00067   Dict* dicts[DICTIONARY_MAX_COUNT];
00068 };
00069 
00070 #define DICTIONARY_GROUP_MAX_COUNT 128
00071 struct SDictChain {
00072   Config* config;
00073   size_t count;
00074   DictGroup* groups[DICTIONARY_GROUP_MAX_COUNT];
00075 };
00076 
00077 struct SDictMeta {
00078   opencc_dictionary_type dict_type;
00079   char* file_name;
00080   size_t index;
00081   size_t stamp;
00082 };
00083 
00084 struct SConfig {
00085   char* title;
00086   char* description;
00087   DictChain* dict_chain;
00088   char* file_path;
00089   DictMeta dicts[DICTIONARY_MAX_COUNT];
00090   size_t dicts_count;
00091   size_t stamp;
00092 };
00093 
00094 struct SConverter {
00095   opencc_conversion_mode conversion_mode;
00096   DictChain* dict_chain;
00097   DictGroup* current_dict_group;
00098   void* data;
00099 };
00100 
00101 #endif // __COMMON_H_
 All Data Structures Files Functions Variables Defines