rpm  5.4.14
Macros | Typedefs | Enumerations | Functions | Variables
rpmgrep.c File Reference
#include "system.h"
#include <rpmio_internal.h>
#include <rpmdir.h>
#include <poptIO.h>
#include "debug.h"
Include dependency graph for rpmgrep.c:

Go to the source code of this file.

Macros

#define _MIRE_INTERNAL
 
#define FALSE   ((BOOL)0)
 
#define TRUE   ((BOOL)1)
 
#define MAX_PATTERN_COUNT   100
 
#define MBUFTHIRD   8192
 
#define _GFB(n)   ((1U << (n)) | 0x40000000)
 
#define GF_ISSET(_FLAG)   ((grepFlags & ((GREP_FLAGS_##_FLAG) & ~0x40000000)) != GREP_FLAGS_NONE)
 

Typedefs

typedef unsigned BOOL
 

Enumerations

enum  dee_e { dee_READ =1, dee_SKIP, dee_RECURSE }
 Actions for the -d option. More...
 
enum  DEE_e { DEE_READ =1, DEE_SKIP }
 Actions for the -D option. More...
 
enum  FN_e {
  FN_NONE, FN_DEFAULT, FN_ONLY, FN_NOMATCH_ONLY,
  FN_FORCE
}
 Values for the "filenames" variable, which specifies options for file name output. More...
 
enum  grepFlags_e {
  GREP_FLAGS_NONE = 0, GREP_FLAGS_WORD_MATCH = ((1U << ( 0 )) | 0x40000000), GREP_FLAGS_LINE_MATCH = ((1U << ( 1 )) | 0x40000000), GREP_FLAGS_FIXED_STRINGS = ((1U << ( 2 )) | 0x40000000),
  GREP_FLAGS_COUNT = ((1U << ( 3 )) | 0x40000000), GREP_FLAGS_COLOR = ((1U << ( 4 )) | 0x40000000), GREP_FLAGS_FOFFSETS = ((1U << ( 5 )) | 0x40000000), GREP_FLAGS_LOFFSETS = ((1U << ( 6 )) | 0x40000000),
  GREP_FLAGS_LNUMBER = ((1U << ( 7 )) | 0x40000000), GREP_FLAGS_MULTILINE = ((1U << ( 8 )) | 0x40000000), GREP_FLAGS_ONLY_MATCHING = ((1U << ( 9 )) | 0x40000000), GREP_FLAGS_INVERT = ((1U << ( 10 )) | 0x40000000),
  GREP_FLAGS_QUIET = ((1U << ( 11 )) | 0x40000000), GREP_FLAGS_SILENT = ((1U << ( 12 )) | 0x40000000), GREP_FLAGS_UTF8 = ((1U << ( 13 )) | 0x40000000), GREP_FLAGS_CASELESS = ((1U << ( 14 )) | 0x40000000)
}
 

Functions

