GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ along with this program; if not, write to the Free Software Foundation
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _GNU_SOURCE 1
#include <cgi.h>
#include "aux.h"
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n);
+#endif
+
char *cgiHeaderString = NULL;
char *cgiType = NULL;
if (res)
res->cookies = cgiReadCookies ();
else
- return NULL;
+ {
+ /* In some cases, we might have no other CGI results.
+ But we still have cookies! */
+ s_cookie **cookies;
+ cookies = cgiReadCookies();
+ if (cookies) {
+ /* We need to create a s_cgi structure. */
+ if ((res = (s_cgi *)malloc (sizeof (s_cgi))) == NULL)
+ return NULL;
+ res->vars = NULL;
+ res->cookies = cookies;
+ res->files = NULL;
+
+ } else {
+ return NULL;
+ }
+ }
if (!res->vars && !res->cookies && !res->files) {
free (res);
}
}
+#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