1*0a6a1f1dSLionel Sambuc /* Id: libroff.h,v 1.28 2013/05/31 21:37:17 schwarze Exp */ 2d65f6f70SBen Gras /* 392395e9cSLionel Sambuc * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4d65f6f70SBen Gras * 5d65f6f70SBen Gras * Permission to use, copy, modify, and distribute this software for any 6d65f6f70SBen Gras * purpose with or without fee is hereby granted, provided that the above 7d65f6f70SBen Gras * copyright notice and this permission notice appear in all copies. 8d65f6f70SBen Gras * 9d65f6f70SBen Gras * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10d65f6f70SBen Gras * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11d65f6f70SBen Gras * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12d65f6f70SBen Gras * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13d65f6f70SBen Gras * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14d65f6f70SBen Gras * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15d65f6f70SBen Gras * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16d65f6f70SBen Gras */ 17d65f6f70SBen Gras #ifndef LIBROFF_H 18d65f6f70SBen Gras #define LIBROFF_H 19d65f6f70SBen Gras 20d65f6f70SBen Gras __BEGIN_DECLS 21d65f6f70SBen Gras 22d65f6f70SBen Gras enum tbl_part { 23d65f6f70SBen Gras TBL_PART_OPTS, /* in options (first line) */ 24d65f6f70SBen Gras TBL_PART_LAYOUT, /* describing layout */ 25d65f6f70SBen Gras TBL_PART_DATA, /* creating data rows */ 26d65f6f70SBen Gras TBL_PART_CDATA /* continue previous row */ 27d65f6f70SBen Gras }; 28d65f6f70SBen Gras 29d65f6f70SBen Gras struct tbl_node { 3092395e9cSLionel Sambuc struct mparse *parse; /* parse point */ 31d65f6f70SBen Gras int pos; /* invocation column */ 32d65f6f70SBen Gras int line; /* invocation line */ 33d65f6f70SBen Gras enum tbl_part part; 34*0a6a1f1dSLionel Sambuc struct tbl_opts opts; 35d65f6f70SBen Gras struct tbl_row *first_row; 36d65f6f70SBen Gras struct tbl_row *last_row; 37d65f6f70SBen Gras struct tbl_span *first_span; 3892395e9cSLionel Sambuc struct tbl_span *current_span; 39d65f6f70SBen Gras struct tbl_span *last_span; 40d65f6f70SBen Gras struct tbl_head *first_head; 41d65f6f70SBen Gras struct tbl_head *last_head; 42d65f6f70SBen Gras struct tbl_node *next; 43d65f6f70SBen Gras }; 44d65f6f70SBen Gras 4592395e9cSLionel Sambuc struct eqn_node { 4692395e9cSLionel Sambuc struct eqn_def *defs; 4792395e9cSLionel Sambuc size_t defsz; 4892395e9cSLionel Sambuc char *data; 4992395e9cSLionel Sambuc size_t rew; 5092395e9cSLionel Sambuc size_t cur; 5192395e9cSLionel Sambuc size_t sz; 5292395e9cSLionel Sambuc int gsize; 5392395e9cSLionel Sambuc struct eqn eqn; 5492395e9cSLionel Sambuc struct mparse *parse; 5592395e9cSLionel Sambuc struct eqn_node *next; 5692395e9cSLionel Sambuc }; 57d65f6f70SBen Gras 5892395e9cSLionel Sambuc struct eqn_def { 5992395e9cSLionel Sambuc char *key; 6092395e9cSLionel Sambuc size_t keysz; 6192395e9cSLionel Sambuc char *val; 6292395e9cSLionel Sambuc size_t valsz; 6392395e9cSLionel Sambuc }; 6492395e9cSLionel Sambuc 6592395e9cSLionel Sambuc struct tbl_node *tbl_alloc(int, int, struct mparse *); 66d65f6f70SBen Gras void tbl_restart(int, int, struct tbl_node *); 67d65f6f70SBen Gras void tbl_free(struct tbl_node *); 68d65f6f70SBen Gras void tbl_reset(struct tbl_node *); 69d65f6f70SBen Gras enum rofferr tbl_read(struct tbl_node *, int, const char *, int); 70d65f6f70SBen Gras int tbl_option(struct tbl_node *, int, const char *); 71d65f6f70SBen Gras int tbl_layout(struct tbl_node *, int, const char *); 72d65f6f70SBen Gras int tbl_data(struct tbl_node *, int, const char *); 73d65f6f70SBen Gras int tbl_cdata(struct tbl_node *, int, const char *); 7492395e9cSLionel Sambuc const struct tbl_span *tbl_span(struct tbl_node *); 7592395e9cSLionel Sambuc void tbl_end(struct tbl_node **); 7692395e9cSLionel Sambuc struct eqn_node *eqn_alloc(const char *, int, int, struct mparse *); 7792395e9cSLionel Sambuc enum rofferr eqn_end(struct eqn_node **); 7892395e9cSLionel Sambuc void eqn_free(struct eqn_node *); 7992395e9cSLionel Sambuc enum rofferr eqn_read(struct eqn_node **, int, 8092395e9cSLionel Sambuc const char *, int, int *); 81d65f6f70SBen Gras 82d65f6f70SBen Gras __END_DECLS 83d65f6f70SBen Gras 84d65f6f70SBen Gras #endif /*LIBROFF_H*/ 85