1 /* sed.h -- types and constants for the stream editor 2 Copyright (C) 1995-2003 Eric S. Raymond 3 Copyright (C) 2004-2005 Rene Rebe 4 */ 5 6 #define TRUE 1 7 #define FALSE 0 8 9 /* data area sizes used by both modules */ 10 #define MAXBUF 4000 /* current line buffer size */ 11 #define MAXAPPENDS 20 /* maximum number of appends */ 12 #define MAXTAGS 9 /* tagged patterns are \1 to \9 */ 13 #define MAXCMDS 200 /* maximum number of compiled commands */ 14 #define MAXLINES 256 /* max # numeric addresses to compile */ 15 16 /* constants for compiled-command representation */ 17 #define EQCMD 0x01 /* = -- print current line number */ 18 #define ACMD 0x02 /* a -- append text after current line */ 19 #define BCMD 0x03 /* b -- branch to label */ 20 #define CCMD 0x04 /* c -- change current line */ 21 #define DCMD 0x05 /* d -- delete all of pattern space */ 22 #define CDCMD 0x06 /* D -- delete first line of pattern space */ 23 #define GCMD 0x07 /* g -- copy hold space to pattern space */ 24 #define CGCMD 0x08 /* G -- append hold space to pattern space */ 25 #define HCMD 0x09 /* h -- copy pattern space to hold space */ 26 #define CHCMD 0x0A /* H -- append hold space to pattern space */ 27 #define ICMD 0x0B /* i -- insert text before current line */ 28 #define LCMD 0x0C /* l -- print pattern space in escaped form */ 29 #define CLCMD 0x20 /* L -- hexdump */ 30 #define NCMD 0x0D /* n -- get next line into pattern space */ 31 #define CNCMD 0x0E /* N -- append next line to pattern space */ 32 #define PCMD 0x0F /* p -- print pattern space to output */ 33 #define CPCMD 0x10 /* P -- print first line of pattern space */ 34 #define QCMD 0x11 /* q -- exit the stream editor */ 35 #define RCMD 0x12 /* r -- read in a file after current line */ 36 #define SCMD 0x13 /* s -- regular-expression substitute */ 37 #define TCMD 0x14 /* t -- branch on last substitute successful */ 38 #define CTCMD 0x15 /* T -- branch on last substitute failed */ 39 #define WCMD 0x16 /* w -- write pattern space to file */ 40 #define CWCMD 0x17 /* W -- write first line of pattern space */ 41 #define XCMD 0x18 /* x -- exhange pattern and hold spaces */ 42 #define YCMD 0x19 /* y -- transliterate text */ 43 44 typedef struct cmd_t /* compiled-command representation */ 45 { 46 char *addr1; /* first address for command */ 47 char *addr2; /* second address for command */ 48 union 49 { 50 char *lhs; /* s command lhs */ 51 struct cmd_t *link; /* label link */ 52 } u; 53 char command; /* command code */ 54 char *rhs; /* s command replacement string */ 55 FILE *fout; /* associated output file descriptor */ 56 struct 57 { 58 unsigned allbut : 1; /* was negation specified? */ 59 unsigned global : 1; /* was p postfix specified? */ 60 unsigned print : 2; /* was g postfix specified? */ 61 unsigned inrange : 1; /* in an address range? */ 62 } flags; 63 unsigned nth; /* sed nth occurance */ 64 } 65 sedcmd; /* use this name for declarations */ 66 67 #define BAD ((char *) -1) /* guaranteed not a string ptr */ 68 69 /* address and regular expression compiled-form markers */ 70 #define STAR 1 /* marker for Kleene star */ 71 #define CCHR 2 /* non-newline character to be matched follows */ 72 #define CDOT 4 /* dot wild-card marker */ 73 #define CCL 6 /* character class follows */ 74 #define CNL 8 /* match line start */ 75 #define CDOL 10 /* match line end */ 76 #define CBRA 12 /* tagged pattern start marker */ 77 #define CKET 14 /* tagged pattern end marker */ 78 #define CBACK 16 /* backslash-digit pair marker */ 79 #define CLNUM 18 /* numeric-address index follows */ 80 #define CEND 20 /* symbol for end-of-source */ 81 #define CEOF 22 /* end-of-field mark */ 82 83 #define bits(b) (1 << (b)) 84 85 /* sed.h ends here */ 86