1*95c635efSGarrett D'Amore /* $Id: libmandoc.h,v 1.29 2011/12/02 01:37:14 schwarze 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 LIBMANDOC_H 18*95c635efSGarrett D'Amore #define LIBMANDOC_H 19*95c635efSGarrett D'Amore 20*95c635efSGarrett D'Amore enum rofferr { 21*95c635efSGarrett D'Amore ROFF_CONT, /* continue processing line */ 22*95c635efSGarrett D'Amore ROFF_RERUN, /* re-run roff interpreter with offset */ 23*95c635efSGarrett D'Amore ROFF_APPEND, /* re-run main parser, appending next line */ 24*95c635efSGarrett D'Amore ROFF_REPARSE, /* re-run main parser on the result */ 25*95c635efSGarrett D'Amore ROFF_SO, /* include another file */ 26*95c635efSGarrett D'Amore ROFF_IGN, /* ignore current line */ 27*95c635efSGarrett D'Amore ROFF_TBL, /* a table row was successfully parsed */ 28*95c635efSGarrett D'Amore ROFF_EQN, /* an equation was successfully parsed */ 29*95c635efSGarrett D'Amore ROFF_ERR /* badness: puke and stop */ 30*95c635efSGarrett D'Amore }; 31*95c635efSGarrett D'Amore 32*95c635efSGarrett D'Amore enum regs { 33*95c635efSGarrett D'Amore REG_nS = 0, /* nS register */ 34*95c635efSGarrett D'Amore REG__MAX 35*95c635efSGarrett D'Amore }; 36*95c635efSGarrett D'Amore 37*95c635efSGarrett D'Amore __BEGIN_DECLS 38*95c635efSGarrett D'Amore 39*95c635efSGarrett D'Amore struct roff; 40*95c635efSGarrett D'Amore struct mdoc; 41*95c635efSGarrett D'Amore struct man; 42*95c635efSGarrett D'Amore 43*95c635efSGarrett D'Amore void mandoc_msg(enum mandocerr, struct mparse *, 44*95c635efSGarrett D'Amore int, int, const char *); 45*95c635efSGarrett D'Amore void mandoc_vmsg(enum mandocerr, struct mparse *, 46*95c635efSGarrett D'Amore int, int, const char *, ...); 47*95c635efSGarrett D'Amore char *mandoc_getarg(struct mparse *, char **, int, int *); 48*95c635efSGarrett D'Amore char *mandoc_normdate(struct mparse *, char *, int, int); 49*95c635efSGarrett D'Amore int mandoc_eos(const char *, size_t, int); 50*95c635efSGarrett D'Amore int mandoc_getcontrol(const char *, int *); 51*95c635efSGarrett D'Amore int mandoc_strntoi(const char *, size_t, int); 52*95c635efSGarrett D'Amore const char *mandoc_a2msec(const char*); 53*95c635efSGarrett D'Amore 54*95c635efSGarrett D'Amore void mdoc_free(struct mdoc *); 55*95c635efSGarrett D'Amore struct mdoc *mdoc_alloc(struct roff *, struct mparse *); 56*95c635efSGarrett D'Amore void mdoc_reset(struct mdoc *); 57*95c635efSGarrett D'Amore int mdoc_parseln(struct mdoc *, int, char *, int); 58*95c635efSGarrett D'Amore int mdoc_endparse(struct mdoc *); 59*95c635efSGarrett D'Amore int mdoc_addspan(struct mdoc *, const struct tbl_span *); 60*95c635efSGarrett D'Amore int mdoc_addeqn(struct mdoc *, const struct eqn *); 61*95c635efSGarrett D'Amore 62*95c635efSGarrett D'Amore void man_free(struct man *); 63*95c635efSGarrett D'Amore struct man *man_alloc(struct roff *, struct mparse *); 64*95c635efSGarrett D'Amore void man_reset(struct man *); 65*95c635efSGarrett D'Amore int man_parseln(struct man *, int, char *, int); 66*95c635efSGarrett D'Amore int man_endparse(struct man *); 67*95c635efSGarrett D'Amore int man_addspan(struct man *, const struct tbl_span *); 68*95c635efSGarrett D'Amore int man_addeqn(struct man *, const struct eqn *); 69*95c635efSGarrett D'Amore 70*95c635efSGarrett D'Amore void roff_free(struct roff *); 71*95c635efSGarrett D'Amore struct roff *roff_alloc(struct mparse *); 72*95c635efSGarrett D'Amore void roff_reset(struct roff *); 73*95c635efSGarrett D'Amore enum rofferr roff_parseln(struct roff *, int, 74*95c635efSGarrett D'Amore char **, size_t *, int, int *); 75*95c635efSGarrett D'Amore void roff_endparse(struct roff *); 76*95c635efSGarrett D'Amore int roff_regisset(const struct roff *, enum regs); 77*95c635efSGarrett D'Amore unsigned int roff_regget(const struct roff *, enum regs); 78*95c635efSGarrett D'Amore void roff_regunset(struct roff *, enum regs); 79*95c635efSGarrett D'Amore char *roff_strdup(const struct roff *, const char *); 80*95c635efSGarrett D'Amore #if 0 81*95c635efSGarrett D'Amore char roff_eqndelim(const struct roff *); 82*95c635efSGarrett D'Amore void roff_openeqn(struct roff *, const char *, 83*95c635efSGarrett D'Amore int, int, const char *); 84*95c635efSGarrett D'Amore int roff_closeeqn(struct roff *); 85*95c635efSGarrett D'Amore #endif 86*95c635efSGarrett D'Amore 87*95c635efSGarrett D'Amore const struct tbl_span *roff_span(const struct roff *); 88*95c635efSGarrett D'Amore const struct eqn *roff_eqn(const struct roff *); 89*95c635efSGarrett D'Amore 90*95c635efSGarrett D'Amore __END_DECLS 91*95c635efSGarrett D'Amore 92*95c635efSGarrett D'Amore #endif /*!LIBMANDOC_H*/ 93