-
Notifications
You must be signed in to change notification settings - Fork 0
/
nomos_utils.h
82 lines (70 loc) · 3.03 KB
/
nomos_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************
Copyright (C) 2006-2014 Hewlett-Packard Development Company, L.P.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
***************************************************************/
#ifndef NOMOS_UTILS_H_
#define NOMOS_UTILS_H_
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif /* not defined _GNU_SOURCE */
#include "util.h"
#include "list.h"
#include "licenses.h"
#include "process.h"
#include "nomos.h"
#include "nomos_regex.h"
#include "_autodefs.h"
#define PG_ERRCODE_UNIQUE_VIOLATION "23505"
#define FOSSY_EXIT( XY , XZ) printf(" %s %s,%d", XY , __FILE__, __LINE__); Bail( XZ );
#define LICENSE_REF_TABLE "ONLY license_ref"
/** shortname cache very simple nonresizing hash table */
struct cachenode
{
char *rf_shortname; ///< License shortname
long rf_pk; ///< License id from database
};
typedef struct cachenode cachenode_t;
/** Root for chachenode_t nodes */
struct cacheroot
{
int maxnodes; ///< No. of nodes in the list
cachenode_t *nodes; ///< Array of nodes
};
typedef struct cacheroot cacheroot_t;
void freeAndClearScan(struct curScan *thisScan);
char *getFieldValue(char *inStr, char *field, int fieldMax, char *value, int valueMax, char separator);
void parseLicenseList();
void Usage(char *Name);
void Bail(int exitval);
int optionIsSet(int val);
void getFileLists(char *dirpath);
void processFile(char *fileToScan);
int recordScanToDB(cacheroot_t *pcroot, struct curScan *scanRecord);
long get_rfpk(cacheroot_t *pcroot, char *rf_shortname);
char convertIndexToHighlightType(int index);
long add2license_ref(char *licenseName);
long updateLicenseFile(long rfPk);
int updateLicenseHighlighting(cacheroot_t *pcroot);
int initLicRefCache(cacheroot_t *pcroot);
long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname);
int lrcache_add(cacheroot_t *pcroot, long rf_pk, char *rf_shortname);
long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname);
void lrcache_free(cacheroot_t *pcroot);
void initializeCurScan(struct curScan* cur);
void addLicence(GArray* theMatches, char* licenceName );
void cleanLicenceBuffer();
bool clearLastElementOfLicenceBuffer(); //returns true to be used in if-statements
void cleanLicenceAndMatchPositions( LicenceAndMatchPositions* in );
MatchPositionAndType* getMatchfromHighlightInfo(GArray* in, int index);
LicenceAndMatchPositions* getLicenceAndMatchPositions(GArray* in,int index);
void cleanTheMatches(GArray* in);
#endif /* NOMOS_UTILS_H_ */