2 #define _STANDALONE_H 1 23 #define PG_DIAG_SQLSTATE 0 36 #define LOG_NOTICE(...) { \ 37 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \ 38 fprintf(stdout, __VA_ARGS__); \ 39 fprintf(stdout, "\n"); \ 41 #define LOG_FATAL(...) { \ 42 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \ 43 fprintf(stdout, __VA_ARGS__); \ 44 fprintf(stdout, "\n"); \ 46 #define LOG_ERROR(...) { \ 47 fprintf(stdout, "ERROR %s.%d: ", __FILE__, __LINE__); \ 48 fprintf(stdout, __VA_ARGS__); \ 49 fprintf(stdout, "\n"); \ 51 #define LOG_WARNING(...) { \ 52 fprintf(stdout, "WARNING %s.%d: ", __FILE__, __LINE__); \ 53 fprintf(stdout, __VA_ARGS__); \ 54 fprintf(stdout, "\n"); \ 65 extern char*
fo_sysconfig(
const char* sectionname,
const char* variablename);
66 extern int fo_GetAgentKey (PGconn *
pgConn,
const char *agent_name,
long unused,
const char *cpunused,
const char *agent_desc);
68 const char *tableName,
const char *ars_status,
int ars_success);
80 #define fo_dbManager_PrepareStamement(dbManager, name, query, ...) \ 81 fo_dbManager_PrepareStamement_str(dbManager, \ 98 extern int PQresultStatus(
const PGresult *res);
99 extern char *PQresultErrorMessage(
const PGresult *res);
100 extern char *PQresultErrorField(
const PGresult *res,
int fieldcode);
101 extern int PQntuples(
const PGresult *res);
102 extern PGresult *PQexec(PGconn *conn,
const char *query);
103 extern void PQclear(PGresult *res);
104 extern char *PQgetvalue(
const PGresult *res,
int tup_num,
int field_num);
105 extern size_t PQescapeStringConn(PGconn *conn,
106 char *to,
const char *from,
size_t length,
108 extern void PQfinish(PGconn *conn);
char * DBConfFile
DB conf file location.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
fo_dbManager_PreparedStatement * fo_dbManager_PrepareStamement_str(fo_dbManager *dbManager, const char *name, const char *query, const char *paramtypes)
Create a prepared statement.
PGconn * pgConn
Database connection.
PGresult * fo_dbManager_ExecPrepared(fo_dbManager_PreparedStatement *preparedStatement,...)
Execute a prepared statement.
char * fo_scheduler_current()
Get the last read string from the scheduler.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
void fo_scheduler_set_special(int option, int value)
Sets something special about the agent within the scheduler.
fo_dbManager * fo_dbManager_new(PGconn *dbConnection)
Create and initialize new fo_dbManager object.
int fo_scheduler_get_special(int option)
Gets if a particular special attribute is set in the scheduler.
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...
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
char * fo_RepMkPath(const char *Type, char *Filename)
Given a filename, construct the full path to the file.
fo_dbManager * dbManager
fo_dbManager object
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
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.
PGconn * db_conn
The connection to Database.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
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.
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_dbManager_free(fo_dbManager *dbManager)
Un-allocate the memory from a DB manager.
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
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...
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.
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.