]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/mdocml/libroff.h
MFV r276761: tcpdump 4.6.2.
[FreeBSD/FreeBSD.git] / contrib / mdocml / libroff.h
1 /*      $Id: libroff.h,v 1.33 2014/12/01 08:05:52 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
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_head  *first_head;
38         struct tbl_head  *last_head;
39         struct tbl_node  *next;
40 };
41
42 struct  eqn_node {
43         struct eqn        eqn;    /* syntax tree of this equation */
44         struct mparse    *parse;  /* main parser, for error reporting */
45         struct eqn_node  *next;   /* singly linked list of equations */
46         struct eqn_def   *defs;   /* array of definitions */
47         char             *data;   /* source code of this equation */
48         size_t            defsz;  /* number of definitions */
49         size_t            sz;     /* length of the source code */
50         size_t            cur;    /* parse point in the source code */
51         size_t            rew;    /* beginning of the current token */
52         int               gsize;  /* default point size */
53         int               delim;  /* in-line delimiters enabled */
54         char              odelim; /* in-line opening delimiter */
55         char              cdelim; /* in-line closing delimiter */
56 };
57
58 struct  eqn_def {
59         char             *key;
60         size_t            keysz;
61         char             *val;
62         size_t            valsz;
63 };
64
65 __BEGIN_DECLS
66
67 struct tbl_node *tbl_alloc(int, int, struct mparse *);
68 void             tbl_restart(int, int, struct tbl_node *);
69 void             tbl_free(struct tbl_node *);
70 void             tbl_reset(struct tbl_node *);
71 enum rofferr     tbl_read(struct tbl_node *, int, const char *, int);
72 int              tbl_option(struct tbl_node *, int, const char *);
73 int              tbl_layout(struct tbl_node *, int, const char *);
74 int              tbl_data(struct tbl_node *, int, const char *);
75 int              tbl_cdata(struct tbl_node *, int, const char *);
76 const struct tbl_span   *tbl_span(struct tbl_node *);
77 void             tbl_end(struct tbl_node **);
78 struct eqn_node *eqn_alloc(int, int, struct mparse *);
79 enum rofferr     eqn_end(struct eqn_node **);
80 void             eqn_free(struct eqn_node *);
81 enum rofferr     eqn_read(struct eqn_node **, int,
82                         const char *, int, int *);
83
84 __END_DECLS