11 static void usage(void);
14 * Process paths on stdin and generate a directory path if it looks
15 * like a pkgsrc directory.
20 main(int ac, char **av)
32 while ((ch = getopt(ac, av, "s")) != -1) {
45 fprintf(stderr, "requires base directory as first argument\n");
52 bpath = strdup(av[0]);
54 while (blen && bpath[blen-1] == '/')
61 while (fgets(buf, sizeof(buf) - 32, stdin) != NULL) {
62 path = strtok(buf, " \t\r\n");
63 if (path == NULL || *path == 0)
66 if (len < blen || bcmp(path, bpath, blen) != 0)
68 if (stat(path, &st) != 0)
71 if (!S_ISDIR(st.st_mode)) {
72 while (len && path[len-1] != '/')
75 while (len && path[len-1] == '/')
77 strcpy(path + len, "/Makefile");
78 if (stat(path, &st) != 0)
80 strcpy(path + len, "/DESCR");
81 if (stat(path, &st) != 0)
86 * Must be at least one sub-directory
89 for (len = blen; path[len]; ++len) {
96 printf("%s\n", path + blen + 1);
106 fprintf(stderr, "getpkgsrcdir: unsupported option\n");