我发现了一个相关的IT技术网站:http://support.zeus.com/zws/examples/2005/12/16/hello_world_in_perl_and_c,并且这两个示例都能正常运行。
现在我试着将其用于Ada,但是两天来一直无法完成。
fcgi_stdio.ads
with Interfaces.C;
with Interfaces.C.Strings;
package fcgi_stdio is
function FCGI_Accept return Interfaces.C.int;
pragma Import (C, FCGI_Accept, "FCGI_Accept");
procedure FCGI_printf (str : Interfaces.C.Strings.chars_ptr);
pragma Import (C, FCGI_printf, "FCGI_printf");
end fcgi_stdio;
test.adb
with fcgi_stdio;
with Interfaces.C;
with Interfaces.C.Strings;
procedure Test is
begin
while Integer (fcgi_stdio.FCGI_Accept) >= 0 loop
fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Content-Type: text/plain" & ASCII.LF & ASCII.LF));
fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Hello World from Ada!" & ASCII.LF));
end loop;
end Test;
当我在控制台中运行时,会出现以下错误:
$ ./test
raised STORAGE_ERROR : stack overflow or erroneous memory access
Apache错误日志显示:
Premature end of script headers: test
有人知道如何让它工作吗?