static void fwrite_check (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 
 if (both_context > 0)
 
 if (((((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)||((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE))&&((grepFlags &((GREP_FLAGS_ONLY_MATCHING)&~0x40000000))!=GREP_FLAGS_NONE))||(((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)&&((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)))
 
 if (((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)||((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE))
 
 if (npatterns==0 &&pattern_filenames==NULL)
 
 for (j=0;j< npatterns;j++)
 
 if (mireLoadPatterns(grepMode, 0, exclude_patterns, NULL,&excludeMire,&nexcludes))
 
 if (mireLoadPatterns(grepMode, 0, include_patterns, NULL,&includeMire,&nincludes))
 
 if (i >=ac)
 
 if (_rpmsw_stats)
 

Variables

static const char * newline = NULL
 
static const char * color_string = NULL
 
static ARGV_t pattern_filenames = NULL
 
static const char * stdin_name = NULL
 
static const char * locale = NULL
 
static ARGV_t patterns = NULL
 
static miRE pattern_list = NULL
 
static int pattern_count = 0
 
static ARGV_t exclude_patterns = NULL
 
static miRE excludeMire = NULL
 
static int nexcludes = 0
 
static ARGV_t include_patterns = NULL
 
static miRE includeMire = NULL
 
static int nincludes = 0
 
static int after_context = 0
 
static int before_context = 0
 
static int both_context = 0
 
static enum dee_e dee_action = dee_READ
 
static enum DEE_e DEE_action = DEE_READ
 
static int error_count = 0
 
static enum FN_e filenames = FN_DEFAULT
 
static enum grepFlags_e grepFlags = GREP_FLAGS_NONE
 
static rpmMireMode grepMode = RPMMIRE_REGEX
 
static struct rpmop_s grep_totalops
 
static struct rpmop_s grep_readops
 
static const char * prefix []
 Tables for prefixing and suffixing patterns, according to the -w, -x, and -F options. More...
 
static const char * suffix []
 
static const unsigned utf8_table3 []
 UTF-8 tables - used only when the newline setting is "any". More...
 
static const char utf8_table4 []
 
static const char * int
 
ARGV_t av = NULL
 
int ac = 0
 
int i = 0
 
int rc = 1
 
int j
 
int xx = rpmswEnter(&grep_totalops, -1)
 
 __progname = "pcregrep"
 
 npatterns = argvCount(patterns)
 
goto errxit
 
 else { BOOL only_one_at_top = (i == ac -1)
 
exit __pad0__
 
 optCon = rpmioFini(optCon)
 
errxit __pad1__
 
goto exit
 

Macro Definition Documentation

#define _GFB (   n)    ((1U << (n)) | 0x40000000)

Definition at line 136 of file rpmgrep.c.

#define _MIRE_INTERNAL

Definition at line 42 of file rpmgrep.c.

#define FALSE   ((BOOL)0)

Definition at line 52 of file rpmgrep.c.

#define GF_ISSET (   _FLAG)    ((grepFlags & ((GREP_FLAGS_##_FLAG) & ~0x40000000)) != GREP_FLAGS_NONE)

Definition at line 137 of file rpmgrep.c.

#define MAX_PATTERN_COUNT   100

Definition at line 55 of file rpmgrep.c.

#define MBUFTHIRD   8192

Definition at line 60 of file rpmgrep.c.

#define TRUE   ((BOOL)1)

Definition at line 53 of file rpmgrep.c.

Referenced by rpmperlRun().

Typedef Documentation

typedef unsigned BOOL

Definition at line 51 of file rpmgrep.c.

Enumeration Type Documentation

enum dee_e

Actions for the -d option.

Enumerator
dee_READ 
dee_SKIP 
dee_RECURSE 

Definition at line 115 of file rpmgrep.c.

enum DEE_e

Actions for the -D option.

Enumerator
DEE_READ 
DEE_SKIP 

Definition at line 120 of file rpmgrep.c.

enum FN_e

Values for the "filenames" variable, which specifies options for file name output.

The order is important; it is assumed that a file name is wanted for all values greater than FN_DEFAULT.

Enumerator
FN_NONE 
FN_DEFAULT 
FN_ONLY 
FN_NOMATCH_ONLY 
FN_FORCE 

Definition at line 132 of file rpmgrep.c.

Enumerator
GREP_FLAGS_NONE 
GREP_FLAGS_WORD_MATCH 

-w,–word-regex ...

GREP_FLAGS_LINE_MATCH 

-x,–line-regex ...

GREP_FLAGS_FIXED_STRINGS 

-F,–fixed-strings ...

GREP_FLAGS_COUNT 

-c,–count ...

GREP_FLAGS_COLOR 

–color ...

GREP_FLAGS_FOFFSETS 

–file-offsets ...

GREP_FLAGS_LOFFSETS 

–line-offsets ...

GREP_FLAGS_LNUMBER 

-n,–line-number ...

GREP_FLAGS_MULTILINE 

-M,–multiline ...

GREP_FLAGS_ONLY_MATCHING 

-o,–only-matching ...

GREP_FLAGS_INVERT 

-v,–invert ...

GREP_FLAGS_QUIET 

-q,–quiet ...

GREP_FLAGS_SILENT 

-s,–no-messages ...

GREP_FLAGS_UTF8 

-u,–utf8 ...

GREP_FLAGS_CASELESS 

-i,–ignore-case ...

Definition at line 139 of file rpmgrep.c.

Function Documentation

for ( )

Definition at line 1518 of file rpmgrep.c.

References errxit, and patterns.

static void fwrite_check ( const void ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)
inlinestatic

Definition at line 63 of file rpmgrep.c.

if ( both_context  ,
 
)

Definition at line 1451 of file rpmgrep.c.

References after_context, before_context, and both_context.

if ( ((((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)||((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE))&&((grepFlags &((GREP_FLAGS_ONLY_MATCHING)&~0x40000000))!=GREP_FLAGS_NONE))||(((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)&&((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE))  )

Definition at line 1460 of file rpmgrep.c.

References _, __progname, errxit, and fprintf().

if ( ((grepFlags &((GREP_FLAGS_FOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)||((grepFlags &((GREP_FLAGS_LOFFSETS)&~0x40000000))!=GREP_FLAGS_NONE)  )

Definition at line 1470 of file rpmgrep.c.

if ( npatterns  = = 0 && pattern_filenames == NULL)

Definition at line 1503 of file rpmgrep.c.

References errxit, and patterns.

Definition at line 1537 of file rpmgrep.c.

References _, __progname, errxit, excludeMire, fprintf(), and nexcludes.

Definition at line 1549 of file rpmgrep.c.

References _, __progname, errxit, fprintf(), includeMire, and nincludes.

if ( i >=  ac)

Definition at line 1562 of file rpmgrep.c.

if ( _rpmsw_stats  )

Definition at line 1603 of file rpmgrep.c.

References grep_readops, grep_totalops, and rpmswPrint().

Variable Documentation

exit __pad0__

Definition at line 1585 of file rpmgrep.c.

errxit __pad1__

Definition at line 1613 of file rpmgrep.c.

__progname = "pcregrep"

Definition at line 1440 of file rpmgrep.c.

ac = 0
int after_context = 0
static

Definition at line 108 of file rpmgrep.c.

Referenced by if().

av = NULL

Definition at line 1430 of file rpmgrep.c.

int before_context = 0
static

Definition at line 110 of file rpmgrep.c.

Referenced by if().

int both_context = 0
static

Definition at line 112 of file rpmgrep.c.

Referenced by if().

color_string = NULL
static

Definition at line 77 of file rpmgrep.c.

enum dee_e dee_action = dee_READ
static

Definition at line 117 of file rpmgrep.c.

enum DEE_e DEE_action = DEE_READ
static

Definition at line 122 of file rpmgrep.c.

else { BOOL only_one_at_top = (i == ac -1)

Definition at line 1572 of file rpmgrep.c.

int error_count = 0
static

Definition at line 125 of file rpmgrep.c.

goto errxit
exclude_patterns = NULL
static

Definition at line 94 of file rpmgrep.c.

excludeMire = NULL
static

Definition at line 96 of file rpmgrep.c.

Referenced by if().

goto exit

Definition at line 1614 of file rpmgrep.c.

enum FN_e filenames = FN_DEFAULT
static

Definition at line 134 of file rpmgrep.c.

struct rpmop_s grep_readops
static

Definition at line 174 of file rpmgrep.c.

Referenced by if().

struct rpmop_s grep_totalops
static

Definition at line 172 of file rpmgrep.c.

Referenced by if().

enum grepFlags_e grepFlags = GREP_FLAGS_NONE
static

Definition at line 162 of file rpmgrep.c.

rpmMireMode grepMode = RPMMIRE_REGEX
static

Definition at line 168 of file rpmgrep.c.

int i = 0

Definition at line 1432 of file rpmgrep.c.

include_patterns = NULL
static

Definition at line 101 of file rpmgrep.c.

includeMire = NULL
static

Definition at line 103 of file rpmgrep.c.

Referenced by if().

const char* int
Initial value:
{
poptContext rpmioInit(int argc, char *const argv[], struct poptOption *optionsTable)
Definition: poptIO.c:752
static struct poptOption optionsTable[]
Definition: rpmqv.c:148
argv
Definition: rpmmtree.c:3679
optCon
Definition: poptALL.c:604
poptContext
Definition: poptALL.c:525

Definition at line 1428 of file rpmgrep.c.

int j

Definition at line 1434 of file rpmgrep.c.

locale = NULL
static

Definition at line 84 of file rpmgrep.c.

newline = NULL
static

Definition at line 74 of file rpmgrep.c.

int nexcludes = 0
static

Definition at line 98 of file rpmgrep.c.

Referenced by if().

int nincludes = 0
static

Definition at line 105 of file rpmgrep.c.

Referenced by if().

npatterns = argvCount(patterns)

Definition at line 1516 of file rpmgrep.c.

optCon = rpmioFini(optCon)

Definition at line 1608 of file rpmgrep.c.

exit pattern_count = 0
static

Definition at line 91 of file rpmgrep.c.

pattern_filenames = NULL
static

Definition at line 79 of file rpmgrep.c.

pattern_list = NULL
static

Definition at line 89 of file rpmgrep.c.

patterns = NULL
static

Definition at line 87 of file rpmgrep.c.

Referenced by cacheWalkPathFilter(), for(), freeGlobs(), if(), and initGlobs().

const char* prefix[]
static
Initial value:
= {
"", "\\b", "^(?:", "^(?:", "\\Q", "\\b\\Q", "^(?:\\Q", "^(?:\\Q"
}

Tables for prefixing and suffixing patterns, according to the -w, -x, and -F options.

These set the 1, 2, and 4 bits in grepFlags, respectively. Note that the combination of -w and -x has the same effect as -x on its own, so we can treat them as the same.

Definition at line 183 of file rpmgrep.c.

Referenced by rpmbcSetRSA(), and showQueryPackage().

return rc = 1

Definition at line 1433 of file rpmgrep.c.

stdin_name = NULL
static

Definition at line 81 of file rpmgrep.c.

const char* suffix[]
static
Initial value:
= {
"", "\\b", ")$", ")$", "\\E", "\\E\\b", "\\E)$", "\\E)$"
}

Definition at line 188 of file rpmgrep.c.

const unsigned utf8_table3[]
static
Initial value:
= {
0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01
}

UTF-8 tables - used only when the newline setting is "any".

Definition at line 194 of file rpmgrep.c.

const char utf8_table4[]
static
Initial value:
= {
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
}

Definition at line 200 of file rpmgrep.c.

Definition at line 1435 of file rpmgrep.c.