FOSSology  4.4.0
Open Source License Compliance by Open Source Software
inits.c File Reference

Bucket agent initialization and lookup functions. More...

#include "buckets.h"
Include dependency graph for inits.c:

Go to the source code of this file.

Functions

FUNCTION int getBucketpool_pk (PGconn *pgConn, char *bucketpool_name)
 Get a bucketpool_pk based on the bucketpool_name. More...
 
FUNCTION pbucketdef_t initBuckets (PGconn *pgConn, int bucketpool_pk, cacheroot_t *pcroot)
 Initialize the bucket definition list. If an error occured, write the error to stdout. More...
 
FUNCTION int * getMatchOnly (PGconn *pgConn, int bucketpool_pk, char *filename, cacheroot_t *pcroot)
 Read the match only file (bucket type 2) More...
 
FUNCTION int ** getMatchEvery (PGconn *pgConn, int bucketpool_pk, char *filename, cacheroot_t *pcroot)
 Read the match every file filename, for bucket type 1. More...
 
FUNCTION regex_file_tgetRegexFile (PGconn *pgConn, int bucketpool_pk, char *filename, cacheroot_t *pcroot)
 Parse filename, for bucket type 5 REGEX-FILE Lines are in format: More...
 
FUNCTION int getRegexFiletype (char *token, char *filepath)
 Given a filetype token from REGEX-FILE return the token int representation. More...
 
FUNCTION int * getLicsInStr (PGconn *pgConn, char *nameStr, cacheroot_t *pcroot)
 Given a string with | separated license names return an integer array of rf_pk's. More...
 
FUNCTION int LatestNomosAgent (PGconn *pgConn, int upload_pk)
 Get the latest nomos agent_pk that has data for this this uploadtree. More...
 
FUNCTION int childParent (PGconn *pgConn, int uploadtree_pk)
 Given an uploadtree_pk of a container, find the uploadtree_pk of it's children (i.e. scan down through artifacts to get the children's parent. More...
 

Variables

int debug
 

Detailed Description

Bucket agent initialization and lookup functions.

Definition in file inits.c.

Function Documentation

◆ childParent()

FUNCTION int childParent ( PGconn *  pgConn,
int  uploadtree_pk 
)

Given an uploadtree_pk of a container, find the uploadtree_pk of it's children (i.e. scan down through artifacts to get the children's parent.

Parameters
pgConnDatabase connection object
uploadtree_pkUpload tree id for container
Returns
uploadtree_pk of children's parent.
Or 0 if there are no children (empty container or non-container)
Note
This function writes error to stdout

Definition at line 639 of file inits.c.

◆ getBucketpool_pk()

FUNCTION int getBucketpool_pk ( PGconn *  pgConn,
char *  bucketpool_name 
)

Get a bucketpool_pk based on the bucketpool_name.

Parameters
pgConnDatabase connection object
bucketpool_nameBucket pool name
Returns
active bucketpool_pk or 0 if error

Definition at line 23 of file inits.c.

◆ getLicsInStr()

FUNCTION int* getLicsInStr ( PGconn *  pgConn,
char *  nameStr,
cacheroot_t pcroot 
)

Given a string with | separated license names return an integer array of rf_pk's.

Parameters
pgConnDatabase connection object
nameStrString of lic names eg "bsd | gpl"
pcrootLicense cache
Returns
an array of rf_pk's that match the names in nameStr
Note
If nameStr contains a license name that is not in the license_ref file, then 0 is returned since there is no way to match all the listed licenses.

Definition at line 529 of file inits.c.

◆ getMatchEvery()

FUNCTION int** getMatchEvery ( PGconn *  pgConn,
int  bucketpool_pk,
char *  filename,
cacheroot_t pcroot 
)

Read the match every file filename, for bucket type 1.

Parameters
pgConnDatabase connection object
bucketpool_pkBucket pool id
filenameFile name to match against
pcrootLicense cache
Returns
an array of arrays of rf_pk's that define a match_every combination or 0 if error.

Definition at line 269 of file inits.c.

◆ getMatchOnly()

FUNCTION int* getMatchOnly ( PGconn *  pgConn,
int  bucketpool_pk,
char *  filename,
cacheroot_t pcroot 
)

Read the match only file (bucket type 2)

Parameters
pgConnDatabase connection object
bucketpool_pkBucket pool id
filenameFile name of match_only file
pcrootLook up cache root
Returns
an array of rf_pk's that match the licenses in filename or 0 if error.

Definition at line 185 of file inits.c.

◆ getRegexFile()

FUNCTION regex_file_t* getRegexFile ( PGconn *  pgConn,
int  bucketpool_pk,
char *  filename,
cacheroot_t pcroot 
)

Parse filename, for bucket type 5 REGEX-FILE Lines are in format:

{regex1} {op} {ftype2} {regex2}

ftype is either "license" or "filename"
op is either "and" (1) or "or" (2) or "not" (3)
The op clause is optional.
For example:

license bsd.*clause \n
license (GPL_?v3|Affero_v3) and filename .*mypkg
Definition: nomos.h:426
Parameters
pgConnDatabase connection object
bucketpool_pkBucket pool id
filenameFilename to be parsed
pcrootLicense cache
Returns
an array of arrays of regex_file_t's that represent the rows in filename.
or 0 if error.

Definition at line 360 of file inits.c.

◆ getRegexFiletype()

FUNCTION int getRegexFiletype ( char *  token,
char *  filepath 
)

Given a filetype token from REGEX-FILE return the token int representation.

Parameters
tokenToken to convert
filepathPath of REGEX-FILE data file. used for error reporting only.
Returns
1=filename, 2=license

Definition at line 504 of file inits.c.

◆ initBuckets()

FUNCTION pbucketdef_t initBuckets ( PGconn *  pgConn,
int  bucketpool_pk,
cacheroot_t pcroot 
)

Initialize the bucket definition list. If an error occured, write the error to stdout.

Parameters
pgConnDatabase connection object
bucketpool_pkBucket pool id
pcrootLicense cache root
Returns
an array of bucket definitions (in eval order) or 0 if error.

Definition at line 52 of file inits.c.

◆ LatestNomosAgent()

FUNCTION int LatestNomosAgent ( PGconn *  pgConn,
int  upload_pk 
)

Get the latest nomos agent_pk that has data for this this uploadtree.

Parameters
pgConnDatabase connection object
upload_pkUpload id
Returns
nomos_agent_pk of the latest version of the nomos agent that has data for this upload.
Or 0 if there is no license data available
Note
This function writes error to stdout

Definition at line 603 of file inits.c.

Variable Documentation

◆ debug

int debug
extern

Print debug messages

Definition at line 57 of file buckets.c.