638 |
638 |
639 // matching rule type 1-byte |
639 // matching rule type 1-byte |
640 if (i<buf_len) bpq->matching_rule = (u_int) buf[i++]; |
640 if (i<buf_len) bpq->matching_rule = (u_int) buf[i++]; |
641 |
641 |
642 // BPQ-value-length SDNV |
642 // BPQ-value-length SDNV |
643 if ( (q_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->query.query_len))) == -1 ) |
643 if ( (q_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->query.query_len))) == -1 ) { |
644 return -1; |
644 fprintf (stderr, "Error decoding BPQ-value-length\n"); |
|
645 return -1; |
|
646 } |
645 i += q_decoding_len; |
647 i += q_decoding_len; |
646 |
648 |
647 // BPQ-value n-bytes |
649 // BPQ-value n-bytes |
648 if (i<buf_len) bpq->query.query_val = &(buf[i]); |
650 if (i<buf_len) bpq->query.query_val = &(buf[i]); |
649 i += bpq->query.query_len; |
651 i += bpq->query.query_len; |
650 |
652 |
651 // number of fragments SDNV |
653 // number of fragments SDNV |
652 if ( (f_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.num_frag_returned))) == -1 ) |
654 if ( (f_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.num_frag_returned))) == -1 ) { |
653 return -1; |
655 fprintf (stderr, "Error decoding number of fragments\n"); |
|
656 return -1; |
|
657 } |
654 i += f_decoding_len; |
658 i += f_decoding_len; |
655 |
659 |
656 for (j=0; i<buf_len && j<bpq->fragments.num_frag_returned; ++j) { |
660 for (j=0; i<buf_len && j<bpq->fragments.num_frag_returned; ++j) { |
657 |
661 |
658 // fragment offsets SDNV |
662 // fragment offsets SDNV |
659 if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.frag_offsets[j]))) == -1 ) |
663 if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.frag_offsets[j]))) == -1 ) { |
|
664 fprintf (stderr, "Error decoding fragment[%d] offset\n", j); |
660 return -1; |
665 return -1; |
|
666 } |
661 i += decoding_len; |
667 i += decoding_len; |
662 |
668 |
663 // fragment lengths SDNV |
669 // fragment lengths SDNV |
664 if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.frag_lenghts[j]))) == -1 ) |
670 if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, &(bpq->fragments.frag_lenghts[j]))) == -1 ) { |
|
671 fprintf (stderr, "Error decoding fragment[%d] length\n", j); |
665 return -1; |
672 return -1; |
|
673 } |
666 i += decoding_len; |
674 i += decoding_len; |
667 } |
675 } |
668 |
676 |
669 if (i != buf_len) |
677 if (i != buf_len) |
670 return -1; |
678 return -1; |