1*55993Sbostic /*- 2*55993Sbostic * Copyright (c) 1992 Diomidis Spinellis. 3*55993Sbostic * Copyright (c) 1992 The Regents of the University of California. 4*55993Sbostic * All rights reserved. 5*55993Sbostic * 6*55993Sbostic * This code is derived from software contributed to Berkeley by 7*55993Sbostic * Diomidis Spinellis of Imperial College, University of London. 8*55993Sbostic * 9*55993Sbostic * %sccs.include.redist.c% 10*55993Sbostic * 11*55993Sbostic * @(#)defs.h 5.1 (Berkeley) 08/23/92 12*55993Sbostic */ 13*55993Sbostic 14*55993Sbostic /* 15*55993Sbostic * Types of address specifications 16*55993Sbostic */ 17*55993Sbostic enum e_atype { 18*55993Sbostic AT_RE, /* Line that match RE */ 19*55993Sbostic AT_LINE, /* Specific line */ 20*55993Sbostic AT_LAST, /* Last line */ 21*55993Sbostic }; 22*55993Sbostic 23*55993Sbostic /* 24*55993Sbostic * Format of an address 25*55993Sbostic */ 26*55993Sbostic struct s_addr { 27*55993Sbostic enum e_atype type; /* Address type */ 28*55993Sbostic union { 29*55993Sbostic u_long l; /* Line number */ 30*55993Sbostic regex_t *r; /* Regular expression */ 31*55993Sbostic } u; 32*55993Sbostic }; 33*55993Sbostic 34*55993Sbostic /* 35*55993Sbostic * Substitution command 36*55993Sbostic */ 37*55993Sbostic struct s_subst { 38*55993Sbostic int n; /* Occurrence to subst 0=g */ 39*55993Sbostic int p; /* True if p flag */ 40*55993Sbostic char *wfile; /* NULL if no wfile */ 41*55993Sbostic int wfd; /* Cached file descriptor */ 42*55993Sbostic regex_t re; /* Regular expression */ 43*55993Sbostic regmatch_t *pmatch; /* Array of match strucs */ 44*55993Sbostic char *new; /* Replacement text */ 45*55993Sbostic }; 46*55993Sbostic 47*55993Sbostic 48*55993Sbostic /* 49*55993Sbostic * An internally compiled command. 50*55993Sbostic * Initialy, label references are stored in u.t, on a second pass they 51*55993Sbostic * are updated to pointers. 52*55993Sbostic */ 53*55993Sbostic struct s_command { 54*55993Sbostic struct s_command *next; /* Pointer to next command */ 55*55993Sbostic struct s_addr *a1, *a2; /* Start and end address */ 56*55993Sbostic char *t; /* Text for : a c i r w */ 57*55993Sbostic union { 58*55993Sbostic struct s_command *c; /* Command(s) for b t { */ 59*55993Sbostic struct s_subst *s; /* Substitute command */ 60*55993Sbostic u_char *y; /* Replace command array */ 61*55993Sbostic int fd; /* File descriptor for w */ 62*55993Sbostic } u; 63*55993Sbostic char code; /* Command code */ 64*55993Sbostic u_int nonsel:1; /* True if ! */ 65*55993Sbostic u_int inrange:1; /* True if in range */ 66*55993Sbostic }; 67*55993Sbostic 68*55993Sbostic /* 69*55993Sbostic * Types of command arguments recognised by the parser 70*55993Sbostic */ 71*55993Sbostic enum e_args { 72*55993Sbostic EMPTY, /* d D g G h H l n N p P q x = \0 */ 73*55993Sbostic TEXT, /* a c i */ 74*55993Sbostic NONSEL, /* ! */ 75*55993Sbostic GROUP, /* { */ 76*55993Sbostic COMMENT, /* # */ 77*55993Sbostic BRANCH, /* b t */ 78*55993Sbostic LABEL, /* : */ 79*55993Sbostic RFILE, /* r */ 80*55993Sbostic WFILE, /* w */ 81*55993Sbostic SUBST, /* s */ 82*55993Sbostic TR /* y */ 83*55993Sbostic }; 84*55993Sbostic 85*55993Sbostic /* 86*55993Sbostic * Structure containing things to append before a line is read 87*55993Sbostic */ 88*55993Sbostic struct s_appends { 89*55993Sbostic enum {AP_STRING, AP_FILE} type; 90*55993Sbostic char *s; 91*55993Sbostic }; 92*55993Sbostic 93*55993Sbostic /* 94*55993Sbostic * Error severity codes: 95*55993Sbostic */ 96*55993Sbostic #define FATAL 0 /* Exit immediately with 1 */ 97*55993Sbostic #define ERROR 1 /* Continue, but change exit value */ 98*55993Sbostic #define WARNING 2 /* Just print the warning */ 99*55993Sbostic #define COMPILE 3 /* Print error, count and finish script */ 100*55993Sbostic #define COMPILE2 3 /* Print error, count and finish script */ 101