2 * Copyright (C) 1998-1999 Ian Jackson
4 * This is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with userv-utils; if not, write to the Free Software
16 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * $Id: ucgicommon.c,v 1.4 2001/03/17 15:32:58 ian Exp $
27 const char *const envok
[]= {
33 "HTTP_ACCEPT_ENCODING",
34 "HTTP_ACCEPT_LANGUAGE",
60 const int nenvok
= sizeof(envok
)/sizeof(envok
[0]);
64 static void outerror(void) {
66 exit(debugmode ?
0 : -1);
69 void syserror(const char *m
) {
70 if (printf("Content-Type: text/plain\n\n"
71 "ucgi: system call error:\n"
73 m
,strerror(errno
))==EOF
|| fflush(stdout
)) outerror();
77 void error(const char *m
) {
78 if (printf("Content-Type: text/plain\n\n"
81 m
)==EOF
|| fflush(stdout
)) outerror();
85 void *xmalloc(size_t sz
) {
89 if (!r
) syserror("malloc failed");
93 void xsetenv(const char *en
, const char *ev
, int overwrite
) {
94 if (setenv(en
,ev
,overwrite
)) syserror("setenv");