1*0a6a1f1dSLionel Sambuc /* Id: libmandoc.h,v 1.37 2014/01/05 19:10:56 joerg Exp */ 2d65f6f70SBen Gras /* 3*0a6a1f1dSLionel Sambuc * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> 4*0a6a1f1dSLionel Sambuc * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org> 5d65f6f70SBen Gras * 6d65f6f70SBen Gras * Permission to use, copy, modify, and distribute this software for any 7d65f6f70SBen Gras * purpose with or without fee is hereby granted, provided that the above 8d65f6f70SBen Gras * copyright notice and this permission notice appear in all copies. 9d65f6f70SBen Gras * 10d65f6f70SBen Gras * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11d65f6f70SBen Gras * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12d65f6f70SBen Gras * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13d65f6f70SBen Gras * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14d65f6f70SBen Gras * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15d65f6f70SBen Gras * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16d65f6f70SBen Gras * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17d65f6f70SBen Gras */ 18d65f6f70SBen Gras #ifndef LIBMANDOC_H 19d65f6f70SBen Gras #define LIBMANDOC_H 20d65f6f70SBen Gras 2192395e9cSLionel Sambuc enum rofferr { 2292395e9cSLionel Sambuc ROFF_CONT, /* continue processing line */ 2392395e9cSLionel Sambuc ROFF_RERUN, /* re-run roff interpreter with offset */ 2492395e9cSLionel Sambuc ROFF_APPEND, /* re-run main parser, appending next line */ 2592395e9cSLionel Sambuc ROFF_REPARSE, /* re-run main parser on the result */ 2692395e9cSLionel Sambuc ROFF_SO, /* include another file */ 2792395e9cSLionel Sambuc ROFF_IGN, /* ignore current line */ 2892395e9cSLionel Sambuc ROFF_TBL, /* a table row was successfully parsed */ 2992395e9cSLionel Sambuc ROFF_EQN, /* an equation was successfully parsed */ 3092395e9cSLionel Sambuc ROFF_ERR /* badness: puke and stop */ 3192395e9cSLionel Sambuc }; 3292395e9cSLionel Sambuc 33d65f6f70SBen Gras __BEGIN_DECLS 34d65f6f70SBen Gras 3592395e9cSLionel Sambuc struct roff; 3692395e9cSLionel Sambuc struct mdoc; 3792395e9cSLionel Sambuc struct man; 3892395e9cSLionel Sambuc 3992395e9cSLionel Sambuc void mandoc_msg(enum mandocerr, struct mparse *, 4092395e9cSLionel Sambuc int, int, const char *); 41*0a6a1f1dSLionel Sambuc #if __GNUC__ - 0 >= 4 42*0a6a1f1dSLionel Sambuc __attribute__((__format__ (__printf__, 5, 6))) 43*0a6a1f1dSLionel Sambuc #endif 4492395e9cSLionel Sambuc void mandoc_vmsg(enum mandocerr, struct mparse *, 4592395e9cSLionel Sambuc int, int, const char *, ...); 4692395e9cSLionel Sambuc char *mandoc_getarg(struct mparse *, char **, int, int *); 4792395e9cSLionel Sambuc char *mandoc_normdate(struct mparse *, char *, int, int); 48*0a6a1f1dSLionel Sambuc int mandoc_eos(const char *, size_t); 4992395e9cSLionel Sambuc int mandoc_strntoi(const char *, size_t, int); 5092395e9cSLionel Sambuc const char *mandoc_a2msec(const char*); 5192395e9cSLionel Sambuc 5292395e9cSLionel Sambuc void mdoc_free(struct mdoc *); 53*0a6a1f1dSLionel Sambuc struct mdoc *mdoc_alloc(struct roff *, struct mparse *, char *); 5492395e9cSLionel Sambuc void mdoc_reset(struct mdoc *); 5592395e9cSLionel Sambuc int mdoc_parseln(struct mdoc *, int, char *, int); 5692395e9cSLionel Sambuc int mdoc_endparse(struct mdoc *); 5792395e9cSLionel Sambuc int mdoc_addspan(struct mdoc *, const struct tbl_span *); 5892395e9cSLionel Sambuc int mdoc_addeqn(struct mdoc *, const struct eqn *); 5992395e9cSLionel Sambuc 6092395e9cSLionel Sambuc void man_free(struct man *); 6192395e9cSLionel Sambuc struct man *man_alloc(struct roff *, struct mparse *); 6292395e9cSLionel Sambuc void man_reset(struct man *); 6392395e9cSLionel Sambuc int man_parseln(struct man *, int, char *, int); 6492395e9cSLionel Sambuc int man_endparse(struct man *); 6592395e9cSLionel Sambuc int man_addspan(struct man *, const struct tbl_span *); 6692395e9cSLionel Sambuc int man_addeqn(struct man *, const struct eqn *); 6792395e9cSLionel Sambuc 6892395e9cSLionel Sambuc void roff_free(struct roff *); 69*0a6a1f1dSLionel Sambuc struct roff *roff_alloc(enum mparset, struct mparse *); 7092395e9cSLionel Sambuc void roff_reset(struct roff *); 7192395e9cSLionel Sambuc enum rofferr roff_parseln(struct roff *, int, 7292395e9cSLionel Sambuc char **, size_t *, int, int *); 7392395e9cSLionel Sambuc void roff_endparse(struct roff *); 74*0a6a1f1dSLionel Sambuc void roff_setreg(struct roff *, const char *, int, char sign); 75*0a6a1f1dSLionel Sambuc int roff_getreg(const struct roff *, const char *); 7692395e9cSLionel Sambuc char *roff_strdup(const struct roff *, const char *); 77*0a6a1f1dSLionel Sambuc int roff_getcontrol(const struct roff *, 78*0a6a1f1dSLionel Sambuc const char *, int *); 7992395e9cSLionel Sambuc #if 0 8092395e9cSLionel Sambuc char roff_eqndelim(const struct roff *); 8192395e9cSLionel Sambuc void roff_openeqn(struct roff *, const char *, 8292395e9cSLionel Sambuc int, int, const char *); 8392395e9cSLionel Sambuc int roff_closeeqn(struct roff *); 8492395e9cSLionel Sambuc #endif 8592395e9cSLionel Sambuc 8692395e9cSLionel Sambuc const struct tbl_span *roff_span(const struct roff *); 8792395e9cSLionel Sambuc const struct eqn *roff_eqn(const struct roff *); 88d65f6f70SBen Gras 89d65f6f70SBen Gras __END_DECLS 90d65f6f70SBen Gras 91d65f6f70SBen Gras #endif /*!LIBMANDOC_H*/ 92