-void bam_aux_init(bam1_t *b)
-{
- khash_t(aux) *h;
- uint8_t *s;
- if (b->hash == 0) {
- h = kh_init(aux);
- b->hash = h;
- } else {
- h = (khash_t(aux)*)b->hash;
- kh_clear(aux, h);
- }
- s = bam1_aux(b);
- while (s < b->data + b->data_len) {
- uint32_t x = (uint32_t)s[0]<<8 | s[1];
- int ret, type;
- khint_t k;
- s += 2; type = toupper(*s); ++s;
- k = kh_put(aux, h, x, &ret);
- kh_value(h, k) = s;
- if (type == 'C') ++s;
- else if (type == 'S') s += 2;
- else if (type == 'I') s += 4;
- else if (type == 'F') s += 4;
- else if (type == 'Z') { while (*s) putchar(*s++); ++s; }
- }
-}
-void bam_aux_destroy(bam1_t *b)
-{
- khash_t(aux) *h = (khash_t(aux)*)b->hash;
- kh_destroy(aux, h);
- b->hash = 0;
-}
-static uint8_t *bam_aux_get_core(bam1_t *b, const char tag[2])
-{
- uint32_t x = (uint32_t)tag[0]<<8 | tag[1];
- khint_t k;
- khash_t(aux) *h;
- if (b->hash == 0) bam_aux_init(b);
- h = (khash_t(aux)*)b->hash;
- k = kh_get(aux, h, x);
- if (k == kh_end(h)) return 0;
- return kh_value(h, k);
-}
-int32_t bam_aux_geti(bam1_t *b, const char tag[2], int *err)