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
13 #include <libtarint/internal.h>
17 #if defined(_WIN32) && !defined(__CYGWIN__)
18 # include <libtar/compat.h>
20 # ifdef HAVE_SYS_PARAM_H
21 # include <sys/param.h>
35 /* determine full path name */
36 /* caller must "free" returned pointer when done with it */
37 /* th_get_pathname return values come directly from strdup */
39 th_get_pathname(TAR
*t
)
41 char filename
[TAR_MAXPATHLEN
];
43 if (t
->th_buf
.gnu_longname
)
44 return strdup(t
->th_buf
.gnu_longname
);
46 if (t
->th_buf
.prefix
[0] != '\0')
48 snprintf(filename
, sizeof(filename
), "%.155s/%.100s",
49 t
->th_buf
.prefix
, t
->th_buf
.name
);
50 return strdup(filename
);
53 snprintf(filename
, sizeof(filename
), "%.100s", t
->th_buf
.name
);
54 return strdup(filename
);
65 pw
= getpwnam(t
->th_buf
.uname
);
69 /* if the password entry doesn't exist */
71 sscanf(t
->th_buf
.uid
, "%o", &uid
);
83 gr
= getgrnam(t
->th_buf
.gname
);
87 /* if the group entry doesn't exist */
89 sscanf(t
->th_buf
.gid
, "%o", &gid
);
99 mode
= (mode_t
)oct_to_int(t
->th_buf
.mode
);
100 if (! (mode
& S_IFMT
))
102 switch (t
->th_buf
.typeflag
)
124 if (t
->th_buf
.name
[strlen(t
->th_buf
.name
) - 1] == '/')