1*260e9a87SYuri Pankov /* $Id: libmandoc.h,v 1.55 2015/01/15 04:26:39 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 3698f87a4SGarrett D'Amore * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> 4*260e9a87SYuri Pankov * Copyright (c) 2013, 2014 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 rofferr { 2095c635efSGarrett D'Amore ROFF_CONT, /* continue processing line */ 2195c635efSGarrett D'Amore ROFF_RERUN, /* re-run roff interpreter with offset */ 2295c635efSGarrett D'Amore ROFF_APPEND, /* re-run main parser, appending next line */ 2395c635efSGarrett D'Amore ROFF_REPARSE, /* re-run main parser on the result */ 2495c635efSGarrett D'Amore ROFF_SO, /* include another file */ 2595c635efSGarrett D'Amore ROFF_IGN, /* ignore current line */ 2695c635efSGarrett D'Amore ROFF_TBL, /* a table row was successfully parsed */ 27*260e9a87SYuri Pankov ROFF_EQN /* an equation was successfully parsed */ 28*260e9a87SYuri Pankov }; 29*260e9a87SYuri Pankov 30*260e9a87SYuri Pankov struct buf { 31*260e9a87SYuri Pankov char *buf; 32*260e9a87SYuri Pankov size_t sz; 3395c635efSGarrett D'Amore }; 3495c635efSGarrett D'Amore 3595c635efSGarrett D'Amore __BEGIN_DECLS 3695c635efSGarrett D'Amore 37*260e9a87SYuri Pankov struct mparse; 38*260e9a87SYuri Pankov struct mchars; 39*260e9a87SYuri Pankov struct tbl_span; 40*260e9a87SYuri Pankov struct eqn; 4195c635efSGarrett D'Amore struct roff; 4295c635efSGarrett D'Amore struct mdoc; 4395c635efSGarrett D'Amore struct man; 4495c635efSGarrett D'Amore 4595c635efSGarrett D'Amore void mandoc_msg(enum mandocerr, struct mparse *, 4695c635efSGarrett D'Amore int, int, const char *); 47*260e9a87SYuri Pankov #if __GNUC__ - 0 >= 4 48*260e9a87SYuri Pankov __attribute__((__format__ (__printf__, 5, 6))) 49*260e9a87SYuri Pankov #endif 5095c635efSGarrett D'Amore void mandoc_vmsg(enum mandocerr, struct mparse *, 5195c635efSGarrett D'Amore int, int, const char *, ...); 5295c635efSGarrett D'Amore char *mandoc_getarg(struct mparse *, char **, int, int *); 5395c635efSGarrett D'Amore char *mandoc_normdate(struct mparse *, char *, int, int); 54*260e9a87SYuri Pankov int mandoc_eos(const char *, size_t); 5595c635efSGarrett D'Amore int mandoc_strntoi(const char *, size_t, int); 5695c635efSGarrett D'Amore const char *mandoc_a2msec(const char*); 5795c635efSGarrett D'Amore 5895c635efSGarrett D'Amore void mdoc_free(struct mdoc *); 59*260e9a87SYuri Pankov struct mdoc *mdoc_alloc(struct roff *, struct mparse *, 60*260e9a87SYuri Pankov const char *, int); 6195c635efSGarrett D'Amore void mdoc_reset(struct mdoc *); 6295c635efSGarrett D'Amore int mdoc_parseln(struct mdoc *, int, char *, int); 63*260e9a87SYuri Pankov void mdoc_endparse(struct mdoc *); 64*260e9a87SYuri Pankov void mdoc_addspan(struct mdoc *, const struct tbl_span *); 65*260e9a87SYuri Pankov void mdoc_addeqn(struct mdoc *, const struct eqn *); 6695c635efSGarrett D'Amore 6795c635efSGarrett D'Amore void man_free(struct man *); 68*260e9a87SYuri Pankov struct man *man_alloc(struct roff *, struct mparse *, 69*260e9a87SYuri Pankov const char *, int); 7095c635efSGarrett D'Amore void man_reset(struct man *); 7195c635efSGarrett D'Amore int man_parseln(struct man *, int, char *, int); 72*260e9a87SYuri Pankov void man_endparse(struct man *); 73*260e9a87SYuri Pankov void man_addspan(struct man *, const struct tbl_span *); 74*260e9a87SYuri Pankov void man_addeqn(struct man *, const struct eqn *); 75*260e9a87SYuri Pankov 76*260e9a87SYuri Pankov int preconv_cue(const struct buf *, size_t); 77*260e9a87SYuri Pankov int preconv_encode(struct buf *, size_t *, 78*260e9a87SYuri Pankov struct buf *, size_t *, int *); 7995c635efSGarrett D'Amore 8095c635efSGarrett D'Amore void roff_free(struct roff *); 81*260e9a87SYuri Pankov struct roff *roff_alloc(struct mparse *, const struct mchars *, int); 8295c635efSGarrett D'Amore void roff_reset(struct roff *); 83*260e9a87SYuri Pankov enum rofferr roff_parseln(struct roff *, int, struct buf *, int *); 8495c635efSGarrett D'Amore void roff_endparse(struct roff *); 85698f87a4SGarrett D'Amore void roff_setreg(struct roff *, const char *, int, char sign); 86698f87a4SGarrett D'Amore int roff_getreg(const struct roff *, const char *); 8795c635efSGarrett D'Amore char *roff_strdup(const struct roff *, const char *); 88698f87a4SGarrett D'Amore int roff_getcontrol(const struct roff *, 89698f87a4SGarrett D'Amore const char *, int *); 90*260e9a87SYuri Pankov int roff_getformat(const struct roff *); 9195c635efSGarrett D'Amore 9295c635efSGarrett D'Amore const struct tbl_span *roff_span(const struct roff *); 9395c635efSGarrett D'Amore const struct eqn *roff_eqn(const struct roff *); 9495c635efSGarrett D'Amore 9595c635efSGarrett D'Amore __END_DECLS 96