FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
liccache.h
1 /***************************************************************
2  Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License
6  version 2 as published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 ***************************************************************/
18 #ifndef _LICCACHE_H
19 #define _LICCACHE_H 1
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <strings.h>
25 #include <ctype.h>
26 #include <regex.h>
27 #include <libgen.h>
28 #include <getopt.h>
29 #include <errno.h>
30 #include <signal.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 
34 #define FUNCTION
35 
40 struct cachenode
41 {
42  char *rf_shortname;
43  long rf_pk;
44 };
45 typedef struct cachenode cachenode_t;
46 
51 struct cacheroot
52 {
53  int maxnodes;
55 };
56 typedef struct cacheroot cacheroot_t;
57 
58 /* liccache.c */
59 long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname);
60 void lrcache_print(cacheroot_t *pcroot);
61 void lrcache_free(cacheroot_t *pcroot);
62 int lrcache_add(cacheroot_t *pcroot, long rf_pk, char *rf_shortname);
63 long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname);
64 int lrcache_init(PGconn *pgConn, cacheroot_t *pcroot);
65 long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname);
66 long add2license_ref(PGconn *pgConn, char *licenseName);
67 
68 #endif /* _LICCACHE_H */
FUNCTION long add2license_ref(PGconn *pgConn, char *licenseName)
Definition: liccache.c:257
int maxnodes
No. of nodes in the list.
Definition: liccache.h:53
cachenode_t * nodes
Array of nodes.
Definition: liccache.h:54
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:146
PGconn * pgConn
Database connection.
Definition: adj2nest.c:98
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:110
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:37
FUNCTION void lrcache_free(cacheroot_t *pcroot)
Free the hash table.
Definition: liccache.c:83
FUNCTION long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname)
Get the rf_pk for rf_shortname.
Definition: liccache.c:224
FUNCTION void lrcache_print(cacheroot_t *pcroot)
Print the contents of the hash table.
Definition: liccache.c:57
FUNCTION int lrcache_init(PGconn *pgConn, cacheroot_t *pcroot)
Build a cache the license ref db table.
Definition: liccache.c:185
char * rf_shortname
License shortname.
Definition: liccache.h:42
long rf_pk
License id from database.
Definition: liccache.h:43