Beispiel #1
0
static int lines_add(UT_array *lines, const line_t *line)
{
    int i;
    i = lines_find(lines, line);
    if (i) return i;
    utarray_push_back(lines, line);
    return lines_find(lines, line);
}
Beispiel #2
0
HashItem *construct_tocentry(char const *key, char *rest)
{
    size_t level;
    char *section = string_firstword(&rest);

    if (!section)
    {
        message_error("incomplete tocentry");
        return 0;
    }
    string_strip(&rest);
                                                /* find the section's index */
    level = lines_find(section, section_levels, sizeofSectionLevels);

    if (level == UFAILED)                       /* no section given is err. */
    {
        message_error("unknown toc-section `%s'", section);
        free(section);
        return 0;
    }

    free(section);
                                            /* write <dd><dl> for deeper
                                               levels */
    for (; level > global.d_toclevel; ++global.d_toclevel)
        lines_add(&global.d_toc, "<dd><dl>");

                                            /* write </dl></dd> when returning
                                               to shallower levels */
    for (; level < global.d_toclevel; --global.d_toclevel)
        lines_add(&global.d_toc, "</dl></dd>");

                                            /* add a new entry              */
    lines_format(&global.d_toc,
                    "<dt>%s<a href=\"%s#l%u\">%s</a>%s</dt>",
                        toc_section[global.d_doctype][level][0],
                        string_str(&global.d_outName),
                        (unsigned)++s_lastLabelNr,
                        rest,
                        toc_section[global.d_doctype][level][1]);

    return hashitem_construct(VOIDPTR, "", (void *)s_lastLabelNr, root_nop);
}