X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fconcord.git;a=blobdiff_plain;f=cos.c;h=6fc2f3f9c18b872cb9b4df5f5e342c48c2a9e06e;hp=97f6099fe4f811c50b89b04d58452fa0478fce12;hb=b6aac1bd870245ed92193dae35e439c2ed214039;hpb=4659a59ea128f72b7d27c40e1b1be233e62b79d8 diff --git a/cos.c b/cos.c index 97f6099..6fc2f3f 100644 --- a/cos.c +++ b/cos.c @@ -20,11 +20,14 @@ #include "sysdep.h" #include "cos-i.h" #include "cos-read.h" +#include "cos-print.h" const char concord_db_format_version[] = CONCORD_DB_FORMAT_VERSION; const char concord_db_dir[] = CONCORD_DB_DIR; const char concord_system_db_dir[] = CONCORD_SI_DB_DIR; +CONCORD_DS concord_current_env = NULL; + int (*COS_Object_release_function_table [COS_OBJECT_TYPE_MAX - COS_Object_Type_char]) (COS_Object) @@ -216,7 +219,7 @@ COS_DS concord_open_env (COS_object ds) { if (COS_OBJECT_DS_P (ds)) - return (COS_DS)ds; + concord_current_env = (COS_DS)ds; else { char* path; @@ -228,9 +231,10 @@ concord_open_env (COS_object ds) else return NULL; - return concord_open_ds (CONCORD_Backend_Berkeley_DB, - path, 0, 0755); + concord_current_env = concord_open_ds (CONCORD_Backend_Berkeley_DB, + path, 0, 0755); } + return concord_current_env; } int @@ -396,3 +400,37 @@ concord_decode_object (COS_object ds, COS_object genre, return NULL; } + +COS_object +concord_object_get_feature_value (COS_object object, COS_object feature) +{ + char id_buf[256]; + CONCORD_Feature fobj; + CONCORD_String_Tank val_st; + COS_String val_string; + + if (COS_OBJECT_CHAR_P (object)) + { + cos_utf8_print_char (object, id_buf, 256); + printf ("Object[char:0x%lX]'s id is %s.\n", object, id_buf); + } + else + return NULL; + + fobj = concord_get_feature (concord_current_env, + "character", feature); + if (fobj == NULL) + return NULL; + + if ( concord_obj_get_feature_value_string (id_buf, fobj, &val_st) ) + return NULL; + + val_string = cos_make_string ((char*)CONCORD_String_data (&val_st), + CONCORD_String_size (&val_st)); + printf ("obj[%s]'s %s = %s\n", + id_buf, + concord_feature_get_name (fobj), + cos_string_data (val_string)); + + return NULL; +}