]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/parse_bsr.c
kes Apply Richard Mortimer's patches for printing an error
[bacula/bacula] / bacula / src / stored / parse_bsr.c
index 9c26e0672f1d2b0477e7369d4af530425879a37f..1bd1fa37ba91c84068acccc326c26e66bfb2ad35 100755 (executable)
@@ -7,11 +7,11 @@
  */
 
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Copyright (C) 2002-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   version 2 as amended with additional clauses defined in the
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -29,6 +29,7 @@ typedef BSR * (ITEM_HANDLER)(LEX *lc, BSR *bsr);
 
 static BSR *store_vol(LEX *lc, BSR *bsr);
 static BSR *store_mediatype(LEX *lc, BSR *bsr);
+static BSR *store_device(LEX *lc, BSR *bsr);
 static BSR *store_client(LEX *lc, BSR *bsr);
 static BSR *store_job(LEX *lc, BSR *bsr);
 static BSR *store_jobid(LEX *lc, BSR *bsr);
@@ -71,8 +72,9 @@ struct kw_items items[] = {
    {"exclude", store_exclude},
    {"volfile", store_volfile},
    {"volblock", store_volblock},
-   {"stream",  store_stream},
-   {"slot",    store_slot},
+   {"stream",   store_stream},
+   {"slot",     store_slot},
+   {"device",   store_device},
    {NULL, NULL}
 
 };
@@ -268,6 +270,28 @@ static BSR *store_mediatype(LEX *lc, BSR *bsr)
    return bsr;
 }
 
+/* Shove the Device name in each Volume in the current bsr */
+static BSR *store_device(LEX *lc, BSR *bsr)
+{
+   int token;
+
+   token = lex_get_token(lc, T_STRING);
+   if (token == T_ERROR) {
+      return NULL;
+   }
+   if (!bsr->volume) {
+      Emsg1(M_ERROR,0, _("Device \"%s\" in bsr at inappropriate place.\n"),
+         lc->str);
+      return bsr;
+   }
+   BSR_VOLUME *bv;
+   for (bv=bsr->volume; bv; bv=bv->next) {
+      bstrncpy(bv->device, lc->str, sizeof(bv->device));
+   }
+   return bsr;
+}
+
+
 
 static BSR *store_client(LEX *lc, BSR *bsr)
 {
@@ -413,7 +437,7 @@ static BSR *store_count(LEX *lc, BSR *bsr)
 static BSR *store_jobtype(LEX *lc, BSR *bsr)
 {
    /* *****FIXME****** */
-   Pmsg0(-1, "JobType not yet implemented\n");
+   Pmsg0(-1, _("JobType not yet implemented\n"));
    return bsr;
 }
 
@@ -421,7 +445,7 @@ static BSR *store_jobtype(LEX *lc, BSR *bsr)
 static BSR *store_joblevel(LEX *lc, BSR *bsr)
 {
    /* *****FIXME****** */
-   Pmsg0(-1, "JobLevel not yet implemented\n");
+   Pmsg0(-1, _("JobLevel not yet implemented\n"));
    return bsr;
 }
 
@@ -603,7 +627,12 @@ static BSR *store_slot(LEX *lc, BSR *bsr)
    if (token == T_ERROR) {
       return NULL;
    }
-   bsr->Slot = lc->pint32_val;
+   if (!bsr->volume) {
+      Emsg1(M_ERROR,0, _("Slot %d in bsr at inappropriate place.\n"),
+         lc->pint32_val);
+      return bsr;
+   }
+   bsr->volume->Slot = lc->pint32_val;
    scan_to_eol(lc);
    return bsr;
 }
@@ -623,7 +652,7 @@ static BSR *store_exclude(LEX *lc, BSR *bsr)
 void dump_volfile(BSR_VOLFILE *volfile)
 {
    if (volfile) {
-      Pmsg2(-1, "VolFile     : %u-%u\n", volfile->sfile, volfile->efile);
+      Pmsg2(-1, _("VolFile     : %u-%u\n"), volfile->sfile, volfile->efile);
       dump_volfile(volfile->next);
    }
 }
@@ -631,7 +660,7 @@ void dump_volfile(BSR_VOLFILE *volfile)
 void dump_volblock(BSR_VOLBLOCK *volblock)
 {
    if (volblock) {
-      Pmsg2(-1, "VolBlock    : %u-%u\n", volblock->sblock, volblock->eblock);
+      Pmsg2(-1, _("VolBlock    : %u-%u\n"), volblock->sblock, volblock->eblock);
       dump_volblock(volblock->next);
    }
 }
