]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_label.c
Fix and document new queries
[bacula/bacula] / bacula / src / dird / ua_label.c
index 50b8b4ac1fe62492d13f3097c03525012ad34f4e..83a1e7563f0ba3c981547f86feb5cebc3d92f798 100644 (file)
@@ -1033,7 +1033,11 @@ void status_slots(UAContext *ua, STORE *store_r)
    int i=1;
    /* output format */
    const char *slot_api_empty_format="%i||||||||\n";
+
+   /* Slot|RealSlot|Volume|Bytes|Status|MediaType|Pool|LastW|Expire */
    const char *slot_api_full_format="%i|%i|%s|%s|%s|%s|%s|%s|%s\n";
+
+   /* Slot | Volume | Status | MediaType | Pool */
    const char *slot_hformat=" %4i%c| %16s | %9s | %20s | %18s |\n";
 
    if (!open_client_db(ua)) {
@@ -1085,12 +1089,13 @@ void status_slots(UAContext *ua, STORE *store_r)
 
       if (!vl->VolName) {
          Dmsg1(100, "No VolName for Slot=%d.\n", vl->Slot);
-         if (!ua->api) {
+         if (ua->api) {
+            ua->send_msg(slot_api_empty_format, vl->Slot);
+
+         } else {
             ua->send_msg(slot_hformat,
                          vl->Slot, '*',
                          "?", "?", "?", "?");
-         } else {
-            ua->send_msg(slot_api_empty_format, vl->Slot);
          }
          continue;
       }
@@ -1098,11 +1103,12 @@ void status_slots(UAContext *ua, STORE *store_r)
       /* Hope that slots are ordered */
       for (; i < vl->Slot; i++) {
          if (slot_list[i]) {
-            if (!ua->api) {
+            if (ua->api) {
+               ua->send_msg(slot_api_empty_format, i);
+
+            } else {
                ua->send_msg(slot_hformat,
                             i, ' ', "", "", "", "");
-            } else {
-               ua->send_msg(slot_api_empty_format, i);
             }       
             slot_list[i]=0;
          }
@@ -1117,30 +1123,31 @@ void status_slots(UAContext *ua, STORE *store_r)
          if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
             strcpy(pr.Name, "?");
          }
+         db_unlock(ua->db);
 
-         if (!ua->api) {
-            /* Print information */
-            ua->send_msg(slot_hformat,
-                         vl->Slot, ((vl->Slot==mr.Slot)?' ':'*'),
-                         mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name);
-         } else {
+         if (ua->api) {
             ua->send_msg(slot_api_full_format,
                          vl->Slot, mr.Slot, mr.VolumeName, 
                          edit_uint64(mr.VolBytes, ed1), 
                          mr.VolStatus, mr.MediaType, pr.Name, 
                          edit_uint64(mr.LastWritten, ed2),
                          edit_uint64(mr.LastWritten+mr.VolRetention, ed3));
+         } else {
+            /* Print information */
+            ua->send_msg(slot_hformat,
+                         vl->Slot, ((vl->Slot==mr.Slot)?' ':'*'),
+                         mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name);
          }
 
-         db_unlock(ua->db);
          continue;
       } else {                  /* TODO: get information from catalog  */
-         if (!ua->api) {
+         if (ua->api) {
+            ua->send_msg(slot_api_empty_format, vl->Slot);
+
+         } else {
             ua->send_msg(slot_hformat,
                          vl->Slot, '*',
                          mr.VolumeName, "?", "?", "?");
-         } else {
-            ua->send_msg(slot_api_empty_format, vl->Slot);
          }
       }
       db_unlock(ua->db);
@@ -1151,10 +1158,11 @@ void status_slots(UAContext *ua, STORE *store_r)
    for (; i <= max_slots; i++) {
       if (slot_list[i]) {
          if (!ua->api) {
+            ua->send_msg(slot_api_empty_format, i);
+
+         } else {
             ua->send_msg(slot_hformat,
                          i, ' ', "", "", "", "");
-         } else {
-            ua->send_msg(slot_api_empty_format, i);
          } 
          slot_list[i]=0;
       }