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