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