![]() |
FOSSology
3.2.0rc1
Open Source License Compliance by Open Source Software
|
search using regex functions More...
#include "nomos_regex.h"#include "nomos_gap.h"#include "nomos_utils.h"
Go to the source code of this file.
Macros | |
| #define | CALL_IF_DEBUG_MODE(x) |
| #define | _XC(q) ((char) xascii[q]) |
Functions | |
| void | regexError (int ret, regex_t *regc, char *regex) |
| Log an error caused by regex. More... | |
| int | endsIn (char *s, char *suffix) |
| Check if a string ends with given suffix. More... | |
| int | lineInFile (char *pathname, char *regex) |
| Check if a line exists in a file. More... | |
| int | textInFile (char *pathname, char *regex, int flags) |
| Check if a regex passes in a file. More... | |
| int | strGrep (char *regex, char *data, int flags) |
| General-purpose grep function, used for one-time-only searches. More... | |
| int | idxGrep (int index, char *data, int flags) |
| compile a regex, and perform the search (on data?) More... | |
| int | idxGrep_recordPosition (int index, char *data, int flags) |
| compile a regex, perform the search and record findings More... | |
| int | idxGrep_recordPositionDoctored (int index, char *data, int flags) |
| compile a regex, perform the search and record findings More... | |
| int | idxGrep_recordIndex (int index, char *data, int flags) |
| compile a regex, perform the search and record index More... | |
| int | matchOnce (int isPlain, char *data, char *regex, regex_t *rp, regmatch_t *regmatch) |
| Perform a regex match on a given data and return only first match. More... | |
| int | storeOneMatch (regmatch_t currentRegMatch, int lastmatch, GArray *allmatches, char **tmpData, char *data) |
| Store a single regex match to array. More... | |
| int | idxGrep_base (int index, char *data, int flags, int mode) |
| compile a regex, and perform the search (on data?) More... | |
| void | recordIndex (GArray *indexList, int index) |
| Add a given index to index list. More... | |
| static int | getOffset (int posInDoctoredBuffer) |
| Get offset from doctored buffer. More... | |
| regmatch_t * | getRegmatch_t (GArray *in, int index) |
| From a given array, get regex match from a given index. More... | |
| void | rememberWhatWeFound (GArray *highlight, GArray *regmatch_tArray, int index, int mode) |
| Store regex matches in highlight array. More... | |
| int | strNbuf (char *data, char *str) |
| Check if a string exists in buffer (case insensitive) More... | |
| int | strNbuf_noGlobals (char *data, char *str, regmatch_t *matchPos, int doSave, char *saveData) |
| This is our own internal, case-insensitive version of strstr(). More... | |
Variables | |
| static char | regexErrbuf [myBUFSIZ] |
| regex_t | idx_regc [NFOOTPRINTS] |
search using regex functions
Functions for dealing with the regex clib functions. Performs the regex searchs on the data.
Definition in file nomos_regex.c.
| int endsIn | ( | char * | s, |
| char * | suffix | ||
| ) |
Check if a string ends with given suffix.
| s | String to check |
| suffix | Suffix to find |
Definition at line 67 of file nomos_regex.c.
|
static |
Get offset from doctored buffer.
| posInDoctoredBuffer |
Definition at line 473 of file nomos_regex.c.
| regmatch_t* getRegmatch_t | ( | GArray * | in, |
| int | index | ||
| ) |
From a given array, get regex match from a given index.
| in | Array to get regex match from |
| index | The index in array required |
Definition at line 484 of file nomos_regex.c.
| int idxGrep | ( | int | index, |
| char * | data, | ||
| int | flags | ||
| ) |
compile a regex, and perform the search (on data?)
| index | number of licence/regex we are looking for (given in STRINGS.in) |
| data | the data to search |
| flags | regcomp cflags |
Definition at line 216 of file nomos_regex.c.
| int idxGrep_base | ( | int | index, |
| char * | data, | ||
| int | flags, | ||
| int | mode | ||
| ) |
compile a regex, and perform the search (on data?)
| index | number of licence/regex we are looking for (given in STRINGS.in) |
| data | the data to search |
| flags | regcomp cflags |
| mode | Flag to control recording of findings (0:No, 1: Yes, 2:Yes doctored buffer) |
Now we have a match
All sanity checks have passed and we have at least one match
Definition at line 335 of file nomos_regex.c.
| int idxGrep_recordIndex | ( | int | index, |
| char * | data, | ||
| int | flags | ||
| ) |
compile a regex, perform the search and record index
If OPTS_NO_HIGHLIGHTINFO is set, do not record. If not set, record the finding index
| index | number of licence/regex we are looking for (given in STRINGS.in) |
| data | the data to search |
| flags | regcomp cflags |
Definition at line 274 of file nomos_regex.c.
| int idxGrep_recordPosition | ( | int | index, |
| char * | data, | ||
| int | flags | ||
| ) |
compile a regex, perform the search and record findings
If OPTS_NO_HIGHLIGHTINFO is set, do not record. If not set, record the findings
| index | number of licence/regex we are looking for (given in STRINGS.in) |
| data | the data to search |
| flags | regcomp cflags |
Definition at line 231 of file nomos_regex.c.
| int idxGrep_recordPositionDoctored | ( | int | index, |
| char * | data, | ||
| int | flags | ||
| ) |
compile a regex, perform the search and record findings
If OPTS_NO_HIGHLIGHTINFO is set, do not record. If not set, record the doctored findings
| index | number of licence/regex we are looking for (given in STRINGS.in) |
| data | the data to search |
| flags | regcomp cflags |
Definition at line 252 of file nomos_regex.c.
| int lineInFile | ( | char * | pathname, |
| char * | regex | ||
| ) |
Check if a line exists in a file.
| pathname | File location |
| regex | Regex to check |
Definition at line 92 of file nomos_regex.c.
| int matchOnce | ( | int | isPlain, |
| char * | data, | ||
| char * | regex, | ||
| regex_t * | rp, | ||
| regmatch_t * | regmatch | ||
| ) |
Perform a regex match on a given data and return only first match.
| isPlain | Do a plain match? | |
| data | The string to perform search on | |
| regex | The regex string | |
| rp | Regex buffer | |
| [out] | regmatch | Regex matches |
Definition at line 293 of file nomos_regex.c.
| void recordIndex | ( | GArray * | indexList, |
| int | index | ||
| ) |
Add a given index to index list.
| [in,out] | indexList | List to add index to |
| [in] | index | Index to be appended |
Definition at line 463 of file nomos_regex.c.
| void regexError | ( | int | ret, |
| regex_t * | regc, | ||
| char * | regex | ||
| ) |
Log an error caused by regex.
Calls regerror()
| ret | Error code |
| regc | Compiled regex |
| regex | Regex string |
Definition at line 49 of file nomos_regex.c.
| void rememberWhatWeFound | ( | GArray * | highlight, |
| GArray * | regmatch_tArray, | ||
| int | index, | ||
| int | mode | ||
| ) |
Store regex matches in highlight array.
| [in,out] | highlight | The array holding the regex matches |
| [in] | regmatch_tArray | Array of regex matches to store |
| [in] | index | Index of license (from STRINGS.in) |
| [in] | mode | Mode to store (1=>get the byte position|2=>get the offset) |
Definition at line 496 of file nomos_regex.c.
| int storeOneMatch | ( | regmatch_t | currentRegMatch, |
| int | lastmatch, | ||
| GArray * | allmatches, | ||
| char ** | tmpData, | ||
| char * | data | ||
| ) |
Store a single regex match to array.
| [in] | currentRegMatch | Match to store |
| [in] | lastmatch | Index of last match |
| [in,out] | allmatches | Array of all matches |
| [in,out] | tmpData | |
| [in] | data |
Definition at line 312 of file nomos_regex.c.
| int strGrep | ( | char * | regex, |
| char * | data, | ||
| int | flags | ||
| ) |
General-purpose grep function, used for one-time-only searches.
Definition at line 150 of file nomos_regex.c.
| int strNbuf | ( | char * | data, |
| char * | str | ||
| ) |
Check if a string exists in buffer (case insensitive)
| data | Haystack |
| str | Needle |
Definition at line 539 of file nomos_regex.c.
| int strNbuf_noGlobals | ( | char * | data, |
| char * | str, | ||
| regmatch_t * | matchPos, | ||
| int | doSave, | ||
| char * | saveData | ||
| ) |
This is our own internal, case-insensitive version of strstr().
No open-source code was consulted/used in the construction of this function.
Definition at line 549 of file nomos_regex.c.
| int textInFile | ( | char * | pathname, |
| char * | regex, | ||
| int | flags | ||
| ) |
Check if a regex passes in a file.
| pathname | File location |
| regex | Regex to check |
| flags | Additional regex flags |
Definition at line 111 of file nomos_regex.c.
|
static |
Buffer to hold regex error
Definition at line 37 of file nomos_regex.c.