MOBI_RET mobi_opf_add_to_rawml(const char *opf_xml, MOBIRawml *rawml) {
    MOBIPart *opf_part;
    size_t uid = 0;
    if (rawml->resources) {
        MOBIPart *part = rawml->resources;
        while (part->next) {
            part = part->next;
        }
        uid = part->uid + 1;
        part->next = calloc(1, sizeof(MOBIPart));
        opf_part = part->next;
    }
    else {
        rawml->resources = calloc(1, sizeof(MOBIPart));
        opf_part = rawml->resources;
    }
    if (opf_part == NULL) {
        return MOBI_MALLOC_FAILED;
    }
    opf_part->uid = uid;
    opf_part->next = NULL;
    opf_part->data = (unsigned char *) strdup(opf_xml);
    if (opf_part->data == NULL) {
        free(opf_part);
        opf_part = NULL;
        return MOBI_MALLOC_FAILED;
    }
    opf_part->size = strlen(opf_xml);
    opf_part->type = T_OPF;
    return MOBI_SUCCESS;
}
MOBI_RET mobi_opf_add_to_rawml(const char *opf_xml, MOBIRawml *rawml) {
    MOBIPart *opf_part;
    size_t uid = 0;
    if (rawml->resources) {
        MOBIPart *part = rawml->resources;
        while (part->next) {
            part = part->next;
        }
        uid = part->uid + 1;
        part->next = calloc(1, sizeof(MOBIPart));
        opf_part = part->next;
    }
    else {
        rawml->resources = calloc(1, sizeof(MOBIPart));
        opf_part = rawml->resources;
    }
    if (opf_part == NULL) {
        return MOBI_MALLOC_FAILED;
    }
    opf_part->uid = uid;
    opf_part->next = NULL;
    opf_part->data = (unsigned char *) strdup(opf_xml);
    if (opf_part->data == NULL) {
        free(opf_part);
        opf_part = NULL;
        return MOBI_MALLOC_FAILED;
    }
    opf_part->size = strlen(opf_xml);
    opf_part->type = T_OPF;
    return MOBI_SUCCESS;
}