defs.h revision 1.9 1 1.9 grant /* $NetBSD: defs.h,v 1.9 2004/11/20 06:40:42 grant Exp $ */
2 1.7 tls
3 1.1 alm /*-
4 1.4 cgd * Copyright (c) 1992, 1993
5 1.4 cgd * The Regents of the University of California. All rights reserved.
6 1.1 alm *
7 1.1 alm * This code is derived from software contributed to Berkeley by
8 1.1 alm * Diomidis Spinellis of Imperial College, University of London.
9 1.1 alm *
10 1.1 alm * Redistribution and use in source and binary forms, with or without
11 1.1 alm * modification, are permitted provided that the following conditions
12 1.1 alm * are met:
13 1.1 alm * 1. Redistributions of source code must retain the above copyright
14 1.1 alm * notice, this list of conditions and the following disclaimer.
15 1.1 alm * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 alm * notice, this list of conditions and the following disclaimer in the
17 1.1 alm * documentation and/or other materials provided with the distribution.
18 1.8 agc * 3. Neither the name of the University nor the names of its contributors
19 1.8 agc * may be used to endorse or promote products derived from this software
20 1.8 agc * without specific prior written permission.
21 1.8 agc *
22 1.8 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.8 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.8 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.8 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.8 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.8 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.8 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.8 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.8 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.8 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.8 agc * SUCH DAMAGE.
33 1.8 agc *
34 1.8 agc * from: @(#)defs.h 8.1 (Berkeley) 6/6/93
35 1.9 grant * $NetBSD: defs.h,v 1.9 2004/11/20 06:40:42 grant Exp $
36 1.8 agc */
37 1.8 agc
38 1.8 agc /*-
39 1.8 agc * Copyright (c) 1992 Diomidis Spinellis.
40 1.8 agc *
41 1.8 agc * This code is derived from software contributed to Berkeley by
42 1.8 agc * Diomidis Spinellis of Imperial College, University of London.
43 1.8 agc *
44 1.8 agc * Redistribution and use in source and binary forms, with or without
45 1.8 agc * modification, are permitted provided that the following conditions
46 1.8 agc * are met:
47 1.8 agc * 1. Redistributions of source code must retain the above copyright
48 1.8 agc * notice, this list of conditions and the following disclaimer.
49 1.8 agc * 2. Redistributions in binary form must reproduce the above copyright
50 1.8 agc * notice, this list of conditions and the following disclaimer in the
51 1.8 agc * documentation and/or other materials provided with the distribution.
52 1.1 alm * 3. All advertising materials mentioning features or use of this software
53 1.1 alm * must display the following acknowledgement:
54 1.1 alm * This product includes software developed by the University of
55 1.1 alm * California, Berkeley and its contributors.
56 1.1 alm * 4. Neither the name of the University nor the names of its contributors
57 1.1 alm * may be used to endorse or promote products derived from this software
58 1.1 alm * without specific prior written permission.
59 1.1 alm *
60 1.1 alm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 1.1 alm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 1.1 alm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 1.1 alm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 1.1 alm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 1.1 alm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 1.1 alm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 1.1 alm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 1.1 alm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 1.1 alm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 1.1 alm * SUCH DAMAGE.
71 1.1 alm *
72 1.5 cgd * from: @(#)defs.h 8.1 (Berkeley) 6/6/93
73 1.9 grant * $NetBSD: defs.h,v 1.9 2004/11/20 06:40:42 grant Exp $
74 1.1 alm */
75 1.1 alm
76 1.1 alm /*
77 1.1 alm * Types of address specifications
78 1.1 alm */
79 1.1 alm enum e_atype {
80 1.1 alm AT_RE, /* Line that match RE */
81 1.1 alm AT_LINE, /* Specific line */
82 1.9 grant AT_LAST /* Last line */
83 1.1 alm };
84 1.1 alm
85 1.1 alm /*
86 1.1 alm * Format of an address
87 1.1 alm */
88 1.1 alm struct s_addr {
89 1.1 alm enum e_atype type; /* Address type */
90 1.1 alm union {
91 1.1 alm u_long l; /* Line number */
92 1.1 alm regex_t *r; /* Regular expression */
93 1.1 alm } u;
94 1.1 alm };
95 1.1 alm
96 1.1 alm /*
97 1.1 alm * Substitution command
98 1.1 alm */
99 1.1 alm struct s_subst {
100 1.1 alm int n; /* Occurrence to subst. */
101 1.1 alm int p; /* True if p flag */
102 1.1 alm char *wfile; /* NULL if no wfile */
103 1.1 alm int wfd; /* Cached file descriptor */
104 1.1 alm regex_t *re; /* Regular expression */
105 1.1 alm int maxbref; /* Largest backreference. */
106 1.1 alm u_long linenum; /* Line number. */
107 1.1 alm char *new; /* Replacement text */
108 1.1 alm };
109 1.1 alm
110 1.1 alm
111 1.1 alm /*
112 1.1 alm * An internally compiled command.
113 1.4 cgd * Initialy, label references are stored in t, on a second pass they
114 1.1 alm * are updated to pointers.
115 1.1 alm */
116 1.1 alm struct s_command {
117 1.1 alm struct s_command *next; /* Pointer to next command */
118 1.1 alm struct s_addr *a1, *a2; /* Start and end address */
119 1.1 alm char *t; /* Text for : a c i r w */
120 1.1 alm union {
121 1.1 alm struct s_command *c; /* Command(s) for b t { */
122 1.1 alm struct s_subst *s; /* Substitute command */
123 1.1 alm u_char *y; /* Replace command array */
124 1.1 alm int fd; /* File descriptor for w */
125 1.1 alm } u;
126 1.1 alm char code; /* Command code */
127 1.1 alm u_int nonsel:1; /* True if ! */
128 1.1 alm u_int inrange:1; /* True if in range */
129 1.1 alm };
130 1.1 alm
131 1.1 alm /*
132 1.1 alm * Types of command arguments recognised by the parser
133 1.1 alm */
134 1.1 alm enum e_args {
135 1.1 alm EMPTY, /* d D g G h H l n N p P q x = \0 */
136 1.1 alm TEXT, /* a c i */
137 1.1 alm NONSEL, /* ! */
138 1.1 alm GROUP, /* { */
139 1.6 mycroft ENDGROUP, /* } */
140 1.1 alm COMMENT, /* # */
141 1.1 alm BRANCH, /* b t */
142 1.1 alm LABEL, /* : */
143 1.1 alm RFILE, /* r */
144 1.1 alm WFILE, /* w */
145 1.1 alm SUBST, /* s */
146 1.1 alm TR /* y */
147 1.1 alm };
148 1.1 alm
149 1.1 alm /*
150 1.1 alm * Structure containing things to append before a line is read
151 1.1 alm */
152 1.1 alm struct s_appends {
153 1.1 alm enum {AP_STRING, AP_FILE} type;
154 1.1 alm char *s;
155 1.4 cgd size_t len;
156 1.1 alm };
157 1.1 alm
158 1.1 alm enum e_spflag {
159 1.1 alm APPEND, /* Append to the contents. */
160 1.9 grant REPLACE /* Replace the contents. */
161 1.1 alm };
162 1.1 alm
163 1.1 alm /*
164 1.1 alm * Structure for a space (process, hold, otherwise).
165 1.1 alm */
166 1.1 alm typedef struct {
167 1.1 alm char *space; /* Current space pointer. */
168 1.1 alm size_t len; /* Current length. */
169 1.1 alm int deleted; /* If deleted. */
170 1.1 alm char *back; /* Backing memory. */
171 1.1 alm size_t blen; /* Backing memory length. */
172 1.1 alm } SPACE;
173 1.1 alm
174 1.1 alm /*
175 1.1 alm * Error severity codes:
176 1.1 alm */
177 1.1 alm #define FATAL 0 /* Exit immediately with 1 */
178 1.1 alm #define ERROR 1 /* Continue, but change exit value */
179 1.1 alm #define WARNING 2 /* Just print the warning */
180 1.1 alm #define COMPILE 3 /* Print error, count and finish script */
181 1.1 alm #define COMPILE2 3 /* Print error, count and finish script */
182