From: Kern Sibbald Date: Wed, 2 May 2007 14:06:18 +0000 (+0000) Subject: Convert all other Dir files to use ne ua class message X-Git-Tag: Release-7.0.0~6452 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=47ad40918170fe3ea3b332094943603af94e17f2;p=bacula%2Fbacula Convert all other Dir files to use ne ua class message routines for bat. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4677 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index c1bb42c513..4b464bf92f 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -140,13 +140,13 @@ static bool is_volume_selected(RBSR_FINDEX *fi, static void print_findex(UAContext *ua, RBSR_FINDEX *fi) { - bsendmsg(ua, "fi=0x%lx\n", fi); + ua->send_msg("fi=0x%lx\n", fi); for ( ; fi; fi=fi->next) { if (fi->findex == fi->findex2) { - bsendmsg(ua, "FileIndex=%d\n", fi->findex); + ua->send_msg("FileIndex=%d\n", fi->findex); Dmsg1(1000, "FileIndex=%d\n", fi->findex); } else { - bsendmsg(ua, "FileIndex=%d-%d\n", fi->findex, fi->findex2); + ua->send_msg("FileIndex=%d-%d\n", fi->findex, fi->findex2); Dmsg2(1000, "FileIndex=%d-%d\n", fi->findex, fi->findex2); } } @@ -185,14 +185,14 @@ bool complete_bsr(UAContext *ua, RBSR *bsr) memset(&jr, 0, sizeof(jr)); jr.JobId = bsr->JobId; if (!db_get_job_record(ua->jcr, ua->db, &jr)) { - bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db)); + ua->error_msg(_("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db)); return false; } bsr->VolSessionId = jr.VolSessionId; bsr->VolSessionTime = jr.VolSessionTime; if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId, &(bsr->VolParams))) == 0) { - bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db)); + ua->error_msg(_("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db)); if (bsr->VolParams) { free(bsr->VolParams); bsr->VolParams = NULL; @@ -244,7 +244,7 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) fd = fopen(fname.c_str(), "w+b"); if (!fd) { berrno be; - bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), + ua->error_msg(_("Unable to create bootstrap file %s. ERR=%s\n"), fname.c_str(), be.strerror()); goto bail_out; } @@ -253,21 +253,21 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) err = ferror(fd); fclose(fd); if (count == 0) { - bsendmsg(ua, _("No files found to restore/migrate. No bootstrap file written.\n")); + ua->info_msg(_("No files found to restore/migrate. No bootstrap file written.\n")); goto bail_out; } if (err) { - bsendmsg(ua, _("Error writing bsr file.\n")); + ua->error_msg(_("Error writing bsr file.\n")); count = 0; goto bail_out; } - bsendmsg(ua, _("Bootstrap records written to %s\n"), fname.c_str()); + ua->send_msg(_("Bootstrap records written to %s\n"), fname.c_str()); /* Tell the user what he will need to mount */ - bsendmsg(ua, "\n"); - bsendmsg(ua, _("The job will require the following\n" + ua->send_msg("\n"); + ua->send_msg(_("The job will require the following\n" " Volume(s) Storage(s) SD Device(s)\n" "===========================================================================\n")); /* Create Unique list of Volumes using prompt list */ @@ -309,15 +309,15 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) } } for (int i=0; i < ua->num_prompts; i++) { - bsendmsg(ua, " %s\n", ua->prompt[i]); + ua->send_msg(" %s\n", ua->prompt[i]); free(ua->prompt[i]); } if (ua->num_prompts == 0) { - bsendmsg(ua, _("No Volumes found to restore.\n")); + ua->send_msg(_("No Volumes found to restore.\n")); count = 0; } ua->num_prompts = 0; - bsendmsg(ua, "\n"); + ua->send_msg("\n"); bail_out: return count; @@ -470,13 +470,13 @@ void print_bsr(UAContext *ua, RBSR *bsr) { for ( ; bsr; bsr=bsr->next) { for (int i=0; i < bsr->VolCount; i++) { - bsendmsg(ua, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); - bsendmsg(ua, "MediaType\"%s\"\n", bsr->VolParams[i].MediaType); - bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId); - bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime); - bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, + ua->send_msg("Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); + ua->send_msg("MediaType\"%s\"\n", bsr->VolParams[i].MediaType); + ua->send_msg("VolSessionId=%u\n", bsr->VolSessionId); + ua->send_msg("VolSessionTime=%u\n", bsr->VolSessionTime); + ua->send_msg("VolFile=%u-%u\n", bsr->VolParams[i].StartFile, bsr->VolParams[i].EndFile); - bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, + ua->send_msg("VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, bsr->VolParams[i].EndBlock); print_findex(ua, bsr->fi); } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 373033a03a..c76a1d7d8c 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -364,7 +364,7 @@ bool cancel_job(UAContext *ua, JCR *jcr) case JS_WaitPriority: case JS_WaitMaxJobs: case JS_WaitStartTime: - bsendmsg(ua, _("JobId %s, Job %s marked to be canceled.\n"), + ua->info_msg(_("JobId %s, Job %s marked to be canceled.\n"), edit_uint64(jcr->JobId, ed1), jcr->Job); jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */ return true; @@ -374,14 +374,14 @@ bool cancel_job(UAContext *ua, JCR *jcr) if (jcr->file_bsock) { ua->jcr->client = jcr->client; if (!connect_to_file_daemon(ua->jcr, 10, FDConnectTimeout, 1)) { - bsendmsg(ua, _("Failed to connect to File daemon.\n")); + ua->error_msg(_("Failed to connect to File daemon.\n")); return 0; } Dmsg0(200, "Connected to file daemon\n"); fd = ua->jcr->file_bsock; bnet_fsend(fd, "cancel Job=%s\n", jcr->Job); while (bnet_recv(fd) >= 0) { - bsendmsg(ua, "%s", fd->msg); + ua->send_msg("%s", fd->msg); } bnet_sig(fd, BNET_TERMINATE); bnet_close(fd); @@ -407,17 +407,17 @@ bool cancel_job(UAContext *ua, JCR *jcr) } if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) { - bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); + ua->error_msg(_("Failed to connect to Storage daemon.\n")); return false; } Dmsg0(200, "Connected to storage daemon\n"); sd = ua->jcr->store_bsock; - bnet_fsend(sd, "cancel Job=%s\n", jcr->Job); - while (bnet_recv(sd) >= 0) { - bsendmsg(ua, "%s", sd->msg); + sd->fsend("cancel Job=%s\n", jcr->Job); + while (sd->recv() >= 0) { + ua->send_msg("%s", sd->msg); } - bnet_sig(sd, BNET_TERMINATE); - bnet_close(sd); + sd->signal(BNET_TERMINATE); + sd->close(); ua->jcr->store_bsock = NULL; } } diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index e293b0abbb..4f8266371c 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -1,15 +1,7 @@ -/* - * - * Bacula Director -- Tape labeling commands - * - * Kern Sibbald, April MMIII - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2006 Free Software Foundation Europe e.V. + Copyright (C) 2003-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- Tape labeling commands + * + * Kern Sibbald, April MMIII + * + * Version $Id$ + */ #include "bacula.h" #include "dird.h" @@ -199,7 +199,7 @@ void update_slots(UAContext *ua) max_slots = get_num_slots_from_SD(ua); Dmsg1(100, "max_slots=%d\n", max_slots); if (max_slots <= 0) { - bsendmsg(ua, _("No slots in changer to scan.\n")); + ua->warning_msg(_("No slots in changer to scan.\n")); return; } slot_list = (char *)malloc(max_slots+1); @@ -211,7 +211,7 @@ void update_slots(UAContext *ua) vol_list = get_vol_list_from_SD(ua, scan); if (!vol_list) { - bsendmsg(ua, _("No Volumes found to label, or no barcodes.\n")); + ua->warning_msg(_("No Volumes found to label, or no barcodes.\n")); goto bail_out; } @@ -221,7 +221,7 @@ void update_slots(UAContext *ua) /* Walk through the list updating the media records */ for (vl=vol_list; vl; vl=vl->next) { if (vl->Slot > max_slots) { - bsendmsg(ua, _("Slot %d greater than max %d ignored.\n"), + ua->warning_msg(_("Slot %d greater than max %d ignored.\n"), vl->Slot, max_slots); continue; } @@ -250,7 +250,7 @@ void update_slots(UAContext *ua) db_unlock(ua->db); if (!vl->VolName) { Dmsg1(000, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot); - bsendmsg(ua, _("No VolName for Slot=%d InChanger set to zero.\n"), vl->Slot); + ua->info_msg(_("No VolName for Slot=%d InChanger set to zero.\n"), vl->Slot); continue; } memset(&mr, 0, sizeof(mr)); @@ -265,20 +265,20 @@ void update_slots(UAContext *ua) mr.Enabled = Enabled; } if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } else { - bsendmsg(ua, _( + ua->info_msg(_( "Catalog record for Volume \"%s\" updated to reference slot %d.\n"), mr.VolumeName, mr.Slot); } } else { - bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"), + ua->info_msg(_("Catalog record for Volume \"%s\" is up to date.\n"), mr.VolumeName); } db_unlock(ua->db); continue; } else { - bsendmsg(ua, _("Volume \"%s\" not found in catalog. Slot=%d InChanger set to zero.\n"), + ua->warning_msg(_("Volume \"%s\" not found in catalog. Slot=%d InChanger set to zero.\n"), mr.VolumeName, vl->Slot); } db_unlock(ua->db); @@ -365,7 +365,7 @@ static int do_label(UAContext *ua, const char *cmd, int relabel) if (db_get_media_record(ua->jcr, ua->db, &omr)) { goto checkVol; } - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } /* No keyword or Vol not found, ask user to select */ if (!select_media_dbr(ua, &omr)) { @@ -375,7 +375,7 @@ static int do_label(UAContext *ua, const char *cmd, int relabel) /* Require Volume to be Purged or Recycled */ checkVol: if (strcmp(omr.VolStatus, "Purged") != 0 && strcmp(omr.VolStatus, "Recycle") != 0) { - bsendmsg(ua, _("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"), + ua->error_msg(_("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"), omr.VolumeName, omr.VolStatus); return 1; } @@ -404,7 +404,7 @@ checkName: /* If VolBytes are zero the Volume is not labeled */ if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.VolBytes != 0) { - bsendmsg(ua, _("Media record for new Volume \"%s\" already exists.\n"), + ua->error_msg(_("Media record for new Volume \"%s\" already exists.\n"), mr.VolumeName); continue; } @@ -444,26 +444,26 @@ checkName: if (relabel) { /* Delete the old media record */ if (!db_delete_media_record(ua->jcr, ua->db, &omr)) { - bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"), + ua->error_msg(_("Delete of Volume \"%s\" failed. ERR=%s"), omr.VolumeName, db_strerror(ua->db)); } else { - bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"), + ua->info_msg(_("Old volume \"%s\" deleted from catalog.\n"), omr.VolumeName); /* Update the number of Volumes in the pool */ pr.NumVols--; if (!db_update_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } } } if (ua->automount) { bstrncpy(dev_name, store.store->dev_name(), sizeof(dev_name)); - bsendmsg(ua, _("Requesting to mount %s ...\n"), dev_name); + ua->info_msg(_("Requesting to mount %s ...\n"), dev_name); bash_spaces(dev_name); bnet_fsend(sd, "mount %s drive=%d", dev_name, drive); unbash_spaces(dev_name); while (bnet_recv(sd) >= 0) { - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); /* Here we can get * 3001 OK mount. Device=xxx or * 3001 Mounted Volume vvvv @@ -480,7 +480,7 @@ checkName: } } if (print_reminder) { - bsendmsg(ua, _("Do not forget to mount the drive!!!\n")); + ua->info_msg(_("Do not forget to mount the drive!!!\n")); } close_sd_bsock(ua); @@ -504,7 +504,7 @@ static void label_from_barcodes(UAContext *ua, int drive) max_slots = get_num_slots_from_SD(ua); if (max_slots <= 0) { - bsendmsg(ua, _("No slots in changer to scan.\n")); + ua->warning_msg(_("No slots in changer to scan.\n")); return; } slot_list = (char *)malloc(max_slots+1); @@ -515,19 +515,19 @@ static void label_from_barcodes(UAContext *ua, int drive) vol_list = get_vol_list_from_SD(ua, false /*no scan*/); if (!vol_list) { - bsendmsg(ua, _("No Volumes found to label, or no barcodes.\n")); + ua->warning_msg(_("No Volumes found to label, or no barcodes.\n")); goto bail_out; } /* Display list of Volumes and ask if he really wants to proceed */ - bsendmsg(ua, _("The following Volumes will be labeled:\n" + ua->send_msg(_("The following Volumes will be labeled:\n" "Slot Volume\n" "==============\n")); for (vl=vol_list; vl; vl=vl->next) { if (!vl->VolName || !slot_list[vl->Slot]) { continue; } - bsendmsg(ua, "%4d %s\n", vl->Slot, vl->VolName); + ua->send_msg("%4d %s\n", vl->Slot, vl->VolName); } if (!get_yesno(ua, _("Do you want to continue? (yes|no): ")) || (ua->pint32_val == 0)) { @@ -550,13 +550,13 @@ static void label_from_barcodes(UAContext *ua, int drive) media_record_exists = false; if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.VolBytes != 0) { - bsendmsg(ua, _("Media record for Slot %d Volume \"%s\" already exists.\n"), + ua->warning_msg(_("Media record for Slot %d Volume \"%s\" already exists.\n"), vl->Slot, mr.VolumeName); mr.Slot = vl->Slot; mr.InChanger = 1; mr.StorageId = store->StorageId; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, _("Error setting InChanger: ERR=%s"), db_strerror(ua->db)); + ua->error_msg(_("Error setting InChanger: ERR=%s"), db_strerror(ua->db)); } continue; } @@ -575,25 +575,25 @@ static void label_from_barcodes(UAContext *ua, int drive) mr.MediaType[0] = 0; mr.StorageId = store->StorageId; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } } else { /* create the media record */ if (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) { - bsendmsg(ua, _("Maximum pool Volumes=%d reached.\n"), pr.MaxVols); + ua->error_msg(_("Maximum pool Volumes=%d reached.\n"), pr.MaxVols); goto bail_out; } set_pool_dbr_defaults_in_media_dbr(&mr, &pr); bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus)); mr.MediaType[0] = 0; if (db_create_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"), + ua->send_msg(_("Catalog record for cleaning tape \"%s\" successfully created.\n"), mr.VolumeName); pr.NumVols++; /* this is a bit suspect */ if (!db_update_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } } else { - bsendmsg(ua, _("Catalog error on cleaning tape: %s"), db_strerror(ua->db)); + ua->error_msg(_("Catalog error on cleaning tape: %s"), db_strerror(ua->db)); } } continue; /* done, go handle next volume */ @@ -629,20 +629,20 @@ bool is_volume_name_legal(UAContext *ua, const char *name) continue; } if (ua) { - bsendmsg(ua, _("Illegal character \"%c\" in a volume name.\n"), *p); + ua->error_msg(_("Illegal character \"%c\" in a volume name.\n"), *p); } return 0; } len = strlen(name); if (len >= MAX_NAME_LENGTH) { if (ua) { - bsendmsg(ua, _("Volume name too long.\n")); + ua->error_msg(_("Volume name too long.\n")); } return 0; } if (len == 0) { if (ua) { - bsendmsg(ua, _("Volume name must be at least one character long.\n")); + ua->error_msg(_("Volume name must be at least one character long.\n")); } return 0; } @@ -676,14 +676,14 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, "MediaType=%s Slot=%d drive=%d", dev_name, omr->VolumeName, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot, drive); - bsendmsg(ua, _("Sending relabel command from \"%s\" to \"%s\" ...\n"), + ua->send_msg(_("Sending relabel command from \"%s\" to \"%s\" ...\n"), omr->VolumeName, mr->VolumeName); } else { bnet_fsend(sd, "label %s VolumeName=%s PoolName=%s MediaType=%s " "Slot=%d drive=%d", dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot, drive); - bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"), + ua->send_msg(_("Sending label command for Volume \"%s\" Slot %d ...\n"), mr->VolumeName, mr->Slot); Dmsg6(100, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d drive=%d\n", dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot, drive); @@ -691,7 +691,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, while (bnet_recv(sd) >= 0) { int dvd; - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu DVD=%d ", &VolBytes, &dvd) == 2) { is_dvd = dvd; @@ -714,7 +714,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, mr->InChanger = 1; mr->StorageId = ua->jcr->wstore->StorageId; if (!db_update_media_record(ua->jcr, ua->db, mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); ok = false; } } else { /* create the media record */ @@ -724,20 +724,20 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, mr->StorageId = ua->jcr->wstore->StorageId; mr->Enabled = 1; if (db_create_media_record(ua->jcr, ua->db, mr)) { - bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), + ua->info_msg(_("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), mr->VolumeName, mr->Slot); /* Update number of volumes in pool */ pr->NumVols++; if (!db_update_pool_record(ua->jcr, ua->db, pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } } else { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); ok = false; } } } else { - bsendmsg(ua, _("Label command failed for Volume %s.\n"), mr->VolumeName); + ua->error_msg(_("Label command failed for Volume %s.\n"), mr->VolumeName); } return ok; } @@ -747,10 +747,10 @@ static BSOCK *open_sd_bsock(UAContext *ua) STORE *store = ua->jcr->wstore; if (!ua->jcr->store_bsock) { - bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d ...\n"), + ua->send_msg(_("Connecting to Storage daemon %s at %s:%d ...\n"), store->name(), store->address, store->SDport); if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) { - bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); + ua->error_msg(_("Failed to connect to Storage daemon.\n")); return NULL; } } @@ -775,7 +775,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot, int drive) int rtn_slot; if (!(sd=open_sd_bsock(ua))) { - bsendmsg(ua, _("Could not open SD socket.\n")); + ua->error_msg(_("Could not open SD socket.\n")); return NULL; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -786,7 +786,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot, int drive) /* Get Volume name in this Slot */ while (bnet_recv(sd) >= 0) { - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); Dmsg1(100, "Got: %s", sd->msg); if (strncmp(sd->msg, NT_("3001 Volume="), 12) == 0) { VolName = (char *)malloc(sd->msglen); @@ -835,7 +835,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) if (sd->msg[0] == '3' && B_ISDIGIT(sd->msg[1]) && B_ISDIGIT(sd->msg[2]) && B_ISDIGIT(sd->msg[3]) && sd->msg[4] == ' ') { - bsendmsg(ua, "%s\n", sd->msg); /* pass them on to user */ + ua->send_msg("%s\n", sd->msg); /* pass them on to user */ continue; } @@ -847,7 +847,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) if (Slot <= 0) { p--; *p = ':'; - bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); + ua->error_msg(_("Invalid Slot number: %s\n"), sd->msg); continue; } } else { @@ -857,7 +857,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) if (!is_an_integer(sd->msg) || (Slot=atoi(sd->msg)) <= 0) { p--; *p = ':'; - bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); + ua->error_msg(_("Invalid Slot number: %s\n"), sd->msg); continue; } } else { @@ -866,7 +866,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) if (!is_volume_name_legal(ua, p)) { p--; *p = ':'; - bsendmsg(ua, _("Invalid Volume name: %s\n"), sd->msg); + ua->error_msg(_("Invalid Volume name: %s\n"), sd->msg); continue; } } @@ -941,11 +941,11 @@ static int get_num_slots_from_SD(UAContext *ua) if (sscanf(sd->msg, "slots=%d\n", &slots) == 1) { break; } else { - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); } } close_sd_bsock(ua); - bsendmsg(ua, _("Device \"%s\" has %d slots.\n"), store->dev_name(), slots); + ua->send_msg(_("Device \"%s\" has %d slots.\n"), store->dev_name(), slots); return slots; } @@ -973,7 +973,7 @@ int get_num_drives_from_SD(UAContext *ua) if (sscanf(sd->msg, NT_("drives=%d\n"), &drives) == 1) { break; } else { - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); } } close_sd_bsock(ua); @@ -994,7 +994,7 @@ static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr) /* Find Pool resource */ ua->jcr->pool = (POOL *)GetResWithName(R_POOL, pr->Name); if (!ua->jcr->pool) { - bsendmsg(ua, _("Pool \"%s\" resource not found for volume \"%s\"!\n"), + ua->error_msg(_("Pool \"%s\" resource not found for volume \"%s\"!\n"), pr->Name, mr->VolumeName); return false; } diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index e6d77d67eb..324c53cea3 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -70,7 +70,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd) ua->auto_display_messages = false; break; default: - bsendmsg(ua, _("ON or OFF keyword missing.\n")); + ua->error_msg(_("ON or OFF keyword missing.\n")); break; } return 1; @@ -94,7 +94,7 @@ int gui_cmd(UAContext *ua, const char *cmd) ua->jcr->gui = ua->gui = false; break; default: - bsendmsg(ua, _("ON or OFF keyword missing.\n")); + ua->error_msg(_("ON or OFF keyword missing.\n")); break; } return 1; @@ -182,16 +182,16 @@ int show_cmd(UAContext *ua, const char *cmd) } break; case -2: - bsendmsg(ua, _("Keywords for the show command are:\n")); + ua->send_msg(_("Keywords for the show command are:\n")); for (j=0; reses[j].res_name; j++) { - bsendmsg(ua, "%s\n", _(reses[j].res_name)); + ua->error_msg("%s\n", _(reses[j].res_name)); } goto bail_out; case -3: - bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]); + ua->error_msg(_("%s resource %s not found.\n"), res_name, ua->argv[i]); goto bail_out; case 0: - bsendmsg(ua, _("Resource %s not found\n"), res_name); + ua->error_msg(_("Resource %s not found\n"), res_name); goto bail_out; default: dump_resource(recurse?type:-type, res, bsendmsg, ua); @@ -259,7 +259,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) Dmsg1(20, "list: %s\n", cmd); if (!ua->db) { - bsendmsg(ua, _("Hey! DB is NULL\n")); + ua->error_msg(_("Hey! DB is NULL\n")); } /* Scan arguments looking for things to do */ @@ -373,7 +373,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) } VolumeName = get_pool_memory(PM_FNAME); n = db_get_job_volume_names(ua->jcr, ua->db, jobid, &VolumeName); - bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName); + ua->send_msg(_("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName); free_pool_memory(VolumeName); done = true; } @@ -391,7 +391,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) for (i=1; iargc; i++) { if (strcasecmp(ua->argk[i], NT_("pool")) == 0) { if (!get_pool_dbr(ua, &pr)) { - bsendmsg(ua, _("No Pool specified.\n")); + ua->error_msg(_("No Pool specified.\n")); return 1; } mr.PoolId = pr.PoolId; @@ -402,7 +402,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) /* List Volumes in all pools */ if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { - bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"), + ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); return 1; } @@ -412,7 +412,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) for (i=0; i < num_pools; i++) { pr.PoolId = ids[i]; if (db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, _("Pool: %s\n"), pr.Name); + ua->send_msg(_("Pool: %s\n"), pr.Name); } mr.PoolId = ids[i]; db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist); @@ -428,7 +428,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) if (j >= 0) { n = atoi(ua->argv[j]); if ((n < 0) || (n > 50)) { - bsendmsg(ua, _("Ignoring invalid value for days. Max is 50.\n")); + ua->warning_msg(_("Ignoring invalid value for days. Max is 50.\n")); n = 1; } } @@ -437,7 +437,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) || strcasecmp(ua->argk[i], NT_("days")) == 0) { /* Ignore it */ } else { - bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i])); + ua->error_msg(_("Unknown list keyword: %s\n"), NPRT(ua->argk[i])); } } return 1; @@ -482,10 +482,10 @@ static bool list_nextvol(UAContext *ua, int ndays) get_job_storage(&store, job, run); mr.StorageId = store.store->StorageId; if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) { - bsendmsg(ua, _("Could not find next Volume for Job %s (%s, %s).\n"), + ua->error_msg(_("Could not find next Volume for Job %s (%s, %s).\n"), job->hdr.name, pr.Name, level_to_str(run->level)); } else { - bsendmsg(ua, + ua->send_msg( _("The next Volume to be used by Job \"%s\" (%s, %s) will be %s\n"), job->hdr.name, pr.Name, level_to_str(run->level), mr.VolumeName); found = true; @@ -496,7 +496,7 @@ static bool list_nextvol(UAContext *ua, int ndays) } } if (!found) { - bsendmsg(ua, _("Could not find next Volume for Job %s.\n"), + ua->error_msg(_("Could not find next Volume for Job %s.\n"), job->hdr.name); return false; } diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 31e62e0389..de27693dde 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -153,8 +153,9 @@ int prunecmd(UAContext *ua, const char *cmd) return false; } if (mr.Enabled == 2) { - bsendmsg(ua, _("Cannot prune Volume \"%s\" because it is archived.\n"), + ua->error_msg(_("Cannot prune Volume \"%s\" because it is archived.\n"), mr.VolumeName); + return false; } if (!confirm_retention(ua, &mr.VolRetention, "Volume")) { return false; @@ -207,14 +208,14 @@ int prune_files(UAContext *ua, CLIENT *client) (uint32_t)period, query.c_str()); cnt.count = 0; if (!db_sql_query(ua->db, query.c_str(), del_count_handler, (void *)&cnt)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); goto bail_out; } if (cnt.count == 0) { if (ua->verbose) { - bsendmsg(ua, _("No Files found to prune.\n")); + ua->warning_msg(_("No Files found to prune.\n")); } goto bail_out; } @@ -236,7 +237,7 @@ int prune_files(UAContext *ua, CLIENT *client) purge_files_from_job_list(ua, del); edit_uint64_with_commas(del.num_del, ed1); - bsendmsg(ua, _("Pruned Files from %s Jobs for client %s from catalog.\n"), + ua->info_msg(_("Pruned Files from %s Jobs for client %s from catalog.\n"), ed1, client->name()); bail_out: @@ -262,7 +263,7 @@ static bool create_temp_tables(UAContext *ua) /* Create temp tables and indicies */ for (i=0; create_deltabs[i]; i++) { if (!db_sql_query(ua->db, create_deltabs[i], NULL, (void *)NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); Dmsg0(050, "create DelTables table failed\n"); return false; } @@ -322,7 +323,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) edit_int64(cr.ClientId, ed2)); if (!db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL)) { if (ua->verbose) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } Dmsg0(050, "insert delcand failed\n"); goto bail_out; @@ -354,16 +355,16 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) Dmsg1(150, "Query=%s\n", query.c_str()); if (!db_sql_query(ua->db, query.c_str(), job_delete_handler, (void *)&del)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } purge_job_list_from_catalog(ua, del); if (del.num_del > 0) { - bsendmsg(ua, _("Pruned %d %s for client %s from catalog.\n"), del.num_del, + ua->info_msg(_("Pruned %d %s for client %s from catalog.\n"), del.num_del, del.num_del==1?_("Job"):_("Jobs"), client->name()); } else if (ua->verbose) { - bsendmsg(ua, _("No Jobs found to prune.\n")); + ua->info_msg(_("No Jobs found to prune.\n")); } bail_out: @@ -448,7 +449,7 @@ int get_prune_list_for_volume(UAContext *ua, MEDIA_DBR *mr, del_ctx *del) Dmsg1(050, "Query=%s\n", query.c_str()); if (!db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)del)) { if (ua->verbose) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); } Dmsg0(050, "Count failed\n"); goto bail_out; diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 9acacd363d..30485d3f90 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -143,7 +143,7 @@ int purgecmd(UAContext *ua, const char *cmd) purge_jobs_from_volume(ua, &mr); } *ua->argk[i] = 0; /* zap keyword already seen */ - bsendmsg(ua, "\n"); + ua->send_msg("\n"); } return 1; default: diff --git a/bacula/src/dird/ua_query.c b/bacula/src/dird/ua_query.c index 4cac6c2ea2..83d6cee13d 100644 --- a/bacula/src/dird/ua_query.c +++ b/bacula/src/dird/ua_query.c @@ -69,7 +69,7 @@ int querycmd(UAContext *ua, const char *cmd) goto bail_out; } if ((fd=fopen(query_file, "rb")) == NULL) { - bsendmsg(ua, _("Could not open %s: ERR=%s\n"), query_file, + ua->error_msg(_("Could not open %s: ERR=%s\n"), query_file, strerror(errno)); goto bail_out; } @@ -95,7 +95,7 @@ int querycmd(UAContext *ua, const char *cmd) } } if (i != item) { - bsendmsg(ua, _("Could not find query.\n")); + ua->error_msg(_("Could not find query.\n")); goto bail_out; } query[0] = 0; @@ -113,7 +113,7 @@ int querycmd(UAContext *ua, const char *cmd) len = strlen(line); if (line[0] == '*') { /* prompt */ if (nprompt >= 9) { - bsendmsg(ua, _("Too many prompts in query, max is 9.\n")); + ua->error_msg(_("Too many prompts in query, max is 9.\n")); } else { line[len++] = ' '; line[len] = 0; @@ -135,7 +135,7 @@ int querycmd(UAContext *ua, const char *cmd) if (query[0] == '!') { db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST); } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) { - bsendmsg(ua, "%s\n", query); + ua->send_msg("%s\n", query); } query[0] = 0; } @@ -147,7 +147,7 @@ int querycmd(UAContext *ua, const char *cmd) if (query[0] == '!') { db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST); } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) { - bsendmsg(ua, "%s\n", query); + ua->error_msg("%s\n", query); } } @@ -216,7 +216,7 @@ static POOLMEM *substitute_prompts(UAContext *ua, *o++ = *p++; } } else { - bsendmsg(ua, _("Warning prompt %d missing.\n"), n+1); + ua->error_msg(_("Warning prompt %d missing.\n"), n+1); } q += 2; break; @@ -261,7 +261,7 @@ int sqlquerycmd(UAContext *ua, const char *cmd) } *query.c_str() = 0; - bsendmsg(ua, _("Entering SQL query mode.\n" + ua->send_msg(_("Entering SQL query mode.\n" "Terminate each query with a semicolon.\n" "Terminate query mode with a blank line.\n")); msg = _("Enter SQL query: "); @@ -285,6 +285,6 @@ int sqlquerycmd(UAContext *ua, const char *cmd) msg = _("Add to SQL query: "); } } - bsendmsg(ua, _("End query mode.\n")); + ua->send_msg(_("End query mode.\n")); return 1; } diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index ae5f9b989d..6fa39efdf0 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -52,7 +52,7 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg) int yes_in_arg = find_arg(ua, NT_("yes")); for ( ;; ) { - bsendmsg(ua, _("The current %s retention period is: %s\n"), + ua->info_msg(_("The current %s retention period is: %s\n"), msg, edit_utime(*ret, ed1, sizeof(ed1))); if (yes_in_arg != -1) { return 1; @@ -65,7 +65,7 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg) return 0; } if (!duration_to_utime(ua->cmd, ret)) { - bsendmsg(ua, _("Invalid period.\n")); + ua->error_msg(_("Invalid period.\n")); continue; } continue; @@ -218,10 +218,10 @@ CAT *get_catalog_resource(UAContext *ua) catalog = (CAT *)GetNextRes(R_CATALOG, NULL); UnlockRes(); if (!catalog) { - bsendmsg(ua, _("Could not find a Catalog resource\n")); + ua->error_msg(_("Could not find a Catalog resource\n")); return NULL; } else if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) { - bsendmsg(ua, _("You must specify a \"use \" command before continuing.\n")); + ua->error_msg(_("You must specify a \"use \" command before continuing.\n")); return NULL; } return catalog; @@ -335,7 +335,7 @@ CLIENT *get_client_resource(UAContext *ua) if (client) { return client; } - bsendmsg(ua, _("Error: Client resource %s does not exist.\n"), ua->argv[i]); + ua->error_msg(_("Error: Client resource %s does not exist.\n"), ua->argv[i]); break; } } @@ -360,7 +360,7 @@ int get_client_dbr(UAContext *ua, CLIENT_DBR *cr) if (db_get_client_record(ua->jcr, ua->db, cr)) { return 1; } - bsendmsg(ua, _("Could not find Client %s: ERR=%s"), cr->Name, db_strerror(ua->db)); + ua->error_msg(_("Could not find Client %s: ERR=%s"), cr->Name, db_strerror(ua->db)); } for (i=1; iargc; i++) { if ((strcasecmp(ua->argk[i], NT_("client")) == 0 || @@ -370,7 +370,7 @@ int get_client_dbr(UAContext *ua, CLIENT_DBR *cr) } bstrncpy(cr->Name, ua->argv[i], sizeof(cr->Name)); if (!db_get_client_record(ua->jcr, ua->db, cr)) { - bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i], + ua->error_msg(_("Could not find Client \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); cr->ClientId = 0; break; @@ -399,11 +399,11 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr) cr->ClientId = 0; if (!db_get_client_ids(ua->jcr, ua->db, &num_clients, &ids)) { - bsendmsg(ua, _("Error obtaining client ids. ERR=%s\n"), db_strerror(ua->db)); + ua->error_msg(_("Error obtaining client ids. ERR=%s\n"), db_strerror(ua->db)); return 0; } if (num_clients <= 0) { - bsendmsg(ua, _("No clients defined. You must run a job before using this command.\n")); + ua->error_msg(_("No clients defined. You must run a job before using this command.\n")); return 0; } @@ -424,7 +424,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr) bstrncpy(ocr.Name, name, sizeof(ocr.Name)); if (!db_get_client_record(ua->jcr, ua->db, &ocr)) { - bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), name, db_strerror(ua->db)); + ua->error_msg(_("Could not find Client \"%s\": ERR=%s"), name, db_strerror(ua->db)); return 0; } memcpy(cr, &ocr, sizeof(ocr)); @@ -450,7 +450,7 @@ bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) acl_access_ok(ua, Pool_ACL, pr->Name)) { return true; } - bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), pr->Name, db_strerror(ua->db)); + ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), pr->Name, db_strerror(ua->db)); } if (!select_pool_dbr(ua, pr, argk)) { /* try once more */ return false; @@ -474,7 +474,7 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) acl_access_ok(ua, Pool_ACL, ua->argv[i])) { bstrncpy(pr->Name, ua->argv[i], sizeof(pr->Name)); if (!db_get_pool_record(ua->jcr, ua->db, pr)) { - bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i], + ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); pr->PoolId = 0; break; @@ -485,11 +485,11 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) pr->PoolId = 0; if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { - bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); + ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); return 0; } if (num_pools <= 0) { - bsendmsg(ua, _("No pools defined. Use the \"create\" command to create one.\n")); + ua->error_msg(_("No pools defined. Use the \"create\" command to create one.\n")); return false; } @@ -510,7 +510,7 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) bstrncpy(opr.Name, name, sizeof(opr.Name)); if (!db_get_pool_record(ua->jcr, ua->db, &opr)) { - bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db)); + ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db)); return false; } memcpy(pr, &opr, sizeof(opr)); @@ -529,11 +529,11 @@ int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr) memset(pr, 0, sizeof(POOL_DBR)); pr->PoolId = mr->PoolId; if (!db_get_pool_record(ua->jcr, ua->db, pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); return 0; } if (!acl_access_ok(ua, Pool_ACL, pr->Name)) { - bsendmsg(ua, _("No access to Pool \"%s\"\n"), pr->Name); + ua->error_msg(_("No access to Pool \"%s\"\n"), pr->Name); return 0; } return 1; @@ -570,7 +570,7 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr) } if (!db_get_media_record(ua->jcr, ua->db, mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); return 0; } return 1; @@ -617,7 +617,7 @@ POOL *get_pool_resource(UAContext *ua) if (pool) { return pool; } - bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]); + ua->error_msg(_("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]); } return select_pool_resource(ua); } @@ -633,7 +633,7 @@ int select_job_dbr(UAContext *ua, JOB_DBR *jr) } jr->JobId = ua->int64_val; if (!db_get_job_record(ua->jcr, ua->db, jr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + ua->error_msg("%s", db_strerror(ua->db)); return 0; } return jr->JobId; @@ -666,7 +666,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr) continue; } if (!db_get_job_record(ua->jcr, ua->db, jr)) { - bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i], + ua->error_msg(_("Could not find Job \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); jr->JobId = 0; break; @@ -746,22 +746,22 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, if (prompt) { bstrncpy(prompt, ua->prompt[1], max_prompt); } - bsendmsg(ua, _("Automatically selected %s: %s\n"), automsg, ua->prompt[1]); + ua->send_msg(_("Automatically selected %s: %s\n"), automsg, ua->prompt[1]); goto done; } /* If running non-interactive, bail out */ if (ua->batch) { - bsendmsg(ua, _("Cannot select %s in batch mode.\n"), automsg); + ua->send_msg(_("Cannot select %s in batch mode.\n"), automsg); item = -1; goto done; } if (ua->api) user->signal(BNET_START_SELECT); - bsendmsg(ua, ua->prompt[0]); + ua->send_msg(ua->prompt[0]); for (i=1; i < ua->num_prompts; i++) { if (ua->api) { - bsendmsg(ua, "%s", ua->prompt[i]); + ua->send_msg("%s", ua->prompt[i]); } else { - bsendmsg(ua, "%6d: %s\n", i, ua->prompt[i]); + ua->send_msg("%6d: %s\n", i, ua->prompt[i]); } } if (ua->api) user->signal(BNET_END_SELECT); @@ -769,13 +769,13 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, for ( ;; ) { /* First item is the prompt string, not the items */ if (ua->num_prompts == 1) { - bsendmsg(ua, _("Selection list for \"%s\" is empty!\n"), automsg); + ua->error_msg(_("Selection list for \"%s\" is empty!\n"), automsg); item = -1; /* list is empty ! */ break; } if (ua->num_prompts == 2) { item = 1; - bsendmsg(ua, _("Automatically selected: %s\n"), ua->prompt[1]); + ua->send_msg(_("Automatically selected: %s\n"), ua->prompt[1]); if (prompt) { bstrncpy(prompt, ua->prompt[1], max_prompt); } @@ -787,12 +787,12 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, if (ua->api) user->signal(BNET_SELECT_INPUT); if (!get_pint(ua, pmsg)) { item = -1; /* error */ - bsendmsg(ua, _("Selection aborted, nothing done.\n")); + ua->info_msg(_("Selection aborted, nothing done.\n")); break; } item = ua->pint32_val; if (item < 1 || item >= ua->num_prompts) { - bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1); + ua->warning_msg(_("Please enter a number between 1 and %d\n"), ua->num_prompts-1); continue; } if (prompt) { @@ -841,7 +841,7 @@ STORE *get_storage_resource(UAContext *ua, bool use_default) } /* Default argument is storage */ if (store_name) { - bsendmsg(ua, _("Storage name given twice.\n")); + ua->error_msg(_("Storage name given twice.\n")); return NULL; } store_name = ua->argk[i]; @@ -858,11 +858,11 @@ STORE *get_storage_resource(UAContext *ua, bool use_default) } else if (strcasecmp(ua->argk[i], NT_("jobid")) == 0) { jobid = str_to_int64(ua->argv[i]); if (jobid <= 0) { - bsendmsg(ua, _("Expecting jobid=nn command, got: %s\n"), ua->argk[i]); + ua->error_msg(_("Expecting jobid=nn command, got: %s\n"), ua->argk[i]); return NULL; } if (!(jcr=get_jcr_by_id(jobid))) { - bsendmsg(ua, _("JobId %s is not running.\n"), edit_int64(jobid, ed1)); + ua->error_msg(_("JobId %s is not running.\n"), edit_int64(jobid, ed1)); return NULL; } store = jcr->wstore; @@ -872,11 +872,11 @@ STORE *get_storage_resource(UAContext *ua, bool use_default) } else if (strcasecmp(ua->argk[i], NT_("job")) == 0 || strcasecmp(ua->argk[i], NT_("jobname")) == 0) { if (!ua->argv[i]) { - bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]); + ua->error_msg(_("Expecting job=xxx, got: %s.\n"), ua->argk[i]); return NULL; } if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) { - bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]); + ua->error_msg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } store = jcr->wstore; @@ -884,11 +884,11 @@ STORE *get_storage_resource(UAContext *ua, bool use_default) break; } else if (strcasecmp(ua->argk[i], NT_("ujobid")) == 0) { if (!ua->argv[i]) { - bsendmsg(ua, _("Expecting ujobid=xxx, got: %s.\n"), ua->argk[i]); + ua->error_msg(_("Expecting ujobid=xxx, got: %s.\n"), ua->argk[i]); return NULL; } if (!(jcr=get_jcr_by_full_name(ua->argv[i]))) { - bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]); + ua->error_msg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } store = jcr->wstore; @@ -904,7 +904,7 @@ STORE *get_storage_resource(UAContext *ua, bool use_default) if (!store && store_name && store_name[0] != 0) { store = (STORE *)GetResWithName(R_STORAGE, store_name); if (!store) { - bsendmsg(ua, _("Storage resource \"%s\": not found\n"), store_name); + ua->error_msg(_("Storage resource \"%s\": not found\n"), store_name); } } if (store && !acl_access_ok(ua, Storage_ACL, store->name())) { diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index a99280d286..6cf7e3e8ac 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -62,30 +62,30 @@ bool dot_status_cmd(UAContext *ua, const char *cmd) Dmsg1(20, "status:%s:\n", cmd); if ((ua->argc != 3) || (strcasecmp(ua->argk[1], "dir"))) { - bsendmsg(ua, "1900 Bad .status command, missing arguments.\n"); + ua->send_msg("1900 Bad .status command, missing arguments.\n"); return false; } if (strcasecmp(ua->argk[2], "current") == 0) { - bsendmsg(ua, OKqstatus, ua->argk[2]); + ua->send_msg(OKqstatus, ua->argk[2]); foreach_jcr(njcr) { if (njcr->JobId != 0 && acl_access_ok(ua, Job_ACL, njcr->job->name())) { - bsendmsg(ua, DotStatusJob, edit_int64(njcr->JobId, ed1), + ua->send_msg(DotStatusJob, edit_int64(njcr->JobId, ed1), njcr->JobStatus, njcr->JobErrors); } } endeach_jcr(njcr); } else if (strcasecmp(ua->argk[2], "last") == 0) { - bsendmsg(ua, OKqstatus, ua->argk[2]); + ua->send_msg(OKqstatus, ua->argk[2]); if ((last_jobs) && (last_jobs->size() > 0)) { job = (s_last_job*)last_jobs->last(); if (acl_access_ok(ua, Job_ACL, job->Job)) { - bsendmsg(ua, DotStatusJob, edit_int64(job->JobId, ed1), + ua->send_msg(DotStatusJob, edit_int64(job->JobId, ed1), job->JobStatus, job->Errors); } } } else { - bsendmsg(ua, "1900 Bad .status command, wrong argument.\n"); + ua->send_msg("1900 Bad .status command, wrong argument.\n"); return false; } @@ -258,17 +258,17 @@ static void do_director_status(UAContext *ua) char dt[MAX_TIME_LENGTH]; char b1[35], b2[35], b3[35], b4[35]; - bsendmsg(ua, _("%s Version: %s (%s) %s %s %s\n"), my_name, VERSION, BDATE, + ua->send_msg(_("%s Version: %s (%s) %s %s %s\n"), my_name, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER); bstrftime_nc(dt, sizeof(dt), daemon_start_time); if (num_jobs_run == 1) { - bsendmsg(ua, _("Daemon started %s, 1 Job run since started.\n"), dt); + ua->send_msg(_("Daemon started %s, 1 Job run since started.\n"), dt); } else { - bsendmsg(ua, _("Daemon started %s, %d Jobs run since started.\n"), + ua->send_msg(_("Daemon started %s, %d Jobs run since started.\n"), dt, num_jobs_run); } - bsendmsg(ua, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), + ua->send_msg(_(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), edit_uint64_with_commas(sm_bytes, b1), edit_uint64_with_commas(sm_max_bytes, b2), edit_uint64_with_commas(sm_buffers, b3), @@ -288,7 +288,7 @@ static void do_director_status(UAContext *ua) * List terminated jobs */ list_terminated_jobs(ua); - bsendmsg(ua, _("====\n")); + ua->send_msg(_("====\n")); } static void do_storage_status(UAContext *ua, STORE *store) @@ -300,10 +300,10 @@ static void do_storage_status(UAContext *ua, STORE *store) pm_strcpy(lstore.store_source, _("unknown source")); set_wstorage(ua->jcr, &lstore); /* Try connecting for up to 15 seconds */ - bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), + ua->send_msg(_("Connecting to Storage daemon %s at %s:%d\n"), store->name(), store->address, store->SDport); if (!connect_to_storage_daemon(ua->jcr, 1, 15, 0)) { - bsendmsg(ua, _("\nFailed to connect to Storage daemon %s.\n====\n"), + ua->send_msg(_("\nFailed to connect to Storage daemon %s.\n====\n"), store->name()); if (ua->jcr->store_bsock) { bnet_close(ua->jcr->store_bsock); @@ -315,7 +315,7 @@ static void do_storage_status(UAContext *ua, STORE *store) sd = ua->jcr->store_bsock; bnet_fsend(sd, "status"); while (bnet_recv(sd) >= 0) { - bsendmsg(ua, "%s", sd->msg); + ua->send_msg("%s", sd->msg); } bnet_sig(sd, BNET_TERMINATE); bnet_close(sd); @@ -338,10 +338,10 @@ static void do_client_status(UAContext *ua, CLIENT *client) ua->jcr->sd_auth_key = bstrdup("dummy"); /* Try to connect for 15 seconds */ - bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), + ua->send_msg(_("Connecting to Client %s at %s:%d\n"), client->name(), client->address, client->FDport); if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) { - bsendmsg(ua, _("Failed to connect to Client %s.\n====\n"), + ua->send_msg(_("Failed to connect to Client %s.\n====\n"), client->name()); if (ua->jcr->file_bsock) { bnet_close(ua->jcr->file_bsock); @@ -353,7 +353,7 @@ static void do_client_status(UAContext *ua, CLIENT *client) fd = ua->jcr->file_bsock; bnet_fsend(fd, "status"); while (bnet_recv(fd) >= 0) { - bsendmsg(ua, "%s", fd->msg); + ua->send_msg("%s", fd->msg); } bnet_sig(fd, BNET_TERMINATE); bnet_close(fd); @@ -364,9 +364,9 @@ static void do_client_status(UAContext *ua, CLIENT *client) static void prt_runhdr(UAContext *ua) { - bsendmsg(ua, _("\nScheduled Jobs:\n")); - bsendmsg(ua, _("Level Type Pri Scheduled Name Volume\n")); - bsendmsg(ua, _("===================================================================================\n")); + ua->send_msg(_("\nScheduled Jobs:\n")); + ua->send_msg(_("Level Type Pri Scheduled Name Volume\n")); + ua->send_msg(_("===================================================================================\n")); } /* Scheduling packet */ @@ -418,7 +418,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) level_ptr = level_to_str(sp->level); break; } - bsendmsg(ua, _("%-14s %-8s %3d %-18s %-18s %s\n"), + ua->send_msg(_("%-14s %-8s %3d %-18s %-18s %s\n"), level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt, sp->job->name(), mr.VolumeName); if (close_db) { @@ -470,7 +470,7 @@ static void list_scheduled_jobs(UAContext *ua) if (i >= 0) { days = atoi(ua->argv[i]); if ((days < 0) || (days > 50)) { - bsendmsg(ua, _("Ignoring invalid value for days. Max is 50.\n")); + ua->send_msg(_("Ignoring invalid value for days. Max is 50.\n")); days = 1; } } @@ -513,9 +513,9 @@ static void list_scheduled_jobs(UAContext *ua) prt_runtime(ua, sp); } if (num_jobs == 0) { - bsendmsg(ua, _("No Scheduled Jobs.\n")); + ua->send_msg(_("No Scheduled Jobs.\n")); } - bsendmsg(ua, _("====\n")); + ua->send_msg(_("====\n")); Dmsg0(200, "Leave list_sched_jobs_runs()\n"); } @@ -530,7 +530,7 @@ static void list_running_jobs(UAContext *ua) bool pool_mem = false; Dmsg0(200, "enter list_run_jobs()\n"); - bsendmsg(ua, _("\nRunning Jobs:\n")); + ua->send_msg(_("\nRunning Jobs:\n")); foreach_jcr(jcr) { if (jcr->JobId == 0) { /* this is us */ /* this is a console or other control job. We only show console @@ -538,7 +538,7 @@ static void list_running_jobs(UAContext *ua) */ if (jcr->JobType == JT_CONSOLE) { bstrftime_nc(dt, sizeof(dt), jcr->start_time); - bsendmsg(ua, _("Console connected at %s\n"), dt); + ua->send_msg(_("Console connected at %s\n"), dt); } continue; } @@ -548,13 +548,13 @@ static void list_running_jobs(UAContext *ua) if (njobs == 0) { /* Note the following message is used in regress -- don't change */ - bsendmsg(ua, _("No Jobs running.\n====\n")); + ua->send_msg(_("No Jobs running.\n====\n")); Dmsg0(200, "leave list_run_jobs()\n"); return; } njobs = 0; - bsendmsg(ua, _(" JobId Level Name Status\n")); - bsendmsg(ua, _("======================================================================\n")); + ua->send_msg(_(" JobId Level Name Status\n")); + ua->send_msg(_("======================================================================\n")); foreach_jcr(jcr) { if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->name())) { continue; @@ -669,7 +669,7 @@ static void list_running_jobs(UAContext *ua) break; } - bsendmsg(ua, _("%6d %-6s %-20s %s\n"), + ua->send_msg(_("%6d %-6s %-20s %s\n"), jcr->JobId, level, jcr->Job, @@ -681,7 +681,7 @@ static void list_running_jobs(UAContext *ua) } } endeach_jcr(jcr); - bsendmsg(ua, _("====\n")); + ua->send_msg(_("====\n")); Dmsg0(200, "leave list_run_jobs()\n"); } @@ -691,14 +691,14 @@ static void list_terminated_jobs(UAContext *ua) char level[10]; if (last_jobs->empty()) { - bsendmsg(ua, _("No Terminated Jobs.\n")); + ua->send_msg(_("No Terminated Jobs.\n")); return; } lock_last_jobs_list(); struct s_last_job *je; - bsendmsg(ua, _("\nTerminated Jobs:\n")); - bsendmsg(ua, _(" JobId Level Files Bytes Status Finished Name \n")); - bsendmsg(ua, _("====================================================================\n")); + ua->send_msg(_("\nTerminated Jobs:\n")); + ua->send_msg(_(" JobId Level Files Bytes Status Finished Name \n")); + ua->send_msg(_("====================================================================\n")); foreach_dlist(je, last_jobs) { char JobName[MAX_NAME_LENGTH]; const char *termstat; @@ -748,7 +748,7 @@ static void list_terminated_jobs(UAContext *ua) termstat = _("Other"); break; } - bsendmsg(ua, _("%6d %-6s %8s %10s %-7s %-8s %s\n"), + ua->send_msg(_("%6d %-6s %8s %10s %-7s %-8s %s\n"), je->JobId, level, edit_uint64_with_commas(je->JobFiles, b1), @@ -756,6 +756,6 @@ static void list_terminated_jobs(UAContext *ua) termstat, dt, JobName); } - bsendmsg(ua, _("\n")); + ua->send_msg(_("\n")); unlock_last_jobs_list(); } diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 33a1766680..5b6341aa32 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -106,7 +106,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) ua->api = tree->ua->api; /* keep API flag too */ BSOCK *user = ua->UA_sock; - bsendmsg(tree->ua, _( + ua->send_msg(_( "\nYou are now entering file selection mode where you add (mark) and\n" "remove (unmark) files to be restored. No files are initially added, unless\n" "you used the \"all\" keyword on the command line.\n" @@ -117,7 +117,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) */ tree->node = (TREE_NODE *)tree->root; tree_getpath(tree->node, cwd, sizeof(cwd)); - bsendmsg(tree->ua, _("cwd is: %s\n"), cwd); + ua->send_msg(_("cwd is: %s\n"), cwd); for ( ;; ) { int found, len, i; if (!get_cmd(ua, "$ ")) { @@ -126,7 +126,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) if (ua->api) user->signal(BNET_CMD_BEGIN); parse_args_only(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS); if (ua->argc == 0) { - bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n")); + ua->warning_msg(_("Invalid command. Enter \"done\" to exit.\n")); if (ua->api) user->signal(BNET_CMD_FAILED); continue; } @@ -141,7 +141,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) break; } if (!found) { - bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n")); + ua->warning_msg(_("Invalid command. Enter \"done\" to exit.\n")); if (ua->api) user->signal(BNET_CMD_FAILED); continue; } @@ -227,7 +227,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row) if (node->inserted) { tree->FileCount++; if (tree->DeltaCount > 0 && (tree->FileCount-tree->LastCount) > tree->DeltaCount) { - bsendmsg(tree->ua, "+"); + tree->ua->send_msg("+"); tree->LastCount = tree->FileCount; } } diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index e93ad3861b..8f50edc8f2 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,8 @@ General: 02May07 +kes Convert all other Dir files to use ne ua class message + routines for bat. kes Tentative fix for missing digest signature in bug 807. kes Correct handle problem in new win32_ftruncate routine. kes Convert ua_purge.c and ua_update.c to use new ua class