From: MORIOKA Tomohiko Date: Fri, 10 Aug 2012 10:32:08 +0000 (+0900) Subject: (struct CONCORD_Object_Header): New structure. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=38761a1b5ddbdc3ecf9a05e7f46f3dd9fae4ba4f;p=chise%2Fconcord.git (struct CONCORD_Object_Header): New structure. (CONCORD_OBJECT_TYPE_NULL): New macro. (CONCORD_OBJECT_TYPE_C_STRING): New macro. (CONCORD_OBJECT_TYPE_INT): New macro. (CONCORD_OBJECT_TYPE_DS): New macro. (CONCORD_OBJECT_TYPE_GENRE): New macro. (CONCORD_OBJECT_TYPE_FEATURE): New macro. (CONCORD_OBJECT_TYPE_INDEX): New macro. (CONCORD_OBJECT_TYPE_OBJECT): New macro. (struct CONCORD_DS_Table): Add new member `header'. (concord_open_ds): Setup ds->header. (struct CONCORD_Genre_Table): Add new member `header'. (concord_ds_open_genre): Setup ds->header. (struct CONCORD_Feature_Table): Add new member `header'. (concord_genre_open_feature): Setup ds->header. (struct CONCORD_INDEX_Table): Add new member `header'. (concord_genre_open_index): Setup ds->header. --- diff --git a/concord.c b/concord.c index f115960..2bac1df 100644 --- a/concord.c +++ b/concord.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2005,2006 MORIOKA Tomohiko +/* Copyright (C) 2003,2004,2005,2006,2011 MORIOKA Tomohiko This file is part of the CONCORD Library. The CONCORD Library is free software; you can redistribute it and/or @@ -66,8 +66,25 @@ CONCORD_Object concord_default_read_object (const unsigned char* string, size_t length); +typedef struct CONCORD_Object_Header +{ + unsigned char prefix; + unsigned char type; +} CONCORD_Object_Header; + +#define CONCORD_OBJECT_TYPE_NULL 0 +#define CONCORD_OBJECT_TYPE_C_STRING 1 +#define CONCORD_OBJECT_TYPE_INT 2 +#define CONCORD_OBJECT_TYPE_DS 16 +#define CONCORD_OBJECT_TYPE_GENRE 17 +#define CONCORD_OBJECT_TYPE_FEATURE 18 +#define CONCORD_OBJECT_TYPE_INDEX 19 +#define CONCORD_OBJECT_TYPE_OBJECT 128 + + struct CONCORD_DS_Table { + CONCORD_Object_Header header; CONCORD_Backend_Type type; char *location; CONCORD_NAME_TABLE* genre_names; @@ -100,6 +117,8 @@ concord_open_ds (CONCORD_Backend_Type type, const char* location, if (ds == NULL) return NULL; + ds->header.prefix = 0xff; + ds->header.type = CONCORD_OBJECT_TYPE_DS; ds->type = type; ds->subtype = ( (subtype != 0) ? subtype : DB_HASH ); ds->modemask = modemask; @@ -271,6 +290,7 @@ concord_ds_foreach_genre_name (CONCORD_DS ds, struct CONCORD_Genre_Table { + CONCORD_Object_Header header; CONCORD_DS ds; char *name; CONCORD_NAME_TABLE* feature_names; @@ -290,6 +310,8 @@ concord_ds_open_genre (CONCORD_DS ds, const char* name) if (genre == NULL) return NULL; + genre->header.prefix = 0xff; + genre->header.type = CONCORD_OBJECT_TYPE_GENRE; genre->ds = ds; genre->name = (char*)malloc (len + 1); if (genre->name == NULL) @@ -529,6 +551,7 @@ concord_genre_get_index (CONCORD_Genre genre, const char* name) struct CONCORD_Feature_Table { + CONCORD_Object_Header header; CONCORD_Genre genre; char* name; DB* db; @@ -548,6 +571,8 @@ concord_genre_open_feature (CONCORD_Genre genre, const char* feature) if (table == NULL) return NULL; + table->header.prefix = 0xff; + table->header.type = CONCORD_OBJECT_TYPE_FEATURE; table->genre = genre; table->db = NULL; table->access = 0; @@ -743,6 +768,7 @@ concord_feature_foreach_obj_string (CONCORD_Feature feature, struct CONCORD_INDEX_Table { + CONCORD_Object_Header header; CONCORD_Genre genre; char *name; DB* db; @@ -762,6 +788,8 @@ concord_genre_open_index (CONCORD_Genre genre, const char* index) if (table == NULL) return NULL; + table->header.prefix = 0xff; + table->header.type = CONCORD_OBJECT_TYPE_INDEX; table->genre = genre; table->db = NULL; table->access = 0;