43   len = (strlen(rf_shortname) < 
sizeof(long)) ? strlen(rf_shortname) : 
sizeof(long);
    44   for (i=0; i<len;i++) hashval += rf_shortname[i] << 8*i;
    45   hashval = hashval % pcroot->
maxnodes;
    63   pcnode = pcroot->
nodes;
    66     if (pcnode->
rf_pk != 0L)
    88   pcnode = pcroot->
nodes;
    91     if (pcnode->
rf_pk != 0L)
   122     noden = (hashval +i) & (pcroot->
maxnodes -1);
   124     pcnode = pcroot->
nodes + noden;
   128       pcnode->
rf_pk = rf_pk;
   132   if (i < pcroot->maxnodes) 
return 0;
   158     noden = (hashval +i) & (pcroot->
maxnodes -1);
   160     pcnode = pcroot->
nodes + noden;
   161     if (!pcnode->
rf_pk) 
return 0;
   164       return pcnode->
rf_pk;
   192     if (!pcroot) 
return 0;
   194     snprintf(query, 
sizeof(query),
   195             "SELECT rf_pk, rf_shortname FROM license_ref where rf_detector_type=2;");
   196     result = PQexec(pgConn, query);
   197     if (
fo_checkPQresult(pgConn, result, query, 
"lrcache_init", __LINE__)) 
return 0;
   199     numLics = PQntuples(result);
   201     for (row = 0; row < numLics; row++)
   203       lrcache_add(pcroot, atol(PQgetvalue(result, row, 0)), PQgetvalue(result, row, 1));
   229   if ((len = strlen(rf_shortname)) == 0)
   231     printf(
"ERROR! %s.%d get_rfpk() passed empty name", __FILE__, __LINE__);
   237   if (rf_pk) 
return rf_pk;
   262     char  escLicName[256];
   263     char *specialLicenseText;
   271     len = strlen(licenseName);
   272     PQescapeStringConn(pgConn, escLicName, licenseName, len, &error);
   274       printf(
"WARNING: %s(%d): Does license name have multibyte encoding?", __FILE__, __LINE__);
   277     sprintf(query, 
"SELECT rf_pk FROM license_ref where rf_shortname='%s' and rf_detector_type=2", escLicName);
   278     result = PQexec(pgConn, query);
   279     if (
fo_checkPQresult(pgConn, result, query, 
"add2license_ref", __LINE__)) 
return 0;
   280     numRows = PQntuples(result);
   283       rf_pk = atol(PQgetvalue(result, 0, 0));
   288     specialLicenseText = 
"License by Nomos.";
   291             "insert into license_ref(rf_shortname, rf_text, rf_detector_type) values('%s', '%s', 2)",
   292             escLicName, specialLicenseText);
   293     result = PQexec(pgConn, insert);
   298     result = PQexec(pgConn, query);
   299     if (
fo_checkPQresult(pgConn, result, query, 
"add2license_ref", __LINE__)) 
return 0;
   300     numRows = PQntuples(result);
   302       rf_pk = atol(PQgetvalue(result, 0, 0));
   305       printf(
"ERROR: %s:%s:%d Just inserted value is missing. On: %s", __FILE__, 
"add2license_ref()", __LINE__, query);
 int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT. 
 
FUNCTION long add2license_ref(PGconn *pgConn, char *licenseName)
 
int maxnodes
No. of nodes in the list. 
 
cachenode_t * nodes
Array of nodes. 
 
FUNCTION long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname)
Lookup rf_pk in the license_ref cache rf_shortname is the key. 
 
PGconn * pgConn
Database connection. 
 
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. 
 
FUNCTION long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname)
Calculate the hash of an rf_shortname rf_shortname is the key. 
 
FUNCTION void lrcache_free(cacheroot_t *pcroot)
Free the hash table. 
 
FUNCTION long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname)
Get the rf_pk for rf_shortname. 
 
FUNCTION void lrcache_print(cacheroot_t *pcroot)
Print the contents of the hash table. 
 
FUNCTION int lrcache_init(PGconn *pgConn, cacheroot_t *pcroot)
Build a cache the license ref db table. 
 
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
 
char * rf_shortname
License shortname. 
 
long rf_pk
License id from database.