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 */
57