case 1: /* Valid header */
/* We should decode next field (mode) first... */
/* Ensure incoming names are null terminated. */
- head->header.name[NAMSIZ-1] = '\0';
- if ( !name_match(head->header.name)
+ if ( !name_match(current_file_name)
|| (f_new_files && hstat.st_mtime<new_time)
- || (f_exclude && check_exclude(head->header.name))) {
+ || (f_exclude && check_exclude(current_file_name))) {
int isextended = 0;
}
if (f_show_omitted_dirs
&& head->header.linkflag == LF_DIR)
- msg ("Omitting %s\n", head->header.name);
+ msg ("Omitting %s\n", current_file_name);
/* Skip past it in the archive */
if (head->header.isextended)
isextended = 1;
userec(head);
if(f_multivol) {
- save_name = head->header.name;
+ save_name = current_file_name;
save_totsize=hstat.st_size;
}
for(size = hstat.st_size;size>0;size-=written) {
check=fwrite(data,sizeof(char), written, msg_file);
userec((union record *)(data+written - 1));
if(check!=written) {
- msg_perror("only wrote %ld of %ld bytes to file %s",check, written,head->header.name);
+ msg_perror("only wrote %ld of %ld bytes to file %s",check, written,current_file_name);
skip_file((long)(size)-written);
break;
}
}
if(f_multivol)
- save_name=head->header.name;
+ save_name=current_file_name;
/* Skip to the next header on the archive */
skip_file((long) hstat.st_size);
register char *p;
register union record *header;
long from_oct();
+ char **longp;
+ char *bp, *data;
+ int size, written;
+ static char *next_long_name, *next_long_link;
+ recurse:
+
header = findrec();
head = header; /* This is our current header */
if (NULL == header)
sum -= 0xFF & header->header.chksum[i];
sum += ' '* sizeof header->header.chksum;
- if (sum == recsum) {
- /*
- * Good record. Decode file size and return.
- */
- if (header->header.linkflag == LF_LINK)
- hstat.st_size = 0; /* Links 0 size on tape */
- else
- hstat.st_size = from_oct(1+12, header->header.size);
- return 1;
- }
-
if (sum == 8*' ') {
/*
* This is a zeroed record...whole record is 0's except
return 2;
}
- return 0;
+ if (sum != recsum)
+ return 0;
+
+ /*
+ * Good record. Decode file size and return.
+ */
+ if (header->header.linkflag == LF_LINK)
+ hstat.st_size = 0; /* Links 0 size on tape */
+ else
+ hstat.st_size = from_oct(1+12, header->header.size);
+
+ header->header.arch_name[NAMSIZ-1] = '\0';
+ if (header->header.linkflag == LF_LONGNAME
+ || header->header.linkflag == LF_LONGLINK)
+ {
+ longp = ((header->header.linkflag == LF_LONGNAME)
+ ? &next_long_name
+ : &next_long_link);
+
+ userec (header);
+ if (*longp)
+ free (*longp);
+ bp = *longp = (char *) ck_malloc (hstat.st_size);
+
+ for (size = hstat.st_size;
+ size > 0;
+ size -= written)
+ {
+ data = findrec ()->charptr;
+ if (data == NULL)
+ {
+ msg ("Unexpected EOF on archive file");
+ break;
+ }
+ written = endofrecs () ->charptr - data;
+ if (written > size)
+ written = size;
+
+ bcopy (data, bp, written);
+ bp += written;
+ userec ((union record *) (data + written - 1));
+ }
+ goto recurse;
+ }
+ else
+ {
+ current_file_name = (next_long_name
+ ? next_long_name
+ : header->header.arch_name);
+ current_link_name = (next_long_link
+ ? next_long_link
+ : header->header.arch_linkname);
+ next_long_link = next_long_name = 0;
+ return 1;
+ }
}
int *stdp;
int wantug;
{
-
long from_oct();
+ char **longp;
+ char *bp, *data;
+ int size, written;
st->st_mode = from_oct(8, header->header.mode);
st->st_mtime = from_oct(1+12, header->header.mtime);
int pad;
char *name;
extern long baserec;
+ static char *longname;
+ static char *longlink;
+ int bumplongs;
if(f_sayblock)
fprintf(msg_file,"rec %10d: ",baserec + (ar_record - ar_block));
/* annofile(msg_file, (char *)NULL); */
-
+
if (f_verbose <= 1) {
/* Just the fax, mam. */
char *name;
- name=quote_copy_string(head->header.name);
+ name=quote_copy_string(current_file_name);
if(name==0)
- name=head->header.name;
+ name=current_file_name;
fprintf(msg_file, "%s\n", name);
- if(name!=head->header.name)
+ if(name!=current_file_name)
free(name);
} else {
/* File type and modes */
modes[0]='N';
break;
+ case LF_LONGNAME:
+ case LF_LONGLINK:
+ msg ("Visible longname error\n");
+ break;
+
case LF_SPARSE:
case LF_NORMAL:
case LF_OLDNORMAL:
case LF_LINK:
modes[0] = '-';
- if ('/' == head->header.name[strlen(head->header.name)-1])
+ if ('/' == current_file_name[strlen(current_file_name)-1])
modes[0] = 'd';
break;
case LF_DUMPDIR:modes[0] = 'd'; break;
pad = strlen(user) + strlen(group) + strlen(size) + 1;
if (pad > ugswidth) ugswidth = pad;
- name = quote_copy_string(head->header.name);
+ name = quote_copy_string(current_file_name);
if(!name)
- name=head->header.name;
- fprintf(msg_file, "%s %s/%s %*s%s %s %s %.*s",
+ name=current_file_name;
+ fprintf(msg_file, "%s %s/%s %*s%s %s %s %s",
modes,
user,
group,
"",
size,
timestamp+4, timestamp+20,
- sizeof(head->header.name),
name);
- if(name!=head->header.name)
+ if(name!=current_file_name)
free(name);
switch (head->header.linkflag) {
case LF_SYMLINK:
- name=quote_copy_string(head->header.linkname);
+ name=quote_copy_string(current_link_name);
if(!name)
- name=head->header.linkname;
+ name=current_link_name;
fprintf(msg_file, " -> %s\n", name);
- if(name!=head->header.linkname)
+ if(name!=current_link_name)
free(name);
break;
case LF_LINK:
- name=quote_copy_string(head->header.linkname);
+ name=quote_copy_string(current_link_name);
if(!name)
- name=head->header.linkname;
- fprintf(msg_file, " link to %s\n", head->header.linkname);
- if(name!=head->header.linkname)
+ name=current_link_name;
+ fprintf(msg_file, " link to %s\n", current_link_name);
+ if(name!=current_link_name)
free(name);
break;