Annotation of mandoc/private.h, Revision 1.90
1.90 ! kristaps 1: /* $Id: private.h,v 1.89 2009/03/16 22:19:19 kristaps Exp $ */
1.1 kristaps 2: /*
3: * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
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 PRIVATE_H
20: #define PRIVATE_H
21:
1.41 kristaps 22: #include "mdoc.h"
1.27 kristaps 23:
1.52 kristaps 24: enum mdoc_next {
25: MDOC_NEXT_SIBLING = 0,
26: MDOC_NEXT_CHILD
27: };
28:
1.41 kristaps 29: struct mdoc {
30: void *data;
31: struct mdoc_cb cb;
32: void *htab;
1.70 kristaps 33: int linetok;
1.52 kristaps 34: int flags;
1.57 kristaps 35: #define MDOC_HALT (1 << 0)
1.90 ! kristaps 36: #define MDOC_LITERAL (1 << 1)
1.86 kristaps 37: int pflags;
1.52 kristaps 38: enum mdoc_next next;
1.41 kristaps 39: struct mdoc_node *last;
40: struct mdoc_node *first;
1.43 kristaps 41: struct mdoc_meta meta;
1.74 kristaps 42: enum mdoc_sec lastnamed;
1.78 kristaps 43: enum mdoc_sec lastsec;
1.36 kristaps 44: };
45:
1.58 kristaps 46:
47: #define MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
48: int ppos, int *pos, char *buf
49:
1.41 kristaps 50: struct mdoc_macro {
1.64 kristaps 51: int (*fp)(MACRO_PROT_ARGS);
52: int flags;
53: #define MDOC_CALLABLE (1 << 0)
54: #define MDOC_PARSED (1 << 1)
55: #define MDOC_EXPLICIT (1 << 2)
1.72 kristaps 56: #define MDOC_PROLOGUE (1 << 3)
1.89 kristaps 57: #define MDOC_IGNDELIM (1 << 4)
58: /* Reserved words in arguments treated as text. */
1.8 kristaps 59: };
1.5 kristaps 60:
1.64 kristaps 61: #define mdoc_nwarn(mdoc, node, type, fmt, ...) \
62: mdoc_vwarn((mdoc), (node)->line, \
63: (node)->pos, (type), (fmt), ##__VA_ARGS__)
64:
65: #define mdoc_nerr(mdoc, node, fmt, ...) \
66: mdoc_verr((mdoc), (node)->line, \
67: (node)->pos, (fmt), ##__VA_ARGS__)
68:
69: #define mdoc_warn(mdoc, type, fmt, ...) \
70: mdoc_vwarn((mdoc), (mdoc)->last->line, \
71: (mdoc)->last->pos, (type), (fmt), ##__VA_ARGS__)
72:
73: #define mdoc_err(mdoc, fmt, ...) \
74: mdoc_verr((mdoc), (mdoc)->last->line, \
75: (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
76:
77: #define mdoc_msg(mdoc, fmt, ...) \
78: mdoc_vmsg((mdoc), (mdoc)->last->line, \
79: (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
80:
81: #define mdoc_pmsg(mdoc, line, pos, fmt, ...) \
82: mdoc_vmsg((mdoc), (line), \
83: (pos), (fmt), ##__VA_ARGS__)
84:
85: #define mdoc_pwarn(mdoc, line, pos, type, fmt, ...) \
86: mdoc_vwarn((mdoc), (line), \
87: (pos), (type), (fmt), ##__VA_ARGS__)
88:
89: #define mdoc_perr(mdoc, line, pos, fmt, ...) \
90: mdoc_verr((mdoc), (line), \
91: (pos), (fmt), ##__VA_ARGS__)
92:
1.41 kristaps 93: extern const struct mdoc_macro *const mdoc_macros;
1.24 kristaps 94:
1.1 kristaps 95: __BEGIN_DECLS
96:
1.64 kristaps 97: int mdoc_vwarn(struct mdoc *, int, int,
98: enum mdoc_warn, const char *, ...);
99: void mdoc_vmsg(struct mdoc *, int, int,
100: const char *, ...);
101: int mdoc_verr(struct mdoc *, int, int,
102: const char *, ...);
1.58 kristaps 103: int mdoc_macro(MACRO_PROT_ARGS);
1.60 kristaps 104: int mdoc_word_alloc(struct mdoc *,
1.59 kristaps 105: int, int, const char *);
1.60 kristaps 106: int mdoc_elem_alloc(struct mdoc *, int, int,
1.86 kristaps 107: int, struct mdoc_arg *);
1.60 kristaps 108: int mdoc_block_alloc(struct mdoc *, int, int,
1.86 kristaps 109: int, struct mdoc_arg *);
1.61 kristaps 110: int mdoc_root_alloc(struct mdoc *);
1.60 kristaps 111: int mdoc_head_alloc(struct mdoc *, int, int, int);
112: int mdoc_tail_alloc(struct mdoc *, int, int, int);
113: int mdoc_body_alloc(struct mdoc *, int, int, int);
1.41 kristaps 114: void mdoc_node_free(struct mdoc_node *);
1.69 kristaps 115: void mdoc_node_freelist(struct mdoc_node *);
1.44 kristaps 116: void *mdoc_tokhash_alloc(void);
117: int mdoc_tokhash_find(const void *, const char *);
118: void mdoc_tokhash_free(void *);
1.45 kristaps 119: int mdoc_iscdelim(char);
1.80 kristaps 120: size_t mdoc_isescape(const char *);
1.67 kristaps 121: enum mdoc_sec mdoc_atosec(const char *);
1.43 kristaps 122: time_t mdoc_atotime(const char *);
1.83 kristaps 123: size_t mdoc_macro2len(int);
1.85 kristaps 124: const char *mdoc_a2arch(const char *);
125: const char *mdoc_a2vol(const char *);
126: const char *mdoc_a2msec(const char *);
1.81 kristaps 127: int mdoc_valid_pre(struct mdoc *,
128: const struct mdoc_node *);
1.60 kristaps 129: int mdoc_valid_post(struct mdoc *);
1.90 ! kristaps 130: int mdoc_action_pre(struct mdoc *,
! 131: const struct mdoc_node *);
1.60 kristaps 132: int mdoc_action_post(struct mdoc *);
1.86 kristaps 133: int mdoc_argv(struct mdoc *, int, int,
134: struct mdoc_arg **, int *, char *);
1.52 kristaps 135: #define ARGV_ERROR (-1)
136: #define ARGV_EOLN (0)
137: #define ARGV_ARG (1)
138: #define ARGV_WORD (2)
1.86 kristaps 139: void mdoc_argv_free(struct mdoc_arg *);
1.45 kristaps 140: int mdoc_args(struct mdoc *, int,
141: int *, char *, int, char **);
142: #define ARGS_ERROR (-1)
143: #define ARGS_EOLN (0)
144: #define ARGS_WORD (1)
145: #define ARGS_PUNCT (2)
1.71 kristaps 146: #define ARGS_QWORD (3)
1.75 kristaps 147: #define ARGS_PHRASE (4)
1.85 kristaps 148: int xstrlcpys(char *, const struct mdoc_node *, size_t);
1.44 kristaps 149: int xstrlcat(char *, const char *, size_t);
150: int xstrlcpy(char *, const char *, size_t);
151: int xstrcmp(const char *, const char *);
152: void *xcalloc(size_t, size_t);
1.84 kristaps 153: void *xrealloc(void *, size_t);
1.44 kristaps 154: char *xstrdup(const char *);
1.57 kristaps 155: int macro_end(struct mdoc *);
1.35 kristaps 156:
1.1 kristaps 157: __END_DECLS
158:
159: #endif /*!PRIVATE_H*/
CVSweb