FOSSology  4.4.0
Open Source License Compliance by Open Source Software
liccache.h
1 /*
2  SPDX-FileCopyrightText: © 2010 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #ifndef _LICCACHE_H
8 #define _LICCACHE_H 1
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <strings.h>
14 #include <ctype.h>
15 #include <regex.h>
16 #include <libgen.h>
17 #include <getopt.h>
18 #include <errno.h>
19 #include <signal.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 
23 #define FUNCTION
24 
29 struct cachenode
30 {
31  char *rf_shortname;
32  long rf_pk;
33 };
34 typedef struct cachenode cachenode_t;
35 
40 struct cacheroot
41 {
42  int maxnodes;
44 };
45 typedef struct cacheroot cacheroot_t;
46 
47 /* liccache.c */
48 long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname);
49 void lrcache_print(cacheroot_t *pcroot);
50 void lrcache_free(cacheroot_t *pcroot);
51 int lrcache_add(cacheroot_t *pcroot, long rf_pk, char *rf_shortname);
52 long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname);
53 int lrcache_init(PGconn *pgConn, cacheroot_t *pcroot);
54 long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname);
55 long add2license_ref(PGconn *pgConn, char *licenseName);
56 
57 #endif /* _LICCACHE_H */
PGconn * pgConn
Database connection.
Definition: adj2nest.c:86
FUNCTION void lrcache_print(cacheroot_t *pcroot)
Print the contents of the hash table.
Definition: liccache.c:46
FUNCTION void lrcache_free(cacheroot_t *pcroot)
Free the hash table.
Definition: liccache.c:72
FUNCTION long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname)
Lookup rf_pk in the license_ref cache rf_shortname is the key.
Definition: liccache.c:135
FUNCTION long add2license_ref(PGconn *pgConn, char *licenseName)
Definition: liccache.c:246
FUNCTION int lrcache_add(cacheroot_t *pcroot, long rf_pk, char *rf_shortname)
Add a rf_shortname, rf_pk to the license_ref cache rf_shortname is the key.
Definition: liccache.c:99
FUNCTION long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname)
Get the rf_pk for rf_shortname.
Definition: liccache.c:213
FUNCTION int lrcache_init(PGconn *pgConn, cacheroot_t *pcroot)
Build a cache the license ref db table.
Definition: liccache.c:174
FUNCTION long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname)
Calculate the hash of an rf_shortname rf_shortname is the key.
Definition: liccache.c:26
long rf_pk
License id from database.
Definition: liccache.h:32
char * rf_shortname
License shortname.
Definition: liccache.h:31
int maxnodes
No. of nodes in the list.
Definition: liccache.h:42
cachenode_t * nodes
Array of nodes.
Definition: liccache.h:43