COMP: Try to remove warnings and add support for cygwin

This commit is contained in:
Andy Cedilnik 2005-12-29 11:15:36 -05:00
parent 14c256ddba
commit c5e532d07d

View File

@ -13,10 +13,12 @@
#include <libtarint/internal.h> #include <libtarint/internal.h>
#include <stdio.h> #include <stdio.h>
#ifndef WIN32
#include <pwd.h> #if !defined(_WIN32) || defined(__CYGWIN__)
#include <grp.h> # include <pwd.h>
# include <grp.h>
#endif #endif
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
@ -64,7 +66,7 @@ void
th_print_long_ls(TAR *t) th_print_long_ls(TAR *t)
{ {
char modestring[12]; char modestring[12];
#ifndef WIN32 #if !defined(_WIN32) || defined(__CYGWIN__)
struct passwd *pw; struct passwd *pw;
struct group *gr; struct group *gr;
#endif #endif
@ -85,26 +87,26 @@ th_print_long_ls(TAR *t)
#endif #endif
uid = th_get_uid(t); uid = th_get_uid(t);
#ifndef WIN32 #if !defined(_WIN32) || defined(__CYGWIN__)
pw = getpwuid(uid); pw = getpwuid(uid);
if (pw != NULL) if (pw != NULL)
strlcpy(username, pw->pw_name, sizeof(username)); strlcpy(username, pw->pw_name, sizeof(username));
else else
#endif #endif
snprintf(username, sizeof(username), "%d", uid); snprintf(username, sizeof(username), "%d", (int)uid);
gid = th_get_gid(t); gid = th_get_gid(t);
#ifndef WIN32 #if !defined(_WIN32) || defined(__CYGWIN__)
gr = getgrgid(gid); gr = getgrgid(gid);
if (gr != NULL) if (gr != NULL)
strlcpy(groupname, gr->gr_name, sizeof(groupname)); strlcpy(groupname, gr->gr_name, sizeof(groupname));
else else
#endif #endif
snprintf(groupname, sizeof(groupname), "%d", gid); snprintf(groupname, sizeof(groupname), "%d", (int)gid);
strmode(th_get_mode(t), modestring); strmode(th_get_mode(t), modestring);
printf("%.10s %-8.8s %-8.8s ", modestring, username, groupname); printf("%.10s %-8.8s %-8.8s ", modestring, username, groupname);
#ifndef WIN32 #if !defined(_WIN32) || defined(__CYGWIN__)
if (TH_ISCHR(t) || TH_ISBLK(t)) if (TH_ISCHR(t) || TH_ISBLK(t))
printf(" %3d, %3d ", th_get_devmajor(t), th_get_devminor(t)); printf(" %3d, %3d ", th_get_devmajor(t), th_get_devminor(t));
else else
@ -124,7 +126,7 @@ th_print_long_ls(TAR *t)
printf(" %s", th_get_pathname(t)); printf(" %s", th_get_pathname(t));
#ifndef _WIN32 #if !defined(_WIN32) || defined(__CYGWIN__)
if (TH_ISSYM(t) || TH_ISLNK(t)) if (TH_ISSYM(t) || TH_ISLNK(t))
{ {
if (TH_ISSYM(t)) if (TH_ISSYM(t))