summaryrefslogtreecommitdiffstats
path: root/share/man/tools/noso.c
blob: a5fd201611a8bf9324737a33b28e2083e99fb0eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>

main(argc, argv)
	char *argv[];
{
	struct stat sb;
	register char *cp;
	int i, fd, count = 0;
	char buf[10];

	for (cp = "", i = 1; i < argc; cp = " ", i++) {
		if (lstat(argv[i], &sb) < 0)
			continue;
		if ((sb.st_mode & S_IFMT) != S_IFREG)
			continue;
		fd = open(argv[i], O_RDONLY);
		if (fd < 0) {
			perror(argv[i]);
			continue;
		}
		if (read(fd, buf, 3) != 3) {
			close(fd);
			continue;
		}
		if (strncmp(buf, ".so", 3))
			count++, printf("%s%s", cp, argv[i]);
		close(fd);
	}
	if (count > 0)
		putchar('\n');
}
OpenPOWER on IntegriCloud