/* Deserializes the supplied (wire) buffer into subscribe data  */
int MQTTDeserialize_subscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int buflen)
/* Deserializes the supplied (wire) buffer into subscribe data  */
int MQTTDeserialize_subscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int buflen)
{
    MQTTHeader header = {0};
    unsigned char* curdata = buf;
    unsigned char* enddata = NULL;
    int rc = -1;
    int mylen = 0;
    FUNC_ENTRY;
    header.byte = readChar(&curdata);
    if (header.bits.type != SUBSCRIBE)
        goto exit;
    *dup = header.bits.dup;
    curdata += (rc = MQTTPacket_decodeBuf(curdata,
                                          &mylen));
    enddata = curdata + mylen;
    *packetid = readInt(&curdata);
    *count = 0;
    while (curdata < enddata) {
        if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
            goto exit;
        if (curdata >= enddata)
            goto exit;
        requestedQoSs[*count] = readChar(&curdata);
        (*count)++;
    }
    rc = 1;
exit:
    FUNC_EXIT_RC(rc);
    return rc;
}