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
17 #include <sys/param.h>
26 /* determine full path name */
28 th_get_pathname(TAR
*t
)
30 if (t
->th_buf
.gnu_longname
)
31 return t
->th_buf
.gnu_longname
;
33 /* allocate the th_pathname buffer if not already */
34 if (t
->th_pathname
== NULL
)
36 t
->th_pathname
= malloc(MAXPATHLEN
* sizeof(char));
37 if (t
->th_pathname
== NULL
)
42 if (t
->th_buf
.prefix
[0] == '\0')
44 snprintf(t
->th_pathname
, MAXPATHLEN
, "%.100s", t
->th_buf
.name
);
48 snprintf(t
->th_pathname
, MAXPATHLEN
, "%.155s/%.100s",
49 t
->th_buf
.prefix
, t
->th_buf
.name
);
52 /* will be deallocated in tar_close() */
53 return t
->th_pathname
;
63 pw
= getpwnam(t
->th_buf
.uname
);
67 /* if the password entry doesn't exist */
68 sscanf(t
->th_buf
.uid
, "%o", &uid
);
79 gr
= getgrnam(t
->th_buf
.gname
);
83 /* if the group entry doesn't exist */
84 sscanf(t
->th_buf
.gid
, "%o", &gid
);
94 mode
= (mode_t
)oct_to_int(t
->th_buf
.mode
);
95 if (! (mode
& S_IFMT
))
97 switch (t
->th_buf
.typeflag
)
115 if (t
->th_buf
.name
[strlen(t
->th_buf
.name
) - 1] == '/')