1 /* 2 * Copyright (c) 1999-2000 David Parsons. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in 11 * the documentation and/or other materials provided with the 12 * distribution. 13 * 3. My name may not be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 20 * PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef __RULE_D 30 #define __RULE_D 31 32 #include <stdio.h> 33 #include <sys/types.h> 34 #include <regex.h> 35 36 enum rule_action { CAT, /* copy stdin -> stdout */ 37 PIPE, /* stdin -> filter -> more */ 38 FPIPE, /* stdin -> spool, spool -> filter -> more */ 39 FILTER, /* stdin -> filter -> stdout */ 40 /* or stdin -> filter ->${FIFO} 41 ${FIFO} -> stdout */ 42 FFILTER, /* stdin -> spool, spool -> filter -> stdout */ 43 TEXT, /* copy stdin -> stdout, \n -> \r\n */ 44 POSTSCRIPT, /* TEXT + "^D" */ 45 REJECT }; /* go away */ 46 47 struct rule { 48 char *pattern; /* pattern to match to do this action */ 49 regex_t regex; /* compiled */ 50 char *hint; /* the format of the resulting stream */ 51 struct rule *hinted; /* a pointer to the rule for that stream */ 52 enum rule_action action; /* what we want to do (see above) */ 53 char **argv; /* arguments to the action */ 54 int argc; /* # of arguments */ 55 struct rule *next; /* next rule in the chain */ 56 } ; 57 58 extern struct rule *get_line(FILE *); 59 extern struct rule *rules; 60 char * action_p(enum rule_action); 61 62 #endif/*__RULE_D*/ 63