version 1.5, 2008/12/15 01:54:58 |
version 1.6, 2009/09/21 14:56:56 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se> |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the |
* purpose with or without fee is hereby granted, provided that the above |
* above copyright notice and this permission notice appear in all |
* copyright notice and this permission notice appear in all copies. |
* copies. |
|
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* PERFORMANCE OF THIS SOFTWARE. |
|
*/ |
*/ |
#ifndef HTML_H |
#ifndef HTML_H |
#define HTML_H |
#define HTML_H |
|
|
#include "ml.h" |
__BEGIN_DECLS |
|
|
enum html_tag { |
enum htmltag { |
HTML_TAG_SPAN = 0, |
TAG_HTML, |
HTML_TAG_HTML = 1, |
TAG_HEAD, |
HTML_TAG_HEAD = 2, |
TAG_BODY, |
HTML_TAG_META = 3, |
TAG_META, |
HTML_TAG_TITLE = 4, |
TAG_TITLE, |
HTML_TAG_STYLE = 5, |
TAG_DIV, |
HTML_TAG_LINK = 6, |
TAG_H1, |
HTML_TAG_BODY = 7, |
TAG_H2, |
HTML_TAG_DIV = 8, |
TAG_P, |
HTML_TAG_TABLE = 9, |
TAG_SPAN, |
HTML_TAG_TD = 10, |
TAG_LINK, |
HTML_TAG_TR = 11, |
TAG_BR, |
HTML_TAG_OL = 12, |
TAG_A, |
HTML_TAG_UL = 13, |
TAG_TABLE, |
HTML_TAG_LI = 14, |
TAG_COL, |
HTML_TAG_H1 = 15, |
TAG_TR, |
HTML_TAG_H2 = 16, |
TAG_TD, |
HTML_TAG_A = 17 |
TAG_LI, |
|
TAG_UL, |
|
TAG_OL, |
|
TAG_BASE, |
|
TAG_MAX |
}; |
}; |
|
|
enum html_attr { |
enum htmlattr { |
HTML_ATTR_CLASS = 0, |
ATTR_HTTPEQUIV, |
HTML_ATTR_HTTP_EQUIV = 1, |
ATTR_CONTENT, |
HTML_ATTR_CONTENT = 2, |
ATTR_NAME, |
HTML_ATTR_NAME = 3, |
ATTR_REL, |
HTML_ATTR_TYPE = 4, |
ATTR_HREF, |
HTML_ATTR_REL = 5, |
ATTR_TYPE, |
HTML_ATTR_HREF = 6, |
ATTR_MEDIA, |
HTML_ATTR_WIDTH = 7, |
ATTR_CLASS, |
HTML_ATTR_ALIGN = 8, |
ATTR_STYLE, |
HTML_ATTR_VALIGN = 9, |
ATTR_WIDTH, |
HTML_ATTR_NOWRAP = 10 |
ATTR_VALIGN, |
|
ATTR_MAX |
}; |
}; |
|
|
enum html_type { |
struct tag { |
HTML_TYPE_4_01_STRICT = 0 |
enum htmltag tag; |
|
SLIST_ENTRY(tag) entry; |
}; |
}; |
|
|
struct html_pair { |
struct ord { |
enum html_attr attr; |
int pos; |
char *val; |
const void *cookie; |
|
SLIST_ENTRY(ord) entry; |
}; |
}; |
|
|
__BEGIN_DECLS |
SLIST_HEAD(tagq, tag); |
|
SLIST_HEAD(ordq, ord); |
|
|
int html_typeput(struct md_mbuf *, |
struct htmlpair { |
enum html_type, size_t *); |
enum htmlattr key; |
int html_commentput(struct md_mbuf *, |
char *val; |
enum ml_scope, size_t *); |
}; |
int html_tput(struct md_mbuf *, |
|
enum ml_scope, enum html_tag, size_t *); |
struct html { |
int html_aput(struct md_mbuf *, enum ml_scope, |
int flags; |
enum html_tag, size_t *, |
#define HTML_NOSPACE (1 << 0) |
int, const struct html_pair *); |
#define HTML_NEWLINE (1 << 1) |
int html_stput(struct md_mbuf *, |
struct tagq tags; |
enum html_tag, size_t *); |
struct ordq ords; |
int html_saput(struct md_mbuf *, enum html_tag, |
void *symtab; |
size_t *, int, const struct html_pair *); |
char *base; |
|
char *style; |
|
}; |
|
|
|
void print_gen_doctype(struct html *); |
|
void print_gen_head(struct html *); |
|
struct tag *print_otag(struct html *, enum htmltag, |
|
int, const struct htmlpair *); |
|
void print_tagq(struct html *, const struct tag *); |
|
void print_stagq(struct html *, const struct tag *); |
|
void print_text(struct html *, const char *); |
|
|
__END_DECLS |
__END_DECLS |
|
|