]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/protos.h
ebl make batch mode usable
[bacula/bacula] / bacula / src / cats / protos.h
1 /*
2  *
3  *  Database routines that are exported by the cats library for
4  *    use elsewhere in Bacula (mainly the Director).
5  *
6  *    Version $Id$
7  */
8 /*
9    Bacula® - The Network Backup Solution
10
11    Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
12
13    The main author of Bacula is Kern Sibbald, with contributions from
14    many others, a complete list can be found in the file AUTHORS.
15    This program is Free Software; you can redistribute it and/or
16    modify it under the terms of version two of the GNU General Public
17    License as published by the Free Software Foundation plus additions
18    that are listed in the file LICENSE.
19
20    This program is distributed in the hope that it will be useful, but
21    WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23    General Public License for more details.
24
25    You should have received a copy of the GNU General Public License
26    along with this program; if not, write to the Free Software
27    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28    02110-1301, USA.
29
30    Bacula® is a registered trademark of John Walker.
31    The licensor of Bacula is the Free Software Foundation Europe
32    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
33    Switzerland, email:ftf@fsfeurope.org.
34 */
35
36 #ifndef __SQL_PROTOS_H
37 #define __SQL_PROTOS_H
38
39 #include "cats.h"
40
41 /* Database prototypes */
42
43 /* sql.c */
44 B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
45                        const char *db_address, int db_port, const char *db_socket,
46                        int mult_db_connections);
47 int  db_open_database(JCR *jcr, B_DB *db);
48 void db_close_database(JCR *jcr, B_DB *db);
49 void db_escape_string(char *snew, char *old, int len);
50 char *db_strerror(B_DB *mdb);
51 int  db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index);
52 int  db_sql_query(B_DB *mdb, const char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
53 void db_start_transaction(JCR *jcr, B_DB *mdb);
54 void db_end_transaction(JCR *jcr, B_DB *mdb);
55 int db_int64_handler(void *ctx, int num_fields, char **row);
56
57
58 /* create.c */
59 bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
60 bool db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
61 int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
62 int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
63 bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
64 bool db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
65 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
66 int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
67 bool db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr);
68 bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
69 bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr);
70 bool db_write_batch_file_records(JCR *jcr);
71 bool my_batch_start(JCR *jcr, B_DB *mdb);
72 bool my_batch_end(JCR *jcr, B_DB *mdb, const char *error);
73 bool my_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
74
75 /* delete.c */
76 int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
77 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
78
79 /* find.c */
80 bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
81 bool db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr);
82 int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr);
83 bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel);
84
85 /* get.c */
86 bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
87 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
88 bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
89 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
90 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
91 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
92 bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
93 int db_get_num_media_records(JCR *jcr, B_DB *mdb);
94 int db_get_num_pool_records(JCR *jcr, B_DB *mdb);
95 int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
96 int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
97 bool db_get_media_ids(JCR *jcr, B_DB *mdb, DBId_t PoolId, int *num_ids, uint32_t **ids);
98 int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS **VolParams);
99 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
100 int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
101
102
103 /* list.c */
104 enum e_list_type {
105    HORZ_LIST,
106    VERT_LIST
107 };
108 void db_list_pool_records(JCR *jcr, B_DB *db, POOL_DBR *pr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
109 void db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
110 void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
111 void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
112 void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
113 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
114 int  db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type);
115 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
116
117 /* update.c */
118 bool db_update_job_start_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
119 int  db_update_job_end_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
120 int  db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
121 int  db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
122 bool db_update_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
123 int  db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
124 int  db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
125 int  db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
126 int  db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest, int type);
127 int  db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
128 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
129
130 #endif /* __SQL_PROTOS_H */