From: tomo Date: Thu, 6 Mar 2003 08:11:26 +0000 (+0000) Subject: Add comments. X-Git-Tag: r0_1_1-pre1~38 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6f45c841989f186d3552d956a56c881b973226fc;p=chise%2Flibchise.git Add comments. --- diff --git a/sample.c b/sample.c index 13251af..c544fcd 100644 --- a/sample.c +++ b/sample.c @@ -6,8 +6,8 @@ int main (int argc, char* argv[]) { CHISE_DS ds; - CHISE_Decoding_Table *dt; - CHISE_Feature_Table *ft; + CHISE_Decoding_Table *dt_daikanwa; + CHISE_Feature_Table *ft_ideographic_structure; int modemask; int accessmask = 0; DBTYPE real_subtype; @@ -15,6 +15,7 @@ main (int argc, char* argv[]) CHISE_Char_ID char_id; CHISE_Value value; + /* open a data-source */ status = chise_open_data_source (&ds, CHISE_DS_Berkeley_DB, db_dir); if (status) { @@ -22,40 +23,61 @@ main (int argc, char* argv[]) 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, + /* setup a decoding-table */ + status = chise_open_decoding_table (&dt_daikanwa, &ds, "ideograph-daikanwa", - real_subtype, accessmask, modemask); + real_subtype, + accessmask, modemask); if (status) { - chise_close_decoding_table (dt); + chise_close_decoding_table (dt_daikanwa); chise_close_data_source (&ds); return -1; } + + /* get a character from the decoding-table */ + char_id = chise_dt_get_char (dt_daikanwa, 364); + + /* close the decoding-table */ + chise_close_decoding_table (dt_daikanwa); - char_id = chise_dt_get_char (dt, 20); - chise_close_decoding_table (dt); - - status = chise_open_feature_table (&ft, &ds, + + /* + * get a ideographic-structure feature of the character + */ + + /* setup a feature-table */ + status = chise_open_feature_table (&ft_ideographic_structure, &ds, "ideographic-structure", real_subtype, accessmask, modemask); if (status) { - chise_close_feature_table (ft); + chise_close_feature_table (ft_ideographic_structure); chise_close_data_source (&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); + /* close the feature-table */ + chise_close_feature_table (ft_ideographic_structure); + + + /* close the data-source */ chise_close_data_source (&ds); }