]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/protos.h
This commit was manufactured by cvs2svn to create tag
[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    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2 of
14    the License, or (at your option) any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public
22    License along with this program; if not, write to the Free
23    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24    MA 02111-1307, USA.
25
26  */
27
28 #ifndef __SQL_PROTOS_H
29 #define __SQL_PROTOS_H
30
31 #include "cats.h"
32
33 /* Database prototypes */
34
35 /* sql.c */
36 B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
37                        const char *db_address, int db_port, const char *db_socket,
38                        int mult_db_connections);
39 int  db_open_database(JCR *jcr, B_DB *db);
40 void db_close_database(JCR *jcr, B_DB *db);
41 void db_escape_string(char *snew, char *old, int len);
42 char *db_strerror(B_DB *mdb);
43 int  db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index);
44 int  db_sql_query(B_DB *mdb, const char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
45 void db_start_transaction(JCR *jcr, B_DB *mdb);
46 void db_end_transaction(JCR *jcr, B_DB *mdb);
47
48
49 /* create.c */
50 int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
51 int db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
52 int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
53 int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
54 bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
55 bool db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
56 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
57 int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
58 bool db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr);
59 bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
60 bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr);
61
62 /* delete.c */
63 int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
64 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
65
66 /* find.c */
67 bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
68 int db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr);
69 int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr);
70 bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel);
71
72 /* get.c */
73 bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
74 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
75 int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
76 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
77 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
78 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
79 bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
80 int db_get_num_media_records(JCR *jcr, B_DB *mdb);
81 int db_get_num_pool_records(JCR *jcr, B_DB *mdb);
82 int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
83 int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
84 bool db_get_media_ids(JCR *jcr, B_DB *mdb, DBId_t PoolId, int *num_ids, uint32_t **ids);
85 int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS **VolParams);
86 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
87 int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
88
89
90 /* list.c */
91 enum e_list_type {
92    HORZ_LIST,
93    VERT_LIST
94 };
95 void db_list_pool_records(JCR *jcr, B_DB *db, POOL_DBR *pr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
96 void db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
97 void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
98 void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
99 void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
100 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
101 int  db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type);
102 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
103
104 /* update.c */
105 bool db_update_job_start_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
106 int  db_update_job_end_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
107 int  db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
108 int  db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
109 bool db_update_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
110 int  db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
111 int  db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
112 int  db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
113 int  db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type);
114 int  db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
115 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
116
117 #endif /* __SQL_PROTOS_H */