+ tm->tm_year = ( dateint / 10000) - 1900;
+ tm->tm_mon = ((dateint % 10000) / 100) - 1;
+ tm->tm_mday = ((dateint % 100) );
+
+ return mktime(tm);
+}
+
+char *
+list_new_tapes(
+ int nb)
+{
+ tape_t *lasttp, *iter;
+ char *result = NULL;
+
+ /* Find latest reusable new tape */
+ lasttp = lookup_tapepos(lookup_nb_tape());
+ while (lasttp && lasttp->reuse == 0)
+ lasttp = lasttp->prev;
+
+ if(lasttp && nb > 0 && strcmp(lasttp->datestamp,"0") == 0) {
+ int c = 0;
+ iter = lasttp;
+ /* count the number of tapes we *actually* used */
+ while(iter && nb > 0 && strcmp(iter->datestamp,"0") == 0) {
+ if (iter->reuse) {
+ c++;
+ nb--;
+ }
+ iter = iter->prev;
+ }
+
+ if(c == 1) {
+ result = g_strdup_printf(
+ _("The next new tape already labelled is: %s."),
+ lasttp->label);
+ } else {
+ result = g_strdup_printf(
+ _("The next %d new tapes already labelled are: %s"),
+ c, lasttp->label);
+ iter = lasttp->prev;
+ c--;
+ while(iter && c > 0 && strcmp(iter->datestamp,"0") == 0) {
+ if (iter->reuse) {
+ result = vstrextend(&result, ", ", iter->label, NULL);
+ c--;
+ }
+ iter = iter->prev;
+ }
+ }
+ }
+ return result;
+}
+
+void
+print_new_tapes(
+ FILE *output,
+ int nb)
+{
+ char *result = list_new_tapes(nb);
+
+ if (result) {
+ g_fprintf(output,"%s\n", result);
+ amfree(result);
+ }