Open Chinese Convert
0.4.3
A project for conversion between Traditional and Simplified Chinese
|
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 #include "dict_group.h" 00020 #include "dict_chain.h" 00021 00022 DictChain* dict_chain_new(Config* config) { 00023 DictChain* dict_chain = (DictChain*)malloc(sizeof(DictChain)); 00024 dict_chain->count = 0; 00025 dict_chain->config = config; 00026 return dict_chain; 00027 } 00028 00029 void dict_chain_delete(DictChain* dict_chain) { 00030 size_t i; 00031 for (i = 0; i < dict_chain->count; i++) { 00032 dict_group_delete(dict_chain->groups[i]); 00033 } 00034 free(dict_chain); 00035 } 00036 00037 DictGroup* dict_chain_add_group(DictChain* dict_chain) { 00038 if (dict_chain->count + 1 == DICTIONARY_GROUP_MAX_COUNT) { 00039 return (DictGroup*)-1; 00040 } 00041 DictGroup* group = dict_group_new(dict_chain); 00042 dict_chain->groups[dict_chain->count++] = group; 00043 return group; 00044 } 00045 00046 DictGroup* dict_chain_get_group(DictChain* dict_chain, size_t index) { 00047 if (index >= dict_chain->count) { 00048 return (DictGroup*)-1; 00049 } 00050 return dict_chain->groups[index]; 00051 }