Snapshot 0.6.0

Chris R. Miller lordSaurontheGreat at gmail.com
Tue May 27 14:46:30 PDT 2008


Jacob Carlborg Wrote:
> Chris R. Miller wrote:
> > a sign that I've been here far 
> > too long and need to find something more impossible to do.  So, requests 
> > if you have any would be great.
> 
> Some suggestions:
> A GUI/window builder for dwt as an eclipse plugin, maybe based on visual 
> editor (http://www.eclipse.org/vep/WebContent/main.php) is a good idea.
> 
> CGI and database library for minid and an apache plugin so you can use 
> minid like php.

Well, if you want to use minid like PHP, then you should probably hack the mod_php module for Apache 2.  There's also the Apache 2 handler API: http://httpd.apache.org/docs/2.2/developer/API.html

If I remember correctly from reading through the source of mod_php.c, it's fairly simple - nothing more than translating a struct of URL information to a call to your php executable.  So www.example.com/index.php?action=doSomething becomes a literal call to something like /usr/bin/php /var/www/htdocs/index.php "action=doSomething" .  Or maybe that was how CGI was handled?  I have no recall for certain, but from what I remember it wasn't exactly rocket science.  You'd just have to rewrite it to something like /usr/bin/minid /var/www/cgi-bin/index "action=doSomething", or something similar to that effect.  Personally I would not try and complicate it any further.

It could also become interesting to write an argparser to allow the interpretation of command line arguments from the CGI dispatcher so that you could utilize compiled code as your web application.  You could further embellish that framework to enable fastcgi, which could yield further speed benefits to the system due to persistent threads as opposed to run-once affairs typical to normal CGI scripts.

If - like me - you are too lazy to read the docs, you could discover the organization and syntaxing of the command line arguments passed to both CGI and/or FCGI dispatches by a short script and a D program:

=== dispatch.cgi ====

exec dispatch ; # dispatch is a compiled program you wrote

=== dispatch.d > dispatch ==== (remember to chmod 755 it!)

import tango.io.Stdout;

void main(char args[][]) {
    foreach(int i, char[] ch; args) {
        Stdout.format("{} :: {}\n", i, ch);
    }
}

======== EOF =======

Forgive me if my Apache/bash/etc. skills are a bit rusty, but that should print out to the screen all the arguments given to CGI dispatches by apache.  Knowing that is all you would really need to know in order to begin writing a CGI/FCGI framework for D - or Minid.

Alack! I am unable to persue the goal personally at the moment, since I am unfortunately working on other, far less rewarding things at the moment - finishing out my last year of High School.

I also thought there was the beginnings of some of that kind of framework in the Wombat framework (http://www.dsource.org/projects/wombat), but the last commit was on 05/06/07, so it may or may not work with more recent versions of DMD/GDC/Tango/Phobos.  I have not personally tested it, so I do not know for certain.


More information about the Digitalmars-d-announce mailing list