FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
database.h
1 /* **************************************************************
2 Copyright (C) 2010, 2011, 2012 Hewlett-Packard Development Company, L.P.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 ************************************************************** */
17 
18 #ifndef DATABASE_H_INCLUDE
19 #define DATABASE_H_INCLUDE
20 
21 /* local includes */
22 #include <job.h>
23 #include <scheduler.h>
24 
25 /* ************************************************************************** */
26 /* **** utility ************************************************************* */
27 /* ************************************************************************** */
28 
29 #define PQget(db_result, row, col) \
30  PQgetvalue(db_result, row, PQfnumber(db_result, col))
31 
32 extern const char* jobsql_failed;
33 
34 /* ************************************************************************** */
35 /* **** constructor destructor ********************************************** */
36 /* ************************************************************************** */
37 
38 void database_init(scheduler_t* scheduler);
39 void email_init(scheduler_t* scheduler);
40 
41 /* ************************************************************************** */
42 /* **** event and functions ************************************************* */
43 /* ************************************************************************** */
44 
45 PGresult* database_exec(scheduler_t* scheduler, const char* sql);
46 void database_exec_event(scheduler_t* scheduler, char* sql);
47 void database_update_event(scheduler_t* scheduler, void* unused);
48 
49 void database_reset_queue(scheduler_t* scheduler);
50 void database_update_job(scheduler_t* db_conn, job_t* j, job_status status);
51 void database_job_processed(int j_id, int number);
52 void database_job_log(int j_id, char* log_name);
53 void database_job_priority(scheduler_t* scheduler, job_t* job, int priority);
54 char* get_email_command(scheduler_t* scheduler, char* user_email);
55 
56 #endif /* DATABASE_H_INCLUDE */
void database_reset_queue(scheduler_t *scheduler)
Resets any jobs in the job queue that are not completed.
Definition: database.c:942
void email_init(scheduler_t *scheduler)
Loads information about the email that will be sent for job notifications.
Definition: database.c:568
void database_init(scheduler_t *scheduler)
Definition: database.c:781
void database_update_event(scheduler_t *scheduler, void *unused)
Checks the job queue for any new entries.
Definition: database.c:852
void database_update_job(scheduler_t *scheduler, job_t *job, job_status status)
Change the status of a job in the database.
Definition: database.c:956
void database_job_log(int j_id, char *log_name)
Enters the name of the log file for a job into the database.
Definition: database.c:1017
PGresult * database_exec(scheduler_t *scheduler, const char *sql)
Executes an sql statement for the scheduler.
Definition: database.c:814
void database_exec_event(scheduler_t *scheduler, char *sql)
Definition: database.c:838
PGconn * db_conn
The connection to Database.
Definition: pkgagent.c:34
void database_job_processed(int j_id, int num)
Updates the number of items that a job queue entry has processed.
Definition: database.c:1003
const char * jobsql_failed
The job structure.
Definition: job.h:61
void database_job_priority(scheduler_t *scheduler, job_t *job, int priority)
Changes the priority of a job queue entry in the database.
Definition: database.c:1032
Header file for the scheduler.
char * get_email_command(scheduler_t *scheduler, char *user_email)
Build command to run to send email.
Definition: database.c:1051