-#include "chise.h"
+#include <chise.h>
-#define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
+char db_dir[] = "/usr/local/lib/chise/char-db";
-char db_dir[] = "/usr/local/lib/xemacs-21.4.10/i586-pc-linux/char-db";
+int
+test_map_func (CHISE_Feature_Table *db,
+ CHISE_Char_ID cid, CHISE_Value *valdatum)
+{
+ printf ("#x%04X\t(%c)\t%s\n",
+ cid, cid, chise_value_to_c_string (valdatum));
+ return 0;
+}
int
main (int argc, char* argv[])
{
- CHISE_DS ds;
- CHISE_Decoding_Table *dt;
- CHISE_Feature_Table *ft;
+ CHISE_DS *ds;
+ CHISE_Decoding_Table *dt_daikanwa;
+ CHISE_Feature_Table *ft_ideographic_structure;
+ CHISE_Feature_Table *ft_ascii;
int modemask;
int accessmask = 0;
DBTYPE real_subtype;
CHISE_Char_ID char_id;
CHISE_Value value;
- status = chise_open_data_source (&ds, CHISE_DS_Berkeley_DB, db_dir);
- if (status)
+ /* open a data-source */
+ ds = chise_open_data_source (CHISE_DS_Berkeley_DB, db_dir);
+ if (ds == NULL)
{
- chise_close_data_source (&ds);
return -1;
}
- modemask = 0755; /* rwxr-xr-x */
+ /*
+ * get a character corresponding with Daikanwa number 364
+ */
+
+ modemask = 0755; /* rwxr-xr-x */
real_subtype = DB_HASH;
accessmask = DB_RDONLY;
- status = chise_open_decoding_table (&dt, &ds,
- "ideograph-daikanwa",
- real_subtype, accessmask, modemask);
- if (status)
+ /* setup a decoding-table */
+ dt_daikanwa
+ = chise_ds_open_decoding_table (ds, "=daikanwa",
+ real_subtype, accessmask, modemask);
+ if (dt_daikanwa == NULL)
{
- chise_close_decoding_table (dt);
- chise_close_data_source (&ds);
+ chise_ds_close (ds);
return -1;
}
+
+ /* get a character from the decoding-table */
+ char_id = chise_dt_get_char (dt_daikanwa, 364);
+
+ /* close the decoding-table */
+ chise_dt_close (dt_daikanwa);
+
- char_id = chise_dt_get_char (dt, 20);
- chise_close_decoding_table (dt);
-
- status = chise_open_feature_table (&ft, &ds,
- "ideographic-structure",
- real_subtype, accessmask, modemask);
- if (status)
+ /*
+ * get a ideographic-structure feature of the character
+ */
+
+ /* setup a feature-table */
+ ft_ideographic_structure
+ = chise_ds_open_feature_table (ds, "ideographic-structure",
+ real_subtype, accessmask, modemask);
+ if (ft_ideographic_structure == NULL)
+ {
+ chise_ds_close (ds);
+ return -1;
+ }
+
+ /* setup a feature-table */
+ ft_ascii = chise_ds_open_feature_table (ds, "ascii",
+ real_subtype, accessmask, modemask);
+ if (ft_ascii == NULL)
{
- chise_close_feature_table (ft);
- chise_close_data_source (&ds);
+ chise_ds_close (ds);
return -1;
}
+
+ /* get a feature-value of the character */
+ status = chise_ft_get_value (ft_ideographic_structure, char_id, &value);
- status = chise_ft_get_value (ft, char_id, &value);
if (!status)
printf ("#x%X => %s\n", char_id, chise_value_to_c_string(&value));
else
printf ("#x%X (%d)\n", char_id, status);
- chise_close_feature_table (ft);
- chise_close_data_source (&ds);
+ chise_ft_iterate (ft_ascii, &test_map_func);
+ chise_ft_iterate (ft_ideographic_structure, &test_map_func);
+
+ /* close the feature-table */
+ chise_ft_close (ft_ideographic_structure);
+ chise_ft_close (ft_ascii);
+
+ /* close the data-source */
+ chise_ds_close (ds);
}