]>
git.cameronkatri.com Git - mandoc.git/blob - private.h
1 /* $Id: private.h,v 1.63 2009/01/14 11:58:24 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,
34 #define MDOC_HALT (1 << 0)
36 struct mdoc_node
*last
;
37 struct mdoc_node
*first
;
38 struct mdoc_meta meta
;
39 enum mdoc_sec sec_lastn
;
40 enum mdoc_sec sec_last
;
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_QUOTABLE (1 << 3)
54 #define MDOC_PROLOGUE (1 << 4)
55 #define MDOC_TABSEP (1 << 5)
58 extern const struct mdoc_macro
*const mdoc_macros
;
62 #define mdoc_vwarn(m, n, t) \
63 mdoc_pwarn((m), (n)->line, (n)->pos, (t))
64 #define mdoc_verr(m, n, t) \
65 mdoc_perr((m), (n)->line, (n)->pos, (t))
66 #define mdoc_warn(m, t) \
67 mdoc_pwarn((m), (m)->last->line, (m)->last->pos, (t))
68 #define mdoc_err(m, t) \
69 mdoc_perr((m), (m)->last->line, (m)->last->pos, (t))
70 int mdoc_pwarn(struct mdoc
*, int, int, enum mdoc_warn
);
71 int mdoc_perr(struct mdoc
*, int, int, enum mdoc_err
);
72 void mdoc_msg(struct mdoc
*, const char *, ...);
73 int mdoc_macro(MACRO_PROT_ARGS
);
74 int mdoc_find(const struct mdoc
*, const char *);
75 int mdoc_word_alloc(struct mdoc
*,
76 int, int, const char *);
77 int mdoc_elem_alloc(struct mdoc
*, int, int,
78 int, size_t, const struct mdoc_arg
*);
79 int mdoc_block_alloc(struct mdoc
*, int, int,
80 int, size_t, const struct mdoc_arg
*);
81 int mdoc_root_alloc(struct mdoc
*);
82 int mdoc_head_alloc(struct mdoc
*, int, int, int);
83 int mdoc_tail_alloc(struct mdoc
*, int, int, int);
84 int mdoc_body_alloc(struct mdoc
*, int, int, int);
85 void mdoc_node_free(struct mdoc_node
*);
86 void mdoc_sibling(struct mdoc
*, int, struct mdoc_node
**,
87 struct mdoc_node
**, struct mdoc_node
*);
88 void *mdoc_tokhash_alloc(void);
89 int mdoc_tokhash_find(const void *, const char *);
90 void mdoc_tokhash_free(void *);
91 int mdoc_isdelim(const char *);
92 int mdoc_iscdelim(char);
93 enum mdoc_sec
mdoc_atosec(size_t, const char **);
94 enum mdoc_msec
mdoc_atomsec(const char *);
95 enum mdoc_vol
mdoc_atovol(const char *);
96 enum mdoc_arch
mdoc_atoarch(const char *);
97 enum mdoc_att
mdoc_atoatt(const char *);
98 time_t mdoc_atotime(const char *);
100 int mdoc_valid_pre(struct mdoc
*, struct mdoc_node
*);
101 int mdoc_valid_post(struct mdoc
*);
102 int mdoc_action_pre(struct mdoc
*, struct mdoc_node
*);
103 int mdoc_action_post(struct mdoc
*);
105 int mdoc_argv(struct mdoc
*, int, int,
106 struct mdoc_arg
*, int *, char *);
107 #define ARGV_ERROR (-1)
108 #define ARGV_EOLN (0)
110 #define ARGV_WORD (2)
111 void mdoc_argv_free(int, struct mdoc_arg
*);
112 int mdoc_args(struct mdoc
*, int,
113 int *, char *, int, char **);
114 #define ARGS_ERROR (-1)
115 #define ARGS_EOLN (0)
116 #define ARGS_WORD (1)
117 #define ARGS_PUNCT (2)
119 #define ARGS_QUOTED (1 << 0)
120 #define ARGS_DELIM (1 << 1)
121 #define ARGS_TABSEP (1 << 2)
123 int xstrlcat(char *, const char *, size_t);
124 int xstrlcpy(char *, const char *, size_t);
125 int xstrcmp(const char *, const char *);
126 void *xcalloc(size_t, size_t);
127 char *xstrdup(const char *);
129 int macro_obsolete(MACRO_PROT_ARGS
);
130 int macro_constant(MACRO_PROT_ARGS
);
131 int macro_constant_scoped(MACRO_PROT_ARGS
);
132 int macro_constant_delimited(MACRO_PROT_ARGS
);
133 int macro_text(MACRO_PROT_ARGS
);
134 int macro_scoped(MACRO_PROT_ARGS
);
135 int macro_scoped_close(MACRO_PROT_ARGS
);
136 int macro_scoped_line(MACRO_PROT_ARGS
);
137 int macro_prologue(MACRO_PROT_ARGS
);
138 int macro_end(struct mdoc
*);
142 #endif /*!PRIVATE_H*/