Example #1
0
// renders document into memory buffer,
int XSD_RenderDocument(document_rendered_t *ret, xml_document_t *doc, int width)
{
    int lines;

    memset(ret, 0, sizeof(document_rendered_t));

    // render document title
    if (doc->title)
    {
        int lines;
        document_tag_text_t *text;
        document_tag_p_t *p;
        xml_document_t *tdoc;

        tdoc = XSD_Document_New();

        // create p tag
        p = (document_tag_p_t *) Q_malloc(sizeof(document_tag_p_t));
        memset(p, 0, sizeof(document_tag_p_t));
        p->type = tag_p;
        p->align = align_center;

        tdoc->content = (document_tag_t *) p;

        // create text tag
        text = (document_tag_text_t *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(doc->title);

        p->tags = (document_tag_t *) text;

        lines = XSD_RenderDocumentOnce(tdoc, NULL, width, 0, NULL, NULL);
        if (lines > 0)
        {
            ret->title = (char *) Q_malloc(lines*width);
	    ret->title_lines = XSD_RenderDocumentOnce(tdoc,(byte *) ret->title, width, lines, NULL, NULL);
        }

        XSD_Document_Free((xml_t *)tdoc);
    }

    // render document body
    lines = XSD_RenderDocumentOnce(doc, NULL, width, 0, NULL, NULL);
    if (lines <= 0)
        goto error;
    ret->text = (char *) Q_malloc(lines*width);
    ret->text_lines = XSD_RenderDocumentOnce(doc,(byte *) ret->text, width, lines, &ret->links, &ret->sections);
    return 1;

error:
    XSD_RenderClear(ret);
    return 0;
}
Example #2
0
// convert to xml_document_t
xml_document_t * XSD_Variable_Convert(xml_t *doc)
{
    xml_document_t *ret;
    xml_variable_t *var = (xml_variable_t *) doc;

    ret = XSD_Document_New();

    // make head
    ret->title = Q_strdup(var->name);

    // make body
    {
        document_tag_text_t *text;

        text = (document_tag_text_t *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(var->description);
        ret->content = (document_tag_t *) text;
    }

    return ret;
}