Change DB reference from KAGE/DB to partsdb and idsdb.
authorKoichi KAMICHI <kamichi@fonts.jp>
Tue, 14 Dec 2004 08:03:15 +0000 (08:03 +0000)
committerKoichi KAMICHI <kamichi@fonts.jp>
Tue, 14 Dec 2004 08:03:15 +0000 (08:03 +0000)
kagecgi/kagecgi.h
kagecgi/kagedb.c

index 4ce9d49..25fb575 100755 (executable)
@@ -9,11 +9,10 @@
 \r
 // define for localhost environment\r
 #define errorFileSize 3992\r
-//#define errorFileName "/usr/local/share/kagecgi/error.png"\r
 #define errorFileName "error.png"\r
-#define pngFilePath "/var/www/fontsjp/v0.4/"\r
-//#define databaseFileName "/usr/local/share/kagecgi/kagedb"\r
-#define databaseFileName "kagedb"\r
+#define pngFilePath "/var/www/v0.4/"\r
+#define partsdbFileName "/var/www/kagedb/partsdb"\r
+#define idsdbFileName "/var/www/kagedb/idsdb"\r
 \r
 #define kBaseline 188\r
 #define pngWidth 200\r
@@ -24,7 +23,8 @@
 #define min(x1,x2) ((x1) > (x2))? (x2):(x1)\r
 #define max(x1,x2) ((x1) > (x2))? (x1):(x2)\r
 \r
-DB *kDatabase;\r
+DB *kPartsdbDatabase;\r
+DB *kIdsdbDatabase;\r
 \r
 FILE *debug;\r
 \r
index 469d833..e1bfa21 100755 (executable)
@@ -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);
        }
 }
-