-/*
- * Convert Job Level into a string
- */
-static const char *level_to_str(int level)
-{
- const char *str;
-
- switch (level) {
- case L_BASE:
- str = _("Base");
- case L_FULL:
- str = _("Full");
- break;
- case L_INCREMENTAL:
- str = _("Incremental");
- break;
- case L_DIFFERENTIAL:
- str = _("Differential");
- break;
- case L_SINCE:
- str = _("Since");
- break;
- case L_VERIFY_CATALOG:
- str = _("Verify Catalog");
- break;
- case L_VERIFY_INIT:
- str = _("Init Catalog");
- break;
- case L_VERIFY_VOLUME_TO_CATALOG:
- str = _("Volume to Catalog");
- break;
- case L_VERIFY_DISK_TO_CATALOG:
- str = _("Disk to Catalog");
- break;
- case L_VERIFY_DATA:
- str = _("Data");
- break;
- case L_NONE:
- str = " ";
- break;
- default:
- str = _("Unknown Job Level");
- break;
- }
- return str;
-}
-
-
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
-#include <windows.h>
-
-int bacstat = 0;
-
-struct s_win32_arg {
- HWND hwnd;
- int idlist;
-};
-
-/*
- * Put message in Window List Box
- */
-static void win32_sendit(const char *msg, int len, void *marg)
-{
- struct s_win32_arg *arg = (struct s_win32_arg *)marg;
-
- if (len > 0 && msg[len-1] == '\n') {
- // when compiling with visual studio some strings are read-only
- // and cause access violations. So we creat a tmp copy.
- char *_msg = (char *)alloca(len);
- bstrncpy(_msg, msg, len);
- msg = _msg;
- }
- SendDlgItemMessage(arg->hwnd, arg->idlist, LB_ADDSTRING, 0, (LONG)msg);
-
-}
-
-void FillStatusBox(HWND hwnd, int idlist)
-{
- struct s_win32_arg arg;
-
- arg.hwnd = hwnd;
- arg.idlist = idlist;
-
- /* Empty box */
- for ( ; SendDlgItemMessage(hwnd, idlist, LB_DELETESTRING, 0, (LONG)0) > 0; )
- { }
- do_status(win32_sendit, (void *)&arg);
-}
-
-char *bac_status(char *buf, int buf_len)
-{
- JCR *njcr;
- const char *termstat = _("Bacula Idle");
- struct s_last_job *job;
- int stat = 0; /* Idle */
-
- if (!last_jobs) {
- goto done;
- }
- Dmsg0(1000, "Begin bac_status jcr loop.\n");
- lock_jcr_chain();
- foreach_jcr(njcr) {
- if (njcr->JobId != 0) {
- stat = JS_Running;
- termstat = _("Bacula Running");
- free_locked_jcr(njcr);
- break;
- }
- free_locked_jcr(njcr);
- }
- unlock_jcr_chain();
- if (stat != 0) {
- goto done;
- }
- if (last_jobs->size() > 0) {
- job = (struct s_last_job *)last_jobs->last();
- stat = job->JobStatus;
- switch (job->JobStatus) {
- case JS_Canceled:
- termstat = _("Last Job Canceled");
- break;
- case JS_ErrorTerminated:
- case JS_FatalError:
- termstat = _("Last Job Failed");
- break;
- default:
- if (job->Errors) {
- termstat = _("Last Job had Warnings");
- }
- break;
- }
- }
- Dmsg0(1000, "End bac_status jcr loop.\n");
-done:
- bacstat = stat;
- if (buf) {
- bstrncpy(buf, termstat, buf_len);
- }
- return buf;