(sample): Add -Wall -Wmissing-prototypes options for gcc.
[chise/libchise.git] / sample.c
index 179c021..ab4b7a7 100644 (file)
--- a/sample.c
+++ b/sample.c
@@ -1,6 +1,6 @@
+#include <alloca.h>
 #include <chise.h>
 
-char db_dir[] = "/usr/local/lib/chise/char-db";
 
 int
 test_map_func (CHISE_Char_ID cid, CHISE_Feature_Table *db,
@@ -35,10 +35,23 @@ main (int argc, char* argv[])
   CHISE_Char_ID char_id;
   CHISE_Value value;
   unsigned char buf[1024];
+  unsigned char *db_dir;
+
+  printf("chise_db_dir = %s\n", chise_db_dir);
+
+  db_dir = (unsigned char*)alloca (strlen (chise_db_dir) + 4);
+  if (db_dir == NULL)
+    {
+      printf ("Can't open data source\n");
+      return -1;
+    }
+  strcpy (db_dir, chise_db_dir);
+  strcat (db_dir, "db/");
+  printf("db_dir = '%s'\n", db_dir);
 
   /* open a data-source */
-  ds = chise_open_data_source (CHISE_DS_Berkeley_DB, db_dir,
-                              real_subtype, modemask);
+  ds = CHISE_DS_open (CHISE_DS_Berkeley_DB, db_dir,
+                     real_subtype, modemask);
   if (ds == NULL)
     {
       printf ("Can't open data source\n");
@@ -50,19 +63,22 @@ main (int argc, char* argv[])
    * get a character corresponding with Daikanwa number 364
    */
 
+#if 1
+  char_id = chise_ds_decode_char (ds, "=daikanwa", 364);
+#else
   /* setup a decoding-table */
   ccs_daikanwa
     = chise_ds_get_ccs (ds, "=daikanwa");
   if (ccs_daikanwa == NULL)
     {
       printf ("Can't open CCS =daikanwa\n");
-      chise_ds_close (ds);
+      CHISE_DS_close (ds);
       return -1;
     }
   
   /* get a character from the decoding-table */
   char_id = chise_ccs_decode (ccs_daikanwa, 364);
-
+#endif
 
   /* get a feature-value of the character */
   ft_ideographic_structure
@@ -78,5 +94,5 @@ main (int argc, char* argv[])
   chise_char_feature_value_iterate (ft_ideographic_structure, &test_map_func);
 
   /* close the data-source */
-  chise_ds_close (ds);
+  CHISE_DS_close (ds);
 }