6 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public
19 License along with this program; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 #ifndef __SQL_PROTOS_H
26 #define __SQL_PROTOS_H
30 /* Database prototypes */
33 B_DB *db_init_database(char *db_name, char *db_user, char *db_password);
34 int db_open_database(B_DB *db);
35 void db_close_database(B_DB *db);
36 void db_escape_string(char *snew, char *old, int len);
37 char *db_strerror(B_DB *mdb);
38 int get_sql_record_max(B_DB *mdb);
39 char *db_next_index(B_DB *mdb, char *table);
40 int db_sql_query(B_DB *mdb, char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
41 int check_tables_version(B_DB *mdb);
42 void _db_unlock(char *file, int line, B_DB *mdb);
43 void _db_lock(char *file, int line, B_DB *mdb);
46 int db_create_file_attributes_record(B_DB *mdb, ATTR_DBR *ar);
47 int db_create_job_record(B_DB *db, JOB_DBR *jr);
48 int db_create_media_record(B_DB *db, MEDIA_DBR *media_dbr);
49 int db_create_client_record(B_DB *db, CLIENT_DBR *cr);
50 int db_create_fileset_record(B_DB *db, FILESET_DBR *fsr);
51 int db_create_pool_record(B_DB *db, POOL_DBR *pool_dbr);
52 int db_create_jobmedia_record(B_DB *mdb, JOBMEDIA_DBR *jr);
55 int db_delete_pool_record(B_DB *db, POOL_DBR *pool_dbr);
56 int db_delete_media_record(B_DB *mdb, MEDIA_DBR *mr);
59 int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime);
60 int db_find_last_full_verify(B_DB *mdb, JOB_DBR *jr);
61 int db_find_next_volume(B_DB *mdb, int index, MEDIA_DBR *mr);
64 int db_get_pool_record(B_DB *db, POOL_DBR *pdbr);
65 int db_get_client_record(B_DB *mdb, CLIENT_DBR *cr);
66 int db_get_job_record(B_DB *mdb, JOB_DBR *jr);
67 int db_get_job_volume_names(B_DB *mdb, uint32_t JobId, char *VolumeNames);
68 int db_get_file_attributes_record(B_DB *mdb, char *fname, FILE_DBR *fdbr);
69 int db_get_fileset_record(B_DB *mdb, FILESET_DBR *fsr);
70 int db_get_media_record(B_DB *mdb, MEDIA_DBR *mr);
71 int db_get_num_media_records(B_DB *mdb);
72 int db_get_num_pool_records(B_DB *mdb);
73 int db_get_pool_ids(B_DB *mdb, int *num_ids, uint32_t **ids);
74 int db_get_media_ids(B_DB *mdb, int *num_ids, uint32_t **ids);
78 void db_list_pool_records(B_DB *db, DB_LIST_HANDLER sendit, void *ctx);
79 void db_list_job_records(B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
80 void db_list_job_totals(B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
81 void db_list_files_for_job(B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
82 void db_list_media_records(B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx);
83 void db_list_jobmedia_records(B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx);
84 int db_list_sql_query(B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx);
87 int db_update_job_start_record(B_DB *db, JOB_DBR *jr);
88 int db_update_job_end_record(B_DB *db, JOB_DBR *jr);
89 int db_update_pool_record(B_DB *db, POOL_DBR *pr);
90 int db_update_media_record(B_DB *db, MEDIA_DBR *mr);
91 int db_add_MD5_to_file_record(B_DB *mdb, FileId_t FileId, char *MD5);
92 int db_mark_file_record(B_DB *mdb, FileId_t FileId, int JobId);
94 #endif /* __SQL_PROTOS_H */