1
/* @(#)rtape.c 19.1 (ES0-DMD) 02/25/03 14:32:27 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.COPYRIGHT (c) 1988 European Southern Observatory
33
.AUTHOR P.Grosbol ESO/IPG
34
.KEYWORDS read tape, copy tape to disk
36
.PURPOSE copy tape to disk files in fix block format
37
.COMMENT Fix block file format is used only because it is more
38
efficient on a VAX/VMS system!!
39
Size could be increased from 512 to 1024 or larger.
40
.VERSION 1.0 1988-Dec-16 : Creation, PJG
41
.VERSION 1.1 1989-Mar-11 : Increase to 1024 byte blocks, PJG
42
--------------------------------------------------------------------*/
44
#define MBUF 32000 /* max. no. of bytes in record */
45
#define BZ 1024 /* block size on disk */
47
static char buf[MBUF]; /* I/O buffer */
52
int mb,idx,nb,i,nbyte;
55
char *output,*newfn();
56
char input[80],prefix[80],list[80];
58
printf("Name of input tape unit : "); scanf("%s",input);
59
printf("Prefix on output filename : "); scanf("%s",prefix);
60
printf("List of file no. to copy : "); scanf("%s",list);
61
if (deflist(list)) { /* check if list valid */
62
printf("Error: Invalid list of file no's\n");
65
fdi = ioopen(input,0,1600); /* Open Mag. tape unit */
66
if (fdi<=0) ospexit(1);
67
iorew(fdi); /* rewind to file no.1 */
69
while (getlist(&nof)) { /* read file one by one */
70
if (nol<nof) { /* position tape */
71
for (i=nol; i<nof; i++) {
72
n = ioread(fdi,buf,BZ);
73
if (n<=0) { /* error of EOT detected */
74
printf("Warning: End of Information detected on tape!\n");
75
iorew(fdi,0); ospexit(1);
80
else if (nof<nol) { /* wrong order in list */
81
printf("Error: List NOT ascending\n");
85
outname(prefix,nof); /* get new file name */
86
output = newfn('I',".mt");
90
for (;;) { /* copy block by block */
91
if ((no=ioread(fdi,&buf[idx],mb))<=0) break;
93
if ((fdo=creat(output,0
101
rec++; nbyte += no; idx += no;
103
nb = write(fdo,buf,nb);
105
for (i=nb; i<no; i++) buf[idx++] = buf[i];
107
if (no<=0 && rec==0) { /* End of Tape mark */
108
printf("Warning: End of Information detected on tape!\n");
111
if (idx) { /* write remaining data to disk */
112
nb = ((idx-1)/BZ + 1) * BZ;
113
i = write(fdo,buf,nb);
117
byte = nbyte/(1024.0*1024.0);
118
printf(" %7.2f Mbyte in %5d records copied to file: %s\n",