#include "sysdep.h"
int initDB(){
- db_create(&kDatabase, NULL, 0);
- kDatabase->open(kDatabase, databaseFileName, NULL, DB_HASH, DB_RDONLY, 0644);
+ db_create(&kPartsdbDatabase, NULL, 0);
+ kPartsdbDatabase->open(kPartsdbDatabase, NULL, partsdbFileName, NULL, DB_HASH, DB_RDONLY, 0644);
+ db_create(&kIdsdbDatabase, NULL, 0);
+ kIdsdbDatabase->open(kIdsdbDatabase, NULL, idsdbFileName, NULL, DB_HASH, DB_RDONLY, 0644);
return 0;
}
int closeDB(){
- kDatabase->close(kDatabase, 0);
+ kPartsdbDatabase->close(kPartsdbDatabase, 0);
+ kIdsdbDatabase->close(kIdsdbDatabase, 0);
return 0;
}
void searchPartsData(const KGString *in, KGString *out){
DBT dbkey, dbdata;
- char *start, *end, *buf;
+ char *buf;
KGString *temp, *temp2;
//cut off the end '-0000' if 'in' end with it
dbkey.data = temp->str;
dbkey.size = temp->len;
kg_string_set_size(out, 0);
- temp2 = kg_string_new("");
- kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0);
+ kPartsdbDatabase->get(kPartsdbDatabase, NULL, &dbkey, &dbdata, 0);
if(dbdata.size != 0){
+ //for temporary : shares glyph both Mincho and Gothic
buf = (char *)malloc(dbdata.size + 1);
- strncpy(buf, dbdata.data, dbdata.size + 1);
- //first:search selected shotai
- if(kShotai == kMincho) start = strstr(buf, ",mincho,");
- else start = strstr(buf, ",gothic,");
- if(start != NULL){
- start = strchr((start+8), ',');
- if(start != NULL){
- start = strchr((start+1), ',');
- if(start != NULL){
- end = strchr((start+1), ',');
- if(end != NULL){
- kg_string_append_len(temp2, (start+1), end - start - 2 + 1);
- convert99(temp2, out);
- return;
- }
- }
- }
- }
- //second:search another shotai
- if(kShotai == kMincho) start = strstr(buf, ",gothic,");
- else start = strstr(buf, ",mincho,");
- if(start != NULL){
- start = strchr((start+8), ',');
- if(start != NULL){
- start = strchr((start+1), ',');
- if(start != NULL){
- end = strchr((start+1), ',');
- if(end != NULL){
- kg_string_append_len(temp2, (start+1), end - start - 2 + 1);
- convert99(temp2, out);
- return;
- }
- }
- }
- }
+ strncpy(buf, dbdata.data, dbdata.size);
+ buf[dbdata.size] = '\0';
+ temp2 = kg_string_new(buf);
+ //fprintf(stderr,"%s\n",buf);
free(buf);
+ convert99(temp2, out);
+ return;
}
}
void searchAliasData(const KGString *in, KGString *out){
DBT dbkey, dbdata;
- char *start, *end, *buf;
+ char *buf;
KGString *temp;
//cut off the end '-0000' if 'in' end with it
dbkey.data = temp->str;
dbkey.size = temp->len;
kg_string_set_size(out, 0);
- kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0);
+ kIdsdbDatabase->get(kIdsdbDatabase, NULL, &dbkey, &dbdata, 0);
if(dbdata.size != 0){
buf = (char *)malloc(dbdata.size + 1);
- strncpy(buf, dbdata.data, dbdata.size + 1);
- start = strstr(buf, ",linkto,");
- if(start != NULL){
- start = strchr((start+8), ',');
- if(start != NULL){
- start = strchr((start+1), ',');
- if(start != NULL){
- end = strchr((start+1), ',');
- if(end != NULL){
- kg_string_append_len(out, (start+1), end - start - 2 + 1);
- }
- }
- }
- }
+ strncpy(buf, dbdata.data, dbdata.size);
+ buf[dbdata.size] = '\0';
+ //fprintf(stderr,"%s\n",buf);
+ kg_string_append(out, buf);
free(buf);
}
}
-