Annotation of mandoc/mdoc.h, Revision 1.146
1.146 ! schwarze 1: /* $Id: mdoc.h,v 1.145 2017/04/24 23:06:18 schwarze Exp $ */
1.1 kristaps 2: /*
1.118 schwarze 3: * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.136 schwarze 4: * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.56 kristaps 7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 9: *
1.137 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.56 kristaps 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.137 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.56 kristaps 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.
1.1 kristaps 17: */
1.146 ! schwarze 18:
! 19: struct roff_node;
! 20: struct roff_man;
1.1 kristaps 21:
1.105 kristaps 22: enum mdocargt {
1.121 kristaps 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 */
1.105 kristaps 50: MDOC_ARG_MAX
51: };
52:
1.129 schwarze 53: /*
54: * An argument to a macro (multiple values = `-column xxx yyy').
1.105 kristaps 55: */
56: struct mdoc_argv {
1.129 schwarze 57: enum mdocargt arg; /* type of argument */
1.105 kristaps 58: int line;
59: int pos;
60: size_t sz; /* elements in "value" */
61: char **value; /* argument strings */
62: };
63:
1.33 kristaps 64: /*
1.105 kristaps 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.
1.33 kristaps 68: */
1.129 schwarze 69: struct mdoc_arg {
1.105 kristaps 70: size_t argc;
71: struct mdoc_argv *argv;
72: unsigned int refcnt;
73: };
1.1 kristaps 74:
1.105 kristaps 75: enum mdoc_list {
76: LIST__NONE = 0,
1.121 kristaps 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 */
1.106 kristaps 88: LIST_MAX
1.105 kristaps 89: };
90:
91: enum mdoc_disp {
92: DISP__NONE = 0,
1.131 schwarze 93: DISP_centered, /* -centered */
1.121 kristaps 94: DISP_ragged, /* -ragged */
95: DISP_unfilled, /* -unfilled */
96: DISP_filled, /* -filled */
97: DISP_literal /* -literal */
1.105 kristaps 98: };
99:
100: enum mdoc_auth {
101: AUTH__NONE = 0,
1.121 kristaps 102: AUTH_split, /* -split */
103: AUTH_nosplit /* -nosplit */
1.105 kristaps 104: };
1.60 kristaps 105:
1.105 kristaps 106: enum mdoc_font {
107: FONT__NONE = 0,
1.121 kristaps 108: FONT_Em, /* Em, -emphasis */
109: FONT_Li, /* Li, -literal */
110: FONT_Sy /* Sy, -symbolic */
1.105 kristaps 111: };
112:
113: struct mdoc_bd {
114: const char *offs; /* -offset */
115: enum mdoc_disp type; /* -ragged, etc. */
116: int comp; /* -compact */
117: };
118:
119: struct 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 */
1.123 schwarze 126: int count; /* -enum counter */
1.105 kristaps 127: };
128:
129: struct mdoc_bf {
130: enum mdoc_font font; /* font */
131: };
132:
133: struct mdoc_an {
134: enum mdoc_auth auth; /* -split, etc. */
135: };
136:
1.111 kristaps 137: struct mdoc_rs {
1.115 kristaps 138: int quote_T; /* whether to quote %T */
1.111 kristaps 139: };
140:
1.105 kristaps 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: */
1.109 kristaps 146: union mdoc_data {
1.129 schwarze 147: struct mdoc_an An;
1.109 kristaps 148: struct mdoc_bd Bd;
149: struct mdoc_bf Bf;
150: struct mdoc_bl Bl;
1.138 schwarze 151: struct roff_node *Es;
1.111 kristaps 152: struct mdoc_rs Rs;
1.109 kristaps 153: };
154:
1.121 kristaps 155: /* Names of macro args. Index is enum mdocargt. */
1.1 kristaps 156: extern const char *const *mdoc_argnames;
1.143 schwarze 157:
158: void mdoc_validate(struct roff_man *);
CVSweb