sed.h (4822B)
1 /* 2 * sed -- stream editor 3 * 4 * Copyright 1975 Bell Telephone Laboratories, Incorporated 5 * 6 * Owner: lem 7 */ 8 9 /* from Unix 7th Edition and Unix 32V sed */ 10 /* Sccsid @(#)sed.h 1.32 (gritter) 2/6/05 */ 11 /* 12 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * Redistributions of source code and documentation must retain the 18 * above copyright notice, this list of conditions and the following 19 * disclaimer. 20 * Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * All advertising materials mentioning features or use of this software 24 * must display the following acknowledgement: 25 * This product includes software developed or owned by Caldera 26 * International, Inc. 27 * Neither the name of Caldera International, Inc. nor the names of 28 * other contributors may be used to endorse or promote products 29 * derived from this software without specific prior written permission. 30 * 31 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 32 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 33 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 36 * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 39 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 41 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 42 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 */ 44 45 #include <sys/types.h> 46 #include <limits.h> 47 #include <stdio.h> 48 #include <stdlib.h> 49 50 #if defined (SUS) || defined (SU3) || defined (S42) 51 #include <regex.h> 52 #endif /* SUS || SU3 || S42 */ 53 54 #ifdef __GLIBC__ 55 #ifdef _IO_getc_unlocked 56 #undef getc 57 #define getc(f) _IO_getc_unlocked(f) 58 #endif /* _IO_getc_unlocked */ 59 #ifdef _IO_putc_unlocked 60 #undef putc 61 #define putc(c, f) _IO_putc_unlocked(c, f) 62 #endif /* _IO_putc_unlocked */ 63 #endif /* __GLIBC__ */ 64 65 #define CEND 16 66 #define CLNUM 14 67 68 #if defined (SUS) || defined (SU3) || defined (S42) 69 struct re_emu { 70 char *r_dummy; 71 regex_t r_preg; 72 }; 73 #endif /* SUS || SU3 || S42 */ 74 75 extern int circf, ceof, nbra, sed; 76 77 struct yitem { 78 struct yitem *y_nxt; 79 wint_t y_oc; 80 wint_t y_yc; 81 char y_mc[MB_LEN_MAX]; 82 }; 83 84 extern int ABUFSIZE; 85 extern int LBSIZE; 86 extern struct reptr **abuf; 87 extern int aptr; 88 extern char *genbuf; 89 extern int gbend; 90 extern int lbend; 91 extern int hend; 92 extern char *linebuf; 93 extern char *holdsp; 94 extern int nflag; 95 extern long long *tlno; 96 97 enum cmd { 98 ACOM = 01, 99 BCOM = 020, 100 CCOM = 02, 101 CDCOM = 025, 102 CNCOM = 022, 103 COCOM = 017, 104 CPCOM = 023, 105 DCOM = 03, 106 ECOM = 015, 107 EQCOM = 013, 108 FCOM = 016, 109 GCOM = 027, 110 CGCOM = 030, 111 HCOM = 031, 112 CHCOM = 032, 113 ICOM = 04, 114 LCOM = 05, 115 NCOM = 012, 116 PCOM = 010, 117 QCOM = 011, 118 RCOM = 06, 119 SCOM = 07, 120 TCOM = 021, 121 WCOM = 014, 122 CWCOM = 024, 123 YCOM = 026, 124 XCOM = 033 125 }; 126 127 extern char *cp; 128 129 #define P(n) ((n) > 0 ? &ptrspace[n - 1] : (struct reptr *)0) 130 #define L(n) ((n) > 0 ? <ab[n - 1] : (struct label *)0) 131 #define A(n) ((n) > 0 ? &abuf[n - 1] : (struct reptr **)0) 132 133 #define slno(ep, n) ( \ 134 *(ep)++ = ((n) & 0xff000000) >> 24, \ 135 *(ep)++ = ((n) & 0x00ff0000) >> 16, \ 136 *(ep)++ = ((n) & 0x0000ff00) >> 8, \ 137 *(ep)++ = ((n) & 0x000000ff) \ 138 ) 139 140 #define glno(p) ( \ 141 ((p)[0]&0377) << 24 | \ 142 ((p)[1]&0377) << 16 | \ 143 ((p)[2]&0377) << 8 | \ 144 ((p)[3]&0377) \ 145 ) 146 147 struct reptr { 148 char *ad1; 149 char *ad2; 150 union { 151 char *re1; 152 int lb1; 153 } bptr; 154 char *rhs; 155 FILE *fcode; 156 enum cmd command; 157 short gfl; 158 char pfl; 159 char inar; 160 char negfl; 161 char nsub; 162 }; 163 164 extern struct reptr *ptrspace; 165 166 struct label { 167 char asc[8*MB_LEN_MAX + 1]; 168 int chain; 169 int address; 170 }; 171 172 extern int status; 173 extern int multibyte; 174 extern int invchar; 175 extern int needdol; 176 177 extern int eargc; 178 179 extern struct reptr *pending; 180 extern char *badp; 181 182 extern void execute(const char *); 183 extern void fatal(const char *, ...); 184 extern void nonfatal(const char *, ...); 185 extern void aptr_inc(void); 186 extern wint_t wc_get(char **, int); 187 #define fetch(s) (multibyte ? wc_get(s, 1) : (*(*(s))++ & 0377)) 188 #define peek(s) (multibyte ? wc_get(s, 0) : (**(s) & 0377)) 189 extern struct yitem *ylook(wint_t , struct yitem **, int); 190 extern void *smalloc(size_t); 191 extern void growsp(const char *);