X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fbdb_list.c;h=a1f3df3e655aaae259c6d41d32fe36faf483969a;hb=8e81c40b1346cdbfd0bbb5f7557e7cdb804a553f;hp=82238c77da482d45c3d9511e9efb90b466d49f53;hpb=66696d1cadedbb362c392dadce9a8ce275dd5d80;p=bacula%2Fbacula diff --git a/bacula/src/cats/bdb_list.c b/bacula/src/cats/bdb_list.c index 82238c77da..a1f3df3e65 100644 --- a/bacula/src/cats/bdb_list.c +++ b/bacula/src/cats/bdb_list.c @@ -12,32 +12,39 @@ * * 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" @@ -57,8 +64,8 @@ /* * 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; @@ -84,9 +91,9 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct fseek(mdb->poolfd, 0L, SEEK_SET); /* rewind file */ 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); + Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n", + pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name); + sendit(ctx, mdb->cmd); } sendit(ctx, "===================================================\n"); db_unlock(mdb); @@ -99,7 +106,7 @@ 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) + DB_LIST_HANDLER *sendit, void *ctx) { char ewc[30]; int len; @@ -112,13 +119,13 @@ 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); + 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); } sendit(ctx, "====================================================================\n"); db_unlock(mdb); @@ -126,7 +133,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, } void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, - DB_LIST_HANDLER *sendit, void *ctx) + 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) { - Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", - jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); - sendit(ctx, mdb->cmd); - break; - } - } - } + 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; + } + } + } } else { - /* 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; - } - } + /* 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; + } + } } } @@ -185,8 +192,9 @@ 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) + DB_LIST_HANDLER *sendit, void *ctx) { +#ifdef xxx int jrlen; JOB_DBR ojr; int done = 0; @@ -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); + 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; } @@ -233,7 +242,7 @@ 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) + DB_LIST_HANDLER *sendit, void *ctx) { char ewc1[30], ewc2[30], ewc3[30]; int jrlen; @@ -260,9 +269,9 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, 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)); + 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,8 +286,8 @@ 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; } @@ -289,16 +298,16 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_ 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_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) + 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) + void *ctx, e_list_type type) { } void