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;
}
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);
--- /dev/null
+###############################################################################
+# makealiasdb.pl
+#
+# create DB file for KAGE/cgi from alias.txt
+# by Koichi Kamichi
+###############################################################################
+
+if($#ARGV != 0 || !(-d $ARGV[0])){
+ print "Usage: perl makealiasdb.pl alias_dir\n";
+ exit;
+}
+$aliasdir = $ARGV[0];
+$aliasdir =~ s/\/?$//; # remove the last slash
+
+if(-e "aliasdb"){
+ print "Remove old aliasdb first.\n";
+ exit;
+}
+
+use Fcntl;
+use BerkeleyDB;
+
+tie %db, "BerkeleyDB::Hash", -Filename => "aliasdb", -Flags => DB_CREATE
+or die "An error occured at ceating DB file.\n";
+%db = ();
+
+open(FH, "<$ARGV[0]/alias.txt");
+@buffer = <FH>;
+
+$counter = 1;
+
+foreach(@buffer){
+ $_ =~ m/(.*?)\t(.*)\n/;
+ $key = $1;
+ $value = $2;
+ if($value ne ""){
+ print "\rcreating ... [$counter] key : $key ";
+ $db{$key} = $value;
+ $counter++;
+ }
+}
+
+close(FH);
+untie(%db);
+print "\n\rdone.\n";
Then ''partsdb'' is to be created.
+* aliasdb : Kanji parts alias database for KAGE/cgi
+
+Get makealiasdb.pl and alias.txt, please type like follows.
+
+ % perl makealiasdb.pl .
+
+Then ''aliasdb'' is to be created.
+
* idsdb : Kanji alias IDS database for KAGE/cgi
Get makeidsdb.pl and CHISE/IDS data, please type like follows.