]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/bdb_list.c
Update comments and echo to indicate this script is for upgrading version
[bacula/bacula] / bacula / src / cats / bdb_list.c
index 837e1e1b8565f665c3cd5efb76d6c437874db28f..a1f3df3e655aaae259c6d41d32fe36faf483969a 100644 (file)
@@ -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"
  * -----------------------------------------------------------------------
  */
 
-/* 
+/*
  * 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);
@@ -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);
+         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);
    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) {
-                  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;
+            }
+         }
       }
    }
 
@@ -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.Type, (char)ojr.Level, 
-               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