13 int main(int argc, char **argv)
15 const char *hex_prefix = argv[2];
16 const int prefix_len = strlen(hex_prefix) / 2;
17 uint8_t *prefix = new uint8_t[prefix_len];
19 for (int i = 0; i < prefix_len; ++i) {
21 x[0] = hex_prefix[i * 2 + 0];
22 x[1] = hex_prefix[i * 2 + 1];
25 sscanf(x, "%02x", &k);
29 mtbl_reader* mtbl = mtbl_reader_init(argv[1], NULL);
30 const mtbl_source *src = mtbl_reader_source(mtbl);
31 mtbl_iter *it = mtbl_source_get_prefix(src, prefix, prefix_len);
33 const uint8_t *key, *val;
34 size_t len_key, len_val;
36 while (mtbl_iter_next(it, &key, &len_key, &val, &len_val)) {
37 string move((char *)(key + prefix_len), len_key - prefix_len);
38 const Count* c = (Count *)val;
39 printf("%s %d %d %d %d %f %f\n", move.c_str(), c->white, c->draw, c->black, c->opening_num, c->avg_white_elo, c->avg_black_elo);