xref: /openbsd-src/usr.bin/mandoc/man.h (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /* $Id: man.h,v 1.1 2009/04/06 20:30:40 kristaps Exp $ */
2 /*
3  * Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 #ifndef MAN_H
20 #define MAN_H
21 
22 #include <time.h>
23 
24 #define	MAN___	 	 0
25 #define	MAN_TH		 1
26 #define	MAN_SH		 2
27 #define	MAN_SS		 3
28 #define	MAN_TP		 4
29 #define	MAN_LP		 5
30 #define	MAN_PP		 6
31 #define	MAN_P		 7
32 #define	MAN_IP		 8
33 #define	MAN_HP		 9
34 #define	MAN_SM		 10
35 #define	MAN_SB		 11
36 #define	MAN_BI		 12
37 #define	MAN_IB		 13
38 #define	MAN_BR		 14
39 #define	MAN_RB		 15
40 #define	MAN_R		 16
41 #define	MAN_B		 17
42 #define	MAN_I		 18
43 #define	MAN_IR		 19
44 #define	MAN_RI		 20
45 #define	MAN_br		 21
46 #define	MAN_na		 22
47 #define	MAN_i		 23
48 #define	MAN_MAX	 	 24
49 
50 enum	man_type {
51 	MAN_TEXT,
52 	MAN_ELEM,
53 	MAN_ROOT
54 };
55 
56 struct	man_meta {
57 	int		 msec;
58 	time_t		 date;
59 	char		*vol;
60 	char		*title;
61 	char		*source;
62 };
63 
64 struct	man_node {
65 	struct man_node	*parent;
66 	struct man_node	*child;
67 	struct man_node	*next;
68 	struct man_node	*prev;
69 	int		 line;
70 	int		 pos;
71 	int		 tok;
72 	int		 flags;
73 #define	MAN_VALID	(1 << 0)
74 #define	MAN_ACTED	(1 << 1)
75 	enum man_type	 type;
76 	char		*string;
77 };
78 
79 #define	MAN_IGN_MACRO	 (1 << 0) /* Ignore unknown macros. */
80 
81 extern	const char *const *man_macronames;
82 
83 struct	man_cb {
84 	int	(*man_warn)(void *, int, int, const char *);
85 	int	(*man_err)(void *, int, int, const char *);
86 };
87 
88 __BEGIN_DECLS
89 
90 struct	man;
91 
92 void	 	  man_free(struct man *);
93 struct	man	 *man_alloc(void *, int, const struct man_cb *);
94 int		  man_reset(struct man *);
95 int	 	  man_parseln(struct man *, int, char *buf);
96 int		  man_endparse(struct man *);
97 int		  man_valid_post(struct man *);
98 
99 const struct man_node *man_node(const struct man *);
100 const struct man_meta *man_meta(const struct man *);
101 
102 __END_DECLS
103 
104 #endif /*!MAN_H*/
105