Import mdocml-1.11.1
[dragonfly.git] / contrib / mdocml / out.h
CommitLineData
60e1e752 1/* $Id: out.h,v 1.18 2011/03/22 10:13:01 kristaps Exp $ */
80387638 2/*
60e1e752 3 * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
80387638
SW
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 OUT_H
18#define OUT_H
19
80387638 20enum roffscale {
60e1e752
SW
21 SCALE_CM, /* centimeters (c) */
22 SCALE_IN, /* inches (i) */
23 SCALE_PC, /* pica (P) */
24 SCALE_PT, /* points (p) */
25 SCALE_EM, /* ems (m) */
26 SCALE_MM, /* mini-ems (M) */
27 SCALE_EN, /* ens (n) */
28 SCALE_BU, /* default horizontal (u) */
29 SCALE_VS, /* default vertical (v) */
30 SCALE_FS, /* syn. for u (f) */
80387638
SW
31 SCALE_MAX
32};
33
34enum roffdeco {
35 DECO_NONE,
60e1e752 36 DECO_NUMBERED, /* numbered character */
80387638
SW
37 DECO_SPECIAL, /* special character */
38 DECO_SSPECIAL, /* single-char special */
39 DECO_RESERVED, /* reserved word */
40 DECO_BOLD, /* bold font */
41 DECO_ITALIC, /* italic font */
42 DECO_ROMAN, /* "normal" undecorated font */
43 DECO_PREVIOUS, /* revert to previous font */
44 DECO_NOSPACE, /* suppress spacing */
45 DECO_FONT, /* font */
46 DECO_FFONT, /* font family */
47 DECO_MAX
48};
49
60e1e752
SW
50enum chars {
51 CHARS_ASCII, /* 7-bit ascii representation */
52 CHARS_HTML /* unicode values */
53};
54
55struct roffcol {
56 size_t width; /* width of cell */
57 size_t decimal; /* decimal position in cell */
58};
59
80387638
SW
60struct roffsu {
61 enum roffscale unit;
62 double scale;
63};
64
60e1e752
SW
65typedef size_t (*tbl_strlen)(const char *, void *);
66typedef size_t (*tbl_len)(size_t, void *);
67
68struct rofftbl {
69 tbl_strlen slen; /* calculate string length */
70 tbl_len len; /* produce width of empty space */
71 struct roffcol *cols; /* master column specifiers */
72 void *arg; /* passed to slen and len */
73};
74
75__BEGIN_DECLS
76
80387638
SW
77#define SCALE_VS_INIT(p, v) \
78 do { (p)->unit = SCALE_VS; \
79 (p)->scale = (v); } \
80 while (/* CONSTCOND */ 0)
81
82#define SCALE_HS_INIT(p, v) \
83 do { (p)->unit = SCALE_BU; \
84 (p)->scale = (v); } \
85 while (/* CONSTCOND */ 0)
86
60e1e752
SW
87int a2roffsu(const char *, struct roffsu *, enum roffscale);
88int a2roffdeco(enum roffdeco *, const char **, size_t *);
89void time2a(time_t, char *, size_t);
90void tblcalc(struct rofftbl *tbl, const struct tbl_span *);
91
92void *chars_init(enum chars);
93const char *chars_num2char(const char *, size_t);
94const char *chars_spec2str(void *, const char *, size_t, size_t *);
95int chars_spec2cp(void *, const char *, size_t);
96const char *chars_res2str(void *, const char *, size_t, size_t *);
97int chars_res2cp(void *, const char *, size_t);
98void chars_free(void *);
80387638
SW
99
100__END_DECLS
101
102#endif /*!OUT_H*/