]>
git.cameronkatri.com Git - mandoc.git/blob - private.h
1 /* $Id: private.h,v 1.88 2009/03/08 19:47:40 kristaps Exp $ */
3 * Copyright (c) 2008 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
7 * above copyright notice and this permission notice appear in all
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.
25 MDOC_NEXT_SIBLING
= 0,
35 #define MDOC_HALT (1 << 0)
38 struct mdoc_node
*last
;
39 struct mdoc_node
*first
;
40 struct mdoc_meta meta
;
41 enum mdoc_sec lastnamed
;
42 enum mdoc_sec lastsec
;
46 #define MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
47 int ppos, int *pos, char *buf
50 int (*fp
)(MACRO_PROT_ARGS
);
52 #define MDOC_CALLABLE (1 << 0)
53 #define MDOC_PARSED (1 << 1)
54 #define MDOC_EXPLICIT (1 << 2)
55 #define MDOC_PROLOGUE (1 << 3)
58 #define mdoc_nwarn(mdoc, node, type, fmt, ...) \
59 mdoc_vwarn((mdoc), (node)->line, \
60 (node)->pos, (type), (fmt), ##__VA_ARGS__)
62 #define mdoc_nerr(mdoc, node, fmt, ...) \
63 mdoc_verr((mdoc), (node)->line, \
64 (node)->pos, (fmt), ##__VA_ARGS__)
66 #define mdoc_warn(mdoc, type, fmt, ...) \
67 mdoc_vwarn((mdoc), (mdoc)->last->line, \
68 (mdoc)->last->pos, (type), (fmt), ##__VA_ARGS__)
70 #define mdoc_err(mdoc, fmt, ...) \
71 mdoc_verr((mdoc), (mdoc)->last->line, \
72 (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
74 #define mdoc_msg(mdoc, fmt, ...) \
75 mdoc_vmsg((mdoc), (mdoc)->last->line, \
76 (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
78 #define mdoc_pmsg(mdoc, line, pos, fmt, ...) \
79 mdoc_vmsg((mdoc), (line), \
80 (pos), (fmt), ##__VA_ARGS__)
82 #define mdoc_pwarn(mdoc, line, pos, type, fmt, ...) \
83 mdoc_vwarn((mdoc), (line), \
84 (pos), (type), (fmt), ##__VA_ARGS__)
86 #define mdoc_perr(mdoc, line, pos, fmt, ...) \
87 mdoc_verr((mdoc), (line), \
88 (pos), (fmt), ##__VA_ARGS__)
90 extern const struct mdoc_macro
*const mdoc_macros
;
94 int mdoc_vwarn(struct mdoc
*, int, int,
95 enum mdoc_warn
, const char *, ...);
96 void mdoc_vmsg(struct mdoc
*, int, int,
98 int mdoc_verr(struct mdoc
*, int, int,
100 int mdoc_macro(MACRO_PROT_ARGS
);
101 int mdoc_word_alloc(struct mdoc
*,
102 int, int, const char *);
103 int mdoc_elem_alloc(struct mdoc
*, int, int,
104 int, struct mdoc_arg
*);
105 int mdoc_block_alloc(struct mdoc
*, int, int,
106 int, struct mdoc_arg
*);
107 int mdoc_root_alloc(struct mdoc
*);
108 int mdoc_head_alloc(struct mdoc
*, int, int, int);
109 int mdoc_tail_alloc(struct mdoc
*, int, int, int);
110 int mdoc_body_alloc(struct mdoc
*, int, int, int);
111 void mdoc_node_free(struct mdoc_node
*);
112 void mdoc_node_freelist(struct mdoc_node
*);
113 void *mdoc_tokhash_alloc(void);
114 int mdoc_tokhash_find(const void *, const char *);
115 void mdoc_tokhash_free(void *);
116 int mdoc_iscdelim(char);
117 size_t mdoc_isescape(const char *);
118 enum mdoc_sec
mdoc_atosec(const char *);
119 time_t mdoc_atotime(const char *);
120 size_t mdoc_macro2len(int);
121 const char *mdoc_a2arch(const char *);
122 const char *mdoc_a2vol(const char *);
123 const char *mdoc_a2msec(const char *);
124 int mdoc_valid_pre(struct mdoc
*,
125 const struct mdoc_node
*);
126 int mdoc_valid_post(struct mdoc
*);
127 int mdoc_action_pre(struct mdoc
*, struct mdoc_node
*);
128 int mdoc_action_post(struct mdoc
*);
129 int mdoc_argv(struct mdoc
*, int, int,
130 struct mdoc_arg
**, int *, char *);
131 #define ARGV_ERROR (-1)
132 #define ARGV_EOLN (0)
134 #define ARGV_WORD (2)
135 void mdoc_argv_free(struct mdoc_arg
*);
136 int mdoc_args(struct mdoc
*, int,
137 int *, char *, int, char **);
138 #define ARGS_ERROR (-1)
139 #define ARGS_EOLN (0)
140 #define ARGS_WORD (1)
141 #define ARGS_PUNCT (2)
142 #define ARGS_QWORD (3)
143 #define ARGS_PHRASE (4)
144 int xstrlcpys(char *, const struct mdoc_node
*, size_t);
145 int xstrlcat(char *, const char *, size_t);
146 int xstrlcpy(char *, const char *, size_t);
147 int xstrcmp(const char *, const char *);
148 void *xcalloc(size_t, size_t);
149 void *xrealloc(void *, size_t);
150 char *xstrdup(const char *);
151 int macro_end(struct mdoc
*);
155 #endif /*!PRIVATE_H*/