]>
git.cameronkatri.com Git - mandoc.git/blob - libmdoc.h
1 /* $Id: libmdoc.h,v 1.9 2009/06/15 10:02:52 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 MDOC_NEXT_SIBLING
= 0,
32 #define MDOC_HALT (1 << 0)
33 #define MDOC_LITERAL (1 << 1)
36 struct mdoc_node
*last
;
37 struct mdoc_node
*first
;
38 struct mdoc_meta meta
;
39 enum mdoc_sec lastnamed
;
40 enum mdoc_sec lastsec
;
44 #define MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
45 int ppos, int *pos, char *buf
48 int (*fp
)(MACRO_PROT_ARGS
);
50 #define MDOC_CALLABLE (1 << 0)
51 #define MDOC_PARSED (1 << 1)
52 #define MDOC_EXPLICIT (1 << 2)
53 #define MDOC_PROLOGUE (1 << 3)
54 #define MDOC_IGNDELIM (1 << 4)
55 /* Reserved words in arguments treated as text. */
58 extern const struct mdoc_macro
*const mdoc_macros
;
63 * When GCC2 is deprecated, most of these can be reverted to #define
64 * as mdoc_vmsg using __VA_ARGS__. Until then, use real functions.
66 int mdoc_vwarn(struct mdoc
*, int, int,
67 enum mdoc_warn
, const char *, ...);
68 void mdoc_vmsg(struct mdoc
*, int, int,
70 int mdoc_verr(struct mdoc
*, int, int,
72 int mdoc_nerr(struct mdoc
*, const struct mdoc_node
*,
74 int mdoc_warn(struct mdoc
*, enum mdoc_warn
, const char *, ...);
75 int mdoc_err(struct mdoc
*, const char *, ...);
76 void mdoc_msg(struct mdoc
*, const char *, ...);
77 void mdoc_pmsg(struct mdoc
*, int, int, const char *, ...);
78 int mdoc_pwarn(struct mdoc
*, int, int,
79 enum mdoc_warn
,const char *, ...);
80 int mdoc_perr(struct mdoc
*, int, int, const char *, ...);
81 int mdoc_macro(MACRO_PROT_ARGS
);
82 int mdoc_word_alloc(struct mdoc
*,
83 int, int, const char *);
84 int mdoc_elem_alloc(struct mdoc
*, int, int,
85 int, struct mdoc_arg
*);
86 int mdoc_block_alloc(struct mdoc
*, int, int,
87 int, struct mdoc_arg
*);
88 int mdoc_head_alloc(struct mdoc
*, int, int, int);
89 int mdoc_tail_alloc(struct mdoc
*, int, int, int);
90 int mdoc_body_alloc(struct mdoc
*, int, int, int);
91 void mdoc_node_free(struct mdoc_node
*);
92 void mdoc_node_freelist(struct mdoc_node
*);
93 void *mdoc_hash_alloc(void);
94 int mdoc_hash_find(const void *, const char *);
95 void mdoc_hash_free(void *);
96 int mdoc_iscdelim(char);
97 int mdoc_isdelim(const char *);
98 size_t mdoc_isescape(const char *);
99 enum mdoc_sec
mdoc_atosec(const char *);
100 time_t mdoc_atotime(const char *);
102 size_t mdoc_macro2len(int);
103 const char *mdoc_a2arch(const char *);
104 const char *mdoc_a2vol(const char *);
105 const char *mdoc_a2msec(const char *);
106 int mdoc_valid_pre(struct mdoc
*,
107 const struct mdoc_node
*);
108 int mdoc_valid_post(struct mdoc
*);
109 int mdoc_action_pre(struct mdoc
*,
110 const struct mdoc_node
*);
111 int mdoc_action_post(struct mdoc
*);
112 int mdoc_argv(struct mdoc
*, int, int,
113 struct mdoc_arg
**, int *, char *);
114 #define ARGV_ERROR (-1)
115 #define ARGV_EOLN (0)
117 #define ARGV_WORD (2)
118 void mdoc_argv_free(struct mdoc_arg
*);
119 int mdoc_args(struct mdoc
*, int,
120 int *, char *, int, char **);
121 #define ARGS_ERROR (-1)
122 #define ARGS_EOLN (0)
123 #define ARGS_WORD (1)
124 #define ARGS_PUNCT (2)
125 #define ARGS_QWORD (3)
126 #define ARGS_PHRASE (4)
128 int mdoc_macroend(struct mdoc
*);
132 #endif /*!LIBMDOC_H*/