update.
[chise/libchise.git] / chise.h
diff --git a/chise.h b/chise.h
index e384802..9fc7e1b 100644 (file)
--- a/chise.h
+++ b/chise.h
-#ifndef _CHISE_H
+/* Copyright (C) 2003,2004,2005 MORIOKA Tomohiko
+   This file is part of the CHISE Library.
 
-#include <db.h>
-#include <errno.h>
+   The CHISE Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-#ifndef HAVE_STRNLEN
+   The CHISE Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-/* original in mysql, strings/strnlen.c.
-uint strnlen(register const char *s, register uint maxlen)
-{
-  const char *end= (const char *)memchr(s, '\0', maxlen);
-  return end ? (uint) (end - s) : maxlen;
-}
-*/
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CHISE Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
-static inline int
-strnlen (register const char *s, register int maxlen)
-{
-  const char *end= (const char *)memchr(s, '\0', maxlen);
-  return end ? (int) (end - s) : maxlen;
-}
+#ifndef _CHISE_H
+#define _CHISE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if 0
+}
 #endif
 
+#include <concord.h>
 
-typedef enum CHISE_DS_Type
-{
-  CHISE_DS_NONE,
-  CHISE_DS_Berkeley_DB
-} CHISE_DS_Type;
+extern const unsigned char chise_db_format_version[];
+extern const unsigned char chise_db_dir[];
+extern const unsigned char chise_system_db_dir[];
 
-typedef struct CHISE_DS
-{
-  CHISE_DS_Type type;
-  char *location;
-} CHISE_DS;
+typedef CONCORD_Backend_Type CHISE_DS_Type;
+#define CHISE_DS_Berkeley_DB CONCORD_Backend_Berkeley_DB
+
+typedef CONCORD_Genre_Table CHISE_DS;
 
-int chise_open_data_source (CHISE_DS *ds, CHISE_DS_Type type,
-                           char *location);
+CHISE_DS*
+CHISE_DS_open (CHISE_DS_Type type, const unsigned char* location,
+              int subtype, int modemask);
 
-int chise_close_data_source (CHISE_DS *ds);
+int CHISE_DS_close (CHISE_DS* ds);
+
+unsigned char* chise_ds_location (CHISE_DS* ds);
+
+int
+chise_ds_foreach_char_feature_name (CHISE_DS* ds,
+                                   int (*func) (CHISE_DS* ds,
+                                                unsigned char* name));
 
 
 typedef int CHISE_Char_ID;
 
 
-typedef DBT CHISE_Value;
+typedef CONCORD_String_Tank CHISE_Value;
+int chise_value_size (const CHISE_Value* s);
+unsigned char* chise_value_data (const CHISE_Value* s);
+unsigned char* chise_value_to_c_string (const CHISE_Value* s);
+
+
+typedef CONCORD_Feature CHISE_Feature;
+
+CHISE_Feature
+chise_ds_get_feature (CHISE_DS* ds, const unsigned char* name);
 
 static inline int
-chise_value_size (const CHISE_Value *s)
-{
-  return s->size;
-}
+chise_ds_load_char_feature_value (CHISE_DS* ds,
+                                 CHISE_Char_ID cid,
+                                 const unsigned char* name,
+                                 CHISE_Value* valdatum);
 
-static inline char *
-chise_value_data (const CHISE_Value *s)
-{
-  return s->data;
-}
+int chise_feature_setup_db (CHISE_Feature feature, int writable);
+
+int chise_feature_sync (CHISE_Feature feature);
+
+int chise_char_set_feature_value (CHISE_Char_ID cid,
+                                 CHISE_Feature feature,
+                                 unsigned char* value);
+
+int chise_char_load_feature_value (CHISE_Char_ID cid,
+                                  CHISE_Feature feature,
+                                  CHISE_Value* valdatum);
 
-static inline char *
-chise_value_to_c_string (const CHISE_Value *s)
+static inline int
+chise_ds_load_char_feature_value (CHISE_DS* ds,
+                                 CHISE_Char_ID cid,
+                                 const unsigned char* name,
+                                 CHISE_Value* valdatum)
 {
-  return s->data;
+  return
+    chise_char_load_feature_value (cid, chise_ds_get_feature (ds, name),
+                                  valdatum);
 }
 
