]> git.cameronkatri.com Git - mandoc.git/blob - man.h
25bef73c3f03d74736f2a4c2d4c3383b20c2e51e
[mandoc.git] / man.h
1 /* $Id: man.h,v 1.6 2009/03/26 14:38:11 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_MAX 21
46
47 enum man_type {
48 MAN_TEXT,
49 MAN_ELEM,
50 MAN_ROOT
51 };
52
53 struct man_meta {
54 int msec;
55 time_t date;
56 char *vol;
57 char *title;
58 char *source;
59 };
60
61 struct man_node {
62 struct man_node *parent;
63 struct man_node *child;
64 struct man_node *next;
65 struct man_node *prev;
66 int line;
67 int pos;
68 int tok;
69 int flags;
70 #define MAN_VALID (1 << 0)
71 #define MAN_ACTED (1 << 1)
72 enum man_type type;
73 char *string;
74 };
75
76 #define MAN_IGN_MACRO (1 << 0) /* Ignore unknown macros. */
77
78 extern const char *const *man_macronames;
79
80 struct man_cb {
81 int (*man_warn)(void *, int, int, const char *);
82 int (*man_err)(void *, int, int, const char *);
83 };
84
85 __BEGIN_DECLS
86
87 struct man;
88
89 void man_free(struct man *);
90 struct man *man_alloc(void *, int, const struct man_cb *);
91 void man_reset(struct man *);
92 int man_parseln(struct man *, int, char *buf);
93 int man_endparse(struct man *);
94 int man_valid_post(struct man *);
95
96 const struct man_node *man_node(const struct man *);
97 const struct man_meta *man_meta(const struct man *);
98
99 __END_DECLS
100
101 #endif /*!MAN_H*/