While experimenting on Mac OS X, it seems that the problem is that FCGI_printf() is a varargs function. It calls FCGI_fprintf() , also varargs:
int FCGI_fprintf(FCGI_FILE *fp, const char *format, ...) { va_list ap; int n = 0; va_start(ap, format); <------ crash here
Ada does not have a standard way of specifying varargs functions, and GNAT also does not have an implementation.
The GNAT documentation says the solution is to provide a C wrapper for the varargs function:
#include <fcgi_stdio.h> int FCGI_printf_wrapper(const char *msg) { return FCGI_printf(msg); }
and import the wrapper:
procedure FCGI_printf (str : Interfaces.C.Strings.chars_ptr); pragma Import (C, FCGI_printf, "FCGI_printf_wrapper");
Another problem with the program is that in Ada, unlike C and many other languages, "\n" not a way to insert a newline character into a string. Try
fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Content-Type: text/plain" & ASCII.LF & ASCII.LF));
[edited 13.1.13]
source share