FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Dummy implementations of library functions for stand-alone operations. More...
#include "standalone.h"
Go to the source code of this file.
Functions | |
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 they have processed. More... | |
void | fo_scheduler_connect (int *argc, char **argv, PGconn **db_conn) |
Establish a connection between an agent and the scheduler. More... | |
void | fo_scheduler_disconnect (int retcode) |
Disconnect the scheduler connection. More... | |
char * | fo_scheduler_next () |
Get the next data to process from the scheduler. More... | |
char * | fo_scheduler_current () |
Get the last read string from the scheduler. More... | |
int | fo_scheduler_userID () |
Gets the id of the user that created the job that the agent is running. More... | |
void | fo_scheduler_set_special (int option, int value) |
Sets something special about the agent within the scheduler. More... | |
int | fo_scheduler_get_special (int option) |
Gets if a particular special attribute is set in the scheduler. More... | |
char * | fo_sysconfig (const char *sectionname, const char *variablename) |
gets a system configuration variable from the configuration data. More... | |
int | fo_GetAgentKey (PGconn *pgConn, const char *agent_name, long unused, const char *cpunused, const char *agent_desc) |
Get the latest enabled agent key (agent_pk) from the database. More... | |
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. More... | |
PGconn * | fo_dbconnect (char *DBConfFile, char **ErrorBuf) |
Connect to a database. The default is Db.conf. More... | |
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 stdout. More... | |
int | fo_checkPQresult (PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb) |
Check the result status of a postgres SELECT. More... | |
int | fo_tableExists (PGconn *pgConn, const char *tableName) |
Check if table exists. Note, this assumes the database name is 'fossology'. More... | |
char * | fo_RepMkPath (char *Type, char *Filename) |
int | GetUploadPerm (PGconn *pgConn, long UploadPk, int user_pk) |
Get users permission to this upload. More... | |
fo_dbManager * | fo_dbManager_new (PGconn *dbConnection) |
Create and initialize new fo_dbManager object. More... | |
void | fo_dbManager_free (fo_dbManager *dbManager) |
Un-allocate the memory from a DB manager. More... | |
fo_dbManager_PreparedStatement * | fo_dbManager_PrepareStamement_str (fo_dbManager *dbManager, const char *name, const char *query, const char *paramtypes) |
Create a prepared statement. More... | |
PGresult * | fo_dbManager_ExecPrepared (fo_dbManager_PreparedStatement *preparedStatement,...) |
Execute a prepared statement. More... | |
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. More... | |
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. More... | |
int | PQresultStatus (const PGresult *res) |
char * | PQresultErrorMessage (const PGresult *res) |
char * | PQresultErrorField (const PGresult *res, int fieldcode) |
int | PQntuples (const PGresult *res) |
PGresult * | PQexec (PGconn *conn, const char *query) |
void | PQclear (PGresult *res) |
char * | PQgetvalue (const PGresult *res, int tup_num, int field_num) |
size_t | PQescapeStringConn (PGconn *conn, char *to, const char *from, size_t length, int *error) |
void | PQfinish (PGconn *conn) |
Variables | |
int | result = 0 |
Dummy implementations of library functions for stand-alone operations.
Definition in file standalone.c.
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.
pgConn | Database connection object pointer. |
upload_pk | Upload ID |
agent_pk | agentPk |
Definition at line 39 of file standalone.c.
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 stdout.
pgConn | Database connection object |
result | Postgres result object |
sql | the sql query |
FileID | is a file identifier string to write into the error message. Typically the caller will use FILE, but any identifier string is ok. |
LineNumb | the line number of the caller (LINE) |
Definition at line 27 of file standalone.c.
int fo_checkPQresult | ( | PGconn * | pgConn, |
PGresult * | result, | ||
char * | sql, | ||
char * | FileID, | ||
int | LineNumb | ||
) |
Check the result status of a postgres SELECT.
If an error occured, write the error to stdout
pgConn | Database connection object |
result | Postgres result object |
sql | the sql query |
FileID | is a file identifier string to write into the error message. Typically the caller will use FILE, but any identifier string is ok. |
LineNumb | the line number of the caller (LINE) |
Definition at line 28 of file standalone.c.
PGconn* fo_dbconnect | ( | char * | DBConfFile, |
char ** | ErrorBuf | ||
) |
Connect to a database. The default is Db.conf.
DBConfFile | File path of the Db.conf file to use. If NULL, use the default Db.conf |
ErrorBuf | Address of pointer to error buffer. fo_dbconnect will allocate this if needed. The caller should free it. |
Definition at line 26 of file standalone.c.
PGresult* fo_dbManager_ExecPrepared | ( | fo_dbManager_PreparedStatement * | preparedStatement, |
... | |||
) |
Execute a prepared statement.
preparedStatement | Prepared statement |
Definition at line 36 of file standalone.c.
void fo_dbManager_free | ( | fo_dbManager * | dbManager | ) |
Un-allocate the memory from a DB manager.
The function applies following actions on the manager before calling free
dbManager | The DB manager to be free-ed |
Definition at line 34 of file standalone.c.
fo_dbManager* fo_dbManager_new | ( | PGconn * | dbConnection | ) |
Create and initialize new fo_dbManager object.
dbConnection | DB connection object |
Definition at line 33 of file standalone.c.
fo_dbManager_PreparedStatement* fo_dbManager_PrepareStamement_str | ( | fo_dbManager * | dbManager, |
const char * | name, | ||
const char * | query, | ||
const char * | paramtypes | ||
) |
Create a prepared statement.
dbManager | DB manager to use |
name | Name of the prepared statement |
query | Query to be perpared |
paramtypes | CSV list of parameter types |
Definition at line 35 of file standalone.c.
int fo_GetAgentKey | ( | PGconn * | pgConn, |
const char * | agent_name, | ||
long | unused, | ||
const char * | cpunused, | ||
const char * | agent_desc | ||
) |
Get the latest enabled agent key (agent_pk) from the database.
pgConn | Database connection object pointer. |
agent_name | Name of agent to look up. |
Upload_pk | is no longer used. |
rev | Agent revision, if given this is the exact revision of the agent being requested. |
agent_desc | Description of the agent. Used to write a new agent record in the case where no enabled agent records exist for this agent_name. |
Definition at line 23 of file standalone.c.
void fo_scheduler_connect | ( | int * | argc, |
char ** | argv, | ||
PGconn ** | db_conn | ||
) |
Establish a connection between an agent and the scheduler.
Steps taken by this function:
Making a call to this function should be the first thing that an agent does after parsing its command line arguments.
If the database connection passed is NULL, then this will not return a database connection, and will not check the agent's database record.
argc | pointer to the number of arguments passed to the agent |
argv | the command line arguments for the agent |
db_conn | pointer to the location for the database connection |
Definition at line 15 of file standalone.c.
char* fo_scheduler_current | ( | ) |
Get the last read string from the scheduler.
Definition at line 18 of file standalone.c.
void fo_scheduler_disconnect | ( | int | retcode | ) |
Disconnect the scheduler connection.
Making a call to this function should be the last thing that an agent does before exiting. Any error reporting to stdout or stderr will not work after this function has finished execution.
retcode | Return code to the scheduler |
Definition at line 16 of file standalone.c.
int fo_scheduler_get_special | ( | int | option | ) |
Gets if a particular special attribute is set in the scheduler.
Possible Options:
SPECIAL_NOKILL
: the agent will not be killed if it stops updating statusSPECIAL_EXCLUSIVE
: the agent cannot run simultaneously with any other agentSPECIAL_NOEMAIL
: the scheduler will not send notification emails for this agentSPECIAL_LOCAL
: the agent is required to run on the same machine as the scheduleroption | the relevant option to the get the value of |
Definition at line 21 of file standalone.c.
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 they have processed.
i | This is the number of itmes processed since the last call to fo_scheduler_heart() |
Definition at line 14 of file standalone.c.
char* fo_scheduler_next | ( | ) |
Get the next data to process from the scheduler.
It is the job of the agent to decide how this string is interpreted.
Steps taken by this function:
Definition at line 17 of file standalone.c.
void fo_scheduler_set_special | ( | int | option, |
int | value | ||
) |
Sets something special about the agent within the scheduler.
Possible Options: SPECIAL_NOKILL
: instruct the scheduler to not kill the agent
option | the option to set |
value | whether to set the option to true or false |
Definition at line 20 of file standalone.c.
int fo_scheduler_userID | ( | ) |
Gets the id of the user that created the job that the agent is running.
Definition at line 19 of file standalone.c.
char* fo_sysconfig | ( | const char * | sectionname, |
const char * | variablename | ||
) |
gets a system configuration variable from the configuration data.
This function should be called after fo_scheduler_connect has been called. This is because the configuration data it not loaded until after that.
sectionname | the group of the variable |
variablename | the name of the variable |
Definition at line 22 of file standalone.c.
int fo_tableExists | ( | PGconn * | pgConn, |
const char * | tableName | ||
) |
Check if table exists. Note, this assumes the database name is 'fossology'.
pgConn | database connection |
tableName | The table in question |
Definition at line 29 of file standalone.c.
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.
If the ars table does not exist, one is created by inheriting the ars_master table. The new table is called {tableName}. For example, "unpack_ars". If ars_pk is zero a new ars record will be created. Otherwise, it is updated.
pgConn | Database connection object pointer. |
ars_pk | If zero, a new record will be created. |
upload_pk | ID of the upload |
agent_pk | Agents should get this from fo_GetAgentKey() |
tableName | ars table name |
ars_status | Status to update ars_status. May be null. |
ars_success | Automatically set to false if ars_pk is zero. |
Definition at line 24 of file standalone.c.
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 | Database connection object pointer. |
upload_pk | uploadPk |
agent_pk | agentPk |
ignoreFilesWithMimeType | To ignore Files With MimeType |
Definition at line 38 of file standalone.c.
int GetUploadPerm | ( | PGconn * | pgConn, |
long | UploadPk, | ||
int | user_pk | ||
) |
Get users permission to this upload.
pgConn | Database connection object pointer. |
upload_pk | Upload ID |
user_pk | User ID |
Definition at line 31 of file standalone.c.