home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / SED.ZIP / SED.H < prev    next >
C/C++ Source or Header  |  1989-01-02  |  4KB  |  77 lines

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