7 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
11 chise_open_data_source (CHISE_DS *ds, CHISE_DS_Type type, char *location)
14 ds->location = location;
19 chise_close_data_source (CHISE_DS *ds)
21 ds->type = CHISE_DS_NONE;
28 chise_open_decoding_table (CHISE_Decoding_Table **db,
29 CHISE_DS *ds, const char *ccs,
31 u_int32_t accessmask, int modemask)
34 chise_open_attribute_table (db, ds->location,
35 ccs, "system-char-id",
36 real_subtype, accessmask, modemask);
40 chise_close_decoding_table (CHISE_Decoding_Table *db)
43 return chise_close_attribute_table (db);
48 chise_dt_get_char (CHISE_Decoding_Table *db, int code_point)
54 sprintf(key_buf, "%d", code_point);
55 status = chise_get_attribute_table (db, key_buf, &valdatum);
59 = (unsigned char *)chise_value_data (&valdatum);
60 int len = strnlen (str, chise_value_size (&valdatum));
63 if ( (len >= 2) && (str[i++] == '?') )
65 unsigned char c = str[i++];
82 return c & (0x80 | 0x1F);
116 if (counter + 2 <= len)
120 for (j = 0; j < counter; j++)
121 cid = (cid << 6) | (str[j + i] & 0x3F);
132 chise_open_feature_table (CHISE_Feature_Table **db,
133 CHISE_DS *ds, const char *feature,
135 u_int32_t accessmask, int modemask)
138 chise_open_attribute_table (db, ds->location,
139 "system-char-id", feature,
140 real_subtype, accessmask, modemask);
144 chise_close_feature_table (CHISE_Feature_Table *db)
147 return chise_close_attribute_table (db);
151 int chise_ft_get_value (CHISE_Feature_Table *db,
152 CHISE_Char_ID cid, CHISE_Value *valdatum)
154 unsigned char key_buf[8];
162 else if (cid <= 0x7ff)
164 key_buf[1] = (cid >> 6) | 0xc0;
165 key_buf[2] = (cid & 0x3f) | 0x80;
168 else if (cid <= 0xffff)
170 key_buf[1] = (cid >> 12) | 0xe0;
171 key_buf[2]= ((cid >> 6) & 0x3f) | 0x80;
172 key_buf[3]= (cid & 0x3f) | 0x80;
175 else if (cid <= 0x1fffff)
177 key_buf[1]= (cid >> 18) | 0xf0;
178 key_buf[2]= ((cid >> 12) & 0x3f) | 0x80;
179 key_buf[3]= ((cid >> 6) & 0x3f) | 0x80;
180 key_buf[4]= (cid & 0x3f) | 0x80;
183 else if (cid <= 0x3ffffff)
185 key_buf[1]= (cid >> 24) | 0xf8;
186 key_buf[2]= ((cid >> 18) & 0x3f) | 0x80;
187 key_buf[3]= ((cid >> 12) & 0x3f) | 0x80;
188 key_buf[4]= ((cid >> 6) & 0x3f) | 0x80;
189 key_buf[5]= (cid & 0x3f) | 0x80;
194 key_buf[1]= (cid >> 30) | 0xfc;
195 key_buf[2]= ((cid >> 24) & 0x3f) | 0x80;
196 key_buf[3]= ((cid >> 18) & 0x3f) | 0x80;
197 key_buf[4]= ((cid >> 12) & 0x3f) | 0x80;
198 key_buf[5]= ((cid >> 6) & 0x3f) | 0x80;
199 key_buf[6]= (cid & 0x3f) | 0x80;
203 chise_get_attribute_table (db, key_buf, valdatum);
208 chise_open_attribute_table (CHISE_Attribute_Table **db,
210 const char *encoding, const char *feature,
212 u_int32_t accessmask, int modemask)
220 status = db_create (&dbase, NULL, 0);
224 len = strlen (db_dir);
225 size = len + strlen (encoding) + strlen (feature) + 4;
226 db_file_name = alloca (size);
227 strcpy (db_file_name, db_dir);
228 if (db_file_name[len - 1] != '/')
230 db_file_name[len++] = '/';
231 db_file_name[len] = '\0';
233 strcat (db_file_name, encoding);
234 strcat (db_file_name, "/");
235 strcat (db_file_name, feature);
236 status = dbase->open (dbase, db_file_name, NULL,
237 real_subtype, accessmask, modemask);
240 dbase->close (dbase, 0);
248 chise_close_attribute_table (CHISE_Attribute_Table *db)
259 chise_get_attribute_table (CHISE_Attribute_Table *db,
260 char *key, CHISE_Value *valdatum)
265 /* DB Version 2 requires DBT's to be zeroed before use. */
270 keydatum.size = strlen (key);
272 status = db->get (db, NULL, &keydatum, valdatum, 0);