155993Sbostic /*- 255993Sbostic * Copyright (c) 1992 Diomidis Spinellis. 355993Sbostic * Copyright (c) 1992 The Regents of the University of California. 455993Sbostic * All rights reserved. 555993Sbostic * 655993Sbostic * This code is derived from software contributed to Berkeley by 755993Sbostic * Diomidis Spinellis of Imperial College, University of London. 855993Sbostic * 955993Sbostic * %sccs.include.redist.c% 1055993Sbostic * 11*56019Sbostic * @(#)defs.h 5.2 (Berkeley) 08/24/92 1255993Sbostic */ 1355993Sbostic 1455993Sbostic /* 1555993Sbostic * Types of address specifications 1655993Sbostic */ 1755993Sbostic enum e_atype { 1855993Sbostic AT_RE, /* Line that match RE */ 1955993Sbostic AT_LINE, /* Specific line */ 2055993Sbostic AT_LAST, /* Last line */ 2155993Sbostic }; 2255993Sbostic 2355993Sbostic /* 2455993Sbostic * Format of an address 2555993Sbostic */ 2655993Sbostic struct s_addr { 2755993Sbostic enum e_atype type; /* Address type */ 2855993Sbostic union { 2955993Sbostic u_long l; /* Line number */ 3055993Sbostic regex_t *r; /* Regular expression */ 3155993Sbostic } u; 3255993Sbostic }; 3355993Sbostic 3455993Sbostic /* 3555993Sbostic * Substitution command 3655993Sbostic */ 3755993Sbostic struct s_subst { 38*56019Sbostic int n; /* Occurrence to subst. */ 3955993Sbostic int p; /* True if p flag */ 4055993Sbostic char *wfile; /* NULL if no wfile */ 4155993Sbostic int wfd; /* Cached file descriptor */ 42*56019Sbostic regex_t *re; /* Regular expression */ 4355993Sbostic regmatch_t *pmatch; /* Array of match strucs */ 44*56019Sbostic int maxbref; /* Largest backreference. */ 45*56019Sbostic u_long linenum; /* Line number. */ 4655993Sbostic char *new; /* Replacement text */ 4755993Sbostic }; 4855993Sbostic 4955993Sbostic 5055993Sbostic /* 5155993Sbostic * An internally compiled command. 5255993Sbostic * Initialy, label references are stored in u.t, on a second pass they 5355993Sbostic * are updated to pointers. 5455993Sbostic */ 5555993Sbostic struct s_command { 5655993Sbostic struct s_command *next; /* Pointer to next command */ 5755993Sbostic struct s_addr *a1, *a2; /* Start and end address */ 5855993Sbostic char *t; /* Text for : a c i r w */ 5955993Sbostic union { 6055993Sbostic struct s_command *c; /* Command(s) for b t { */ 6155993Sbostic struct s_subst *s; /* Substitute command */ 6255993Sbostic u_char *y; /* Replace command array */ 6355993Sbostic int fd; /* File descriptor for w */ 6455993Sbostic } u; 6555993Sbostic char code; /* Command code */ 6655993Sbostic u_int nonsel:1; /* True if ! */ 6755993Sbostic u_int inrange:1; /* True if in range */ 6855993Sbostic }; 6955993Sbostic 7055993Sbostic /* 7155993Sbostic * Types of command arguments recognised by the parser 7255993Sbostic */ 7355993Sbostic enum e_args { 7455993Sbostic EMPTY, /* d D g G h H l n N p P q x = \0 */ 7555993Sbostic TEXT, /* a c i */ 7655993Sbostic NONSEL, /* ! */ 7755993Sbostic GROUP, /* { */ 7855993Sbostic COMMENT, /* # */ 7955993Sbostic BRANCH, /* b t */ 8055993Sbostic LABEL, /* : */ 8155993Sbostic RFILE, /* r */ 8255993Sbostic WFILE, /* w */ 8355993Sbostic SUBST, /* s */ 8455993Sbostic TR /* y */ 8555993Sbostic }; 8655993Sbostic 8755993Sbostic /* 8855993Sbostic * Structure containing things to append before a line is read 8955993Sbostic */ 9055993Sbostic struct s_appends { 9155993Sbostic enum {AP_STRING, AP_FILE} type; 9255993Sbostic char *s; 9355993Sbostic }; 9455993Sbostic 9555993Sbostic /* 9655993Sbostic * Error severity codes: 9755993Sbostic */ 9855993Sbostic #define FATAL 0 /* Exit immediately with 1 */ 9955993Sbostic #define ERROR 1 /* Continue, but change exit value */ 10055993Sbostic #define WARNING 2 /* Just print the warning */ 10155993Sbostic #define COMPILE 3 /* Print error, count and finish script */ 10255993Sbostic #define COMPILE2 3 /* Print error, count and finish script */ 103