X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=sample.c;h=aba694064f1a417fde361924aec8be23a2deecdd;hb=4b0d2ee4a086f4dae7e293a80cc4e3ddfc319148;hp=3b27e8ea379268a38e275975a73ef9c9be1f7fa4;hpb=b71ff6b6d40ece7e383145cc8cd9856528a9d79a;p=chise%2Flibchise.git diff --git a/sample.c b/sample.c index 3b27e8e..aba6940 100644 --- a/sample.c +++ b/sample.c @@ -1,8 +1,16 @@ +#include +#include #include -char db_dir[] = "/usr/local/lib/chise/char-db"; -int +static int +test_name_map_func (CHISE_DS *ds, unsigned char *name) +{ + printf ("feature : %s\n", name); + return 0; +} + +static int test_map_func (CHISE_Char_ID cid, CHISE_Feature_Table *db, CHISE_Value *valdatum) { @@ -26,15 +34,28 @@ int main (int argc, char* argv[]) { CHISE_DS *ds; +#if 0 CHISE_CCS ccs_daikanwa; +#endif CHISE_Feature ft_ideographic_structure; CHISE_Feature ft_ascii; int modemask = 0755; /* rwxr-xr-x */ DBTYPE real_subtype = DB_HASH; - int status; CHISE_Char_ID char_id; - CHISE_Value value; unsigned char buf[1024]; + unsigned char *db_dir; + + printf("chise_db_dir = %s\n", chise_db_dir); + + db_dir = (unsigned char*)alloca (strlen (chise_db_dir) + 4); + if (db_dir == NULL) + { + printf ("Can't open data source\n"); + return -1; + } + strcpy (db_dir, chise_db_dir); + strcat (db_dir, "db/"); + printf("db_dir = '%s'\n", db_dir); /* open a data-source */ ds = CHISE_DS_open (CHISE_DS_Berkeley_DB, db_dir, @@ -76,10 +97,15 @@ main (int argc, char* argv[]) else printf ("#x%X\n", char_id); + chise_ds_foreach_char_feature_name (ds, &test_name_map_func); + ft_ascii = chise_ds_get_feature (ds, "ascii"); - chise_char_feature_value_iterate (ft_ascii, &test_map_func); - chise_char_feature_value_iterate (ft_ideographic_structure, &test_map_func); + chise_feature_foreach_char_with_value (ft_ascii, &test_map_func); + chise_feature_foreach_char_with_value + (ft_ideographic_structure, &test_map_func); /* close the data-source */ CHISE_DS_close (ds); + + return 0; }