| * BSD license, See the LICENSE file for more information. |
| #include "BinaryXMLDecoder.h" |
| #include "BinaryXMLName.h" |
| char *ndn_decodeBinaryXMLName(struct ndn_Name *name, unsigned char *input, unsigned int inputLength) |
| struct ndn_BinaryXMLDecoder decoder; |
| ndn_BinaryXMLDecoder_init(&decoder, input, inputLength); |
| if (error = ndn_BinaryXMLDecoder_readDTag(&decoder, ndn_BinaryXML_DTag_Name)) |
| if (error = ndn_BinaryXMLDecoder_peekDTag(&decoder, ndn_BinaryXML_DTag_Component, &gotExpectedTag)) |
| unsigned char *component; |
| unsigned int componentLen; |
| if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement(&decoder, ndn_BinaryXML_DTag_Component, 0, &component, &componentLen)) |
| // Add the component to the name. |
| if (name->nComponents >= name->maxComponents) |
| return "ndn_decodeBinaryXMLName: read a component past the maximum number of components allowed in the name"; |
| ndn_NameComponent_init(name->components + name->nComponents, component, componentLen); |
| if (error = ndn_BinaryXMLDecoder_readElementClose(&decoder)) |