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