3 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
7 chise_open_data_source (CHISE_DS *ds, CHISE_DS_Type type, char *location)
10 ds->location = location;
15 chise_close_data_source (CHISE_DS *ds)
17 ds->type = CHISE_DS_NONE;
24 chise_open_decoding_table (CHISE_Decoding_Table **db,
25 CHISE_DS *ds, const char *ccs,
27 u_int32_t accessmask, int modemask)
30 chise_open_attribute_table (db, ds->location,
31 ccs, "system-char-id",
32 real_subtype, accessmask, modemask);
36 chise_close_decoding_table (CHISE_Decoding_Table *db)
39 return chise_close_attribute_table (db);
44 chise_dt_get_char (CHISE_Decoding_Table *db, int code_point)
50 sprintf(key_buf, "%d", code_point);
51 status = chise_get_attribute_table (db, key_buf, &valdatum);
55 = (unsigned char *)chise_value_to_c_string (&valdatum);
56 int len = strlen (str);
59 if ( (len >= 2) && (str[i++] == '?') )
61 unsigned char c = str[i++];
102 if (counter + 2 <= len)
106 for (j = 0; j < counter; j++)
107 cid = (cid << 6) | (str[j + i] & 0x3F);
118 chise_open_feature_table (CHISE_Feature_Table **db,
119 CHISE_DS *ds, const char *feature,
121 u_int32_t accessmask, int modemask)
124 chise_open_attribute_table (db, ds->location,
125 "system-char-id", feature,
126 real_subtype, accessmask, modemask);
130 chise_close_feature_table (CHISE_Feature_Table *db)
133 return chise_close_attribute_table (db);
137 int chise_ft_get_value (CHISE_Feature_Table *db,
138 CHISE_Char_ID cid, CHISE_Value *valdatum)
140 unsigned char key_buf[8];
148 else if (cid <= 0x7ff)
150 key_buf[1] = (cid >> 6) | 0xc0;
151 key_buf[2] = (cid & 0x3f) | 0x80;
154 else if (cid <= 0xffff)
156 key_buf[1] = (cid >> 12) | 0xe0;
157 key_buf[2]= ((cid >> 6) & 0x3f) | 0x80;
158 key_buf[3]= (cid & 0x3f) | 0x80;
161 else if (cid <= 0x1fffff)
163 key_buf[1]= (cid >> 18) | 0xf0;
164 key_buf[2]= ((cid >> 12) & 0x3f) | 0x80;
165 key_buf[3]= ((cid >> 6) & 0x3f) | 0x80;
166 key_buf[4]= (cid & 0x3f) | 0x80;
169 else if (cid <= 0x3ffffff)
171 key_buf[1]= (cid >> 24) | 0xf8;
172 key_buf[2]= ((cid >> 18) & 0x3f) | 0x80;
173 key_buf[3]= ((cid >> 12) & 0x3f) | 0x80;
174 key_buf[4]= ((cid >> 6) & 0x3f) | 0x80;
175 key_buf[5]= (cid & 0x3f) | 0x80;
180 key_buf[1]= (cid >> 30) | 0xfc;
181 key_buf[2]= ((cid >> 24) & 0x3f) | 0x80;
182 key_buf[3]= ((cid >> 18) & 0x3f) | 0x80;
183 key_buf[4]= ((cid >> 12) & 0x3f) | 0x80;
184 key_buf[5]= ((cid >> 6) & 0x3f) | 0x80;
185 key_buf[6]= (cid & 0x3f) | 0x80;
189 chise_get_attribute_table (db, key_buf, valdatum);
194 chise_open_attribute_table (CHISE_Attribute_Table **db,
196 const char *encoding, const char *feature,
198 u_int32_t accessmask, int modemask)
206 status = db_create (&dbase, NULL, 0);
210 len = strlen (db_dir);
211 size = len + strlen (encoding) + strlen (feature) + 4;
212 db_file_name = alloca (size);
213 strcpy (db_file_name, db_dir);
214 if (db_file_name[len - 1] != '/')
216 db_file_name[len++] = '/';
217 db_file_name[len] = '\0';
219 strcat (db_file_name, encoding);
220 strcat (db_file_name, "/");
221 strcat (db_file_name, feature);
222 status = dbase->open (dbase, db_file_name, NULL,
223 real_subtype, accessmask, modemask);
226 dbase->close (dbase, 0);
234 chise_close_attribute_table (CHISE_Attribute_Table *db)
245 chise_get_attribute_table (CHISE_Attribute_Table *db,
246 char *key, CHISE_Value *valdatum)
251 /* DB Version 2 requires DBT's to be zeroed before use. */
256 keydatum.size = strlen (key);
258 status = db->get (db, NULL, &keydatum, valdatum, 0);