Index: changer-src/chg-scsi.c
===================================================================
RCS file: /cvsroot/amanda/amanda/changer-src/chg-scsi.c,v
retrieving revision 1.6.2.24
diff -u -r1.6.2.24 chg-scsi.c
--- changer-src/chg-scsi.c	2001/04/16 17:54:23	1.6.2.24
+++ changer-src/chg-scsi.c	2001/04/26 23:57:35
@@ -638,17 +638,20 @@
 
 
 /* minor command line args */
-#define SLOTCOUNT 5
 #define SLOT_CUR 0
 #define SLOT_NEXT 1
 #define SLOT_PREV 2
 #define SLOT_FIRST 3
 #define SLOT_LAST 4
+#define SLOT_ADVANCE 5
 argument slotdefs[]={{"current",SLOT_CUR,0},
                      {"next",SLOT_NEXT,0},
                      {"prev",SLOT_PREV,0},
                      {"first",SLOT_FIRST,0},
-                     {"last",SLOT_LAST,0}};
+                     {"last",SLOT_LAST,0},
+                     {"advance",SLOT_ADVANCE,0},
+	};
+#define SLOTCOUNT (sizeof(slotdefs) / sizeof(slotdefs[0]))
 
 int is_positive_number(char *tmp) /* is the string a valid positive int? */
 {
@@ -704,10 +707,11 @@
 }
 
 /* used to find actual slot number from keywords next, prev, first, etc */
-int get_relative_target(int fd,int nslots,char *parameter,int loaded, 
-                        char *changer_file,int slot_offset,int maxslot)
+int get_relative_target(int fd,int nslots,char *parameter,int param_index,
+			int loaded,char *changer_file,
+			int slot_offset,int maxslot)
 {
-  int current_slot,i;
+  int current_slot;
   
   current_slot = get_current_slot(changer_file);
 
@@ -718,15 +722,12 @@
     current_slot = slot_offset;
   }
 
-  i=0;
-  while((i<SLOTCOUNT)&&(strcmp(slotdefs[i].str,parameter)))
-    i++;
-
-  switch(i) {
+  switch(param_index) {
   case SLOT_CUR:
     return current_slot;
     break;
   case SLOT_NEXT:
+  case SLOT_ADVANCE:
     if (++current_slot==nslots+slot_offset)
       return slot_offset;
     else
@@ -840,6 +841,7 @@
   char *clean_file=NULL;
   char *time_file=NULL;
 
+  int param_index;
 
   int use_slots;
   int slot_offset;
@@ -1072,11 +1074,18 @@
           } else {
             target = target+slot_offset;
           }
-        } else
+        } else {
+          param_index=0;
+          while((param_index<SLOTCOUNT)
+		&&(strcmp(slotdefs[param_index].str,com.parameter))) {
+            param_index++;
+	  }
           target=get_relative_target(fd, use_slots,
-                                     com.parameter,
+                                     com.parameter,param_index,
                                      loaded, 
-                                     changer_file,slot_offset,slot_offset+use_slots);
+                                     changer_file,
+				     slot_offset,slot_offset+use_slots);
+        }
       }
     if (loaded) {
       oldtarget = get_current_slot(changer_file);
@@ -1107,7 +1116,7 @@
       endstatus = 1;
       break;
     }
-    if (!loaded)
+    if (!loaded && param_index != SLOT_ADVANCE)
       {
         if (ask_clean(scsitapedevice))
           clean_tape(fd,tape_device,clean_file,drive_num,
