Annotation of mandoc/out.h, Revision 1.19
1.19 ! kristaps 1: /* $Id: out.h,v 1.18 2011/03/22 10:13:01 kristaps Exp $ */
1.1 kristaps 2: /*
1.16 schwarze 3: * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.1 kristaps 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
1.6 kristaps 19:
1.3 kristaps 20: enum roffscale {
1.18 kristaps 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) */
1.3 kristaps 31: SCALE_MAX
32: };
33:
1.18 kristaps 34: enum chars {
35: CHARS_ASCII, /* 7-bit ascii representation */
36: CHARS_HTML /* unicode values */
37: };
38:
39: struct roffcol {
40: size_t width; /* width of cell */
41: size_t decimal; /* decimal position in cell */
42: };
43:
1.3 kristaps 44: struct roffsu {
45: enum roffscale unit;
1.4 kristaps 46: double scale;
1.3 kristaps 47: };
48:
1.18 kristaps 49: typedef size_t (*tbl_strlen)(const char *, void *);
50: typedef size_t (*tbl_len)(size_t, void *);
51:
52: struct rofftbl {
53: tbl_strlen slen; /* calculate string length */
54: tbl_len len; /* produce width of empty space */
55: struct roffcol *cols; /* master column specifiers */
56: void *arg; /* passed to slen and len */
57: };
58:
59: __BEGIN_DECLS
60:
1.3 kristaps 61: #define SCALE_VS_INIT(p, v) \
62: do { (p)->unit = SCALE_VS; \
1.12 kristaps 63: (p)->scale = (v); } \
1.8 kristaps 64: while (/* CONSTCOND */ 0)
65:
1.3 kristaps 66: #define SCALE_HS_INIT(p, v) \
67: do { (p)->unit = SCALE_BU; \
1.12 kristaps 68: (p)->scale = (v); } \
1.8 kristaps 69: while (/* CONSTCOND */ 0)
1.3 kristaps 70:
1.18 kristaps 71: int a2roffsu(const char *, struct roffsu *, enum roffscale);
72: void time2a(time_t, char *, size_t);
73: void tblcalc(struct rofftbl *tbl, const struct tbl_span *);
74:
75: void *chars_init(enum chars);
76: const char *chars_num2char(const char *, size_t);
77: const char *chars_spec2str(void *, const char *, size_t, size_t *);
78: int chars_spec2cp(void *, const char *, size_t);
79: const char *chars_res2str(void *, const char *, size_t, size_t *);
80: int chars_res2cp(void *, const char *, size_t);
81: void chars_free(void *);
1.1 kristaps 82:
83: __END_DECLS
84:
1.15 kristaps 85: #endif /*!OUT_H*/
CVSweb