Annotation of src/usr.bin/mandoc/libroff.h, Revision 1.10
1.10 ! deraadt 1: /* $OpenBSD: libroff.h,v 1.9 2014/10/25 14:32:07 schwarze Exp $ */
1.1 schwarze 2: /*
3: * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.8 schwarze 4: * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
1.1 schwarze 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: __BEGIN_DECLS
20:
21: enum tbl_part {
22: TBL_PART_OPTS, /* in options (first line) */
23: TBL_PART_LAYOUT, /* describing layout */
24: TBL_PART_DATA, /* creating data rows */
25: TBL_PART_CDATA /* continue previous row */
26: };
27:
28: struct tbl_node {
1.4 schwarze 29: struct mparse *parse; /* parse point */
1.1 schwarze 30: int pos; /* invocation column */
31: int line; /* invocation line */
32: enum tbl_part part;
1.6 schwarze 33: struct tbl_opts opts;
1.1 schwarze 34: struct tbl_row *first_row;
35: struct tbl_row *last_row;
36: struct tbl_span *first_span;
1.2 schwarze 37: struct tbl_span *current_span;
1.1 schwarze 38: struct tbl_span *last_span;
39: struct tbl_head *first_head;
40: struct tbl_head *last_head;
41: struct tbl_node *next;
42: };
43:
1.3 schwarze 44: struct eqn_node {
1.8 schwarze 45: struct eqn eqn; /* syntax tree of this equation */
46: struct mparse *parse; /* main parser, for error reporting */
47: struct eqn_node *next; /* singly linked list of equations */
48: struct eqn_def *defs; /* array of definitions */
49: char *data; /* source code of this equation */
50: size_t defsz; /* number of definitions */
51: size_t sz; /* length of the source code */
52: size_t cur; /* parse point in the source code */
53: size_t rew; /* beginning of the current token */
54: int gsize; /* default point size */
55: int delim; /* in-line delimiters enabled */
56: char odelim; /* in-line opening delimiter */
57: char cdelim; /* in-line closing delimiter */
1.5 schwarze 58: };
59:
60: struct eqn_def {
61: char *key;
62: size_t keysz;
63: char *val;
64: size_t valsz;
1.3 schwarze 65: };
66:
1.4 schwarze 67: struct tbl_node *tbl_alloc(int, int, struct mparse *);
1.1 schwarze 68: void tbl_restart(int, int, struct tbl_node *);
69: void tbl_free(struct tbl_node *);
70: void tbl_reset(struct tbl_node *);
1.7 schwarze 71: enum rofferr tbl_read(struct tbl_node *, int, const char *, int);
1.1 schwarze 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 *);
1.2 schwarze 76: const struct tbl_span *tbl_span(struct tbl_node *);
1.5 schwarze 77: void tbl_end(struct tbl_node **);
1.9 schwarze 78: struct eqn_node *eqn_alloc(int, int, struct mparse *);
1.5 schwarze 79: enum rofferr eqn_end(struct eqn_node **);
1.3 schwarze 80: void eqn_free(struct eqn_node *);
1.7 schwarze 81: enum rofferr eqn_read(struct eqn_node **, int,
1.5 schwarze 82: const char *, int, int *);
1.1 schwarze 83:
84: __END_DECLS