(CHISE_Attribute_Table): Define as a structure.
[chise/libchise.git] / chise.c
diff --git a/chise.c b/chise.c
index fdb73b1..e76f8e1 100644 (file)
--- 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;
+}