From: Koichi KAMICHI Date: Tue, 14 Dec 2004 08:03:15 +0000 (+0000) Subject: Change DB reference from KAGE/DB to partsdb and idsdb. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d5b90e9dec22ea7ec2f5b2030a4c0129db29f33;p=chise%2Fkage.git Change DB reference from KAGE/DB to partsdb and idsdb. --- diff --git a/kagecgi/kagecgi.h b/kagecgi/kagecgi.h index 4ce9d49..25fb575 100755 --- a/kagecgi/kagecgi.h +++ b/kagecgi/kagecgi.h @@ -9,11 +9,10 @@ // define for localhost environment #define errorFileSize 3992 -//#define errorFileName "/usr/local/share/kagecgi/error.png" #define errorFileName "error.png" -#define pngFilePath "/var/www/fontsjp/v0.4/" -//#define databaseFileName "/usr/local/share/kagecgi/kagedb" -#define databaseFileName "kagedb" +#define pngFilePath "/var/www/v0.4/" +#define partsdbFileName "/var/www/kagedb/partsdb" +#define idsdbFileName "/var/www/kagedb/idsdb" #define kBaseline 188 #define pngWidth 200 @@ -24,7 +23,8 @@ #define min(x1,x2) ((x1) > (x2))? (x2):(x1) #define max(x1,x2) ((x1) > (x2))? (x1):(x2) -DB *kDatabase; +DB *kPartsdbDatabase; +DB *kIdsdbDatabase; FILE *debug; diff --git a/kagecgi/kagedb.c b/kagecgi/kagedb.c index 469d833..e1bfa21 100755 --- a/kagecgi/kagedb.c +++ b/kagecgi/kagedb.c @@ -6,19 +6,22 @@ #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 @@ -38,52 +41,23 @@ void searchPartsData(const KGString *in, KGString *out){ 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 @@ -103,24 +77,13 @@ void searchAliasData(const KGString *in, KGString *out){ 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); } } -