From 9fb32b8dd24d1dbd1d344b8f7c4410294ca523fb Mon Sep 17 00:00:00 2001 From: Koichi KAMICHI Date: Fri, 1 Jul 2005 07:22:13 +0000 Subject: [PATCH] Added some debugging codes. --- kagecgi/kagedb.c | 185 ++++++++++++++++++++++++++++-------------------------- kagecgi/kageeg.c | 8 +++ 2 files changed, 103 insertions(+), 90 deletions(-) diff --git a/kagecgi/kagedb.c b/kagecgi/kagedb.c index cebb14d..d1d5098 100755 --- a/kagecgi/kagedb.c +++ b/kagecgi/kagedb.c @@ -6,103 +6,108 @@ #include "sysdep.h" int initDB(){ - 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); - db_create(&kAliasdbDatabase, NULL, 0); - kAliasdbDatabase->open(kAliasdbDatabase, NULL, aliasdbFileName, NULL, DB_HASH, DB_RDONLY, 0644); - return 0; + 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); + db_create(&kAliasdbDatabase, NULL, 0); + kAliasdbDatabase->open(kAliasdbDatabase, NULL, aliasdbFileName, NULL, DB_HASH, DB_RDONLY, 0644); + return 0; } int closeDB(){ - kPartsdbDatabase->close(kPartsdbDatabase, 0); - kIdsdbDatabase->close(kIdsdbDatabase, 0); - kAliasdbDatabase->close(kAliasdbDatabase, 0); - return 0; + kPartsdbDatabase->close(kPartsdbDatabase, 0); + kIdsdbDatabase->close(kIdsdbDatabase, 0); + kAliasdbDatabase->close(kAliasdbDatabase, 0); + return 0; } void searchPartsData(const KGString *in, KGString *out){ - DBT dbkey, dbdata; - char *buf; - KGString *temp, *temp2; - - //cut off the end '-0000' if 'in' end with it - temp = kg_string_new(in->str); -// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); - if((temp->str)[0] == 'u'){ - if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); - else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - } - - memset(&dbkey,0,sizeof(DBT)); - memset(&dbdata,0,sizeof(DBT)); - dbkey.data = temp->str; - dbkey.size = temp->len; - kg_string_set_size(out, 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); - buf[dbdata.size] = '\0'; - temp2 = kg_string_new(buf); - //fprintf(stderr,"%s\n",buf); - free(buf); - convert99(temp2, out); - return; - } + DBT dbkey, dbdata; + char *buf; + KGString *temp, *temp2; + + //cut off the end '-0000' if 'in' end with it + temp = kg_string_new(in->str); + //if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); + if((temp->str)[0] == 'u'){ + if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); + else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + } + //else{ + // kg_string_set_size(temp, in->len); + //} + + memset(&dbkey,0,sizeof(DBT)); + memset(&dbdata,0,sizeof(DBT)); + dbkey.data = temp->str; + dbkey.size = temp->len; + kg_string_set_size(out, 0); + //fprintf(stderr, "trytogetparts:%s(%s:%d)\n", in->str, temp->str,temp->len); + kPartsdbDatabase->get(kPartsdbDatabase, NULL, &dbkey, &dbdata, 0); + if(dbdata.size != 0){ + //fprintf(stderr, "getparts:%s\n", in->str); + //for temporary : shares glyph both Mincho and Gothic + buf = (char *)malloc(dbdata.size + 1); + 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 *buf; - KGString *temp; - - //cut off the end '-0000' if 'in' end with it - temp = kg_string_new(in->str); -// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); - if((temp->str)[0] == 'u'){ - if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); - else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); - } - - memset(&dbkey,0,sizeof(DBT)); - memset(&dbdata,0,sizeof(DBT)); - dbkey.data = temp->str; - dbkey.size = temp->len; - kg_string_set_size(out, 0); - kAliasdbDatabase->get(kAliasdbDatabase, NULL, &dbkey, &dbdata, 0); - if(dbdata.size != 0){ - buf = (char *)malloc(dbdata.size + 1); - strncpy(buf, dbdata.data, dbdata.size); - buf[dbdata.size] = '\0'; - //fprintf(stderr,"%s\n",buf); - kg_string_append(out, buf); - free(buf); - return; - } - - memset(&dbkey,0,sizeof(DBT)); - memset(&dbdata,0,sizeof(DBT)); - dbkey.data = temp->str; - dbkey.size = temp->len; - kg_string_set_size(out, 0); - kIdsdbDatabase->get(kIdsdbDatabase, NULL, &dbkey, &dbdata, 0); - if(dbdata.size != 0){ - buf = (char *)malloc(dbdata.size + 1); - strncpy(buf, dbdata.data, dbdata.size); - buf[dbdata.size] = '\0'; - //fprintf(stderr,"%s\n",buf); - kg_string_append(out, buf); - free(buf); - } + DBT dbkey, dbdata; + char *buf; + KGString *temp; + + //cut off the end '-0000' if 'in' end with it + temp = kg_string_new(in->str); + //if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); + if((temp->str)[0] == 'u'){ + if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); + else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + } + + memset(&dbkey,0,sizeof(DBT)); + memset(&dbdata,0,sizeof(DBT)); + dbkey.data = temp->str; + dbkey.size = temp->len; + kg_string_set_size(out, 0); + kAliasdbDatabase->get(kAliasdbDatabase, NULL, &dbkey, &dbdata, 0); + if(dbdata.size != 0){ + buf = (char *)malloc(dbdata.size + 1); + strncpy(buf, dbdata.data, dbdata.size); + buf[dbdata.size] = '\0'; + //fprintf(stderr,"%s\n",buf); + kg_string_append(out, buf); + free(buf); + return; + } + + memset(&dbkey,0,sizeof(DBT)); + memset(&dbdata,0,sizeof(DBT)); + dbkey.data = temp->str; + dbkey.size = temp->len; + kg_string_set_size(out, 0); + kIdsdbDatabase->get(kIdsdbDatabase, NULL, &dbkey, &dbdata, 0); + if(dbdata.size != 0){ + buf = (char *)malloc(dbdata.size + 1); + strncpy(buf, dbdata.data, dbdata.size); + buf[dbdata.size] = '\0'; + //fprintf(stderr,"%s\n",buf); + kg_string_append(out, buf); + free(buf); + } } diff --git a/kagecgi/kageeg.c b/kagecgi/kageeg.c index caf2e77..7174b22 100755 --- a/kagecgi/kageeg.c +++ b/kagecgi/kageeg.c @@ -48,19 +48,27 @@ void generateGlyph(const KGString *in, KGString *out){ //search from parts searchPartsData(in, tmp); if(tmp->len != 0){ + //fprintf(stderr, "partsFound:%s\n",tmp->str); tmp = CalcSizes(tmp, 1);// this line may not be needed out = kg_string_assign(out, tmp->str); return; } + //else{ + // fprintf(stderr, "partsNotFound:%s\n",in->str); + //} //search from alias searchAliasData(in, tmp); if(tmp->len != 0){ + //fprintf(stderr, "aliasFound:%s(%d)\n",tmp->str,tmp->len); generateGlyph(tmp, out); if(out->len == 0) return; //save to cache ... not yet return; } + //else{ + // fprintf(stderr, "aliasNotFound:%s\n",in->str); + //} //check if its IDS if(isIDS(in)){ -- 1.7.10.4