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[0] == '?') )
61 unsigned char c = str[1];
96 if (counter + 2 <= len)
100 for (i = 0; i < counter; i++)
101 cid = (cid << 6) | (str[i + 2] & 0x3F);
112 chise_open_feature_table (CHISE_Feature_Table **db,
113 CHISE_DS *ds, const char *feature,
115 u_int32_t accessmask, int modemask)
118 chise_open_attribute_table (db, ds->location,
119 "system-char-id", feature,
120 real_subtype, accessmask, modemask);
124 chise_close_feature_table (CHISE_Feature_Table *db)
127 return chise_close_attribute_table (db);
131 int chise_ft_get_value (CHISE_Feature_Table *db,
132 CHISE_Char_ID cid, CHISE_Value *valdatum)
134 unsigned char key_buf[8];
142 else if (cid <= 0x7ff)
144 key_buf[1] = (cid >> 6) | 0xc0;
145 key_buf[2] = (cid & 0x3f) | 0x80;
148 else if (cid <= 0xffff)
150 key_buf[1] = (cid >> 12) | 0xe0;
151 key_buf[2]= ((cid >> 6) & 0x3f) | 0x80;
152 key_buf[3]= (cid & 0x3f) | 0x80;
155 else if (cid <= 0x1fffff)
157 key_buf[1]= (cid >> 18) | 0xf0;
158 key_buf[2]= ((cid >> 12) & 0x3f) | 0x80;
159 key_buf[3]= ((cid >> 6) & 0x3f) | 0x80;
160 key_buf[4]= (cid & 0x3f) | 0x80;
163 else if (cid <= 0x3ffffff)
165 key_buf[1]= (cid >> 24) | 0xf8;
166 key_buf[2]= ((cid >> 18) & 0x3f) | 0x80;
167 key_buf[3]= ((cid >> 12) & 0x3f) | 0x80;
168 key_buf[4]= ((cid >> 6) & 0x3f) | 0x80;
169 key_buf[5]= (cid & 0x3f) | 0x80;
174 key_buf[1]= (cid >> 30) | 0xfc;
175 key_buf[2]= ((cid >> 24) & 0x3f) | 0x80;
176 key_buf[3]= ((cid >> 18) & 0x3f) | 0x80;
177 key_buf[4]= ((cid >> 12) & 0x3f) | 0x80;
178 key_buf[5]= ((cid >> 6) & 0x3f) | 0x80;
179 key_buf[6]= (cid & 0x3f) | 0x80;
183 chise_get_attribute_table (db, key_buf, valdatum);
188 chise_open_attribute_table (CHISE_Attribute_Table **db,
190 const char *encoding, const char *feature,
192 u_int32_t accessmask, int modemask)
200 status = db_create (&dbase, NULL, 0);
204 len = strlen (db_dir);
205 size = len + strlen (encoding) + strlen (feature) + 4;
206 db_file_name = alloca (size);
207 strcpy (db_file_name, db_dir);
208 if (db_file_name[len - 1] != '/')
210 db_file_name[len++] = '/';
211 db_file_name[len] = '\0';
213 strcat (db_file_name, encoding);
214 strcat (db_file_name, "/");
215 strcat (db_file_name, feature);
216 status = dbase->open (dbase, db_file_name, NULL,
217 real_subtype, accessmask, modemask);
220 dbase->close (dbase, 0);
228 chise_close_attribute_table (CHISE_Attribute_Table *db)
239 chise_get_attribute_table (CHISE_Attribute_Table *db,
240 char *key, CHISE_Value *valdatum)
245 /* DB Version 2 requires DBT's to be zeroed before use. */
250 keydatum.size = strlen (key);
252 status = db->get (db, NULL, &keydatum, valdatum, 0);