@@ -641,9 +670,9 @@ void dump_findex(BSR_FINDEX *FileIndex)
 {
    if (FileIndex) {
       if (FileIndex->findex == FileIndex->findex2) {
-         Pmsg1(-1, "FileIndex   : %u\n", FileIndex->findex);
+         Pmsg1(-1, _("FileIndex   : %u\n"), FileIndex->findex);
       } else {
-         Pmsg2(-1, "FileIndex   : %u-%u\n", FileIndex->findex, FileIndex->findex2);
+         Pmsg2(-1, _("FileIndex   : %u-%u\n"), FileIndex->findex, FileIndex->findex2);
       }
       dump_findex(FileIndex->next);
    }
@@ -653,9 +682,9 @@ void dump_jobid(BSR_JOBID *jobid)
 {
    if (jobid) {
       if (jobid->JobId == jobid->JobId2) {
-         Pmsg1(-1, "JobId       : %u\n", jobid->JobId);
+         Pmsg1(-1, _("JobId       : %u\n"), jobid->JobId);
       } else {
-         Pmsg2(-1, "JobId       : %u-%u\n", jobid->JobId, jobid->JobId2);
+         Pmsg2(-1, _("JobId       : %u-%u\n"), jobid->JobId, jobid->JobId2);
       }
       dump_jobid(jobid->next);
    }
@@ -665,9 +694,9 @@ void dump_sessid(BSR_SESSID *sessid)
 {
    if (sessid) {
       if (sessid->sessid == sessid->sessid2) {
-         Pmsg1(-1, "SessId      : %u\n", sessid->sessid);
+         Pmsg1(-1, _("SessId      : %u\n"), sessid->sessid);
       } else {
-         Pmsg2(-1, "SessId      : %u-%u\n", sessid->sessid, sessid->sessid2);
+         Pmsg2(-1, _("SessId      : %u-%u\n"), sessid->sessid, sessid->sessid2);
       }
       dump_sessid(sessid->next);
    }
@@ -676,7 +705,10 @@ void dump_sessid(BSR_SESSID *sessid)
 void dump_volume(BSR_VOLUME *volume)
 {
    if (volume) {
-      Pmsg1(-1, "VolumeName  : %s\n", volume->VolumeName);
+      Pmsg1(-1, _("VolumeName  : %s\n"), volume->VolumeName);
+      Pmsg1(-1, _("  MediaType : %s\n"), volume->MediaType);
+      Pmsg1(-1, _("  Device    : %s\n"), volume->device);
+      Pmsg1(-1, _("  Slot      : %d\n"), volume->Slot);
       dump_volume(volume->next);
    }
 }
@@ -685,7 +717,7 @@ void dump_volume(BSR_VOLUME *volume)
 void dump_client(BSR_CLIENT *client)
 {
    if (client) {
-      Pmsg1(-1, "Client      : %s\n", client->ClientName);
+      Pmsg1(-1, _("Client      : %s\n"), client->ClientName);
       dump_client(client->next);
    }
 }
@@ -693,7 +725,7 @@ void dump_client(BSR_CLIENT *client)
 void dump_job(BSR_JOB *job)
 {
    if (job) {
-      Pmsg1(-1, "Job          : %s\n", job->Job);
+      Pmsg1(-1, _("Job          : %s\n"), job->Job);
       dump_job(job->next);
    }
 }
@@ -701,7 +733,7 @@ void dump_job(BSR_JOB *job)
 void dump_sesstime(BSR_SESSTIME *sesstime)
 {
    if (sesstime) {
-      Pmsg1(-1, "SessTime    : %u\n", sesstime->sesstime);
+      Pmsg1(-1, _("SessTime    : %u\n"), sesstime->sesstime);
       dump_sesstime(sesstime->next);
    }
 }
@@ -715,12 +747,12 @@ void dump_bsr(BSR *bsr, bool recurse)
    int save_debug = debug_level;
    debug_level = 1;
    if (!bsr) {
-      Pmsg0(-1, "BSR is NULL\n");
+      Pmsg0(-1, _("BSR is NULL\n"));
       debug_level = save_debug;
       return;
    }
-   Pmsg1(-1,    "Next        : 0x%x\n", bsr->next);
-   Pmsg1(-1,    "Root bsr    : 0x%x\n", bsr->root);
+   Pmsg1(-1,    _("Next        : 0x%x\n"), bsr->next);
+   Pmsg1(-1,    _("Root bsr    : 0x%x\n"), bsr->root);
    dump_volume(bsr->volume);
    dump_sessid(bsr->sessid);
    dump_sesstime(bsr->sesstime);
@@ -730,17 +762,14 @@ void dump_bsr(BSR *bsr, bool recurse)
    dump_jobid(bsr->JobId);
    dump_job(bsr->job);
    dump_findex(bsr->FileIndex);
-   if (bsr->Slot) {
-      Pmsg1(-1, "Slot        : %u\n", bsr->Slot);
-   }
    if (bsr->count) {
-      Pmsg1(-1, "count       : %u\n", bsr->count);
-      Pmsg1(-1, "found       : %u\n", bsr->found);
+      Pmsg1(-1, _("count       : %u\n"), bsr->count);
+      Pmsg1(-1, _("found       : %u\n"), bsr->found);
    }
 
-   Pmsg1(-1,    "done        : %s\n", bsr->done?"yes":"no");
-   Pmsg1(-1,    "positioning : %d\n", bsr->use_positioning);
-   Pmsg1(-1,    "fast_reject : %d\n", bsr->use_fast_rejection);
+   Pmsg1(-1,    _("done        : %s\n"), bsr->done?_("yes"):_("no"));
+   Pmsg1(-1,    _("positioning : %d\n"), bsr->use_positioning);
+   Pmsg1(-1,    _("fast_reject : %d\n"), bsr->use_fast_rejection);
    if (recurse && bsr->next) {
       Pmsg0(-1, "\n");
       dump_bsr(bsr->next, true);
@@ -875,6 +904,8 @@ void create_restore_volume_list(JCR *jcr)
             vol = new_restore_volume();
             bstrncpy(vol->VolumeName, bsrvol->VolumeName, sizeof(vol->VolumeName));
             bstrncpy(vol->MediaType,  bsrvol->MediaType,  sizeof(vol->MediaType));
+            bstrncpy(vol->device, bsrvol->device, sizeof(vol->device));
+            vol->Slot = bsrvol->Slot;
             vol->start_file = sfile;
             if (add_restore_volume(jcr, vol)) {
                jcr->NumVolumes++;