| Commit | Line | Data |
|---|---|---|
| 32c903ac | 1 | /* $Id: html.h,v 1.17 2009/10/28 08:00:18 kristaps Exp $ */ |
| 589e7c1d SW |
2 | /* |
| 3 | * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> | |
| 4 | * | |
| 5 | * Permission to use, copy, modify, and distribute this software for any | |
| 6 | * purpose with or without fee is hereby granted, provided that the above | |
| 7 | * copyright notice and this permission notice appear in all copies. | |
| 8 | * | |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 16 | */ | |
| 17 | #ifndef HTML_H | |
| 18 | #define HTML_H | |
| 19 | ||
| 20 | __BEGIN_DECLS | |
| 21 | ||
| 22 | enum htmltag { | |
| 23 | TAG_HTML, | |
| 24 | TAG_HEAD, | |
| 25 | TAG_BODY, | |
| 26 | TAG_META, | |
| 27 | TAG_TITLE, | |
| 28 | TAG_DIV, | |
| 29 | TAG_H1, | |
| 30 | TAG_H2, | |
| 31 | TAG_P, | |
| 32 | TAG_SPAN, | |
| 33 | TAG_LINK, | |
| 34 | TAG_BR, | |
| 35 | TAG_A, | |
| 36 | TAG_TABLE, | |
| 37 | TAG_COL, | |
| 38 | TAG_TR, | |
| 39 | TAG_TD, | |
| 40 | TAG_LI, | |
| 41 | TAG_UL, | |
| 42 | TAG_OL, | |
| 43 | TAG_BASE, | |
| 44 | TAG_MAX | |
| 45 | }; | |
| 46 | ||
| 47 | enum htmlattr { | |
| 48 | ATTR_HTTPEQUIV, | |
| 49 | ATTR_CONTENT, | |
| 50 | ATTR_NAME, | |
| 51 | ATTR_REL, | |
| 52 | ATTR_HREF, | |
| 53 | ATTR_TYPE, | |
| 54 | ATTR_MEDIA, | |
| 55 | ATTR_CLASS, | |
| 56 | ATTR_STYLE, | |
| 57 | ATTR_WIDTH, | |
| 58 | ATTR_VALIGN, | |
| 59 | ATTR_TARGET, | |
| 60 | ATTR_ID, | |
| 32c903ac | 61 | ATTR_SUMMARY, |
| 589e7c1d SW |
62 | ATTR_MAX |
| 63 | }; | |
| 64 | ||
| 65 | struct tag { | |
| cbce6d97 | 66 | struct tag *next; |
| 589e7c1d | 67 | enum htmltag tag; |
| 589e7c1d SW |
68 | }; |
| 69 | ||
| 70 | struct ord { | |
| cbce6d97 | 71 | struct ord *next; |
| 589e7c1d | 72 | const void *cookie; |
| cbce6d97 | 73 | int pos; |
| 589e7c1d SW |
74 | }; |
| 75 | ||
| cbce6d97 SW |
76 | struct tagq { |
| 77 | struct tag *head; | |
| 78 | }; | |
| 79 | struct ordq { | |
| 80 | struct ord *head; | |
| 81 | }; | |
| 589e7c1d SW |
82 | |
| 83 | struct htmlpair { | |
| 84 | enum htmlattr key; | |
| 85 | const char *val; | |
| 86 | }; | |
| 87 | ||
| 88 | #define PAIR_CLASS_INIT(p, v) \ | |
| 89 | do { (p)->key = ATTR_CLASS; \ | |
| 90 | (p)->val = (v); } while (/* CONSTCOND */ 0) | |
| 91 | #define PAIR_HREF_INIT(p, v) \ | |
| 92 | do { (p)->key = ATTR_HREF; \ | |
| 93 | (p)->val = (v); } while (/* CONSTCOND */ 0) | |
| 94 | #define PAIR_STYLE_INIT(p, h) \ | |
| 95 | do { (p)->key = ATTR_STYLE; \ | |
| 96 | (p)->val = (h)->buf; } while (/* CONSTCOND */ 0) | |
| 32c903ac SW |
97 | #define PAIR_SUMMARY_INIT(p, v) \ |
| 98 | do { (p)->key = ATTR_SUMMARY; \ | |
| 99 | (p)->val = (v); } while (/* CONSTCOND */ 0) | |
| 589e7c1d SW |
100 | |
| 101 | struct html { | |
| 102 | int flags; | |
| 103 | #define HTML_NOSPACE (1 << 0) | |
| 104 | #define HTML_NEWLINE (1 << 1) | |
| 105 | #define HTML_IGNDELIM (1 << 2) | |
| 106 | struct tagq tags; | |
| 107 | struct ordq ords; | |
| 108 | void *symtab; | |
| 109 | char *base; | |
| 110 | char *base_man; | |
| 111 | char *base_includes; | |
| 112 | char *style; | |
| 113 | char buf[BUFSIZ]; | |
| 114 | size_t buflen; | |
| 115 | }; | |
| 116 | ||
| 117 | struct roffsu; | |
| 118 | ||
| 119 | void print_gen_doctype(struct html *); | |
| 120 | void print_gen_head(struct html *); | |
| 121 | struct tag *print_otag(struct html *, enum htmltag, | |
| 122 | int, const struct htmlpair *); | |
| 123 | void print_tagq(struct html *, const struct tag *); | |
| 124 | void print_stagq(struct html *, const struct tag *); | |
| 125 | void print_text(struct html *, const char *); | |
| 126 | ||
| 127 | void bufcat_su(struct html *, const char *, | |
| 128 | const struct roffsu *); | |
| 129 | void buffmt_man(struct html *, | |
| 130 | const char *, const char *); | |
| 131 | void buffmt_includes(struct html *, const char *); | |
| 132 | void buffmt(struct html *, const char *, ...); | |
| 133 | void bufcat(struct html *, const char *); | |
| 134 | void bufcat_style(struct html *, | |
| 135 | const char *, const char *); | |
| 136 | void bufncat(struct html *, const char *, size_t); | |
| 137 | void bufinit(struct html *); | |
| 138 | ||
| 32c903ac SW |
139 | void html_idcat(char *, const char *, int); |
| 140 | ||
| 589e7c1d SW |
141 | __END_DECLS |
| 142 | ||
| 143 | #endif /*!HTML_H*/ |