35 int uploadtree_pk,
int skipProcessedCheck,
38 char *fcnName =
"walkTree";
40 PGresult *result, *origresult;
41 int numChildren, childIdx;
43 int bucketpool_pk = bucketDefArray->bucketpool_pk;
47 if (
debug) printf(
"---- START walkTree, uploadtree_pk=%d ----\n",uploadtree_pk);
50 sprintf(sqlbuf,
"select pfile_fk, lft, rgt, ufile_mode, ufile_name, upload_fk from %s where uploadtree_pk=%d",
51 bucketDefArray->uploadtree_tablename, uploadtree_pk);
52 origresult = PQexec(
pgConn, sqlbuf);
54 if (PQntuples(origresult) == 0)
56 printf(
"FATAL: %s.%s missing uploadtree_pk %d\n", __FILE__, fcnName, uploadtree_pk);
60 uploadtree.pfile_fk = atol(PQgetvalue(origresult, 0, 0));
61 uploadtree.lft = atol(PQgetvalue(origresult, 0, 1));
62 uploadtree.rgt = atol(PQgetvalue(origresult, 0, 2));
63 uploadtree.ufile_mode = atol(PQgetvalue(origresult, 0, 3));
64 uploadtree.ufile_name = strdup(PQgetvalue(origresult, 0, 4));
65 uploadtree.upload_fk = atol(PQgetvalue(origresult, 0, 5));
67 if (!skipProcessedCheck)
84 sprintf(sqlbuf,
"select uploadtree_pk,pfile_fk, lft, rgt, ufile_mode, ufile_name from %s where parent=%d",
85 bucketDefArray->uploadtree_tablename, uploadtree_pk);
86 result = PQexec(
pgConn, sqlbuf);
88 numChildren = PQntuples(result);
91 printf(
"FATAL: %s.%s: Inconsistent uploadtree. uploadtree_pk %d should have children based on lft and rgt\n",
92 __FILE__, fcnName, uploadtree_pk);
97 for (childIdx = 0; childIdx < numChildren; childIdx++)
99 childuploadtree.
uploadtree_pk = atol(PQgetvalue(result, childIdx, 0));
100 childuploadtree.
pfile_fk = atol(PQgetvalue(result, childIdx, 1));
103 childuploadtree.
lft = atoi(PQgetvalue(result, childIdx, 2));
104 childuploadtree.
rgt = atoi(PQgetvalue(result, childIdx, 3));
105 childuploadtree.
ufile_mode = atoi(PQgetvalue(result, childIdx, 4));
106 childuploadtree.
ufile_name = strdup(PQgetvalue(result, childIdx, 5));
111 if (childuploadtree.
rgt == (childuploadtree.
lft+1))
173 char *fcnName =
"processFile";
182 && (puploadtree->
rgt == puploadtree->
lft+1))
return 0;
199 snprintf(sql,
sizeof(sql),
200 "select pkg_name, version, '' as vendor, source as srcpkg from pkg_deb where pfile_fk='%d' \
202 select pkg_name, version, vendor, source_rpm as srcpkg from pkg_rpm where pfile_fk='%d' ",
204 result = PQexec(
pgConn, sql);
206 isPkg = PQntuples(result);
214 strncpy(package.
pkgname, PQgetvalue(result, 0, 0),
sizeof(package.
pkgname)-1);
219 strncpy(package.
pkgvers, PQgetvalue(result, 0, 1),
sizeof(package.
pkgvers)-1);
224 strncpy(package.
vendor, PQgetvalue(result, 0, 2),
sizeof(package.
vendor)-1);
250 if (bucketList) free(bucketList);
PGconn * pgConn
Database connection.
FUNCTION int * getContainerBuckets(PGconn *pgConn, pbucketdef_t bucketDefArray, int uploadtree_pk)
Given a container uploadtree_pk and bucketdef, determine what buckets the container is in.
FUNCTION int processLeaf(PGconn *pgConn, pbucketdef_t bucketDefArray, puploadtree_t puploadtree, ppackage_t ppackage, int agent_pk, int hasPrules)
Determine which bucket(s) a leaf node is in and write results.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
Contains information required by uploadtree elements.
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...
FUNCTION int walkTree(PGconn *pgConn, pbucketdef_t bucketDefArray, int agent_pk, int uploadtree_pk, int skipProcessedCheck, int hasPrules)
This function does a recursive depth first walk through a file tree (uploadtree).
FUNCTION int processFile(PGconn *pgConn, pbucketdef_t bucketDefArray, puploadtree_t puploadtree, int agent_pk, int hasPrules)
Process a file.
FUNCTION int writeBuckets(PGconn *pgConn, int pfile_pk, int uploadtree_pk, int *bucketList, int agent_pk, int nomosagent_pk, int bucketpool_pk)
Write bucket results to either db (bucket_file, bucket_container) or stdout.