]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/protos.h
Revert to using LGPLv3 for simple scripts
[bacula/bacula] / bacula / src / cats / protos.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from many
7    others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    Bacula® is a registered trademark of Kern Sibbald.
15 */
16 /*
17  *
18  *  Database routines that are exported by the cats library for
19  *    use elsewhere in Bacula (mainly the Director).
20  *
21  *    Written by Kern Sibbald, MM
22  */
23
24 #ifndef __SQL_PROTOS_H
25 #define __SQL_PROTOS_H
26
27 #include "cats.h"
28
29 /* Database prototypes */
30
31 /* sql.c */
32 bool db_open_batch_connexion(JCR *jcr, B_DB *mdb);
33 char *db_strerror(B_DB *mdb);
34 int db_int64_handler(void *ctx, int num_fields, char **row);
35 int db_strtime_handler(void *ctx, int num_fields, char **row);
36 int db_list_handler(void *ctx, int num_fields, char **row);
37 void db_debug_print(JCR *jcr, FILE *fp);
38 int db_int_handler(void *ctx, int num_fields, char **row);
39 void db_check_backend_thread_safe();
40 int db_string_list_handler(void *ctx, int num_fields, char **row);
41
42 /* sql_create.c */
43 int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
44 bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
45 bool db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
46 int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
47 int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
48 bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
49 bool db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
50 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
51 int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
52 bool db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr);
53 bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
54 bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr);
55 bool db_write_batch_file_records(JCR *jcr);
56 bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
57 bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ar);
58 bool db_create_base_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
59 bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb);
60 bool db_create_base_file_list(JCR *jcr, B_DB *mdb, char *jobids);
61 void db_disable_batch_insert(bool disable);
62
63 /* sql_delete.c */
64 int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
65 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
66
67 /* sql_find.c */
68 bool db_find_last_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime, char *job, int JobLevel);
69 bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime, char *job);
70 bool db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr);
71 int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr);
72 bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel);
73
74 /* sql_get.c */
75 bool db_get_volume_jobids(JCR *jcr, B_DB *mdb,
76                          MEDIA_DBR *mr, db_list_ctx *lst);
77 bool db_get_base_file_list(JCR *jcr, B_DB *mdb, bool use_md5,
78                            DB_RESULT_HANDLER *result_handler,void *ctx);
79 int db_get_path_record(JCR *jcr, B_DB *mdb);
80 bool db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr);
81 bool db_get_pool_numvols(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr);
82 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
83 bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
84 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
85 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
86 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
87 bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
88 int db_get_num_media_records(JCR *jcr, B_DB *mdb);
89 int db_get_num_pool_records(JCR *jcr, B_DB *mdb);
90 int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
91 int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
92 bool db_get_media_ids(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr, int *num_ids, uint32_t **ids);
93 int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS **VolParams);
94 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
95 int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
96 bool db_get_query_dbids(JCR *jcr, B_DB *mdb, POOL_MEM &query, dbid_list &ids);
97 bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids,
98                       bool use_md5, bool use_delta,
99                       DB_RESULT_HANDLER *result_handler, void *ctx);
100 bool db_get_base_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr, JobId_t *jobid);
101 bool db_accurate_get_jobids(JCR *jcr, B_DB *mdb, JOB_DBR *jr, db_list_ctx *jobids);
102 bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, db_list_ctx *result);
103 /* sql_list.c */
104 enum e_list_type {
105    HORZ_LIST,
106    VERT_LIST,
107    FAILED_JOBS,
108    INCOMPLETE_JOBS
109 };
110
111 void db_list_pool_records(JCR *jcr, B_DB *db, POOL_DBR *pr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
112 alist *db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
113 void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
114 void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
115 void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
116 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
117 void db_list_joblog_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
118 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);
119 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
120 void db_list_copies_records(JCR *jcr, B_DB *mdb, uint32_t limit, char *jobids, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
121 void
122 db_list_base_files_for_job(JCR *jcr, B_DB *mdb, JobId_t jobid, DB_LIST_HANDLER *sendit, void *ctx);
123
124
125 /* sql_update.c */
126 bool db_update_job_start_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
127 int  db_update_job_end_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
128 int  db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
129 int  db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
130 bool db_update_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
131 int  db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
132 int  db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
133 int  db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
134 int  db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest, int type);
135 int  db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
136 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
137 int db_update_stats(JCR *jcr, B_DB *mdb, utime_t age);
138
139 #endif /* __SQL_PROTOS_H */