mandoc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/COPYING +674 -0
  4. data/README.md +117 -0
  5. data/ext/mandoc/extconf.rb +59 -0
  6. data/ext/mandoc/rb_mandoc.c +548 -0
  7. data/ext/mandoc/rb_mandoc.h +22 -0
  8. data/lib/mandoc/version.rb +19 -0
  9. data/lib/mandoc.rb +26 -0
  10. data/mandoc-1.14.6/LICENSE +55 -0
  11. data/mandoc-1.14.6/arch.c +54 -0
  12. data/mandoc-1.14.6/att.c +49 -0
  13. data/mandoc-1.14.6/catman.c +260 -0
  14. data/mandoc-1.14.6/cgi.c +1279 -0
  15. data/mandoc-1.14.6/chars.c +507 -0
  16. data/mandoc-1.14.6/compat_err.c +103 -0
  17. data/mandoc-1.14.6/compat_fts.c +696 -0
  18. data/mandoc-1.14.6/compat_fts.h +106 -0
  19. data/mandoc-1.14.6/compat_getline.c +59 -0
  20. data/mandoc-1.14.6/compat_getsubopt.c +87 -0
  21. data/mandoc-1.14.6/compat_isblank.c +23 -0
  22. data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
  23. data/mandoc-1.14.6/compat_mkstemps.c +63 -0
  24. data/mandoc-1.14.6/compat_ohash.c +330 -0
  25. data/mandoc-1.14.6/compat_ohash.h +72 -0
  26. data/mandoc-1.14.6/compat_progname.c +31 -0
  27. data/mandoc-1.14.6/compat_reallocarray.c +40 -0
  28. data/mandoc-1.14.6/compat_recallocarray.c +99 -0
  29. data/mandoc-1.14.6/compat_strcasestr.c +64 -0
  30. data/mandoc-1.14.6/compat_stringlist.c +135 -0
  31. data/mandoc-1.14.6/compat_stringlist.h +48 -0
  32. data/mandoc-1.14.6/compat_strlcat.c +57 -0
  33. data/mandoc-1.14.6/compat_strlcpy.c +52 -0
  34. data/mandoc-1.14.6/compat_strndup.c +42 -0
  35. data/mandoc-1.14.6/compat_strsep.c +70 -0
  36. data/mandoc-1.14.6/compat_strtonum.c +67 -0
  37. data/mandoc-1.14.6/compat_vasprintf.c +47 -0
  38. data/mandoc-1.14.6/config.h +52 -0
  39. data/mandoc-1.14.6/dba.c +508 -0
  40. data/mandoc-1.14.6/dba.h +50 -0
  41. data/mandoc-1.14.6/dba_array.c +190 -0
  42. data/mandoc-1.14.6/dba_array.h +47 -0
  43. data/mandoc-1.14.6/dba_read.c +74 -0
  44. data/mandoc-1.14.6/dba_write.c +127 -0
  45. data/mandoc-1.14.6/dba_write.h +30 -0
  46. data/mandoc-1.14.6/dbm.c +480 -0
  47. data/mandoc-1.14.6/dbm.h +68 -0
  48. data/mandoc-1.14.6/dbm_map.c +194 -0
  49. data/mandoc-1.14.6/dbm_map.h +29 -0
  50. data/mandoc-1.14.6/demandoc.c +260 -0
  51. data/mandoc-1.14.6/eqn.c +1132 -0
  52. data/mandoc-1.14.6/eqn.h +72 -0
  53. data/mandoc-1.14.6/eqn_html.c +246 -0
  54. data/mandoc-1.14.6/eqn_parse.h +48 -0
  55. data/mandoc-1.14.6/eqn_term.c +174 -0
  56. data/mandoc-1.14.6/html.c +1102 -0
  57. data/mandoc-1.14.6/html.h +142 -0
  58. data/mandoc-1.14.6/lib.c +35 -0
  59. data/mandoc-1.14.6/libman.h +42 -0
  60. data/mandoc-1.14.6/libmandoc.h +85 -0
  61. data/mandoc-1.14.6/libmdoc.h +87 -0
  62. data/mandoc-1.14.6/main.c +1375 -0
  63. data/mandoc-1.14.6/main.h +53 -0
  64. data/mandoc-1.14.6/man.c +345 -0
  65. data/mandoc-1.14.6/man.h +21 -0
  66. data/mandoc-1.14.6/man_html.c +640 -0
  67. data/mandoc-1.14.6/man_macro.c +470 -0
  68. data/mandoc-1.14.6/man_term.c +1143 -0
  69. data/mandoc-1.14.6/man_validate.c +660 -0
  70. data/mandoc-1.14.6/manconf.h +58 -0
  71. data/mandoc-1.14.6/mandoc.c +669 -0
  72. data/mandoc-1.14.6/mandoc.h +329 -0
  73. data/mandoc-1.14.6/mandoc_aux.c +118 -0
  74. data/mandoc-1.14.6/mandoc_aux.h +27 -0
  75. data/mandoc-1.14.6/mandoc_msg.c +375 -0
  76. data/mandoc-1.14.6/mandoc_ohash.c +65 -0
  77. data/mandoc-1.14.6/mandoc_ohash.h +23 -0
  78. data/mandoc-1.14.6/mandoc_parse.h +44 -0
  79. data/mandoc-1.14.6/mandoc_xr.c +123 -0
  80. data/mandoc-1.14.6/mandoc_xr.h +31 -0
  81. data/mandoc-1.14.6/mandocd.c +282 -0
  82. data/mandoc-1.14.6/mandocdb.c +2448 -0
  83. data/mandoc-1.14.6/manpath.c +363 -0
  84. data/mandoc-1.14.6/mansearch.c +851 -0
  85. data/mandoc-1.14.6/mansearch.h +118 -0
  86. data/mandoc-1.14.6/mdoc.c +433 -0
  87. data/mandoc-1.14.6/mdoc.h +158 -0
  88. data/mandoc-1.14.6/mdoc_argv.c +682 -0
  89. data/mandoc-1.14.6/mdoc_html.c +1762 -0
  90. data/mandoc-1.14.6/mdoc_macro.c +1600 -0
  91. data/mandoc-1.14.6/mdoc_man.c +1850 -0
  92. data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
  93. data/mandoc-1.14.6/mdoc_state.c +256 -0
  94. data/mandoc-1.14.6/mdoc_term.c +1964 -0
  95. data/mandoc-1.14.6/mdoc_validate.c +3062 -0
  96. data/mandoc-1.14.6/msec.c +37 -0
  97. data/mandoc-1.14.6/out.c +544 -0
  98. data/mandoc-1.14.6/out.h +70 -0
  99. data/mandoc-1.14.6/preconv.c +179 -0
  100. data/mandoc-1.14.6/read.c +732 -0
  101. data/mandoc-1.14.6/roff.c +4390 -0
  102. data/mandoc-1.14.6/roff.h +561 -0
  103. data/mandoc-1.14.6/roff_html.c +119 -0
  104. data/mandoc-1.14.6/roff_int.h +94 -0
  105. data/mandoc-1.14.6/roff_term.c +266 -0
  106. data/mandoc-1.14.6/roff_validate.c +151 -0
  107. data/mandoc-1.14.6/soelim.c +182 -0
  108. data/mandoc-1.14.6/st.c +82 -0
  109. data/mandoc-1.14.6/tag.c +327 -0
  110. data/mandoc-1.14.6/tag.h +35 -0
  111. data/mandoc-1.14.6/tbl.c +183 -0
  112. data/mandoc-1.14.6/tbl.h +121 -0
  113. data/mandoc-1.14.6/tbl_data.c +323 -0
  114. data/mandoc-1.14.6/tbl_html.c +293 -0
  115. data/mandoc-1.14.6/tbl_int.h +47 -0
  116. data/mandoc-1.14.6/tbl_layout.c +376 -0
  117. data/mandoc-1.14.6/tbl_opts.c +173 -0
  118. data/mandoc-1.14.6/tbl_parse.h +30 -0
  119. data/mandoc-1.14.6/tbl_term.c +948 -0
  120. data/mandoc-1.14.6/term.c +1113 -0
  121. data/mandoc-1.14.6/term.h +158 -0
  122. data/mandoc-1.14.6/term_ascii.c +424 -0
  123. data/mandoc-1.14.6/term_ps.c +1362 -0
  124. data/mandoc-1.14.6/term_tab.c +130 -0
  125. data/mandoc-1.14.6/term_tag.c +227 -0
  126. data/mandoc-1.14.6/term_tag.h +34 -0
  127. data/mandoc-1.14.6/tree.c +536 -0
  128. metadata +170 -0
