9 test_name_map_func (CHISE_DS *ds, unsigned char *name)
11 printf ("feature : %s\n", name);
16 test_map_func (CHISE_Char_ID cid, CHISE_Feature db,
17 CHISE_Value *valdatum)
19 unsigned char buf[256];
20 unsigned char name[256];
23 printf ("#x%08X ", cid);
25 if ( chise_char_gets_feature_value
26 (cid, chise_ds_get_feature (ds, "=ucs"),
27 buf, sizeof (buf)) != NULL )
30 printf ("[U-%08X]", ucs);
32 else if ( chise_char_gets_feature_value
33 (cid, chise_ds_get_feature (ds, "=>ucs"),
34 buf, sizeof (buf)) != NULL )
37 printf ("(U-%08X)", ucs);
42 if ( chise_char_gets_feature_value
43 (cid, chise_ds_get_feature (ds, "name"),
44 name, sizeof (name)) != NULL )
47 if (chise_value_size (valdatum) < 256)
49 strncpy (buf, chise_value_data (valdatum),
50 chise_value_size (valdatum));
51 buf[chise_value_size (valdatum)] = '\0';
52 printf ("\t%s\n", buf);
56 chise_value_to_c_string (valdatum));
61 test_radical_func (CHISE_Char_ID cid, CHISE_Feature db,
62 CHISE_Value *valdatum)
64 unsigned char buf[256];
65 unsigned char name[256];
68 if (chise_value_size (valdatum) < 256)
70 strncpy (buf, chise_value_data (valdatum),
71 chise_value_size (valdatum));
72 buf[chise_value_size (valdatum)] = '\0';
77 chise_value_to_c_string (valdatum));
79 if (strcmp (buf, "75") == 0) /* Tree */
81 printf ("#x%08X ", cid);
82 if ( chise_char_gets_feature_value
83 (cid, chise_ds_get_feature (ds, "=ucs"),
84 buf, sizeof (buf)) != NULL )
87 printf ("[U-%08X]", ucs);
89 else if ( chise_char_gets_feature_value
90 (cid, chise_ds_get_feature (ds, "=>ucs"),
91 buf, sizeof (buf)) != NULL )
94 printf ("(U-%08X)", ucs);
107 main (int argc, char* argv[])
110 CHISE_CCS ccs_daikanwa;
112 CHISE_Feature ft_ideographic_structure;
113 CHISE_Feature ft_numeric_value;
114 CHISE_Feature ft_radicals;
115 CHISE_Char_ID char_id;
116 unsigned char buf[1024];
118 printf("chise_system_db_dir = %s\n", chise_system_db_dir);
120 /* open a data-source */
121 ds = CHISE_DS_open (CHISE_DS_Berkeley_DB, chise_system_db_dir,
122 0 /* DB_HASH */, 0755 /* rwxr-xr-x */);
125 printf ("Can't open data source\n");
129 printf("data source location = %s\n", chise_ds_location(ds));
133 * get a character corresponding with Daikanwa number 364
137 char_id = chise_ds_decode_char (ds, "=daikanwa", 364);
139 /* setup a decoding-table */
141 = chise_ds_get_ccs (ds, "=daikanwa");
142 if (ccs_daikanwa == NULL)
144 printf ("Can't open CCS =daikanwa\n");
149 /* get a character from the decoding-table */
150 char_id = chise_ccs_decode (ccs_daikanwa, 364);
153 /* get a feature-value of the character */
154 ft_ideographic_structure
155 = chise_ds_get_feature (ds, "ideographic-structure");
156 if (chise_char_gets_feature_value
157 (char_id, ft_ideographic_structure, buf, sizeof (buf)) != NULL)
158 printf ("#x%X => %s\n", char_id, buf);
160 printf ("#x%X\n", char_id);
162 chise_ds_foreach_char_feature_name (ds, &test_name_map_func);
164 ft_radicals = chise_ds_get_feature (ds, "ideographic-radical");
165 chise_feature_foreach_char_with_value (ft_radicals, &test_radical_func);
167 ft_numeric_value = chise_ds_get_feature (ds, "numeric-value");
168 chise_feature_foreach_char_with_value (ft_numeric_value, &test_map_func);
169 chise_feature_foreach_char_with_value
170 (ft_ideographic_structure, &test_map_func);
172 /* close the data-source */