From: tomo Date: Sun, 17 Aug 2003 13:56:15 +0000 (+0000) Subject: (main): Modify for new API. X-Git-Tag: b1c-r0_2_0-pre2~1 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=308ab62de360c855c552ee1a2e3524696b5f76d2;p=chise%2Flibchise.git (main): Modify for new API. --- diff --git a/sample.c b/sample.c index 29e6756..b72940c 100644 --- a/sample.c +++ b/sample.c @@ -14,10 +14,10 @@ test_map_func (CHISE_Feature_Table *db, int main (int argc, char* argv[]) { - CHISE_DS ds; - CHISE_Decoding_Table dt_daikanwa; - CHISE_Feature_Table ft_ideographic_structure; - CHISE_Feature_Table ft_ascii; + 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; @@ -26,10 +26,9 @@ main (int argc, char* argv[]) CHISE_Value value; /* open a data-source */ - status = chise_open_data_source (&ds, CHISE_DS_Berkeley_DB, db_dir); - if (status) + ds = chise_open_data_source (CHISE_DS_Berkeley_DB, db_dir); + if (ds == NULL) { - chise_close_data_source (&ds); return -1; } @@ -43,22 +42,20 @@ main (int argc, char* argv[]) accessmask = DB_RDONLY; /* setup a decoding-table */ - status = chise_open_decoding_table (&dt_daikanwa, &ds, - "=daikanwa", - real_subtype, - accessmask, modemask); - if (status) + dt_daikanwa + = chise_ds_open_decoding_table (ds, "=daikanwa", + real_subtype, accessmask, modemask); + if (dt_daikanwa == NULL) { - chise_close_decoding_table (&dt_daikanwa); - 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); + char_id = chise_dt_get_char (dt_daikanwa, 364); /* close the decoding-table */ - chise_close_decoding_table (&dt_daikanwa); + chise_dt_close (dt_daikanwa); /* @@ -66,44 +63,39 @@ main (int argc, char* argv[]) */ /* setup a feature-table */ - status = chise_open_feature_table (&ft_ideographic_structure, &ds, - "ideographic-structure", - real_subtype, accessmask, modemask); - if (status) + ft_ideographic_structure + = chise_ds_open_feature_table (ds, "ideographic-structure", + real_subtype, accessmask, modemask); + if (ft_ideographic_structure == NULL) { - chise_close_feature_table (&ft_ideographic_structure); - chise_close_data_source (&ds); + chise_ds_close (ds); return -1; } /* setup a feature-table */ - status = chise_open_feature_table (&ft_ascii, &ds, - "ascii", - real_subtype, accessmask, modemask); - if (status) + ft_ascii = chise_ds_open_feature_table (ds, "ascii", + real_subtype, accessmask, modemask); + if (ft_ascii == NULL) { - chise_close_feature_table (&ft_ascii); - 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_ideographic_structure, 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_ft_iterate (&ft_ascii, &test_map_func); - chise_ft_iterate (&ft_ideographic_structure, &test_map_func); + chise_ft_iterate (ft_ascii, &test_map_func); + chise_ft_iterate (ft_ideographic_structure, &test_map_func); /* close the feature-table */ - chise_close_feature_table (&ft_ideographic_structure); - - chise_close_feature_table (&ft_ascii); - + chise_ft_close (ft_ideographic_structure); + chise_ft_close (ft_ascii); /* close the data-source */ - chise_close_data_source (&ds); + chise_ds_close (ds); }