www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Does D work with Apache?

reply Mr.Novice <Mr.Novice_member pathlink.com> writes:
Goodday fellows!
The subject is my curious question :)
Aug 18 2004
next sibling parent pragma <EricAnderton at yahoo dot com> <pragma_member pathlink.com> writes:
In article <cg0c1g$t51$1 digitaldaemon.com>, Mr.Novice says...
Goodday fellows!
The subject is my curious question :)

I've done some work in this area, but haven't gotten too far. After much hacking around with making a binary-compatible module for my server, I came to a dead-end; this was *many* D revisions ago. I wound up using a c-module wrapper that calls a D dll instead of using a pure D solution. If you plan on making a pure D module, your major stumbling block is going to be converting the Apache header files to D, which are ridden with complex macros. After that, it's a matter of linking against apache's libraries, which under Win32 isn't trivial: you'll most likely have to convert apache.dll and link against it, or convert the precompiled apache.lib from COFF to OMF format. At least under Linux, you'll only have to worry about converting the header files. Hope this helps. - Pragma
Aug 18 2004
prev sibling parent Martin <Martin_member pathlink.com> writes:
You mean like cgi program?
Yes you can write a cgi program in D that works well in Apache.
Right now I am writing one. 

But there is one thing that You must keep in mind!
I have discovered that D has a little bug in it. It only appears, if you run the
program in a busy server, because there memory addresses are often changed. 
The program:

int func(){
int A[5000];
<---your code---->
]

is not a very good idea, it sometimes crashes. Only sometimes, but you don't
want that.   
You should write:

int func(){
int A[]=new int[5000];
<---your code---->
]
It works fine.

For example, here is a code, that works fine in my computer, but crashes in 10%
of time, when it works on a busy server. (The servr is fine, everything else is
working well).
(And it is not the fflush function, I tried without it, it's the same)
------------------------------------------------------------
import std.c.stdlib;
import std.c.stdio;
import std.stream;
import std.string;
import std.conv;

void ulog(char []s){  //LOGS ONTO SCREEN
printf("%.*s\n",s);
fflush(std.c.stdio.stdout);
}

int open(){
char *s;
char abs[2000];
char qu[100];
int a;
ulog("reaches this only 9 times of 10!\n"); // but 10% cases it does not reach
here
return 0;
}

int yhenda(){
char MEM[2000];
int a;
ulog("point(2.1) \n"); //it reaches this point
open();
ulog("point(2.2) \n");
return 0;
}

int main(){
printf("Content-type: text/html\n\n");
fflush(std.c.stdio.stdout);
ulog("point(1.1)\n");
yhenda();
ulog("point(1.2)\n");
return 0;
}
------------------------------------------------------


The second bug I found was
int A=new int[10];
A[]=1;
I think this was a bug, beacause my program crashed sometimes with it.
When I changed it to
int A=new int[10];
for(int x=0;x<A.length;x++)A[x]=1;
it worked fine
I think this might be already fixed, (check change log), I haven't checked it
since the version 0.92.

But I think the first bug is still in (atleast the version 0.98).

My program is about 3000 lines long and works fine. These two bugs are nothing
serious, you can easily work around them. And D is very good language for
writing cgi programs so you should use it.

If you want more help, let me know.
My email is  m a l e t a m i n d at y a h o o . c o m ofcourse without these
blanks (I want to keep spam robots away)

Good luck.



In article <cg0c1g$t51$1 digitaldaemon.com>, Mr.Novice says...
Goodday fellows!
The subject is my curious question :)

Aug 18 2004