libroff.h revision 274880
1207614Simp/* $Id: libroff.h,v 1.29 2014/04/20 16:46:04 schwarze Exp $ */ 2207614Simp/* 3207614Simp * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4207614Simp * 5207614Simp * Permission to use, copy, modify, and distribute this software for any 6207614Simp * purpose with or without fee is hereby granted, provided that the above 7207614Simp * copyright notice and this permission notice appear in all copies. 8207614Simp * 9207614Simp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10207614Simp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11207614Simp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12207614Simp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13207614Simp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14207614Simp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15207614Simp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16207614Simp */ 17207614Simp#ifndef LIBROFF_H 18207614Simp#define LIBROFF_H 19207614Simp 20207614Simp__BEGIN_DECLS 21207614Simp 22207614Simpenum tbl_part { 23207614Simp TBL_PART_OPTS, /* in options (first line) */ 24207614Simp TBL_PART_LAYOUT, /* describing layout */ 25207614Simp TBL_PART_DATA, /* creating data rows */ 26207614Simp TBL_PART_CDATA /* continue previous row */ 27207614Simp}; 28207614Simp 29207614Simpstruct tbl_node { 30207614Simp struct mparse *parse; /* parse point */ 31207614Simp int pos; /* invocation column */ 32207614Simp int line; /* invocation line */ 33207614Simp enum tbl_part part; 34207614Simp struct tbl_opts opts; 35207614Simp struct tbl_row *first_row; 36207614Simp struct tbl_row *last_row; 37207614Simp struct tbl_span *first_span; 38207614Simp struct tbl_span *current_span; 39229780Suqs struct tbl_span *last_span; 40207614Simp struct tbl_head *first_head; 41207614Simp struct tbl_head *last_head; 42207614Simp struct tbl_node *next; 43229780Suqs}; 44207614Simp 45207614Simpstruct eqn_node { 46207614Simp struct eqn_def *defs; 47207614Simp size_t defsz; 48207614Simp char *data; 49207614Simp size_t rew; 50207614Simp size_t cur; 51207614Simp size_t sz; 52207614Simp int gsize; 53207614Simp struct eqn eqn; 54207614Simp struct mparse *parse; 55207614Simp struct eqn_node *next; 56207614Simp}; 57207614Simp 58207614Simpstruct eqn_def { 59207614Simp char *key; 60207614Simp size_t keysz; 61207614Simp char *val; 62207614Simp size_t valsz; 63207614Simp}; 64207614Simp 65207614Simpstruct tbl_node *tbl_alloc(int, int, struct mparse *); 66207614Simpvoid tbl_restart(int, int, struct tbl_node *); 67213099Smariusvoid tbl_free(struct tbl_node *); 68207614Simpvoid tbl_reset(struct tbl_node *); 69207614Simpenum rofferr tbl_read(struct tbl_node *, int, const char *, int); 70213099Smariusint tbl_option(struct tbl_node *, int, const char *); 71207614Simpint tbl_layout(struct tbl_node *, int, const char *); 72207614Simpint tbl_data(struct tbl_node *, int, const char *); 73207614Simpint tbl_cdata(struct tbl_node *, int, const char *); 74207614Simpconst struct tbl_span *tbl_span(struct tbl_node *); 75207614Simpvoid tbl_end(struct tbl_node **); 76207614Simpstruct eqn_node *eqn_alloc(const char *, int, int, struct mparse *); 77213099Smariusenum rofferr eqn_end(struct eqn_node **); 78207614Simpvoid eqn_free(struct eqn_node *); 79207614Simpenum rofferr eqn_read(struct eqn_node **, int, 80207614Simp const char *, int, int *); 81207614Simp 82207614Simp__END_DECLS 83207614Simp 84207614Simp#endif /*LIBROFF_H*/ 85207614Simp