]> git.cameronkatri.com Git - mandoc.git/blob - libroff.h
improve documentation of .Fa, .Va, and .Vt;
[mandoc.git] / libroff.h
1 /* $Id: libroff.h,v 1.30 2014/10/16 01:11:20 schwarze Exp $ */
2 /*
3 * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2014 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 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 #ifndef LIBROFF_H
19 #define LIBROFF_H
20
21 __BEGIN_DECLS
22
23 enum tbl_part {
24 TBL_PART_OPTS, /* in options (first line) */
25 TBL_PART_LAYOUT, /* describing layout */
26 TBL_PART_DATA, /* creating data rows */
27 TBL_PART_CDATA /* continue previous row */
28 };
29
30 struct tbl_node {
31 struct mparse *parse; /* parse point */
32 int pos; /* invocation column */
33 int line; /* invocation line */
34 enum tbl_part part;
35 struct tbl_opts opts;
36 struct tbl_row *first_row;
37 struct tbl_row *last_row;
38 struct tbl_span *first_span;
39 struct tbl_span *current_span;
40 struct tbl_span *last_span;
41 struct tbl_head *first_head;
42 struct tbl_head *last_head;
43 struct tbl_node *next;
44 };
45
46 struct eqn_node {
47 struct eqn eqn; /* syntax tree of this equation */
48 struct mparse *parse; /* main parser, for error reporting */
49 struct eqn_node *next; /* singly linked list of equations */
50 struct eqn_def *defs; /* array of definitions */
51 char *data; /* source code of this equation */
52 size_t defsz; /* number of definitions */
53 size_t sz; /* length of the source code */
54 size_t cur; /* parse point in the source code */
55 size_t rew; /* beginning of the current token */
56 int gsize; /* default point size */
57 int delim; /* in-line delimiters enabled */
58 char odelim; /* in-line opening delimiter */
59 char cdelim; /* in-line closing delimiter */
60 };
61
62 struct eqn_def {
63 char *key;
64 size_t keysz;
65 char *val;
66 size_t valsz;
67 };
68
69 struct tbl_node *tbl_alloc(int, int, struct mparse *);
70 void tbl_restart(int, int, struct tbl_node *);
71 void tbl_free(struct tbl_node *);
72 void tbl_reset(struct tbl_node *);
73 enum rofferr tbl_read(struct tbl_node *, int, const char *, int);
74 int tbl_option(struct tbl_node *, int, const char *);
75 int tbl_layout(struct tbl_node *, int, const char *);
76 int tbl_data(struct tbl_node *, int, const char *);
77 int tbl_cdata(struct tbl_node *, int, const char *);
78 const struct tbl_span *tbl_span(struct tbl_node *);
79 void tbl_end(struct tbl_node **);
80 struct eqn_node *eqn_alloc(const char *, int, int, struct mparse *);
81 enum rofferr eqn_end(struct eqn_node **);
82 void eqn_free(struct eqn_node *);
83 enum rofferr eqn_read(struct eqn_node **, int,
84 const char *, int, int *);
85
86 __END_DECLS
87
88 #endif /*LIBROFF_H*/