From: tomo Date: Tue, 12 Aug 2003 02:28:59 +0000 (+0000) Subject: (chise_dt_put_char): New function. X-Git-Tag: r0_1_1-pre1~1 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3ad2e8a6bd2a7b010077f475e52244352ecaa0c;p=chise%2Flibchise.git (chise_dt_put_char): New function. (chise_put_attribute_table): New function. --- diff --git a/chise.c b/chise.c index fdb73b1..e76f8e1 100644 --- a/chise.c +++ b/chise.c @@ -276,6 +276,18 @@ chise_dt_get_char (CHISE_Decoding_Table *db, int code_point) return -1; } +int +chise_dt_put_char (CHISE_Decoding_Table *db, + int code_point, CHISE_Char_ID cid) +{ + CHISE_Value valdatum; + char key_buf[16], val_buf[8]; + + sprintf(key_buf, "%d", code_point); + chise_format_char_id (cid, val_buf, 8); + return chise_put_attribute_table (db, key_buf, val_buf); +} + int @@ -419,3 +431,24 @@ chise_get_attribute_table (CHISE_Attribute_Table *db, status = db->get (db, NULL, &keydatum, valdatum, 0); return status; } + +int +chise_put_attribute_table (CHISE_Attribute_Table *db, + char *key, char *value) +{ + DBT keydatum, valdatum; + int status = 0; + + /* DB Version 2 requires DBT's to be zeroed before use. */ + xzero (keydatum); + xzero (valdatum); + + keydatum.data = key; + keydatum.size = strlen (key); + + valdatum.data = value; + valdatum.size = strlen (value); + + status = db->put (db, NULL, &keydatum, &valdatum, 0); + return status; +}