9 db_create(&kDatabase, NULL, 0);
10 kDatabase->open(kDatabase, databaseFileName, NULL, DB_HASH, DB_RDONLY, 0644);
15 kDatabase->close(kDatabase, 0);
19 void searchPartsData(const KGString *in, KGString *out){
21 char *start, *end, *buf;
22 KGString *temp, *temp2;
24 //cut off the end '-0000' if 'in' end with it
25 temp = kg_string_new(in->str);
26 // if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5);
27 if((temp->str)[0] == 'u'){
28 if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4);
29 else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
30 else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
31 else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
32 else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
33 else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
36 memset(&dbkey,0,sizeof(DBT));
37 memset(&dbdata,0,sizeof(DBT));
38 dbkey.data = temp->str;
39 dbkey.size = temp->len;
40 kg_string_set_size(out, 0);
41 temp2 = kg_string_new("");
42 kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0);
44 buf = (char *)malloc(dbdata.size + 1);
45 strncpy(buf, dbdata.data, dbdata.size + 1);
46 //first:search selected shotai
47 if(kShotai == kMincho) start = strstr(buf, ",mincho,");
48 else start = strstr(buf, ",gothic,");
50 start = strchr((start+8), ',');
52 start = strchr((start+1), ',');
54 end = strchr((start+1), ',');
56 kg_string_append_len(temp2, (start+1), end - start - 2 + 1);
57 convert99(temp2, out);
63 //second:search another shotai
64 if(kShotai == kMincho) start = strstr(buf, ",gothic,");
65 else start = strstr(buf, ",mincho,");
67 start = strchr((start+8), ',');
69 start = strchr((start+1), ',');
71 end = strchr((start+1), ',');
73 kg_string_append_len(temp2, (start+1), end - start - 2 + 1);
74 convert99(temp2, out);
84 void searchAliasData(const KGString *in, KGString *out){
86 char *start, *end, *buf;
89 //cut off the end '-0000' if 'in' end with it
90 temp = kg_string_new(in->str);
91 // if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5);
92 if((temp->str)[0] == 'u'){
93 if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4);
94 else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
95 else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
96 else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
97 else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
98 else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2);
101 memset(&dbkey,0,sizeof(DBT));
102 memset(&dbdata,0,sizeof(DBT));
103 dbkey.data = temp->str;
104 dbkey.size = temp->len;
105 kg_string_set_size(out, 0);
106 kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0);
107 if(dbdata.size != 0){
108 buf = (char *)malloc(dbdata.size + 1);
109 strncpy(buf, dbdata.data, dbdata.size + 1);
110 start = strstr(buf, ",linkto,");
112 start = strchr((start+8), ',');
114 start = strchr((start+1), ',');
116 end = strchr((start+1), ',');
118 kg_string_append_len(out, (start+1), end - start - 2 + 1);