00001 /* sed.h -- types and constants for the stream editor 00002 Copyright (C) 1995-2003 Eric S. Raymond 00003 Copyright (C) 2004-2005 Rene Rebe 00004 */ 00005 00006 #define TRUE 1 00007 #define FALSE 0 00008 00009 /* data area sizes used by both modules */ 00010 #define MAXBUF 4000 /* current line buffer size */ 00011 #define MAXAPPENDS 20 /* maximum number of appends */ 00012 #define MAXTAGS 9 /* tagged patterns are \1 to \9 */ 00013 #define MAXCMDS 200 /* maximum number of compiled commands */ 00014 #define MAXLINES 256 /* max # numeric addresses to compile */ 00015 00016 /* constants for compiled-command representation */ 00017 #define EQCMD 0x01 /* = -- print current line number */ 00018 #define ACMD 0x02 /* a -- append text after current line */ 00019 #define BCMD 0x03 /* b -- branch to label */ 00020 #define CCMD 0x04 /* c -- change current line */ 00021 #define DCMD 0x05 /* d -- delete all of pattern space */ 00022 #define CDCMD 0x06 /* D -- delete first line of pattern space */ 00023 #define GCMD 0x07 /* g -- copy hold space to pattern space */ 00024 #define CGCMD 0x08 /* G -- append hold space to pattern space */ 00025 #define HCMD 0x09 /* h -- copy pattern space to hold space */ 00026 #define CHCMD 0x0A /* H -- append hold space to pattern space */ 00027 #define ICMD 0x0B /* i -- insert text before current line */ 00028 #define LCMD 0x0C /* l -- print pattern space in escaped form */ 00029 #define CLCMD 0x20 /* L -- hexdump */ 00030 #define NCMD 0x0D /* n -- get next line into pattern space */ 00031 #define CNCMD 0x0E /* N -- append next line to pattern space */ 00032 #define PCMD 0x0F /* p -- print pattern space to output */ 00033 #define CPCMD 0x10 /* P -- print first line of pattern space */ 00034 #define QCMD 0x11 /* q -- exit the stream editor */ 00035 #define RCMD 0x12 /* r -- read in a file after current line */ 00036 #define SCMD 0x13 /* s -- regular-expression substitute */ 00037 #define TCMD 0x14 /* t -- branch on last substitute successful */ 00038 #define CTCMD 0x15 /* T -- branch on last substitute failed */ 00039 #define WCMD 0x16 /* w -- write pattern space to file */ 00040 #define CWCMD 0x17 /* W -- write first line of pattern space */ 00041 #define XCMD 0x18 /* x -- exhange pattern and hold spaces */ 00042 #define YCMD 0x19 /* y -- transliterate text */ 00043 00044 typedef struct cmd_t /* compiled-command representation */ 00045 { 00046 char *addr1; /* first address for command */ 00047 char *addr2; /* second address for command */ 00048 union 00049 { 00050 char *lhs; /* s command lhs */ 00051 struct cmd_t *link; /* label link */ 00052 } u; 00053 char command; /* command code */ 00054 char *rhs; /* s command replacement string */ 00055 FILE *fout; /* associated output file descriptor */ 00056 struct 00057 { 00058 unsigned allbut : 1; /* was negation specified? */ 00059 unsigned global : 1; /* was p postfix specified? */ 00060 unsigned print : 2; /* was g postfix specified? */ 00061 unsigned inrange : 1; /* in an address range? */ 00062 } flags; 00063 unsigned nth; /* sed nth occurance */ 00064 } 00065 sedcmd; /* use this name for declarations */ 00066 00067 #define BAD ((char *) -1) /* guaranteed not a string ptr */ 00068 00069 /* address and regular expression compiled-form markers */ 00070 #define STAR 1 /* marker for Kleene star */ 00071 #define CCHR 2 /* non-newline character to be matched follows */ 00072 #define CDOT 4 /* dot wild-card marker */ 00073 #define CCL 6 /* character class follows */ 00074 #define CNL 8 /* match line start */ 00075 #define CDOL 10 /* match line end */ 00076 #define CBRA 12 /* tagged pattern start marker */ 00077 #define CKET 14 /* tagged pattern end marker */ 00078 #define CBACK 16 /* backslash-digit pair marker */ 00079 #define CLNUM 18 /* numeric-address index follows */ 00080 #define CEND 20 /* symbol for end-of-source */ 00081 #define CEOF 22 /* end-of-field mark */ 00082 00083 #define bits(b) (1 << (b)) 00084 00085 /* sed.h ends here */
1.5.8