8 #define _STANDALONE_H 1
15 PGRES_EMPTY_QUERY = 0,
29 #define PG_DIAG_SQLSTATE 0
42 #define LOG_NOTICE(...) { \
43 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \
44 fprintf(stdout, __VA_ARGS__); \
45 fprintf(stdout, "\n"); \
47 #define LOG_FATAL(...) { \
48 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \
49 fprintf(stdout, __VA_ARGS__); \
50 fprintf(stdout, "\n"); \
52 #define LOG_ERROR(...) { \
53 fprintf(stdout, "ERROR %s.%d: ", __FILE__, __LINE__); \
54 fprintf(stdout, __VA_ARGS__); \
55 fprintf(stdout, "\n"); \
57 #define LOG_WARNING(...) { \
58 fprintf(stdout, "WARNING %s.%d: ", __FILE__, __LINE__); \
59 fprintf(stdout, __VA_ARGS__); \
60 fprintf(stdout, "\n"); \
71 extern char*
fo_sysconfig(
const char* sectionname,
const char* variablename);
72 extern int fo_GetAgentKey (PGconn *
pgConn,
const char *agent_name,
long unused,
const char *cpunused,
const char *agent_desc);
74 const char *tableName,
const char *ars_status,
int ars_success);
86 #define fo_dbManager_PrepareStamement(dbManager, name, query, ...) \
87 fo_dbManager_PrepareStamement_str(dbManager, \
104 extern int PQresultStatus(
const PGresult *res);
105 extern char *PQresultErrorMessage(
const PGresult *res);
106 extern char *PQresultErrorField(
const PGresult *res,
int fieldcode);
107 extern int PQntuples(
const PGresult *res);
108 extern PGresult *PQexec(PGconn *conn,
const char *query);
109 extern void PQclear(PGresult *res);
110 extern char *PQgetvalue(
const PGresult *res,
int tup_num,
int field_num);
111 extern size_t PQescapeStringConn(PGconn *conn,
112 char *to,
const char *from,
size_t length,
114 extern void PQfinish(PGconn *conn);
PGconn * pgConn
Database connection.
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
PGresult * checkDuplicateReq(PGconn *pgConn, int uploadPk, int agentPk)
Get the upload_pk and agent_pk to find out the agent has already scanned the package.
FUNCTION int fo_WriteARS(PGconn *pgConn, int ars_pk, int upload_pk, int agent_pk, const char *tableName, const char *ars_status, int ars_success)
Write ars record.
FUNCTION int fo_GetAgentKey(PGconn *pgConn, const char *agent_name, long Upload_pk, const char *rev, const char *agent_desc)
Get the latest enabled agent key (agent_pk) from the database.
PGresult * getSelectedPFiles(PGconn *pgConn, int uploadPk, int agentPk, bool ignoreFilesWithMimeType)
Get the upload_pk, agent_pk and ignoreFilesWithMimeType to get all the file Ids for nomos.
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
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 * fo_RepMkPath(const char *Type, char *Filename)
Given a filename, construct the full path to the file.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_heart(int i)
This function must be called by agents to let the scheduler know they are alive and how many items th...
void fo_scheduler_set_special(int option, int value)
Sets something special about the agent within the scheduler.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
int fo_scheduler_get_special(int option)
Gets if a particular special attribute is set in the scheduler.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
char * fo_scheduler_current()
Get the last read string from the scheduler.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
fo_dbManager * dbManager
fo_dbManager object
fo_dbManager_PreparedStatement * fo_dbManager_PrepareStamement_str(fo_dbManager *dbManager, const char *name, const char *query, const char *paramtypes)
Create a prepared statement.
PGresult * fo_dbManager_ExecPrepared(fo_dbManager_PreparedStatement *preparedStatement,...)
Execute a prepared statement.
fo_dbManager * fo_dbManager_new(PGconn *dbConnection)
Create and initialize new fo_dbManager object.
void fo_dbManager_free(fo_dbManager *dbManager)
Un-allocate the memory from a DB manager.
PGconn * db_conn
The connection to Database.
char * DBConfFile
DB conf file location.