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_data (&valdatum);
56 int len = strnlen (str, chise_value_size (&valdatum));
59 if ( (len >= 2) && (str[i++] == '?') )
61 unsigned char c = str[i++];
78 return c & (0x80 | 0x1F);
112 if (counter + 2 <= len)
116 for (j = 0; j < counter; j++)
117 cid = (cid << 6) | (str[j + i] & 0x3F);
128 chise_open_feature_table (CHISE_Feature_Table **db,
129 CHISE_DS *ds, const char *feature,
131 u_int32_t accessmask, int modemask)
134 chise_open_attribute_table (db, ds->location,
135 "system-char-id", feature,
136 real_subtype, accessmask, modemask);
140 chise_close_feature_table (CHISE_Feature_Table *db)
143 return chise_close_attribute_table (db);
147 int chise_ft_get_value (CHISE_Feature_Table *db,
148 CHISE_Char_ID cid, CHISE_Value *valdatum)
150 unsigned char key_buf[8];
158 else if (cid <= 0x7ff)
160 key_buf[1] = (cid >> 6) | 0xc0;
161 key_buf[2] = (cid & 0x3f) | 0x80;
164 else if (cid <= 0xffff)
166 key_buf[1] = (cid >> 12) | 0xe0;
167 key_buf[2]= ((cid >> 6) & 0x3f) | 0x80;
168 key_buf[3]= (cid & 0x3f) | 0x80;
171 else if (cid <= 0x1fffff)
173 key_buf[1]= (cid >> 18) | 0xf0;
174 key_buf[2]= ((cid >> 12) & 0x3f) | 0x80;
175 key_buf[3]= ((cid >> 6) & 0x3f) | 0x80;
176 key_buf[4]= (cid & 0x3f) | 0x80;
179 else if (cid <= 0x3ffffff)
181 key_buf[1]= (cid >> 24) | 0xf8;
182 key_buf[2]= ((cid >> 18) & 0x3f) | 0x80;
183 key_buf[3]= ((cid >> 12) & 0x3f) | 0x80;
184 key_buf[4]= ((cid >> 6) & 0x3f) | 0x80;
185 key_buf[5]= (cid & 0x3f) | 0x80;
190 key_buf[1]= (cid >> 30) | 0xfc;
191 key_buf[2]= ((cid >> 24) & 0x3f) | 0x80;
192 key_buf[3]= ((cid >> 18) & 0x3f) | 0x80;
193 key_buf[4]= ((cid >> 12) & 0x3f) | 0x80;
194 key_buf[5]= ((cid >> 6) & 0x3f) | 0x80;
195 key_buf[6]= (cid & 0x3f) | 0x80;
199 chise_get_attribute_table (db, key_buf, valdatum);
204 chise_open_attribute_table (CHISE_Attribute_Table **db,
206 const char *encoding, const char *feature,
208 u_int32_t accessmask, int modemask)
216 status = db_create (&dbase, NULL, 0);
220 len = strlen (db_dir);
221 size = len + strlen (encoding) + strlen (feature) + 4;
222 db_file_name = alloca (size);
223 strcpy (db_file_name, db_dir);
224 if (db_file_name[len - 1] != '/')
226 db_file_name[len++] = '/';
227 db_file_name[len] = '\0';
229 strcat (db_file_name, encoding);
230 strcat (db_file_name, "/");
231 strcat (db_file_name, feature);
232 status = dbase->open (dbase, db_file_name, NULL,
233 real_subtype, accessmask, modemask);
236 dbase->close (dbase, 0);
244 chise_close_attribute_table (CHISE_Attribute_Table *db)
255 chise_get_attribute_table (CHISE_Attribute_Table *db,
256 char *key, CHISE_Value *valdatum)
261 /* DB Version 2 requires DBT's to be zeroed before use. */
266 keydatum.size = strlen (key);
268 status = db->get (db, NULL, &keydatum, valdatum, 0);