Jeff Thompson | 76317aa | 2013-06-25 19:11:48 -0700 | [diff] [blame] | 1 | /* |
| 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 |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | struct ndn_BinaryXMLDecoder { |
| 15 | const unsigned char *input; |
Jeff Thompson | f731669 | 2013-06-26 21:31:42 -0700 | [diff] [blame] | 16 | unsigned int inputLength; |
Jeff Thompson | 76317aa | 2013-06-25 19:11:48 -0700 | [diff] [blame] | 17 | unsigned int offset; |
| 18 | }; |
| 19 | |
Jeff Thompson | f731669 | 2013-06-26 21:31:42 -0700 | [diff] [blame] | 20 | static void ndn_BinaryXMLDecoder_init(struct ndn_BinaryXMLDecoder *self, const unsigned char *input, unsigned int inputLength) { |
Jeff Thompson | 76317aa | 2013-06-25 19:11:48 -0700 | [diff] [blame] | 21 | self->input = input; |
Jeff Thompson | f731669 | 2013-06-26 21:31:42 -0700 | [diff] [blame] | 22 | self->inputLength = inputLength; |
Jeff Thompson | 76317aa | 2013-06-25 19:11:48 -0700 | [diff] [blame] | 23 | self->offset = 0; |
| 24 | } |
| 25 | |
| 26 | // Even though the first byte should not be zero, this silently ignores initial zeros. |
| 27 | const char *ndn_BinaryXMLDecoder_decodeTypeAndValue(struct ndn_BinaryXMLDecoder *self, unsigned int *type, unsigned int *value); |
| 28 | |
Jeff Thompson | f731669 | 2013-06-26 21:31:42 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Set the offset into the input, used for the next read. |
| 31 | * @param self pointer to the ndn_BinaryXMLDecoder struct |
| 32 | * @param offset the new offset |
| 33 | */ |
| 34 | static inline void ndn_BinaryXMLDecoder_seek(struct ndn_BinaryXMLDecoder *self, unsigned int offset) { |
| 35 | self->offset = offset; |
| 36 | } |
| 37 | |
Jeff Thompson | 76317aa | 2013-06-25 19:11:48 -0700 | [diff] [blame] | 38 | #ifdef __cplusplus |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | #endif |