8 #define _STANDALONE_H 1
15 #define PG_DIAG_SQLSTATE 0
16 #define PGRES_COMMAND_OK 1
17 #define PGRES_NONFATAL_ERROR 2
28 #define LOG_NOTICE(...) { \
29 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \
30 fprintf(stdout, __VA_ARGS__); \
31 fprintf(stdout, "\n"); \
33 #define LOG_FATAL(...) { \
34 fprintf(stdout, "FATAL %s.%d: ", __FILE__, __LINE__); \
35 fprintf(stdout, __VA_ARGS__); \
36 fprintf(stdout, "\n"); \
38 #define LOG_ERROR(...) { \
39 fprintf(stdout, "ERROR %s.%d: ", __FILE__, __LINE__); \
40 fprintf(stdout, __VA_ARGS__); \
41 fprintf(stdout, "\n"); \
43 #define LOG_WARNING(...) { \
44 fprintf(stdout, "WARNING %s.%d: ", __FILE__, __LINE__); \
45 fprintf(stdout, __VA_ARGS__); \
46 fprintf(stdout, "\n"); \
49 #define LOG_DEBUG(...) { \
50 fprintf(stdout, "DEBUG %s.%d: ", __FILE__, __LINE__); \
51 fprintf(stdout, __VA_ARGS__); \
52 fprintf(stdout, "\n"); \
62 extern char*
fo_sysconfig(
const char* sectionname,
const char* variablename);
63 extern int fo_GetAgentKey (PGconn *
pgConn,
const char *agent_name,
long unused,
const char *cpunused,
const char *agent_desc);
65 const char *tableName,
const char *ars_status,
int ars_success);
75 extern int PQresultStatus(
const PGresult *res);
76 extern char* PQresultErrorMessage(
const PGresult *res);
77 extern char* PQresultErrorField(
const PGresult *res,
int fieldcode);
78 extern int PQntuples(
const PGresult *res);
79 extern PGresult *PQexec(PGconn *conn,
const char *query);
80 extern void PQclear(PGresult *res);
81 extern char* PQgetvalue(
const PGresult *res,
int tup_num,
int field_num);
82 extern size_t PQescapeStringConn(PGconn *conn,
83 char *to,
const char *from,
size_t length,
85 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.
FUNCTION int fo_CreateARSTable(PGconn *pgConn, const char *tableName)
Create ars table if it doesn't already exist.
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.
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.
int fo_RepExist2(char *Type, char *Filename)
Determine if a file exists.
int fo_RepImport(char *Source, char *Type, char *Filename, int Link)
Import a file into the repository.
int fo_RepExist(char *Type, char *Filename)
Determine if a file exists.
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_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.
PGconn * db_conn
The connection to Database.