| |
| Posted by Martin in reply to Mr.Novice | PermalinkReply |
|
Martin
Posted in reply to Mr.Novice
| 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 :)
>
>
|