rpm 5.3.12
|
#include "system.h"
#include <rpmio_internal.h>
#include <rpmdir.h>
#include <poptIO.h>
#include "debug.h"
Go to the source code of this file.
Defines | |
#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) |
static const char * | end_of_line (const char *p, const char *endptr, size_t *lenptr) |
static const char * | previous_line (const char *p, const char *startptr) |
static void | do_after_lines (int lastmatchnumber, const char *lastmatchrestart, const char *endptr, const char *printname) |
static int | pcregrep (FD_t fd, const char *printname) |
static int | chkSuffix (const char *fn, const char *suffix) |
Check file name for a suffix. | |
static int | grep_or_recurse (const char *pathname, BOOL dir_recurse, BOOL only_one_at_top) |
static BOOL | compile_single_pattern (const char *pattern, const char *filename, int count) |
static BOOL | compile_pattern (const char *pattern, const char *filename, int count) |
static int | mireLoadPatternFiles (ARGV_t files) |
Load patterns from files. | |
static void | grepArgCallback (poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, void *data) |
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. | |
static const char * | suffix [] |
static const unsigned | utf8_table3 [] |
UTF-8 tables - used only when the newline setting is "any". | |
static const char | utf8_table4 [] |
#define FALSE ((BOOL)0) |
Definition at line 52 of file rpmgrep.c.
Referenced by compile_pattern(), compile_single_pattern(), grep_or_recurse(), and pcregrep().
#define GF_ISSET | ( | _FLAG | ) | ((grepFlags & ((GREP_FLAGS_##_FLAG) & ~0x40000000)) != GREP_FLAGS_NONE) |
Definition at line 137 of file rpmgrep.c.
Referenced by compile_pattern(), do_after_lines(), end_of_line(), grep_or_recurse(), grepArgCallback(), pcregrep(), and previous_line().
#define MAX_PATTERN_COUNT 100 |
Definition at line 55 of file rpmgrep.c.
Referenced by compile_single_pattern().
#define MBUFTHIRD 8192 |
Definition at line 60 of file rpmgrep.c.
Referenced by compile_pattern(), compile_single_pattern(), mireLoadPatternFiles(), and pcregrep().
#define TRUE ((BOOL)1) |
Definition at line 53 of file rpmgrep.c.
Referenced by compile_single_pattern(), pcregrep(), and rpmperlRun().
enum dee_e |
enum DEE_e |
enum FN_e |
enum grepFlags_e |
static int chkSuffix | ( | const char * | fn, |
const char * | suffix | ||
) | [static] |
Check file name for a suffix.
fn | file name |
suffix | suffix |
Definition at line 909 of file rpmgrep.c.
Referenced by grep_or_recurse().
static BOOL compile_pattern | ( | const char * | pattern, |
const char * | filename, | ||
int | count | ||
) | [static] |
Definition at line 1128 of file rpmgrep.c.
References compile_single_pattern(), end_of_line(), FALSE, GF_ISSET, and MBUFTHIRD.
Referenced by mireLoadPatternFiles().
static BOOL compile_single_pattern | ( | const char * | pattern, |
const char * | filename, | ||
int | count | ||
) | [static] |
Definition at line 1072 of file rpmgrep.c.
References _, __progname, _mirePCREtables, FALSE, grepFlags, grepMode, MAX_PATTERN_COUNT, MBUFTHIRD, mireRegcomp(), mireSetCOptions(), pattern_count, pattern_list, prefix, suffix, and TRUE.
Referenced by compile_pattern().
static void do_after_lines | ( | int | lastmatchnumber, |
const char * | lastmatchrestart, | ||
const char * | endptr, | ||
const char * | printname | ||
) | [static] |
Definition at line 472 of file rpmgrep.c.
References after_context, rpmop_s::count, end_of_line(), fwrite_check(), and GF_ISSET.
Referenced by pcregrep().
static const char* end_of_line | ( | const char * | p, |
const char * | endptr, | ||
size_t * | lenptr | ||
) | [static] |
Definition at line 222 of file rpmgrep.c.
References _mireEL, EL_ANY, EL_ANYCRLF, EL_CR, EL_CRLF, EL_LF, GF_ISSET, utf8_table3, and utf8_table4.
Referenced by compile_pattern(), do_after_lines(), and pcregrep().
static void fwrite_check | ( | const void * | ptr, |
size_t | size, | ||
size_t | nmemb, | ||
FILE * | stream | ||
) | [inline, static] |
Definition at line 63 of file rpmgrep.c.
Referenced by do_after_lines(), and pcregrep().
static int grep_or_recurse | ( | const char * | pathname, |
BOOL | dir_recurse, | ||
BOOL | only_one_at_top | ||
) | [static] |
Definition at line 931 of file rpmgrep.c.
References _, __progname, chkSuffix(), DEE_action, dee_action, dee_READ, dee_RECURSE, DEE_SKIP, dee_SKIP, dirent, errno, excludeMire, FALSE, Fclose(), fdDup(), fdstat_op(), FDSTAT_READ, Ferror(), filenames, FN_DEFAULT, Fopen(), Fstrerror(), GF_ISSET, grep_readops, includeMire, mireApply(), nexcludes, nincludes, pcregrep(), rpmswAdd(), snprintf(), and Stat().
static void grepArgCallback | ( | poptContext | con, |
enum poptCallbackReason | reason, | ||
const struct poptOption * | opt, | ||
const char * | arg, | ||
void * | data | ||
) | [static] |
Definition at line 1215 of file rpmgrep.c.
References _, __progname, _free(), color_string, DEE_action, dee_action, DEE_READ, dee_READ, dee_RECURSE, DEE_SKIP, dee_SKIP, getenv(), GF_ISSET, GREP_FLAGS_COLOR, grepFlags, VERSION, and xstrdup().
static int mireLoadPatternFiles | ( | ARGV_t | files | ) | [static] |
Load patterns from files.
files | array of file names |
Definition at line 1154 of file rpmgrep.c.
References _, __progname, compile_pattern(), Fclose(), fdGetFILE, fdstat_op(), FDSTAT_READ, Ferror(), Fopen(), Fstrerror(), grep_readops, MBUFTHIRD, rpmswAdd(), stdin_name, and xisspace().
static int pcregrep | ( | FD_t | fd, |
const char * | printname | ||
) | [static] |
Definition at line 509 of file rpmgrep.c.
References _, __progname, after_context, before_context, color_string, rpmop_s::count, do_after_lines(), end_of_line(), error_count, FALSE, filenames, FN_NOMATCH_ONLY, FN_ONLY, Fread(), fwrite_check(), GF_ISSET, MBUFTHIRD, mireRegexec(), mireSetEOptions(), pattern_count, pattern_list, previous_line(), and TRUE.
Referenced by grep_or_recurse().
static const char* previous_line | ( | const char * | p, |
const char * | startptr | ||
) | [static] |
Definition at line 372 of file rpmgrep.c.
References _mireEL, EL_ANY, EL_ANYCRLF, EL_CR, EL_CRLF, EL_LF, GF_ISSET, utf8_table3, and utf8_table4.
Referenced by pcregrep().
int after_context = 0 [static] |
Definition at line 108 of file rpmgrep.c.
Referenced by do_after_lines(), and pcregrep().
int before_context = 0 [static] |
Definition at line 110 of file rpmgrep.c.
Referenced by pcregrep().
int both_context = 0 [static] |
const char* color_string = NULL [static] |
Definition at line 77 of file rpmgrep.c.
Referenced by grepArgCallback(), and pcregrep().
enum dee_e dee_action = dee_READ [static] |
Definition at line 117 of file rpmgrep.c.
Referenced by grep_or_recurse(), and grepArgCallback().
enum DEE_e DEE_action = DEE_READ [static] |
Definition at line 122 of file rpmgrep.c.
Referenced by grep_or_recurse(), and grepArgCallback().
int error_count = 0 [static] |
Definition at line 125 of file rpmgrep.c.
Referenced by pcregrep().
ARGV_t exclude_patterns = NULL [static] |
miRE excludeMire = NULL [static] |
Definition at line 96 of file rpmgrep.c.
Referenced by grep_or_recurse().
Definition at line 134 of file rpmgrep.c.
Referenced by grep_or_recurse(), and pcregrep().
struct rpmop_s grep_readops [static] |
Definition at line 174 of file rpmgrep.c.
Referenced by grep_or_recurse(), and mireLoadPatternFiles().
struct rpmop_s grep_totalops [static] |
enum grepFlags_e grepFlags = GREP_FLAGS_NONE [static] |
Definition at line 162 of file rpmgrep.c.
Referenced by compile_single_pattern(), and grepArgCallback().
rpmMireMode grepMode = RPMMIRE_REGEX [static] |
Definition at line 168 of file rpmgrep.c.
Referenced by compile_single_pattern().
ARGV_t include_patterns = NULL [static] |
miRE includeMire = NULL [static] |
Definition at line 103 of file rpmgrep.c.
Referenced by grep_or_recurse().
int nexcludes = 0 [static] |
Definition at line 98 of file rpmgrep.c.
Referenced by grep_or_recurse().
int nincludes = 0 [static] |
Definition at line 105 of file rpmgrep.c.
Referenced by grep_or_recurse().
int pattern_count = 0 [static] |
Definition at line 91 of file rpmgrep.c.
Referenced by compile_single_pattern(), and pcregrep().
ARGV_t pattern_filenames = NULL [static] |
miRE pattern_list = NULL [static] |
Definition at line 89 of file rpmgrep.c.
Referenced by compile_single_pattern(), and pcregrep().
Definition at line 87 of file rpmgrep.c.
Referenced by cacheWalkPathFilter(), freeGlobs(), and initGlobs().
const char* prefix[] [static] |
{ "", "\\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 compile_single_pattern(), rpmbcSetRSA(), and showQueryPackage().
const char* stdin_name = NULL [static] |
Definition at line 81 of file rpmgrep.c.
Referenced by mireLoadPatternFiles().
const char* suffix[] [static] |
{ "", "\\b", ")$", ")$", "\\E", "\\E\\b", "\\E)$", "\\E)$" }
Definition at line 188 of file rpmgrep.c.
Referenced by compile_single_pattern().
const unsigned utf8_table3[] [static] |
{ 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.
Referenced by end_of_line(), and previous_line().
const char utf8_table4[] [static] |
{ 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.
Referenced by end_of_line(), and previous_line().