hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

grep.h (4103B)


      1 /*
      2  * grep - search a file for a pattern
      3  *
      4  * Gunnar Ritter, Freiburg i. Br., Germany, April 2001.
      5  */
      6 /*
      7  * Copyright (c) 2003 Gunnar Ritter
      8  *
      9  * This software is provided 'as-is', without any express or implied
     10  * warranty. In no event will the authors be held liable for any damages
     11  * arising from the use of this software.
     12  *
     13  * Permission is granted to anyone to use this software for any purpose,
     14  * including commercial applications, and to alter it and redistribute
     15  * it freely, subject to the following restrictions:
     16  *
     17  * 1. The origin of this software must not be misrepresented; you must not
     18  *    claim that you wrote the original software. If you use this software
     19  *    in a product, an acknowledgment in the product documentation would be
     20  *    appreciated but is not required.
     21  *
     22  * 2. Altered source versions must be plainly marked as such, and must not be
     23  *    misrepresented as being the original software.
     24  *
     25  * 3. This notice may not be removed or altered from any source distribution.
     26  */
     27 
     28 /*	Sccsid @(#)grep.h	1.23 (gritter) 1/4/05>	*/
     29 
     30 #include	<sys/types.h>
     31 #include	<regex.h>
     32 
     33 #include	"iblok.h"
     34 
     35 #include	"config.h"
     36 
     37 #define	BSZ		512		/* block size */
     38 
     39 /*
     40  * Expression flags.
     41  */
     42 enum eflags {
     43 	E_NONE	= 0,		/* no flags set */
     44 	E_NL	= 1,		/* pattern ends with newline */
     45 	E_NULL	= 2		/* no pattern, not even an empty one */
     46 };
     47 
     48 /*
     49  * List of search expressions; not used for compile() matching.
     50  */
     51 struct expr {
     52 	struct expr	*e_nxt;		/* next item in list */
     53 	char		*e_pat;		/* search pattern */
     54 	regex_t		*e_exp;		/* compiled pattern from regcomp() */
     55 	long		e_len;		/* pattern length */
     56 	enum eflags	e_flg;		/* expression flags */
     57 };
     58 
     59 /*
     60  * Matcher flags.
     61  */
     62 enum	matchflags {
     63 	MF_NULTERM	= 01,	/* search string must be \0 terminated*/
     64 	MF_LOCONV	= 02	/* lower-case search string if -i is set */
     65 };
     66 
     67 /*
     68  * Variables in grep.c.
     69  */
     70 extern int		Eflag;		/* use EREs */
     71 extern int		Fflag;		/* use fixed strings */
     72 extern int		bflag;		/* print buffer count */
     73 extern int		cflag;		/* print count only */
     74 extern int		fflag;		/* had pattern file argument */
     75 extern int		hflag;		/* do not print filenames */
     76 extern int		iflag;		/* ignore case */
     77 extern int		lflag;		/* print filenames only */
     78 extern int		nflag;		/* print line numbers */
     79 extern int		qflag;		/* no output at all */
     80 extern int		sflag;		/* avoid error messages */
     81 extern int		vflag;		/* inverse selection */
     82 extern int		wflag;		/* search for words */
     83 extern int		xflag;		/* match entire line */
     84 extern int		mb_cur_max;	/* MB_CUR_MAX */
     85 #define	mbcode		(mb_cur_max>1)	/* multibyte characters in use */
     86 extern unsigned		status;		/* exit status */
     87 extern off_t		lmatch;		/* count of matching lines */
     88 extern off_t		lineno;		/* current line number */
     89 extern char		*progname;	/* argv[0] to main() */
     90 extern char		*filename;	/* name of current file */
     91 extern void		(*build)(void);	/* compile function */
     92 extern int		(*match)(const char *, size_t); /* comparison */
     93 extern int		(*range)(struct iblok *, char *); /* grep range */
     94 extern struct expr	*e0;		/* start of expression list */
     95 extern enum matchflags	matchflags;	/* matcher flags */
     96 
     97 /*
     98  * These differ amongst grep flavors.
     99  */
    100 extern int		sus;		/* POSIX.2 command version in use */
    101 extern char		*stdinmsg;	/* name for standard input */
    102 extern char		*usagemsg;	/* usage string */
    103 extern char		*options;	/* for getopt() */
    104 
    105 /*
    106  * In grep.c.
    107  */
    108 extern size_t		loconv(char *, char *, size_t);
    109 extern void		wcomp(char **, long *);
    110 extern void		report(const char *, size_t, off_t, int);
    111 
    112 /*
    113  * Flavor dependent.
    114  */
    115 extern void		usage(void);
    116 extern void		misop(void);
    117 extern void		rc_error(struct expr *, int);
    118 extern void		init(void);
    119 
    120 /*
    121  * Traditional egrep only.
    122  */
    123 extern void		eg_select(void);
    124 
    125 /*
    126  * Fgrep only.
    127  */
    128 extern void		ac_select(void);
    129 
    130 /*
    131  * compile()/step()-related.
    132  */
    133 extern void		st_select(void);
    134 
    135 /*
    136  * regcomp()/regexec()-related.
    137  */
    138 extern void		rc_select(void);
    139 
    140 /*
    141  * Not for SVID3 grep.
    142  */
    143 extern void		patstring(char *);
    144 extern void		patfile(char *);
    145 extern int		nextch(void);
    146 extern void		outline(struct iblok *, char *, size_t);