3 * This file is part of dds2tar.
4 * Copyright by J"org Weule
17 static const char hash_sign = '#';
20 * Skip to the next block.
22 ********************************************************************/
23 void dds_index_skip(){
25 * The hp-DAT is slowed down with dds_getpos().
26 * Is there a reason for this?
28 * Now the cur_blkno is incremented.
31 dds_read_next_block();
34 if ((cur_blkno & 0x1f) == 0) {
35 if ((cur_blkno & 0x7ff) == 0) {
36 fprintf(stderr, " %d\n",cur_byte);
39 write(2, &hash_sign, 1);
44 * Converting a tar-record to an entry in the index file.
46 * input: tar_record is the header of one file in the archive.
47 * The location of the header is given by the
48 * block and index value.
49 * output: The returned index is the location of the next header.
50 * Normalization of the pair (block,rec) with respect to
51 * the block length will give the right position.
52 * extern: index_fp, verbose
53 * index_fp is the FILE to write the rec.
54 * verbose indicates the loggin mode.
56 * If the name length of the file name is zero,
57 * and an empty block is found, the end
58 * of the archive is found and the program stops.
60 ********************************************************************/
62 dds_index_h(tar_record *const ptr, int const block, int rec)
65 char *p = ptr->hdr.magic;
68 fputs("dds_index_h()\n", stderr);
71 if ( dds_is_tar_header_record(ptr) == 0 ) {
72 fprintf(stderr,"dds2index: skipping to next header\n");
78 if (ptr->hdr.linkflag == 'V') p = "label ";
81 if (ptr->hdr.name[0] == 0) {
84 while ((((char *) ptr)[i] == 0) && (i < 512))
87 fprintf(index_fp, dds_index_format,
96 if (ptr->hdr.size[0] != 0)
97 sscanf(ptr->hdr.size, "%o", &size);
101 if ( ptr->hdr.linkflag == LF_LONGNAME ) long_name_len = size ;
104 char *name = ptr->hdr.name ;
105 if ( ptr->hdr.linkflag != LF_LONGLINK &&
106 ptr->hdr.linkflag != LF_LONGNAME &&
107 long_name[0] != '\0' ) name = long_name ;
108 sprintf(cur_line, dds_index_format,
115 fputs(cur_line, index_fp);
116 if ( ptr->hdr.linkflag != LF_LONGLINK &&
117 ptr->hdr.linkflag != LF_LONGNAME ) {
118 long_name[0] = '\0' ;
122 fputs(cur_line, stderr);
123 /* calculate the number of records */
124 /* there was one header record */
132 * Converting a table line to the numbers.
137 int *const ptr_blkno,
138 int *const ptr_recno,
140 char **const ptr_name
145 char const *dds_fmt = NULL;
148 fprintf(stderr,"rt_line(...)\n");
151 if (cur_line[16] == ':') {
152 dds_fmt = dds_old_index_scan_format ;
153 *ptr_name = cur_line + 27;
155 if (cur_line[17] == ':') {
156 dds_fmt = dds_index_scan_format ;
157 *ptr_name = cur_line + 28;
161 if ((i = sscanf(cur_line,
167 fprintf(stderr, "Wrong line inside the index file,"
168 " scanned %d values\n", i);
170 fprintf(stderr,"end >> rt_line(...)\n");
175 /* procedure to create the index table */
179 * extern: device, index_fp
181 * The archive is read, and the index file is written.
183 ************************************************************/
191 fputs("dds_index()\n", stderr);
195 fputs(dds_headline, index_fp);
196 if (verbose) fputs(dds_headline, index_fp);
202 if ((cur_blkno & 0x1f) == 0) {
203 write(2, &hash_sign, 1);
207 while (cur_rec < cur_bs) {
209 new_rec = dds_index_h(
214 if ( long_name_len > 0 ) {
216 while ( long_name_len > (i<<9) ){
219 * note: dds_index_skip operates on
222 if ( cur_rec >= cur_bs )
224 memcpy(long_name+((i++)<<9),
229 /* Now go to the next block behind the
233 else cur_rec = new_rec ;
239 fprintf(stderr, "dds_index: unexpected end of tar archive \n");