aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-10-11 00:06:48 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-10-11 00:06:48 +0000
commit0ab114271e8b7edb69ff22487903e9a508fb548e (patch)
tree9349d8706995e852aa3dee3e3396f15ca8e59a4c /cgi.c
parent2b4534f0aa61e07273ac5ef33558adb568e69a2e (diff)
downloadmandoc-0ab114271e8b7edb69ff22487903e9a508fb548e.tar.gz
mandoc-0ab114271e8b7edb69ff22487903e9a508fb548e.tar.zst
mandoc-0ab114271e8b7edb69ff22487903e9a508fb548e.zip
Thomas Klausner <wiz at NetBSD dot org> finally succeeded to build
on SmartOS and sent these additional patches, thanks!
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/cgi.c b/cgi.c
index 6d40fcde..64bde45c 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.45 2013/06/05 02:00:26 schwarze Exp $ */
+/* $Id: cgi.c,v 1.46 2013/10/11 00:06:48 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -34,6 +34,13 @@
#include <string.h>
#include <unistd.h>
+#if defined(__sun)
+/* for stat() */
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
#include "apropos_db.h"
#include "mandoc.h"
#include "mdoc.h"
@@ -42,7 +49,7 @@
#include "manpath.h"
#include "mandocdb.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(__sun)
# include <db_185.h>
#else
# include <db.h>
@@ -1097,11 +1104,20 @@ static int
pathstop(DIR *dir)
{
struct dirent *d;
+#if defined(__sun)
+ struct stat sb;
+#endif
- while (NULL != (d = readdir(dir)))
+ while (NULL != (d = readdir(dir))) {
+#if defined(__sun)
+ stat(d->d_name, &sb);
+ if (S_IFREG & sb.st_mode)
+#else
if (DT_REG == d->d_type)
+#endif
if (0 == strcmp(d->d_name, "catman.conf"))
return(1);
+ }
return(0);
}
@@ -1118,6 +1134,9 @@ pathgen(DIR *dir, char *path, struct req *req)
DIR *cd;
int rc;
size_t sz, ssz;
+#if defined(__sun)
+ struct stat sb;
+#endif
sz = strlcat(path, "/", PATH_MAX);
if (sz >= PATH_MAX) {
@@ -1133,7 +1152,13 @@ pathgen(DIR *dir, char *path, struct req *req)
rc = 0;
while (0 == rc && NULL != (d = readdir(dir))) {
- if (DT_DIR != d->d_type || strcmp(d->d_name, "etc"))
+#if defined(__sun)
+ stat(d->d_name, &sb);
+ if (!(S_IFDIR & sb.st_mode)
+#else
+ if (DT_DIR != d->d_type
+#endif
+ || strcmp(d->d_name, "etc"))
continue;
path[(int)sz] = '\0';
@@ -1182,7 +1207,13 @@ pathgen(DIR *dir, char *path, struct req *req)
rewinddir(dir);
while (NULL != (d = readdir(dir))) {
- if (DT_DIR != d->d_type || '.' == d->d_name[0])
+#if defined(__sun)
+ stat(d->d_name, &sb);
+ if (!(S_IFDIR & sb.st_mode)
+#else
+ if (DT_DIR != d->d_type
+#endif
+ || '.' == d->d_name[0])
continue;
path[(int)sz] = '\0';