- /*
- * First, scan for the "etc" directory.
- * If it's found, then see if it should cause us to stop. This
- * happens when a catman.conf is found in the directory.
- */
-
- rc = 0;
- while (0 == rc && NULL != (d = readdir(dir))) {
- if (DT_DIR != d->d_type || strcmp(d->d_name, "etc"))
- continue;
-
- path[(int)sz] = '\0';
- ssz = strlcat(path, d->d_name, MAXPATHLEN);
-
- if (ssz >= MAXPATHLEN) {
- fprintf(stderr, "%s: Path too long", path);
- return;
- } else if (NULL == (cd = opendir(path))) {
- perror(path);
- return;
- }
-
- rc = pathstop(cd);
- closedir(cd);
- }
-
- if (rc > 0) {
- /* This also strips the trailing slash. */
- path[(int)--sz] = '\0';
- req->p = mandoc_realloc
- (req->p,
- (req->psz + 1) * sizeof(struct paths));
- /*
- * Strip out the leading "./" unless we're just a ".",
- * in which case use an empty string as our name.
- */
- req->p[(int)req->psz].path = mandoc_strdup(path);
- req->p[(int)req->psz].name =
- cp = mandoc_strdup(path + (1 == sz ? 1 : 2));
- req->psz++;
- /*
- * The name is just the path with all the slashes taken
- * out of it. Simple but effective.
- */
- for ( ; '\0' != *cp; cp++)
- if ('/' == *cp)
- *cp = ' ';