+unsigned char*
+chise_char_gets_feature_value (CHISE_Char_ID cid,
+                              CHISE_Feature feature,
+                              unsigned char* dst, size_t size);
 
-typedef DB CHISE_Attribute_Table;
+int
+chise_feature_foreach_char_with_value (CHISE_Feature feature,
+                                      int (*func) (CHISE_Char_ID cid,
+                                                   CHISE_Feature feature,
+                                                   CHISE_Value* valdatum));
 
 
-typedef CHISE_Attribute_Table CHISE_Decoding_Table;
+typedef CONCORD_INDEX CHISE_CCS;
 
-int chise_open_decoding_table (CHISE_Decoding_Table **db,
-                              CHISE_DS *ds, const char *ccs,
-                              DBTYPE real_subtype,
-                              u_int32_t accessmask, int modemask);
+CHISE_CCS chise_ds_get_ccs (CHISE_DS* ds, const unsigned char* name);
 
-int chise_close_decoding_table (CHISE_Decoding_Table *db);
+static inline CHISE_Char_ID
+chise_ds_decode_char (CHISE_DS* ds,
+                     const unsigned char* ccs, int code_point);
 
-CHISE_Char_ID chise_dt_get_char (CHISE_Decoding_Table *db, int code_point);
+int chise_ccs_setup_db (CHISE_CCS ccs, int writable);
 
+int chise_ccs_sync (CHISE_CCS ccs);
 
-typedef CHISE_Attribute_Table CHISE_Feature_Table;
+int chise_ccs_set_decoded_char (CHISE_CCS ccs,
+                               int code_point, CHISE_Char_ID cid);
 
-int chise_open_feature_table (CHISE_Feature_Table **db,
-                             CHISE_DS *ds, const char *feature,
-                             DBTYPE real_subtype,
-                             u_int32_t accessmask, int modemask);
+CHISE_Char_ID chise_ccs_decode (CHISE_CCS ccs, int code_point);
 
-int chise_close_feature_table (CHISE_Feature_Table *db);
+static inline CHISE_Char_ID
+chise_ds_decode_char (CHISE_DS* ds,
+                     const unsigned char* name, int code_point)
+{
+  return
+    chise_ccs_decode (chise_ds_get_ccs (ds, name), code_point);
+}
 
-int chise_ft_get_value (CHISE_Feature_Table *db,
-                       CHISE_Char_ID cid, CHISE_Value *valdatum);
 
+typedef CONCORD_Feature CHISE_Property;
 
+CHISE_Property
+chise_ds_get_property (CHISE_DS* ds, const unsigned char* name);
 
-CHISE_Char_ID chise_decode_char (CHISE_DS *ds, char *ccs, int code_point);
+int chise_property_setup_db (CHISE_Property property, int writable);
 
-int chise_get_feature (CHISE_DS *ds, CHISE_Char_ID cid,
-                      char *key, CHISE_Value *valdatum);
+int chise_property_sync (CHISE_Property property);
 
+int chise_feature_set_property_value (CHISE_Feature feature,
+                                     CHISE_Property property,
+                                     unsigned char* value);
 
-int chise_open_attribute_table (CHISE_Attribute_Table **db,
-                               const char *db_dir,
-                               const char *encoding, const char *feature,
-                               DBTYPE real_subtype,
-                               u_int32_t accessmask, int modemask);
+int chise_feature_load_property_value (CHISE_Feature feature,
+                                      CHISE_Property property,
+                                      CHISE_Value* valdatum);
 
-int chise_close_attribute_table (CHISE_Attribute_Table *db);
+unsigned char*
+chise_feature_gets_property_value (CHISE_Feature feature,
+                                  CHISE_Property property,
+                                  unsigned char* buf, size_t size);
 
-int chise_get_attribute_table (CHISE_Attribute_Table *db,
-                              char *key, CHISE_Value *valdatum);
+#if 0
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* !_CHISE_H */