+static void do_director_status(UAContext *ua);
+static void do_all_status(UAContext *ua);
+
+static char OKqstatus[] = "1000 OK .status\n";
+static char DotStatusJob[] = "JobId=%s JobStatus=%c JobErrors=%d\n";
+
+/*
+ * .status command
+ */
+
+bool dot_status_cmd(UAContext *ua, const char *cmd)
+{
+ JCR* njcr = NULL;
+ s_last_job* job;
+ char ed1[50];
+
+ Dmsg1(20, "status:%s:\n", cmd);
+
+ if ((ua->argc != 3) || (strcasecmp(ua->argk[1], "dir"))) {
+ ua->send_msg("1900 Bad .status command, missing arguments.\n");
+ return false;
+ }
+
+ if (strcasecmp(ua->argk[2], "current") == 0) {
+ ua->send_msg(OKqstatus, ua->argk[2]);
+ foreach_jcr(njcr) {
+ if (njcr->JobId != 0 && acl_access_ok(ua, Job_ACL, njcr->job->name())) {
+ ua->send_msg(DotStatusJob, edit_int64(njcr->JobId, ed1),
+ njcr->JobStatus, njcr->JobErrors);
+ }
+ }
+ endeach_jcr(njcr);
+ } else if (strcasecmp(ua->argk[2], "last") == 0) {
+ 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)) {
+ ua->send_msg(DotStatusJob, edit_int64(job->JobId, ed1),
+ job->JobStatus, job->Errors);
+ }
+ }
+ } else if (strcasecmp(ua->argk[2], "header") == 0) {
+ list_dir_status_header(ua);
+ } else if (strcasecmp(ua->argk[2], "scheduled") == 0) {
+ list_scheduled_jobs(ua);
+ } else if (strcasecmp(ua->argk[2], "running") == 0) {
+ list_running_jobs(ua);
+ } else if (strcasecmp(ua->argk[2], "terminated") == 0) {
+ list_terminated_jobs(ua);
+ } else {
+ ua->send_msg("1900 Bad .status command, wrong argument.\n");
+ return false;
+ }
+
+ return true;
+}
+
+/* This is the *old* command handler, so we must return
+ * 1 or it closes the connection
+ */
+int qstatus_cmd(UAContext *ua, const char *cmd)
+{
+ dot_status_cmd(ua, cmd);
+ return 1;
+}