}
void syserror(const char *m) {
- if (printf("Content-Type: text/plain\n\n"
+ if (printf("Content-Type: text/plain\n"
+ "Status: 500\n\n"
"ucgi: system call error:\n"
"%s: %s\n",
m,strerror(errno))==EOF || fflush(stdout)) outerror();
exit(0);
}
-void error(const char *m) {
- if (printf("Content-Type: text/plain\n\n"
+void error(const char *m, int st) {
+ if (printf("Content-Type: text/plain\n"
+ "Status: %d\n\n"
"ucgi: error:\n"
"%s\n",
- m)==EOF || fflush(stdout)) outerror();
+ st, m)==EOF || fflush(stdout)) outerror();
exit(0);
}
l= strlen(buf);
if (buf[l - 1] == '\n') buf[--l]= 0;
if (l + 1 == sizeof(buf))
- error("line too long in environment filter file");
+ error("line too long in environment filter file", 500);
p= buf; q= p + l;
while (isspace((unsigned char)*p)) p++;
while (q > p && isspace((unsigned char)q[-1])) q--;
rc= envvar_match(flags, en, defaults, 0, ev);
if (rc) return rc;
} else
- error("unknown pattern directive");
+ error("unknown pattern directive", 500);
continue;
}
if (envvar_match(flags, en + pn, patv, defaults, &ev) > 0) {
n= strcspn(en, "=");
if (n >= sizeof(enbuf))
- error("environment variable name too long");
+ error("environment variable name too long", 500);
memcpy(enbuf, en, n);
enbuf[n]= 0;
D( if (debugmode)