1*260e9a87SYuri Pankov /* $Id: libroff.h,v 1.38 2015/01/30 04:11:50 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 395c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4*260e9a87SYuri Pankov * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> 595c635efSGarrett D'Amore * 695c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 795c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 895c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 995c635efSGarrett D'Amore * 1095c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1195c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1295c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1395c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1495c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1595c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1695c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1795c635efSGarrett D'Amore */ 1895c635efSGarrett D'Amore 1995c635efSGarrett D'Amore enum tbl_part { 2095c635efSGarrett D'Amore TBL_PART_OPTS, /* in options (first line) */ 2195c635efSGarrett D'Amore TBL_PART_LAYOUT, /* describing layout */ 2295c635efSGarrett D'Amore TBL_PART_DATA, /* creating data rows */ 2395c635efSGarrett D'Amore TBL_PART_CDATA /* continue previous row */ 2495c635efSGarrett D'Amore }; 2595c635efSGarrett D'Amore 2695c635efSGarrett D'Amore struct tbl_node { 2795c635efSGarrett D'Amore struct mparse *parse; /* parse point */ 2895c635efSGarrett D'Amore int pos; /* invocation column */ 2995c635efSGarrett D'Amore int line; /* invocation line */ 3095c635efSGarrett D'Amore enum tbl_part part; 31698f87a4SGarrett D'Amore struct tbl_opts opts; 3295c635efSGarrett D'Amore struct tbl_row *first_row; 3395c635efSGarrett D'Amore struct tbl_row *last_row; 3495c635efSGarrett D'Amore struct tbl_span *first_span; 3595c635efSGarrett D'Amore struct tbl_span *current_span; 3695c635efSGarrett D'Amore struct tbl_span *last_span; 3795c635efSGarrett D'Amore struct tbl_node *next; 3895c635efSGarrett D'Amore }; 3995c635efSGarrett D'Amore 4095c635efSGarrett D'Amore struct eqn_node { 41*260e9a87SYuri Pankov struct eqn eqn; /* syntax tree of this equation */ 42*260e9a87SYuri Pankov struct mparse *parse; /* main parser, for error reporting */ 43*260e9a87SYuri Pankov struct eqn_node *next; /* singly linked list of equations */ 44*260e9a87SYuri Pankov struct eqn_def *defs; /* array of definitions */ 45*260e9a87SYuri Pankov char *data; /* source code of this equation */ 46*260e9a87SYuri Pankov size_t defsz; /* number of definitions */ 47*260e9a87SYuri Pankov size_t sz; /* length of the source code */ 48*260e9a87SYuri Pankov size_t cur; /* parse point in the source code */ 49*260e9a87SYuri Pankov size_t rew; /* beginning of the current token */ 50*260e9a87SYuri Pankov int gsize; /* default point size */ 51*260e9a87SYuri Pankov int delim; /* in-line delimiters enabled */ 52*260e9a87SYuri Pankov char odelim; /* in-line opening delimiter */ 53*260e9a87SYuri Pankov char cdelim; /* in-line closing delimiter */ 5495c635efSGarrett D'Amore }; 5595c635efSGarrett D'Amore 5695c635efSGarrett D'Amore struct eqn_def { 5795c635efSGarrett D'Amore char *key; 5895c635efSGarrett D'Amore size_t keysz; 5995c635efSGarrett D'Amore char *val; 6095c635efSGarrett D'Amore size_t valsz; 6195c635efSGarrett D'Amore }; 6295c635efSGarrett D'Amore 63*260e9a87SYuri Pankov __BEGIN_DECLS 64*260e9a87SYuri Pankov 6595c635efSGarrett D'Amore struct tbl_node *tbl_alloc(int, int, struct mparse *); 6695c635efSGarrett D'Amore void tbl_restart(int, int, struct tbl_node *); 6795c635efSGarrett D'Amore void tbl_free(struct tbl_node *); 6895c635efSGarrett D'Amore void tbl_reset(struct tbl_node *); 6995c635efSGarrett D'Amore enum rofferr tbl_read(struct tbl_node *, int, const char *, int); 70*260e9a87SYuri Pankov void tbl_option(struct tbl_node *, int, const char *, int *); 71*260e9a87SYuri Pankov void tbl_layout(struct tbl_node *, int, const char *, int); 72*260e9a87SYuri Pankov void tbl_data(struct tbl_node *, int, const char *, int); 73*260e9a87SYuri Pankov int tbl_cdata(struct tbl_node *, int, const char *, int); 7495c635efSGarrett D'Amore const struct tbl_span *tbl_span(struct tbl_node *); 75*260e9a87SYuri Pankov int tbl_end(struct tbl_node **); 76*260e9a87SYuri Pankov struct eqn_node *eqn_alloc(int, int, struct mparse *); 7795c635efSGarrett D'Amore enum rofferr eqn_end(struct eqn_node **); 7895c635efSGarrett D'Amore void eqn_free(struct eqn_node *); 7995c635efSGarrett D'Amore enum rofferr eqn_read(struct eqn_node **, int, 8095c635efSGarrett D'Amore const char *, int, int *); 8195c635efSGarrett D'Amore 8295c635efSGarrett D'Amore __END_DECLS 83