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
15 Copyright (C) 2001, 2002 Kern Sibbald and John Walker
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License as
19 published by the Free Software Foundation; either version 2 of
20 the License, or (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public
28 License along with this program; if not, write to the Free
29 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /* The following is necessary so that we do not include
36 * the dummy external definition of DB.
38 #define __SQL_C /* indicate that this is sql.c */
46 /* Forward referenced functions */
48 /* -----------------------------------------------------------------------
50 * Bacula specific defines and subroutines
52 * -----------------------------------------------------------------------
57 * Delete a Pool record given the Name
60 * the number of records deleted on success
62 int db_delete_pool_record(B_DB *mdb, POOL_DBR *pr)
67 pr->PoolId = 0; /* Search on Pool Name */
68 if (!db_get_pool_record(mdb, pr)) {
69 Mmsg1(&mdb->errmsg, "No pool record %s exists\n", pr->Name);
73 fseek(mdb->poolfd, pr->rec_addr, SEEK_SET);
74 memset(&opr, 0, sizeof(opr));
75 stat = fwrite(&opr, sizeof(opr), 1, mdb->poolfd);
80 int db_delete_media_record(B_DB *mdb, MEDIA_DBR *mr)
85 if (!db_get_media_record(mdb, mr)) {
86 Mmsg0(&mdb->errmsg, "Media record not found.\n");
90 fseek(mdb->mediafd, mr->rec_addr, SEEK_SET);
91 memset(&omr, 0, sizeof(omr));
92 stat = fwrite(&omr, sizeof(omr), 1, mdb->mediafd);
97 #endif /* HAVE_BACULA_DB */