@@ -0,0 +1,142 @@
1
+ /* $Id: html.h,v 1.109 2021/09/09 14:47:24 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org>
4
+ * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
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 AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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
+ * Internal interfaces for mandoc(1) HTML formatters.
19
+ * For use by the individual HTML formatters only.
20
+ */
21
+
22
+ enum htmltag {
23
+ TAG_HTML,
24
+ TAG_HEAD,
25
+ TAG_META,
26
+ TAG_LINK,
27
+ TAG_STYLE,
28
+ TAG_TITLE,
29
+ TAG_BODY,
30
+ TAG_DIV,
31
+ TAG_SECTION,
32
+ TAG_TABLE,
33
+ TAG_TR,
34
+ TAG_TD,
35
+ TAG_LI,
36
+ TAG_UL,
37
+ TAG_OL,
38
+ TAG_DL,
39
+ TAG_DT,
40
+ TAG_DD,
41
+ TAG_H1,
42
+ TAG_H2,
43
+ TAG_P,
44
+ TAG_PRE,
45
+ TAG_A,
46
+ TAG_B,
47
+ TAG_CITE,
48
+ TAG_CODE,
49
+ TAG_I,
50
+ TAG_SMALL,
51
+ TAG_SPAN,
52
+ TAG_VAR,
53
+ TAG_BR,
54
+ TAG_HR,
55
+ TAG_MARK,
56
+ TAG_MATH,
57
+ TAG_MROW,
58
+ TAG_MI,
59
+ TAG_MN,
60
+ TAG_MO,
61
+ TAG_MSUP,
62
+ TAG_MSUB,
63
+ TAG_MSUBSUP,
64
+ TAG_MFRAC,
65
+ TAG_MSQRT,
66
+ TAG_MFENCED,
67
+ TAG_MTABLE,
68
+ TAG_MTR,
69
+ TAG_MTD,
70
+ TAG_MUNDEROVER,
71
+ TAG_MUNDER,
72
+ TAG_MOVER,
73
+ TAG_MAX
74
+ };
75
+
76
+ struct tag {
77
+ struct tag *next;
78
+ int refcnt;
79
+ int closed;
80
+ enum htmltag tag;
81
+ };
82
+
83
+ struct html {
84
+ int flags;
85
+ #define HTML_NOSPACE (1 << 0) /* suppress next space */
86
+ #define HTML_IGNDELIM (1 << 1)
87
+ #define HTML_KEEP (1 << 2)
88
+ #define HTML_PREKEEP (1 << 3)
89
+ #define HTML_NONOSPACE (1 << 4) /* never add spaces */
90
+ #define HTML_SKIPCHAR (1 << 6) /* skip the next character */
91
+ #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
92
+ #define HTML_SPLIT (1 << 8) /* break line before .An */
93
+ #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
94
+ #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */
95
+ #define HTML_TOCDONE (1 << 11) /* The TOC was already written. */
96
+ size_t indent; /* current output indentation level */
97
+ int noindent; /* indent disabled by <pre> */
98
+ size_t col; /* current output byte position */
99
+ size_t bufcol; /* current buf byte position */
100
+ char buf[80]; /* output buffer */
101
+ struct tag *tag; /* last open tag */
102
+ struct rofftbl tbl; /* current table */
103
+ struct tag *tblt; /* current open table scope */
104
+ char *base_man1; /* bases for manpage href */
105
+ char *base_man2;
106
+ char *base_includes; /* base for include href */
107
+ char *style; /* style-sheet URI */
108
+ struct tag *metaf; /* current open font scope */
109
+ enum mandoc_esc metal; /* last used font */
110
+ enum mandoc_esc metac; /* current font mode */
111
+ int oflags; /* output options */
112
+ #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */
113
+ #define HTML_TOC (1 << 1) /* emit a table of contents */
114
+ };
115
+
116
+
117
+ struct roff_node;
118
+ struct tbl_span;
119
+ struct eqn_box;
120
+
121
+ void roff_html_pre(struct html *, const struct roff_node *);
122
+
123
+ void print_gen_comment(struct html *, struct roff_node *);
124
+ void print_gen_decls(struct html *);
125
+ void print_gen_head(struct html *);
126
+ struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
127
+ struct tag *print_otag_id(struct html *, enum htmltag, const char *,
128
+ struct roff_node *);
129
+ void print_tagq(struct html *, const struct tag *);
130
+ void print_stagq(struct html *, const struct tag *);
131
+ void print_tagged_text(struct html *, const char *,
132
+ struct roff_node *);
133
+ void print_text(struct html *, const char *);
134
+ void print_tblclose(struct html *);
135
+ void print_tbl(struct html *, const struct tbl_span *);
136
+ void print_eqn(struct html *, const struct eqn_box *);
137
+ void print_endline(struct html *);
138
+
139
+ void html_close_paragraph(struct html *);
140
+ enum roff_tok html_fillmode(struct html *, enum roff_tok);
141
+ char *html_make_id(const struct roff_node *, int);
142
+ int html_setfont(struct html *, enum mandoc_esc);
@@ -0,0 +1,35 @@
1
+ /* $Id: lib.c,v 1.15 2018/12/13 11:55:46 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
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
+ #include "config.h"
18
+
19
+ #include <sys/types.h>
20
+ #include <string.h>
21
+
22
+ #include "roff.h"
23
+ #include "libmdoc.h"
24
+
25
+ #define LINE(x, y) \
26
+ if (0 == strcmp(p, x)) return(y);
27
+
28
+ const char *
29
+ mdoc_a2lib(const char *p)
30
+ {
31
+
32
+ #include "lib.in"
33
+
34
+ return NULL;
35
+ }
@@ -0,0 +1,42 @@
1
+ /* $Id: libman.h,v 1.86 2018/12/31 10:04:39 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4
+ * Copyright (c) 2014, 2015, 2018 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
+ struct roff_node;
20
+ struct roff_man;
21
+
22
+ #define MACRO_PROT_ARGS struct roff_man *man, \
23
+ enum roff_tok tok, \
24
+ int line, \
25
+ int ppos, \
26
+ int *pos, \
27
+ char *buf
28
+
29
+ struct man_macro {
30
+ void (*fp)(MACRO_PROT_ARGS);
31
+ int flags;
32
+ #define MAN_BSCOPED (1 << 0) /* Optional next-line block scope. */
33
+ #define MAN_ESCOPED (1 << 1) /* Optional next-line element scope. */
34
+ #define MAN_NSCOPED (1 << 2) /* Allowed in next-line element scope. */
35
+ #define MAN_XSCOPE (1 << 3) /* Exit next-line block scope. */
36
+ #define MAN_JOIN (1 << 4) /* Join arguments together. */
37
+ };
38
+
39
+ const struct man_macro *man_macro(enum roff_tok);
40
+
41
+ void man_descope(struct roff_man *, int, int, char *);
42
+ void man_unscope(struct roff_man *, const struct roff_node *);
@@ -0,0 +1,85 @@
1
+ /* $Id: libmandoc.h,v 1.80 2021/06/27 17:57:54 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2013-2015,2017,2018,2020 Ingo Schwarze <schwarze@openbsd.org>
4
+ * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
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
+ * Internal interfaces for parser utilities needed by multiple parsers
19
+ * and the top-level functions to call the mdoc, man, and roff parsers.
20
+ */
21
+
22
+ /*
23
+ * Return codes passed from the roff parser to the main parser.
24
+ */
25
+
26
+ /* Main instruction: what to do with the returned line. */
27
+ #define ROFF_IGN 0x000 /* Don't do anything with it. */
28
+ #define ROFF_CONT 0x001 /* Give it to the high-level parser. */
29
+ #define ROFF_RERUN 0x002 /* Re-run the roff parser with an offset. */
30
+ #define ROFF_REPARSE 0x004 /* Recursively run the main parser on it. */
31
+ #define ROFF_SO 0x008 /* Include the named file. */
32
+ #define ROFF_MASK 0x00f /* Only one of these bits should be set. */
33
+
34
+ /* Options for further parsing, to be OR'ed with the above. */
35
+ #define ROFF_APPEND 0x010 /* Append the next line to this one. */
36
+ #define ROFF_USERCALL 0x020 /* Start execution of a new macro. */
37
+ #define ROFF_USERRET 0x040 /* Abort execution of the current macro. */
38
+ #define ROFF_WHILE 0x100 /* Start a new .while loop. */
39
+ #define ROFF_LOOPCONT 0x200 /* Iterate the current .while loop. */
40
+ #define ROFF_LOOPEXIT 0x400 /* Exit the current .while loop. */
41
+ #define ROFF_LOOPMASK 0xf00
42
+
43
+
44
+ struct buf {
45
+ char *buf;
46
+ size_t sz;
47
+ struct buf *next;
48
+ };
49
+
50
+
51
+ struct roff;
52
+ struct roff_man;
53
+ struct roff_node;
54
+
55
+ char *mandoc_normdate(struct roff_node *, struct roff_node *);
56
+ int mandoc_eos(const char *, size_t);
57
+ int mandoc_strntoi(const char *, size_t, int);
58
+ const char *mandoc_a2msec(const char*);
59
+
60
+ int mdoc_parseln(struct roff_man *, int, char *, int);
61
+ void mdoc_endparse(struct roff_man *);
62
+
63
+ int man_parseln(struct roff_man *, int, char *, int);
64
+ void man_endparse(struct roff_man *);
65
+
66
+ int preconv_cue(const struct buf *, size_t);
67
+ int preconv_encode(const struct buf *, size_t *,
68
+ struct buf *, size_t *, int *);
69
+
70
+ void roff_free(struct roff *);
71
+ struct roff *roff_alloc(int);
72
+ void roff_reset(struct roff *);
73
+ void roff_man_free(struct roff_man *);
74
+ struct roff_man *roff_man_alloc(struct roff *, const char *, int);
75
+ void roff_man_reset(struct roff_man *);
76
+ int roff_parseln(struct roff *, int, struct buf *, int *, size_t);
77
+ void roff_userret(struct roff *);
78
+ void roff_endparse(struct roff *);
79
+ void roff_setreg(struct roff *, const char *, int, char);
80
+ int roff_getreg(struct roff *, const char *);
81
+ char *roff_strdup(const struct roff *, const char *);
82
+ char *roff_getarg(struct roff *, char **, int, int *);
83
+ int roff_getcontrol(const struct roff *,
84
+ const char *, int *);
85
+ int roff_getformat(const struct roff *);
@@ -0,0 +1,87 @@
1
+ /* $Id: libmdoc.h,v 1.117 2018/12/31 04:55:46 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4
+ * Copyright (c) 2013,2014,2015,2017,2018 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
+ struct roff_node;
20
+ struct roff_man;
21
+ struct mdoc_arg;
22
+
23
+ #define MACRO_PROT_ARGS struct roff_man *mdoc, \
24
+ enum roff_tok tok, \
25
+ int line, \
26
+ int ppos, \
27
+ int *pos, \
28
+ char *buf
29
+
30
+ struct mdoc_macro {
31
+ void (*fp)(MACRO_PROT_ARGS);
32
+ int flags;
33
+ #define MDOC_CALLABLE (1 << 0)
34
+ #define MDOC_PARSED (1 << 1)
35
+ #define MDOC_EXPLICIT (1 << 2)
36
+ #define MDOC_PROLOGUE (1 << 3)
37
+ #define MDOC_IGNDELIM (1 << 4)
38
+ #define MDOC_JOIN (1 << 5)
39
+ };
40
+
41
+ enum margserr {
42
+ ARGS_ERROR,
43
+ ARGS_EOLN, /* end-of-line */
44
+ ARGS_WORD, /* normal word */
45
+ ARGS_ALLOC, /* normal word from roff_getarg() */
46
+ ARGS_PUNCT, /* series of punctuation */
47
+ ARGS_PHRASE /* Bl -column phrase */
48
+ };
49
+
50
+ /*
51
+ * A punctuation delimiter is opening, closing, or "middle mark"
52
+ * punctuation. These govern spacing.
53
+ * Opening punctuation (e.g., the opening parenthesis) suppresses the
54
+ * following space; closing punctuation (e.g., the closing parenthesis)
55
+ * suppresses the leading space; middle punctuation (e.g., the vertical
56
+ * bar) can do either. The middle punctuation delimiter bends the rules
57
+ * depending on usage.
58
+ */
59
+ enum mdelim {
60
+ DELIM_NONE = 0,
61
+ DELIM_OPEN,
62
+ DELIM_MIDDLE,
63
+ DELIM_CLOSE,
64
+ DELIM_MAX
65
+ };
66
+
67
+ const struct mdoc_macro *mdoc_macro(enum roff_tok);
68
+
69
+ void mdoc_elem_alloc(struct roff_man *, int, int,
70
+ enum roff_tok, struct mdoc_arg *);
71
+ struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
72
+ enum roff_tok, struct mdoc_arg *);
73
+ void mdoc_tail_alloc(struct roff_man *, int, int,
74
+ enum roff_tok);
75
+ struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int,
76
+ enum roff_tok, struct roff_node *);
77
+ void mdoc_state(struct roff_man *, struct roff_node *);
78
+ const char *mdoc_a2arch(const char *);
79
+ const char *mdoc_a2att(const char *);
80
+ const char *mdoc_a2lib(const char *);
81
+ enum roff_sec mdoc_a2sec(const char *);
82
+ const char *mdoc_a2st(const char *);
83
+ void mdoc_argv(struct roff_man *, int, enum roff_tok,
84
+ struct mdoc_arg **, int *, char *);
85
+ enum margserr mdoc_args(struct roff_man *, int,
86
+ int *, char *, enum roff_tok, char **);
87
+ enum mdelim mdoc_isdelim(const char *);