/** * @PROJECT CGI Bash Shell Interface * @COPYRIGHT See COPYING in the top level directory * @FILE error.c * @PURPOSE Error handling * @DEVELOPERS Nathan Angelacos * Rafal Kupiec */ #include #include #include #include #include #include #include "common.h" #include "buffer.h" #include "subshell.h" #include "cbsi.h" #include "error.h" char* g_err_msg[] = { "", "Memory Allocation Failure", "Unable to open file %s", "%c> before <%c", "Missing %c>", "Unknown operation", "Unable to start subshell", "Unspecified Error", }; void die_with_error(char* msg) { fprintf(stderr, "Error: %s\n", msg); exit(-1); } void die_with_message(void* sp, char* where, const char* s, ...) { script_t* script = sp; va_list p; FILE* fo = stderr; fo = stdout; fprintf(fo, "HTTP/1.0 500 Server Error\nContent-Type: text/html\n\nCBSI Error
\n");
	va_start(p, s);
	vfprintf(fo, s, p);
	va_end(p);
	if(where && sp) {
		fprintf(fo, " near line %d of %s\n",
		count_lines(script->buf, script->size, where),
		script->name);
	}
	printf("\n");
	fprintf(fo, "
\n"); exit(-1); }