#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

int main(int argc, char *argv[]) {
int i;
struct stat buf;
char *desc_str;

for (i = 1; i < argc; i++) {
	printf("%s: ", argv[i]);
	if (lstat(argv[i], &buf) == -1)
		desc_str = strerror(errno);
	else if (S_ISREG(buf.st_mode)) desc_str = "-";
	else if (S_ISDIR(buf.st_mode)) desc_str = "d";
	else if (S_ISCHR(buf.st_mode)) desc_str = "c";
	else if (S_ISBLK(buf.st_mode)) desc_str = "b";
	else if (S_ISFIFO(buf.st_mode)) desc_str = "p";
	else if (S_ISLNK(buf.st_mode)) desc_str = "s";
#ifdef S_ISSOCK
	else if (S_ISSOCK(buf.st_mode)) desc_str = "socket";
#endif
	else desc_str = "**Unknown mode**";
	printf("%s", desc_str);
}
return 0;
}

/* number to symbolic for user id and group id 
                userinfo = getpwuid(stat_info.st_uid);
                groupinfo = getgrgid(stat_info.st_gid);

                ((userinfo != NULL) ? (userinfo->pw_name) : "UNKNOWN")
                ((groupinfo != NULL) ? (groupinfo->gr_name) : "UNKNOWN")
*/
