7 test_name_map_func (CHISE_DS *ds, unsigned char *name)
9 printf ("feature : %s\n", name);
14 test_map_func (CHISE_Char_ID cid, CHISE_Feature_Table *db,
15 CHISE_Value *valdatum)
17 unsigned char buf[256];
19 printf ("(flags = %x)\n", valdatum->flags);
20 if (chise_value_size (valdatum) < 256)
22 strncpy (buf, chise_value_data (valdatum),
23 chise_value_size (valdatum));
24 buf[chise_value_size (valdatum)] = '\0';
25 printf ("#x%04X\t(%c)\t%s\n", cid, cid, buf);
28 printf ("#x%04X\t(%c)\t%s\n",
29 cid, cid, chise_value_to_c_string (valdatum));
34 main (int argc, char* argv[])
38 CHISE_CCS ccs_daikanwa;
40 CHISE_Feature ft_ideographic_structure;
41 CHISE_Feature ft_ascii;
42 int modemask = 0755; /* rwxr-xr-x */
43 DBTYPE real_subtype = DB_HASH;
44 CHISE_Char_ID char_id;
45 unsigned char buf[1024];
46 unsigned char *db_dir;
48 printf("chise_db_dir = %s\n", chise_db_dir);
50 db_dir = (unsigned char*)alloca (strlen (chise_db_dir) + 4);
53 printf ("Can't open data source\n");
56 strcpy (db_dir, chise_db_dir);
57 strcat (db_dir, "db/");
58 printf("db_dir = '%s'\n", db_dir);
60 /* open a data-source */
61 ds = CHISE_DS_open (CHISE_DS_Berkeley_DB, db_dir,
62 real_subtype, modemask);
65 printf ("Can't open data source\n");
71 * get a character corresponding with Daikanwa number 364
75 char_id = chise_ds_decode_char (ds, "=daikanwa", 364);
77 /* setup a decoding-table */
79 = chise_ds_get_ccs (ds, "=daikanwa");
80 if (ccs_daikanwa == NULL)
82 printf ("Can't open CCS =daikanwa\n");
87 /* get a character from the decoding-table */
88 char_id = chise_ccs_decode (ccs_daikanwa, 364);
91 /* get a feature-value of the character */
92 ft_ideographic_structure
93 = chise_ds_get_feature (ds, "ideographic-structure");
94 if (chise_char_gets_feature_value
95 (char_id, ft_ideographic_structure, buf, sizeof (buf)) != NULL)
96 printf ("#x%X => %s\n", char_id, buf);
98 printf ("#x%X\n", char_id);
100 chise_ds_foreach_char_feature_name (ds, &test_name_map_func);
102 ft_ascii = chise_ds_get_feature (ds, "ascii");
103 chise_feature_foreach_char_with_value (ft_ascii, &test_map_func);
104 chise_feature_foreach_char_with_value
105 (ft_ideographic_structure, &test_map_func);
107 /* close the data-source */