]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/protos.h
20Feb06
[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-2006 Kern Sibbald
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
13    version 2 as amended with additional clauses defined in the
14    file LICENSE in the main source directory.
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 
19    the file LICENSE for additional details.
20
21  */
22
23 #ifndef __SQL_PROTOS_H
24 #define __SQL_PROTOS_H
25
26 #include "cats.h"
27
28 /* Database prototypes */
29
30 /* sql.c */
31 B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
32                        const char *db_address, int db_port, const char *db_socket,
33                        int mult_db_connections);
34 int  db_open_database(JCR *jcr, B_DB *db);
35 void db_close_database(JCR *jcr, B_DB *db);
36 void db_escape_string(char *snew, char *old, int len);
37 char *db_strerror(B_DB *mdb);
38 int  db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index);
39 int  db_sql_query(B_DB *mdb, const char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
40 void db_start_transaction(JCR *jcr, B_DB *mdb);
41 void db_end_transaction(JCR *jcr, B_DB *mdb);
42
43
44 /* create.c */
45 int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
46 bool db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
47 bool db_create_mac_record(JCR *jcr, B_DB *db, MAC_DBR *mr);
48 int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
49 int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
50 bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
51 bool db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
52 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
53 int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
54 bool db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr);
55 bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
56 bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr);
57
58 /* delete.c */
59 int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
60 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
61
62 /* find.c */
63 bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
64 bool db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr);
65 int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr);
66 bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel);
67
68 /* get.c */
69 bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
70 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
71 bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
72 bool db_get_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr);
73 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
74 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
75 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
76 bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
77 int db_get_num_media_records(JCR *jcr, B_DB *mdb);
78 int db_get_num_pool_records(JCR *jcr, B_DB *mdb);
79 int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
80 int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, DBId_t **ids);
81 bool db_get_media_ids(JCR *jcr, B_DB *mdb, DBId_t PoolId, int *num_ids, uint32_t **ids);
82 int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS **VolParams);
83 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
84 int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
85
86
87 /* list.c */
88 enum e_list_type {
89    HORZ_LIST,
90    VERT_LIST
91 };
92 void db_list_pool_records(JCR *jcr, B_DB *db, POOL_DBR *pr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
93 void db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, e_list_type type);
94 void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
95 void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
96 void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
97 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
98 int  db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type);
99 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
100
101 /* update.c */
102 bool db_update_job_start_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
103 int  db_update_job_end_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
104 int  db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
105 int  db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
106 bool db_update_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr);
107 int  db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
108 int  db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
109 int  db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
110 int  db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest, int type);
111 int  db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
112 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
113
114 #endif /* __SQL_PROTOS_H */