X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fbdb_list.c;h=a1f3df3e655aaae259c6d41d32fe36faf483969a;hb=8e81c40b1346cdbfd0bbb5f7557e7cdb804a553f;hp=49fa0f39b7108a524c63094fa9d200b23da3f9bb;hpb=4137d8ab47939bf6d83eb5153ec854c5da0f776d;p=bacula%2Fbacula diff --git a/bacula/src/cats/bdb_list.c b/bacula/src/cats/bdb_list.c index 49fa0f39b7..a1f3df3e65 100644 --- a/bacula/src/cats/bdb_list.c +++ b/bacula/src/cats/bdb_list.c @@ -7,37 +7,44 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ - /* - Copyright (C) 2001-2003 Kern Sibbald and John Walker + Bacula® - The Network Backup Solution + + Copyright (C) 2001-2006 Free Software Foundation Europe e.V. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. - */ + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* The following is necessary so that we do not include * the dummy external definition of DB. */ -#define __SQL_C /* indicate that this is sql.c */ +#define __SQL_C /* indicate that this is sql.c */ #include "bacula.h" #include "cats.h" @@ -54,11 +61,11 @@ * ----------------------------------------------------------------------- */ -/* +/* * Submit general SQL query */ -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, - void *ctx, int verbose) +int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, + void *ctx, int verbose) { sendit(ctx, "SQL Queries not implemented with internal database.\n"); return 0; @@ -85,8 +92,8 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct len = sizeof(pr); while (fread(&pr, len, 1, mdb->poolfd) > 0) { Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n", - pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name); - sendit(ctx, mdb->cmd); + pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name); + sendit(ctx, mdb->cmd); } sendit(ctx, "===================================================\n"); db_unlock(mdb); @@ -98,8 +105,8 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct /* * List Media records */ -void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, - DB_LIST_HANDLER *sendit, void *ctx) +void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, + DB_LIST_HANDLER *sendit, void *ctx) { char ewc[30]; int len; @@ -112,21 +119,21 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, } sendit(ctx, " Status VolBytes MediaType VolumeName\n"); sendit(ctx, "=============================================================\n"); - fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */ + fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */ len = sizeof(mr); while (fread(&mr, len, 1, mdb->mediafd) > 0) { Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n", - mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc), - mr.MediaType, mr.VolumeName); - sendit(ctx, mdb->cmd); + mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc), + mr.MediaType, mr.VolumeName); + sendit(ctx, mdb->cmd); } sendit(ctx, "====================================================================\n"); db_unlock(mdb); return; } -void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, - DB_LIST_HANDLER *sendit, void *ctx) +void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, + DB_LIST_HANDLER *sendit, void *ctx) { JOBMEDIA_DBR jm; MEDIA_DBR mr; @@ -149,29 +156,29 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, while (fread(&jm, jmlen, 1, mdb->jobmediafd) > 0) { /* List by JobId */ if (JobId != 0) { - if (jm.JobId == JobId) { - /* Now find VolumeName in corresponding Media record */ - fseek(mdb->mediafd, 0L, SEEK_SET); - while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { - if (mr.MediaId == jm.MediaId) { + if (jm.JobId == JobId) { + /* Now find VolumeName in corresponding Media record */ + fseek(mdb->mediafd, 0L, SEEK_SET); + while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { + if (mr.MediaId == jm.MediaId) { Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", - jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); - sendit(ctx, mdb->cmd); - break; - } - } - } + jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); + sendit(ctx, mdb->cmd); + break; + } + } + } } else { - /* List all records */ - fseek(mdb->mediafd, 0L, SEEK_SET); - while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { - if (mr.MediaId == jm.MediaId) { + /* List all records */ + fseek(mdb->mediafd, 0L, SEEK_SET); + while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { + if (mr.MediaId == jm.MediaId) { Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", - jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); - sendit(ctx, mdb->cmd); - break; - } - } + jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); + sendit(ctx, mdb->cmd); + break; + } + } } } @@ -184,9 +191,10 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, /* * List Job records */ -void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, - DB_LIST_HANDLER *sendit, void *ctx) +void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, + DB_LIST_HANDLER *sendit, void *ctx) { +#ifdef xxx int jrlen; JOB_DBR ojr; int done = 0; @@ -200,7 +208,7 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, return; } fseek(mdb->jobfd, 0L, SEEK_SET); /* rewind file */ - /* + /* * Linear search through Job records */ sendit(ctx, " JobId StartTime Type Level Bytes Files Stat JobName\n"); @@ -208,23 +216,24 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, jrlen = sizeof(ojr); while (!done && fread(&ojr, jrlen, 1, mdb->jobfd) > 0) { if (jr->JobId != 0) { - if (jr->JobId == ojr.JobId) { - done = 1; - } else { - continue; - } + if (jr->JobId == ojr.JobId) { + done = 1; + } else { + continue; + } } localtime_r(&ojr.StartTime, &tm); strftime(dt, sizeof(dt), "%m-%d %H:%M", &tm); - Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", - ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, - edit_uint64_with_commas(ojr.JobBytes, ewc1), - edit_uint64_with_commas(ojr.JobFiles, ewc2), - (char)ojr.JobStatus, ojr.Name); + Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", + ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, + edit_uint64_with_commas(ojr.JobBytes, ewc1), + edit_uint64_with_commas(ojr.JobFiles, ewc2), + (char)ojr.JobStatus, ojr.Name); sendit(ctx, mdb->cmd); } sendit(ctx, "============================================================================\n"); db_unlock(mdb); +#endif return; } @@ -232,8 +241,8 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, /* * List Job Totals */ -void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, - DB_LIST_HANDLER *sendit, void *ctx) +void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, + DB_LIST_HANDLER *sendit, void *ctx) { char ewc1[30], ewc2[30], ewc3[30]; int jrlen; @@ -248,7 +257,7 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, return; } fseek(mdb->jobfd, 0L, SEEK_SET); /* rewind file */ - /* + /* * Linear search through JobStart records */ sendit(ctx, " NumJobs NumFiles NumBytes\n"); @@ -259,10 +268,10 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, total_bytes += ojr.JobBytes; total_jobs++; } - Mmsg(mdb->cmd, " %7s %10s %15s\n", - edit_uint64_with_commas(total_jobs, ewc1), - edit_uint64_with_commas(total_files, ewc2), - edit_uint64_with_commas(total_bytes, ewc3)); + Mmsg(mdb->cmd, " %7s %10s %15s\n", + edit_uint64_with_commas(total_jobs, ewc1), + edit_uint64_with_commas(total_files, ewc2), + edit_uint64_with_commas(total_bytes, ewc3)); sendit(ctx, mdb->cmd); sendit(ctx, "=======================================\n"); db_unlock(mdb); @@ -277,28 +286,28 @@ void db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx) { } -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, - void *ctx, int verbose, e_list_type type) +int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, + void *ctx, int verbose, e_list_type type) { return 0; } void -db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } void -db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, - DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, + DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } -void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, - DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, + DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } void -db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, - void *ctx, e_list_type type) +db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, + void *ctx, e_list_type type) { } void