2 ** Copyright 1998-2003 University of Illinois Board of Trustees
3 ** Copyright 1998-2003 Mark D. Roth
4 ** All rights reserved.
6 ** decode.c - libtar code to decode tar header blocks
8 ** Mark D. Roth <roth@uiuc.edu>
9 ** Campus Information Technologies and Educational Services
10 ** University of Illinois at Urbana-Champaign
16 #include <sys/param.h>
25 /* determine full path name */
27 th_get_pathname(TAR
*t
)
29 if (t
->th_buf
.gnu_longname
)
30 return t
->th_buf
.gnu_longname
;
32 /* allocate the th_pathname buffer if not already */
33 if (t
->th_pathname
== NULL
)
35 t
->th_pathname
= malloc(MAXPATHLEN
* sizeof(char));
36 if (t
->th_pathname
== NULL
)
41 if (t
->th_buf
.prefix
[0] == '\0')
43 snprintf(t
->th_pathname
, MAXPATHLEN
, "%.100s", t
->th_buf
.name
);
47 snprintf(t
->th_pathname
, MAXPATHLEN
, "%.155s/%.100s",
48 t
->th_buf
.prefix
, t
->th_buf
.name
);
51 /* will be deallocated in tar_close() */
52 return t
->th_pathname
;
62 pw
= getpwnam(t
->th_buf
.uname
);
66 /* if the password entry doesn't exist */
67 sscanf(t
->th_buf
.uid
, "%o", &uid
);
78 gr
= getgrnam(t
->th_buf
.gname
);
82 /* if the group entry doesn't exist */
83 sscanf(t
->th_buf
.gid
, "%o", &gid
);
93 mode
= (mode_t
)oct_to_int(t
->th_buf
.mode
);
94 if (! (mode
& S_IFMT
))
96 switch (t
->th_buf
.typeflag
)
114 if (t
->th_buf
.name
[strlen(t
->th_buf
.name
) - 1] == '/')