FOSSology  4.4.0
Open Source License Compliance by Open Source Software
match.h
1 /*
2  Author: Daniele Fognini, Andreas Wuerl
3  SPDX-FileCopyrightText: © 2013-2014 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 #ifndef MONK_AGENT_MATCH_H
9 #define MONK_AGENT_MATCH_H
10 
11 #include <glib.h>
12 
13 #include "monk.h"
14 #include "string_operations.h"
15 #include "diff.h"
16 
17 #define MATCH_TYPE_FULL 0
18 #define MATCH_TYPE_DIFF 1
19 
20 typedef struct {
21  const License* license;
22  union {
23  DiffPoint* full;
24  DiffResult* diff;
25  } ptr;
26  int type;
27 } Match;
28 
29 typedef struct {
30  int (*onAll)(MonkState* state, const File* file, const GArray* matches);
31  int (*onNo)(MonkState* state, const File* file);
32  int (*onFull)(MonkState* state, const File* file, const License* license, const DiffMatchInfo* matchInfo);
33  int (*onDiff)(MonkState* state, const File* file, const License* license, const DiffResult* diffResult);
34  int (*onBeginOutput)(MonkState* state);
35  int (*onBetweenIndividualOutputs)(MonkState* state);
36  int (*onEndOutput)(MonkState* state);
37  int (*ignore)(MonkState* state, const File* file);
39 
40 void match_array_free(GArray* matches);
41 #define match_array_index(matches, i) (g_array_index(matches, Match*, i))
42 
43 void match_free(Match* match);
44 
45 #if GLIB_CHECK_VERSION(2,32,0)
46 void match_destroyNotify(gpointer matchP);
47 #endif
48 
49 size_t match_getStart(const Match* match);
50 size_t match_getEnd(const Match* match);
51 
52 GArray* findAllMatchesBetween(const File* file, const Licenses* licenses, unsigned maxAllowedDiff, unsigned minAdjacentMatches, unsigned maxLeadingDiff);
53 
54 int matchPFileWithLicenses(MonkState* state, long pFileId, const Licenses* licenses, const MatchCallbacks* callbacks, char* delimiters);
55 int matchFileWithLicenses(MonkState* state, const File* file, const Licenses* licenses, const MatchCallbacks* callbacks);
56 
57 void findDiffMatches(const File* file, const License* license,
58  size_t textStartPosition, size_t searchStartPosition,
59  GArray* matches,
60  unsigned maxAllowedDiff, unsigned minAdjacentMatches);
61 
62 GArray* filterNonOverlappingMatches(GArray* matches);
63 int match_partialComparator(const Match* thisMatch, const Match* otherMatch);
64 
65 int processMatches(MonkState* state, const File* file, const GArray* matches, const MatchCallbacks* callbacks);
66 
67 char* formatMatchArray(GArray* matchInfo);
68 
69 #endif // MONK_AGENT_MATCH_H
void matchPFileWithLicenses(CopyrightState const &state, int agentId, unsigned long pFileId, CopyrightDatabaseHandler &databaseHandler)
Get the file contents, scan for statements and save findings to database.
void matchFileWithLicenses(const string &sContent, unsigned long pFileId, CopyrightState const &state, int agentId, CopyrightDatabaseHandler &databaseHandler)
Scan a given file with all available scanners and save findings to database.
Definition: diff.h:14
Definition: monk.h:61
Definition: monk.h:55
Definition: monk.h:67
Definition: match.h:20
Definition: monk.h:44
Definition: nomos.h:426
Store the results of a regex match.
Definition: scanners.hpp:28