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-2006 Kern Sibbald
19 This program is free software; you can redistribute it and/or
20 modify it under the terms of the GNU General Public License
21 version 2 as amended with additional clauses defined in the
22 file LICENSE in the main source directory.
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
27 the file LICENSE for additional details.
32 /* The following is necessary so that we do not include
33 * the dummy external definition of DB.
35 #define __SQL_C /* indicate that this is sql.c */
43 /* Forward referenced functions */
45 /* -----------------------------------------------------------------------
47 * Bacula specific defines and subroutines
49 * -----------------------------------------------------------------------
54 * Delete a Pool record given the Name
57 * the number of records deleted on success
59 int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
65 pr->PoolId = 0; /* Search on Pool Name */
66 if (!db_get_pool_record(jcr, mdb, pr)) {
67 Mmsg1(&mdb->errmsg, "No pool record %s exists\n", pr->Name);
71 fseek(mdb->poolfd, pr->rec_addr, SEEK_SET);
72 memset(&opr, 0, sizeof(opr));
73 stat = fwrite(&opr, sizeof(opr), 1, mdb->poolfd);
78 int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
84 if (!db_get_media_record(jcr, mdb, mr)) {
85 Mmsg0(&mdb->errmsg, "Media record not found.\n");
89 fseek(mdb->mediafd, mr->rec_addr, SEEK_SET);
90 memset(&omr, 0, sizeof(omr));
91 stat = fwrite(&omr, sizeof(omr), 1, mdb->mediafd);
96 #endif /* HAVE_BACULA_DB */