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

Bucket agent validation, and usage functions. More...

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

Go to the source code of this file.

Functions

FUNCTION int arrayAinB (int *arrayA, int *arrayB)
 Verify that all the values in array A are also in B. More...
 
FUNCTION int intAinB (int intA, int *arrayB)
 Verify that all the value A is a member of array B. More...
 
FUNCTION int validate_pk (PGconn *pgConn, char *sql)
 Verify a primary key exists. More...
 
FUNCTION void Usage (char *Name)
 
FUNCTION int processed (PGconn *pgConn, int agent_pk, int nomos_agent_pk, int pfile_pk, int uploadtree_pk, int bucketpool_pk, int bucket_pk)
 Has this pfile or uploadtree_pk already been bucket processed? This only works if the bucket has been recorded in table bucket_file, or bucket_container. More...
 
FUNCTION int UploadProcessed (PGconn *pgConn, int bucketagent_pk, int nomosagent_pk, int pfile_pk, int uploadtree_pk, int upload_pk, int bucketpool_pk)
 Has this upload already been bucket processed? This function checks buckets_ars to see if the upload has been processed. More...
 

Variables

int debug
 

Detailed Description

Bucket agent validation, and usage functions.

Definition in file validate.c.

Function Documentation

◆ arrayAinB()

FUNCTION int arrayAinB ( int *  arrayA,
int *  arrayB 
)

Verify that all the values in array A are also in B.

Parameters
arrayAnull terminated array of ints
arrayBnull terminated array of ints
Returns
true (!0) if all the elements in A are also in B else return false (0)

Definition at line 24 of file validate.c.

◆ intAinB()

FUNCTION int intAinB ( int  intA,
int *  arrayB 
)

Verify that all the value A is a member of array B.

Parameters
intAint to match
arrayBnull terminated array of ints
Returns
true (!0) if intA is in B else return false (0)

Definition at line 54 of file validate.c.

◆ processed()

FUNCTION int processed ( PGconn *  pgConn,
int  agent_pk,
int  nomos_agent_pk,
int  pfile_pk,
int  uploadtree_pk,
int  bucketpool_pk,
int  bucket_pk 
)

Has this pfile or uploadtree_pk already been bucket processed? This only works if the bucket has been recorded in table bucket_file, or bucket_container.

Parameters
pgConnpostgresql connection
agent_pkbucket agent_pk
nomos_agent_pknomos agent_pk
pfile_pkpfile id which was processed
uploadtree_pkupload tree id
bucketpool_pkbucket pool id
bucket_pkmay be zero (to skip bucket_pk check)
Returns
1=yes, 0=no

Definition at line 139 of file validate.c.

◆ UploadProcessed()

FUNCTION int UploadProcessed ( PGconn *  pgConn,
int  bucketagent_pk,
int  nomosagent_pk,
int  pfile_pk,
int  uploadtree_pk,
int  upload_pk,
int  bucketpool_pk 
)

Has this upload already been bucket processed? This function checks buckets_ars to see if the upload has been processed.

Parameters
pgConnpostgresql connection
bucketagent_pkbucket agent ID
nomosagent_pknomos agent ID
pfile_pk
uploadtree_pk
bucketpool_pk
Returns
1=yes upload has been processed
0=upload has not been processed
Note
This could also cross check with the bucket_file and bucket_container recs but doesn't at this time. This is the reason for the unused function args.

Definition at line 204 of file validate.c.

◆ Usage()

FUNCTION void Usage ( char *  Name)

Print usage of bucket agent

Parameters
NameAbsolute path of agent

Definition at line 103 of file validate.c.

◆ validate_pk()

FUNCTION int validate_pk ( PGconn *  pgConn,
char *  sql 
)

Verify a primary key exists.

This works by running the sql (must be select) and returning the first column of the first row.
The sql should make this the primary key.
This could be used to simply return the first column of the first result for any query.

Parameters
pgConnDatabase connection object
sqlsql must select a single column, value in first row is returned.
Returns
primary key, or 0 if it doesn't exist
Note
This function writes error to stdout

Definition at line 84 of file validate.c.

Variable Documentation

◆ debug

int debug
extern

Print debug messages

Definition at line 57 of file buckets.c.