[BACK]Return to grep.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / grep

Annotation of src/usr.bin/grep/grep.h, Revision 1.2

1.2     ! deraadt     1: /*     $OpenBSD$       */
        !             2:
1.1       deraadt     3: /*-
                      4:  * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     17:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     18:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     19:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     20:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     21:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     22:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     24:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     25:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     26:  * SUCH DAMAGE.
                     27:  */
                     28:
                     29: #include <sys/types.h>
                     30:
                     31: #include <regex.h>
                     32: #include <stdio.h>
                     33: #include <zlib.h>
                     34:
                     35: #define VER_MAJ 0
                     36: #define VER_MIN 9
                     37:
                     38: typedef struct {
                     39:        size_t           len;
                     40:        int              line_no;
                     41:        int              off;
                     42:        char            *file;
                     43:        char            *dat;
                     44: } str_t;
                     45:
                     46: /* Flags passed to regcomp() and regexec() */
                     47: extern int      cflags, eflags;
                     48:
                     49: /* Command line flags */
                     50: extern int      Aflag, Bflag, Hflag, Lflag, Pflag, Sflag, Rflag, Zflag,
                     51:                 aflag, bflag, cflag, hflag, lflag, nflag, qflag, sflag,
                     52:                 vflag, wflag, xflag;
                     53:
                     54: extern int      first, lead, matchall, patterns, tail;
                     55: extern char    **pattern;
                     56: extern regex_t *r_pattern;
                     57:
                     58: /* For regex errors  */
                     59: #define RE_ERROR_BUF 512
                     60: extern char     re_error[RE_ERROR_BUF + 1];    /* Seems big enough */
                     61:
                     62: /* util.c */
                     63: int             procfile(char *fn);
                     64: int             grep_tree(char **argv);
                     65: void           *grep_malloc(size_t size);
                     66: void           *grep_realloc(void *ptr, size_t size);
                     67: void            printline(str_t *line, int sep);
                     68:
                     69: /* queue.c */
                     70: void            initqueue();
                     71: void            enqueue(str_t *x);
                     72: void            printqueue();
                     73: void            clearqueue();
                     74:
                     75: /* mmfile.c */
                     76: typedef struct mmfile {
                     77:        int      fd;
                     78:        size_t   len;
                     79:        char    *base, *end, *ptr;
                     80: } mmf_t;
                     81:
                     82: mmf_t          *mmopen(char *fn, char *mode);
                     83: void            mmclose(mmf_t *mmf);
                     84: char           *mmfgetln(mmf_t *mmf, size_t *l);
                     85: long            mmtell(mmf_t *mmf);
                     86: void            mmrewind(mmf_t *mmf);
                     87:
                     88: /* file.c */
                     89: struct file;
                     90: typedef struct file file_t;
                     91:
                     92: file_t         *grep_fdopen(int fd, char *mode);
                     93: file_t         *grep_open(char *path, char *mode);
                     94: int             grep_bin_file(file_t *f);
                     95: long            grep_tell(file_t *f);
                     96: char           *grep_fgetln(file_t *f, size_t *l);
                     97: void            grep_close(file_t *f);
                     98:
                     99: /* binary.c */
                    100: int             bin_file(FILE * f);
                    101: int             gzbin_file(gzFile * f);
                    102: int             mmbin_file(mmf_t *f);
                    103: