#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
#include "sysdep.h"
#include "concord.h"
+#include "cos-i.h"
#include "concord-name.h"
#include "concord-bdb.h"
CONCORD_Genre concord_ds_open_genre (CONCORD_DS ds, const char* name);
-int concord_close_genre (CONCORD_Genre genre);
-
CONCORD_Feature
concord_genre_open_feature (CONCORD_Genre genre, const char* name);
-int concord_close_feature (CONCORD_Feature feature);
-
CONCORD_INDEX
concord_genre_open_index (CONCORD_Genre genre, const char* index);
CONCORD_Feature
concord_genre_get_feature_0 (CONCORD_Genre genre, const char* name);
-int concord_close_index (CONCORD_INDEX table);
-
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
+struct COS_DS_ent
{
- CONCORD_Object_Header header;
+ COS_Object_Header header;
CONCORD_Backend_Type type;
char *location;
CONCORD_NAME_TABLE* genre_names;
CONCORD_Object object_nil;
CONCORD_Object (*read_object) (const unsigned char* str, size_t length);
+ CONCORD_NAME_TABLE* symbol_names;
};
CONCORD_Object
return NULL;
strncpy ((char*)buf, (char*)str, length);
buf[length] = '\0';
- return buf;
+ return (CONCORD_Object)buf;
}
CONCORD_DS
concord_open_ds (CONCORD_Backend_Type type, const char* location,
int subtype, int modemask)
{
- CONCORD_DS ds = (CONCORD_DS)malloc (sizeof (CONCORD_DS_Table));
+#if 0
+ CONCORD_DS ds = (CONCORD_DS)malloc (sizeof (CONCORD_DS_ent));
size_t len = strlen (location);
if (ds == NULL)
return NULL;
ds->header.prefix = 0xff;
- ds->header.type = CONCORD_OBJECT_TYPE_DS;
+ ds->header.type = CONCORD_Object_Type_DS;
+#else
+ CONCORD_DS ds = COS_ALLOCATE_OBJECT (DS);
+ size_t len = strlen (location);
+
+ if (ds == NULL)
+ return NULL;
+#endif
+
ds->type = type;
ds->subtype = ( (subtype != 0) ? subtype : DB_HASH );
ds->modemask = modemask;
return NULL;
}
+ ds->symbol_names = concord_make_name_table ();
+ if (ds->symbol_names == NULL)
+ {
+ concord_destroy_name_table (ds->genre_names);
+ free (ds->location);
+ free (ds);
+ return NULL;
+ }
+
ds->object_nil = NULL;
ds->read_object = &concord_default_read_object;
free (ds->location);
if (ds->genre_names != NULL)
concord_destroy_name_table (ds->genre_names);
+ if (ds->symbol_names != NULL)
+ concord_destroy_name_table (ds->symbol_names);
free (ds);
return 0;
}
}
-struct CONCORD_Genre_Table
+struct COS_Genre_ent
{
- CONCORD_Object_Header header;
+ COS_Object_Header header;
CONCORD_DS ds;
char *name;
CONCORD_NAME_TABLE* feature_names;
if (ds == NULL)
return NULL;
- genre = (CONCORD_Genre)malloc (sizeof (CONCORD_Genre_Table));
+#if 0
+ genre = (CONCORD_Genre)malloc (sizeof (CONCORD_Genre_ent));
if (genre == NULL)
return NULL;
genre->header.prefix = 0xff;
- genre->header.type = CONCORD_OBJECT_TYPE_GENRE;
+ genre->header.type = CONCORD_Object_Type_Genre;
+#else
+ genre = COS_ALLOCATE_OBJECT (Genre);
+ if (genre == NULL)
+ return NULL;
+#endif
+
genre->ds = ds;
genre->name = (char*)malloc (len + 1);
if (genre->name == NULL)
}
-struct CONCORD_Feature_Table
+struct COS_Feature_ent
{
- CONCORD_Object_Header header;
+ COS_Object_Header header;
CONCORD_Genre genre;
char* name;
DB* db;
if (genre == NULL)
return NULL;
- table = (CONCORD_Feature)malloc (sizeof (CONCORD_Feature_Table));
+#if 0
+ table = (CONCORD_Feature)malloc (sizeof (CONCORD_Feature_ent));
if (table == NULL)
return NULL;
table->header.prefix = 0xff;
- table->header.type = CONCORD_OBJECT_TYPE_FEATURE;
+ table->header.type = CONCORD_Object_Type_Feature;
+#else
+ table = COS_ALLOCATE_OBJECT (Feature);
+ if (table == NULL)
+ return NULL;
+#endif
+
table->genre = genre;
table->db = NULL;
table->access = 0;
}
-struct CONCORD_INDEX_Table
+struct COS_Feature_INDEX_ent
{
- CONCORD_Object_Header header;
+ COS_Object_Header header;
CONCORD_Genre genre;
char *name;
DB* db;
if (genre == NULL)
return NULL;
- table = (CONCORD_INDEX)malloc (sizeof (CONCORD_INDEX_Table));
+#if 0
+ table = (CONCORD_INDEX)malloc (sizeof (CONCORD_INDEX_ent));
if (table == NULL)
return NULL;
table->header.prefix = 0xff;
- table->header.type = CONCORD_OBJECT_TYPE_INDEX;
+ table->header.type = CONCORD_Object_Type_INDEX;
+#else
+ table = COS_ALLOCATE_OBJECT (Feature_INDEX);
+ if (table == NULL)
+ return NULL;
+#endif
+
table->genre = genre;
table->db = NULL;
table->access = 0;
return status;
}
+char*
+concord_index_get_name (CONCORD_INDEX index)
+{
+ return index->name;
+}
+
+CONCORD_Genre
+concord_index_get_genre (CONCORD_INDEX index)
+{
+ return index->genre;
+}
+
int
concord_index_setup_db (CONCORD_INDEX index, int writable)
{