xref: /netbsd-src/share/man/tools/noso.c (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <sys/file.h>
5 
6 main(argc, argv)
7 	char *argv[];
8 {
9 	struct stat sb;
10 	register char *cp;
11 	int i, fd, count = 0;
12 	char buf[10];
13 
14 	for (cp = "", i = 1; i < argc; cp = " ", i++) {
15 		if (lstat(argv[i], &sb) < 0)
16 			continue;
17 		if (!S_ISREG(sb.st_mode))
18 			continue;
19 		fd = open(argv[i], O_RDONLY);
20 		if (fd < 0) {
21 			perror(argv[i]);
22 			continue;
23 		}
24 		if (read(fd, buf, 3) != 3) {
25 			close(fd);
26 			continue;
27 		}
28 		if (strncmp(buf, ".so", 3))
29 			count++, printf("%s%s", cp, argv[i]);
30 		close(fd);
31 	}
32 	if (count > 0)
33 		putchar('\n');
34 }
35