HashItem *construct_preset(char const *setkey, char *rest) { char *key; HashItem *mapItem; if (!(key = string_firstword(&rest))) /* get the key */ { /* e.g., title */ message_error("`preset ...: missing key"); return 0; } if (strcmp(key, "nohtmlfive") == 0) global.d_html5 = 0; else { if (!*string_strip(&rest)) /* get the value */ warning("Empty value of symbol `%s'", key); /* e.g., This is... */ if (strcmp(key, "styleopt") == 0) /* store styleopts */ lines_add(&global.d_styleopt, rest); else { /* look up the key */ mapItem = hashmap_find(&global.d_symbol, key, ANY); if (mapItem != PFAILED) /* reassign */ hashitem_set(mapItem, rest, free); /* existing value */ else /* or insert new */ hashmap_insert(&global.d_symbol, /* element */ hashitem_construct(VOIDPTR, key, new_str(rest), free)); } } free(key); return hashitem_construct(VOIDPTR, "", 0, root_nop); }
HashItem *construct_label(char const *key, char *rest) { HashItem *item; LabelInfo *li = new_memory(1, sizeof(LabelInfo)); li->d_section = lines_size(&global.d_section) - 1; li->d_filenr = global.d_filecount; if (!*rest) { message_error("Missing label name"); return 0; } item = hashitem_construct(VOIDPTR, rest, li, free); if (hashmap_insert(&symtab, item) == FAILED) { message_show(MSG_ERR); message("%s: %s doubly defined", args_programName(), key); return 0; } return hashitem_construct(VOIDPTR, rest, 0, root_nop); }
HashItem *construct_newfile(char const *key, char *rest) { global.d_filecount++; if (global.d_noext) { string_format(&global.d_outName, "%s%02u.%s", global.d_noext, (unsigned)global.d_filecount, global.d_ext); } /* arguments are for the handlers to process */ return *rest ? hashitem_construct(VOIDPTR, "", new_str(rest), free) : hashitem_construct(VOIDPTR, "", 0, root_nop); }
void builtin_insert(HashMap *symtab, Builtin *builtin) { while (builtin->d_name) { hashmap_insert ( symtab, hashitem_construct(BUILTIN, builtin->d_name, builtin, root_nop) ); builtin++; } }
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); }
HashItem *construct_txt_tocentry(char const *key, char *rest) { lines_add(&global.d_toc, rest); /* add a new entry */ return hashitem_construct(VOIDPTR, "", 0, root_nop); }
HashItem *construct_xml_done(char const *key, char *rest) { return hashitem_construct(VOIDPTR, "", new_str(rest), free); }