1 /* $NetBSD: defs.h,v 1.10 2010/02/19 16:35:27 tnn Exp $ */
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Diomidis Spinellis of Imperial College, University of London.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * from: @(#)defs.h 8.1 (Berkeley) 6/6/93
35 * $NetBSD: defs.h,v 1.10 2010/02/19 16:35:27 tnn Exp $
39 * Copyright (c) 1992 Diomidis Spinellis.
41 * This code is derived from software contributed to Berkeley by
42 * Diomidis Spinellis of Imperial College, University of London.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * from: @(#)defs.h 8.1 (Berkeley) 6/6/93
73 * $NetBSD: defs.h,v 1.10 2010/02/19 16:35:27 tnn Exp $
77 * Types of address specifications
80 AT_RE
, /* Line that match RE */
81 AT_LINE
, /* Specific line */
82 AT_LAST
/* Last line */
86 * Format of an address
89 enum e_atype type
; /* Address type */
91 u_long l
; /* Line number */
92 regex_t
*r
; /* Regular expression */
97 * Substitution command
100 int n
; /* Occurrence to subst. */
101 int p
; /* True if p flag */
102 char *wfile
; /* NULL if no wfile */
103 int wfd
; /* Cached file descriptor */
104 regex_t
*re
; /* Regular expression */
105 int maxbref
; /* Largest backreference. */
106 u_long linenum
; /* Line number. */
107 char *new; /* Replacement text */
112 * An internally compiled command.
113 * Initialy, label references are stored in t, on a second pass they
114 * are updated to pointers.
117 struct s_command
*next
; /* Pointer to next command */
118 struct s_addr
*a1
, *a2
; /* Start and end address */
119 char *t
; /* Text for : a c i r w */
121 struct s_command
*c
; /* Command(s) for b t { */
122 struct s_subst
*s
; /* Substitute command */
123 u_char
*y
; /* Replace command array */
124 int fd
; /* File descriptor for w */
126 char code
; /* Command code */
127 u_int nonsel
:1; /* True if ! */
128 u_int inrange
:1; /* True if in range */
132 * Types of command arguments recognised by the parser
135 EMPTY
, /* d D g G h H l n N p P q x = \0 */
150 * Structure containing things to append before a line is read
153 enum {AP_STRING
, AP_FILE
} type
;
159 APPEND
, /* Append to the contents. */
160 REPLACE
/* Replace the contents. */
164 * Structure for a space (process, hold, otherwise).
167 char *space
; /* Current space pointer. */
168 size_t len
; /* Current length. */
169 int deleted
; /* If deleted. */
170 char *back
; /* Backing memory. */
171 size_t blen
; /* Backing memory length. */
175 * Error severity codes:
177 #define FATAL 0 /* Exit immediately with 1 */
178 #define ERROR 1 /* Continue, but change exit value */
179 #define WARNING 2 /* Just print the warning */
180 #define COMPILE 3 /* Print error, count and finish script */
181 #define COMPILE2 3 /* Print error, count and finish script */
184 * Round up to the nearest multiple of _POSIX2_LINE_MAX
186 #define ROUNDLEN(x) \
187 (((x) + _POSIX2_LINE_MAX - 1) & ~(_POSIX2_LINE_MAX - 1))