2 * Bacula Catalog Database Delete record interface routines
4 * Bacula Catalog Database routines written specifically
5 * for Bacula. Note, these routines are VERY dumb and
6 * do not provide all the functionality of an SQL database.
7 * The purpose of these routines is to ensure that Bacula
8 * can limp along if no real database is loaded on the
11 * Kern Sibbald, January MMI
17 Copyright (C) 2001-2003 Kern Sibbald and John Walker
19 This program is free software; you can redistribute it and/or
20 modify it under the terms of the GNU General Public License as
21 published by the Free Software Foundation; either version 2 of
22 the License, or (at your option) any later version.
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
29 You should have received a copy of the GNU General Public
30 License along with this program; if not, write to the Free
31 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 /* The following is necessary so that we do not include
38 * the dummy external definition of DB.
40 #define __SQL_C /* indicate that this is sql.c */
48 /* Forward referenced functions */
50 /* -----------------------------------------------------------------------
52 * Bacula specific defines and subroutines
54 * -----------------------------------------------------------------------
59 * Delete a Pool record given the Name
62 * the number of records deleted on success
64 int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
70 pr->PoolId = 0; /* Search on Pool Name */
71 if (!db_get_pool_record(jcr, mdb, pr)) {
72 Mmsg1(&mdb->errmsg, "No pool record %s exists\n", pr->Name);
76 fseek(mdb->poolfd, pr->rec_addr, SEEK_SET);
77 memset(&opr, 0, sizeof(opr));
78 stat = fwrite(&opr, sizeof(opr), 1, mdb->poolfd);
83 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
89 if (!db_get_media_record(jcr, mdb, mr)) {
90 Mmsg0(&mdb->errmsg, "Media record not found.\n");
94 fseek(mdb->mediafd, mr->rec_addr, SEEK_SET);
95 memset(&omr, 0, sizeof(omr));
96 stat = fwrite(&omr, sizeof(omr), 1, mdb->mediafd);
101 #endif /* HAVE_BACULA_DB */