1*95c635efSGarrett D'Amore /* $Id: libroff.h,v 1.27 2011/07/25 15:37:00 kristaps Exp $ */ 2*95c635efSGarrett D'Amore /* 3*95c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4*95c635efSGarrett D'Amore * 5*95c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 6*95c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 7*95c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 8*95c635efSGarrett D'Amore * 9*95c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10*95c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11*95c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12*95c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13*95c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14*95c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15*95c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16*95c635efSGarrett D'Amore */ 17*95c635efSGarrett D'Amore #ifndef LIBROFF_H 18*95c635efSGarrett D'Amore #define LIBROFF_H 19*95c635efSGarrett D'Amore 20*95c635efSGarrett D'Amore __BEGIN_DECLS 21*95c635efSGarrett D'Amore 22*95c635efSGarrett D'Amore enum tbl_part { 23*95c635efSGarrett D'Amore TBL_PART_OPTS, /* in options (first line) */ 24*95c635efSGarrett D'Amore TBL_PART_LAYOUT, /* describing layout */ 25*95c635efSGarrett D'Amore TBL_PART_DATA, /* creating data rows */ 26*95c635efSGarrett D'Amore TBL_PART_CDATA /* continue previous row */ 27*95c635efSGarrett D'Amore }; 28*95c635efSGarrett D'Amore 29*95c635efSGarrett D'Amore struct tbl_node { 30*95c635efSGarrett D'Amore struct mparse *parse; /* parse point */ 31*95c635efSGarrett D'Amore int pos; /* invocation column */ 32*95c635efSGarrett D'Amore int line; /* invocation line */ 33*95c635efSGarrett D'Amore enum tbl_part part; 34*95c635efSGarrett D'Amore struct tbl opts; 35*95c635efSGarrett D'Amore struct tbl_row *first_row; 36*95c635efSGarrett D'Amore struct tbl_row *last_row; 37*95c635efSGarrett D'Amore struct tbl_span *first_span; 38*95c635efSGarrett D'Amore struct tbl_span *current_span; 39*95c635efSGarrett D'Amore struct tbl_span *last_span; 40*95c635efSGarrett D'Amore struct tbl_head *first_head; 41*95c635efSGarrett D'Amore struct tbl_head *last_head; 42*95c635efSGarrett D'Amore struct tbl_node *next; 43*95c635efSGarrett D'Amore }; 44*95c635efSGarrett D'Amore 45*95c635efSGarrett D'Amore struct eqn_node { 46*95c635efSGarrett D'Amore struct eqn_def *defs; 47*95c635efSGarrett D'Amore size_t defsz; 48*95c635efSGarrett D'Amore char *data; 49*95c635efSGarrett D'Amore size_t rew; 50*95c635efSGarrett D'Amore size_t cur; 51*95c635efSGarrett D'Amore size_t sz; 52*95c635efSGarrett D'Amore int gsize; 53*95c635efSGarrett D'Amore struct eqn eqn; 54*95c635efSGarrett D'Amore struct mparse *parse; 55*95c635efSGarrett D'Amore struct eqn_node *next; 56*95c635efSGarrett D'Amore }; 57*95c635efSGarrett D'Amore 58*95c635efSGarrett D'Amore struct eqn_def { 59*95c635efSGarrett D'Amore char *key; 60*95c635efSGarrett D'Amore size_t keysz; 61*95c635efSGarrett D'Amore char *val; 62*95c635efSGarrett D'Amore size_t valsz; 63*95c635efSGarrett D'Amore }; 64*95c635efSGarrett D'Amore 65*95c635efSGarrett D'Amore struct tbl_node *tbl_alloc(int, int, struct mparse *); 66*95c635efSGarrett D'Amore void tbl_restart(int, int, struct tbl_node *); 67*95c635efSGarrett D'Amore void tbl_free(struct tbl_node *); 68*95c635efSGarrett D'Amore void tbl_reset(struct tbl_node *); 69*95c635efSGarrett D'Amore enum rofferr tbl_read(struct tbl_node *, int, const char *, int); 70*95c635efSGarrett D'Amore int tbl_option(struct tbl_node *, int, const char *); 71*95c635efSGarrett D'Amore int tbl_layout(struct tbl_node *, int, const char *); 72*95c635efSGarrett D'Amore int tbl_data(struct tbl_node *, int, const char *); 73*95c635efSGarrett D'Amore int tbl_cdata(struct tbl_node *, int, const char *); 74*95c635efSGarrett D'Amore const struct tbl_span *tbl_span(struct tbl_node *); 75*95c635efSGarrett D'Amore void tbl_end(struct tbl_node **); 76*95c635efSGarrett D'Amore struct eqn_node *eqn_alloc(const char *, int, int, struct mparse *); 77*95c635efSGarrett D'Amore enum rofferr eqn_end(struct eqn_node **); 78*95c635efSGarrett D'Amore void eqn_free(struct eqn_node *); 79*95c635efSGarrett D'Amore enum rofferr eqn_read(struct eqn_node **, int, 80*95c635efSGarrett D'Amore const char *, int, int *); 81*95c635efSGarrett D'Amore 82*95c635efSGarrett D'Amore __END_DECLS 83*95c635efSGarrett D'Amore 84*95c635efSGarrett D'Amore #endif /*LIBROFF_H*/ 85