1 /* $NetBSD: defs.h,v 1.12 2014/06/06 21:56:39 wiz Exp $ */
4 * Copyright (c) 1992 Diomidis Spinellis.
5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Diomidis Spinellis of Imperial College, University of London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * @(#)defs.h 8.1 (Berkeley) 6/6/93
36 * $FreeBSD: head/usr.bin/sed/defs.h 192732 2009-05-25 06:45:33Z brian $
40 * Types of address specifications
43 AT_RE
= 1, /* Line that match RE */
44 AT_LINE
, /* Specific line */
45 AT_RELLINE
, /* Relative line */
46 AT_LAST
/* Last line */
50 * Format of an address
53 enum e_atype type
; /* Address type */
55 u_long l
; /* Line number */
56 regex_t
*r
; /* Regular expression */
61 * Substitution command
64 int n
; /* Occurrence to subst. */
65 int p
; /* True if p flag */
66 int icase
; /* True if I flag */
67 char *wfile
; /* NULL if no wfile */
68 int wfd
; /* Cached file descriptor */
69 regex_t
*re
; /* Regular expression */
70 unsigned int maxbref
; /* Largest backreference. */
71 u_long linenum
; /* Line number. */
72 char *new; /* Replacement text */
79 unsigned char bytetab
[256];
82 char from
[MB_LEN_MAX
];
90 * An internally compiled command.
91 * Initialy, label references are stored in t, on a second pass they
92 * are updated to pointers.
95 struct s_command
*next
; /* Pointer to next command */
96 struct s_addr
*a1
, *a2
; /* Start and end address */
97 u_long startline
; /* Start line number or zero */
98 char *t
; /* Text for : a c i r w */
100 struct s_command
*c
; /* Command(s) for b t { */
101 struct s_subst
*s
; /* Substitute command */
102 struct s_tr
*y
; /* Replace command array */
103 int fd
; /* File descriptor for w */
105 char code
; /* Command code */
106 u_int nonsel
:1; /* True if ! */
110 * Types of command arguments recognised by the parser
113 EMPTY
, /* d D g G h H l n N p P q x = \0 */
128 * Structure containing things to append before a line is read
131 enum {AP_STRING
, AP_FILE
} type
;
137 APPEND
, /* Append to the contents. */
138 REPLACE
/* Replace the contents. */
142 * Structure for a space (process, hold, otherwise).
145 char *space
; /* Current space pointer. */
146 size_t len
; /* Current length. */
147 int deleted
; /* If deleted. */
148 char *back
; /* Backing memory. */
149 size_t blen
; /* Backing memory length. */