]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/mandoc/libroff.h
Implement pmap_advise(). (Without a working pmap_advise() implementation
[FreeBSD/FreeBSD.git] / contrib / mandoc / libroff.h
1 /*      $Id: libroff.h,v 1.42 2017/07/08 17:52:49 schwarze Exp $ */
2 /*
3  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4  * Copyright (c) 2014, 2015, 2017 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
19 enum    tbl_part {
20         TBL_PART_OPTS, /* in options (first line) */
21         TBL_PART_LAYOUT, /* describing layout */
22         TBL_PART_DATA, /* creating data rows */
23         TBL_PART_CDATA /* continue previous row */
24 };
25
26 struct  tbl_node {
27         struct mparse    *parse; /* parse point */
28         int               pos; /* invocation column */
29         int               line; /* invocation line */
30         enum tbl_part     part;
31         struct tbl_opts   opts;
32         struct tbl_row   *first_row;
33         struct tbl_row   *last_row;
34         struct tbl_span  *first_span;
35         struct tbl_span  *current_span;
36         struct tbl_span  *last_span;
37         struct tbl_node  *next;
38 };
39
40 struct  eqn_node {
41         struct mparse    *parse;  /* main parser, for error reporting */
42         struct roff_node *node;   /* syntax tree of this equation */
43         struct eqn_def   *defs;   /* array of definitions */
44         char             *data;   /* source code of this equation */
45         char             *start;  /* first byte of the current token */
46         char             *end;    /* first byte of the next token */
47         size_t            defsz;  /* number of definitions */
48         size_t            sz;     /* length of the source code */
49         size_t            toksz;  /* length of the current token */
50         int               gsize;  /* default point size */
51         int               delim;  /* in-line delimiters enabled */
52         char              odelim; /* in-line opening delimiter */
53         char              cdelim; /* in-line closing delimiter */
54 };
55
56 struct  eqn_def {
57         char             *key;
58         size_t            keysz;
59         char             *val;
60         size_t            valsz;
61 };
62
63
64 struct tbl_node *tbl_alloc(int, int, struct mparse *);
65 void             tbl_restart(int, int, struct tbl_node *);
66 void             tbl_free(struct tbl_node *);
67 void             tbl_reset(struct tbl_node *);
68 void             tbl_read(struct tbl_node *, int, const char *, int);
69 void             tbl_option(struct tbl_node *, int, const char *, int *);
70 void             tbl_layout(struct tbl_node *, int, const char *, int);
71 void             tbl_data(struct tbl_node *, int, const char *, int);
72 void             tbl_cdata(struct tbl_node *, int, const char *, int);
73 const struct tbl_span   *tbl_span(struct tbl_node *);
74 int              tbl_end(struct tbl_node *);
75 struct eqn_node *eqn_alloc(struct mparse *);
76 void             eqn_box_free(struct eqn_box *);
77 void             eqn_free(struct eqn_node *);
78 void             eqn_parse(struct eqn_node *);
79 void             eqn_read(struct eqn_node *, const char *);
80 void             eqn_reset(struct eqn_node *);