nrelease - fix/improve livecd
[dragonfly.git] / contrib / mdocml / mdoc.h
CommitLineData
54ba9607 1/* $Id: mdoc.h,v 1.146 2018/12/30 00:49:55 schwarze Exp $ */
80387638 2/*
60e1e752 3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
54ba9607 4 * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
80387638
SW
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
54ba9607 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
80387638 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
54ba9607 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
80387638
SW
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
80387638 18
54ba9607
SW
19struct roff_node;
20struct roff_man;
80387638 21
80387638 22enum mdocargt {
60e1e752
SW
23 MDOC_Split, /* -split */
24 MDOC_Nosplit, /* -nospli */
25 MDOC_Ragged, /* -ragged */
26 MDOC_Unfilled, /* -unfilled */
27 MDOC_Literal, /* -literal */
28 MDOC_File, /* -file */
29 MDOC_Offset, /* -offset */
30 MDOC_Bullet, /* -bullet */
31 MDOC_Dash, /* -dash */
32 MDOC_Hyphen, /* -hyphen */
33 MDOC_Item, /* -item */
34 MDOC_Enum, /* -enum */
35 MDOC_Tag, /* -tag */
36 MDOC_Diag, /* -diag */
37 MDOC_Hang, /* -hang */
38 MDOC_Ohang, /* -ohang */
39 MDOC_Inset, /* -inset */
40 MDOC_Column, /* -column */
41 MDOC_Width, /* -width */
42 MDOC_Compact, /* -compact */
43 MDOC_Std, /* -std */
44 MDOC_Filled, /* -filled */
45 MDOC_Words, /* -words */
46 MDOC_Emphasis, /* -emphasis */
47 MDOC_Symbolic, /* -symbolic */
48 MDOC_Nested, /* -nested */
49 MDOC_Centred, /* -centered */
80387638
SW
50 MDOC_ARG_MAX
51};
52
070c62a6
FF
53/*
54 * An argument to a macro (multiple values = `-column xxx yyy').
80387638
SW
55 */
56struct mdoc_argv {
070c62a6 57 enum mdocargt arg; /* type of argument */
80387638
SW
58 int line;
59 int pos;
60 size_t sz; /* elements in "value" */
61 char **value; /* argument strings */
62};
63
64/*
65 * Reference-counted macro arguments. These are refcounted because
66 * blocks have multiple instances of the same arguments spread across
67 * the HEAD, BODY, TAIL, and BLOCK node types.
68 */
070c62a6 69struct mdoc_arg {
80387638
SW
70 size_t argc;
71 struct mdoc_argv *argv;
72 unsigned int refcnt;
73};
74
80387638
SW
75enum mdoc_list {
76 LIST__NONE = 0,
60e1e752
SW
77 LIST_bullet, /* -bullet */
78 LIST_column, /* -column */
79 LIST_dash, /* -dash */
80 LIST_diag, /* -diag */
81 LIST_enum, /* -enum */
82 LIST_hang, /* -hang */
83 LIST_hyphen, /* -hyphen */
84 LIST_inset, /* -inset */
85 LIST_item, /* -item */
86 LIST_ohang, /* -ohang */
87 LIST_tag, /* -tag */
80387638
SW
88 LIST_MAX
89};
90
80387638
SW
91enum mdoc_disp {
92 DISP__NONE = 0,
070c62a6 93 DISP_centered, /* -centered */
60e1e752
SW
94 DISP_ragged, /* -ragged */
95 DISP_unfilled, /* -unfilled */
96 DISP_filled, /* -filled */
97 DISP_literal /* -literal */
80387638
SW
98};
99
80387638
SW
100enum mdoc_auth {
101 AUTH__NONE = 0,
60e1e752
SW
102 AUTH_split, /* -split */
103 AUTH_nosplit /* -nosplit */
80387638
SW
104};
105
80387638
SW
106enum mdoc_font {
107 FONT__NONE = 0,
60e1e752
SW
108 FONT_Em, /* Em, -emphasis */
109 FONT_Li, /* Li, -literal */
110 FONT_Sy /* Sy, -symbolic */
80387638
SW
111};
112
80387638
SW
113struct mdoc_bd {
114 const char *offs; /* -offset */
115 enum mdoc_disp type; /* -ragged, etc. */
116 int comp; /* -compact */
117};
118
80387638
SW
119struct mdoc_bl {
120 const char *width; /* -width */
121 const char *offs; /* -offset */
122 enum mdoc_list type; /* -tag, -enum, etc. */
123 int comp; /* -compact */
124 size_t ncols; /* -column arg count */
125 const char **cols; /* -column val ptr */
f88b6c16 126 int count; /* -enum counter */
80387638
SW
127};
128
80387638
SW
129struct mdoc_bf {
130 enum mdoc_font font; /* font */
131};
132
80387638
SW
133struct mdoc_an {
134 enum mdoc_auth auth; /* -split, etc. */
135};
136
137struct mdoc_rs {
60e1e752 138 int quote_T; /* whether to quote %T */
80387638
SW
139};
140
141/*
142 * Consists of normalised node arguments. These should be used instead
143 * of iterating through the mdoc_arg pointers of a node: defaults are
144 * provided, etc.
145 */
146union mdoc_data {
070c62a6 147 struct mdoc_an An;
80387638
SW
148 struct mdoc_bd Bd;
149 struct mdoc_bf Bf;
150 struct mdoc_bl Bl;
54ba9607 151 struct roff_node *Es;
80387638
SW
152 struct mdoc_rs Rs;
153};
154
60e1e752 155/* Names of macro args. Index is enum mdocargt. */
80387638
SW
156extern const char *const *mdoc_argnames;
157
54ba9607 158void mdoc_validate(struct roff_man *);