blob: c9e558dda053e18966a0f0d79287fc0b04fc0779 [file] [log] [blame]
Jeff Thompson76317aa2013-06-25 19:11:48 -07001/*
2 * Author: Jeff Thompson
3 *
4 * BSD license, See the LICENSE file for more information.
5 */
6
7#ifndef NDN_BINARYXMLDECODER_H
8#define NDN_BINARYXMLDECODER_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14struct ndn_BinaryXMLDecoder {
Jeff Thompsond6f13282013-06-27 17:31:50 -070015 unsigned char *input;
Jeff Thompsonf7316692013-06-26 21:31:42 -070016 unsigned int inputLength;
Jeff Thompson76317aa2013-06-25 19:11:48 -070017 unsigned int offset;
18};
19
Jeff Thompsond6f13282013-06-27 17:31:50 -070020static inline void ndn_BinaryXMLDecoder_init(struct ndn_BinaryXMLDecoder *self, unsigned char *input, unsigned int inputLength)
Jeff Thompson6c9b6512013-06-27 15:59:47 -070021{
Jeff Thompson76317aa2013-06-25 19:11:48 -070022 self->input = input;
Jeff Thompsonf7316692013-06-26 21:31:42 -070023 self->inputLength = inputLength;
Jeff Thompson76317aa2013-06-25 19:11:48 -070024 self->offset = 0;
25}
26
27// Even though the first byte should not be zero, this silently ignores initial zeros.
Jeff Thompsond6f13282013-06-27 17:31:50 -070028char *ndn_BinaryXMLDecoder_decodeTypeAndValue(struct ndn_BinaryXMLDecoder *self, unsigned int *type, unsigned int *value);
Jeff Thompson76317aa2013-06-25 19:11:48 -070029
Jeff Thompsonf7316692013-06-26 21:31:42 -070030/**
31 * Set the offset into the input, used for the next read.
32 * @param self pointer to the ndn_BinaryXMLDecoder struct
33 * @param offset the new offset
34 */
Jeff Thompson6c9b6512013-06-27 15:59:47 -070035static inline void ndn_BinaryXMLDecoder_seek(struct ndn_BinaryXMLDecoder *self, unsigned int offset)
36{
Jeff Thompsonf7316692013-06-26 21:31:42 -070037 self->offset = offset;
38}
39
Jeff Thompson76317aa2013-06-25 19:11:48 -070040#ifdef __cplusplus
41}
42#endif
43
44#endif