Patch by W. Michael Petullo to use autotools for strncpy()
[infodrom/cgilib] / cgi.c
diff --git a/cgi.c b/cgi.c
index c07f931..5782d5b 100644 (file)
--- a/cgi.c
+++ b/cgi.c
 #include <cgi.h>
 #include "aux.h"
 
 #include <cgi.h>
 #include "aux.h"
 
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n);
+#endif
+
 char *cgiHeaderString = NULL;
 char *cgiType = NULL;
 
 char *cgiHeaderString = NULL;
 char *cgiType = NULL;
 
@@ -857,6 +861,18 @@ void cgiFree (s_cgi *parms)
     }
 }
 
     }
 }
 
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n) {
+    char *fnval;
+
+    if ((fnval = (char *)malloc (n + 1)) == NULL)
+       return NULL;
+    strncpy(fnval, s, n);
+    fnval[n] = '\0';
+    return fnval;
+}
+#endif
+
 /*
  * Local variables:
  *  c-indent-level: 4
 /*
  * Local variables:
  *  c-indent-level: 4