Skip to content

Commit bf15c15

Browse files
committed
update checking for DB types to support lmdb and kyotocabinet checks properly
1 parent 8184063 commit bf15c15

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libduc/db.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ char *duc_db_type_check(const char *path_db)
117117
/* read first MAGIC_LEN bytes of file then look for the strings, etc for each type of DB we support. */
118118
size_t len = fread(buf, 1, sizeof(buf),f);
119119

120-
if (strncmp(buf,"Kyoto CaBiNeT",13) == 0) {
121-
return("kyotocabinet");
120+
char kyotocabinet[] = { 0x4b,0x43,0x0a,0x0,0x10,0x0e,0x06,0xb4,0x31,0x08,0x0a,0x04,0x00,0x00,0x00,0x00 };
121+
if (memcmp(buf,kyotocabinet,16) == 0) {
122+
return("kyotocabinet(hex)");
122123
}
123124

124125
if (strncmp(buf,"ToKyO CaBiNeT",13) == 0) {
@@ -133,7 +134,9 @@ char *duc_db_type_check(const char *path_db)
133134
return("sqlite3");
134135
}
135136

136-
if (strncmp(buf,"SQLite format 3",15) == 0) {
137+
char lmdb[] = { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x08,0x0,0x0,0x0,0x0,0x0,
138+
0xde,0xc0,0xef,0xbe,0x01,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
139+
if (memcmp(buf,lmdb,32) == 0) {
137140
return("lmdb");
138141
}
139142

0 commit comments

Comments
 (0)