httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <>
Subject FYI: Current hacking: mod_js (JavaScript module)
Date Thu, 28 May 1998 15:55:37 GMT

Just for your information what "research-hacking" I'm currently doing in the

There is the JavaScript implementation in the Mozilla source tree.  Hmm.. this
is under the NPL and the source makes me not very happy (sorry). And a guy
started a mod_javascript.c recently (see which uses this
code. Ok. 

Then these days I found the NGS JavaScript Interpreter (see from Markku Rossi <> which is (although the
version reads 0.1.0) a very impressive piece of work (clean sources, GNU
Autoconf, etc. pp.). It is a nice and free JavaScript re-implementation
staying under the GPL. I contacted Markku in the last days and he is a very
friendly guy (the author of GNU enscript, BTW).  I discussed with him if its
possible to use his JavaScript implementation for a mod_js.c and we came to
the conclusion that its not only possible. We think its a great idea because
his implementation although has a C API and is very small (look at the size of
the below: its only 200KB. I like this, really).

So yesterday I've started to write a mod_js.c which should proof if my idea
has a future. And it has a future. The result in detail:

| rse@en1:/e/apache/work/mod_js/mod_js
| :> ll
| total 10
| -rw-r--r--  1 rse  wheel   892 May 28 16:48 Makefile
| -rw-r--r--  1 rse  wheel    63 May 28 17:26 hello.js
| -rw-r--r--  1 rse  wheel  2305 May 28 17:23 js_apache.c
| -rw-r--r--  1 rse  wheel  1347 May 28 17:29 js_apache.o
| -rw-r--r--  1 rse  wheel  2243 May 28 17:26 mod_js.c

Via "apxs -g -n js" I've initially created the above stuff  and after poking
around in the JS API sources I've added a first cut for allocating a
JavaScript interpreter, adding an Apache object to it and executing a script
through it. And after running this through APXS here is the result:

| rse@en1:/e/apache/work/mod_js/mod_js
| :> make test
| ../apache/sbin/apxs -c -DMOD_JS -I../js/include -L../js/lib -ljs -lm mod_js.c
| js_apache.c
| gcc -funsigned-char -fpic -DSHARED_MODULE
| -I/e/apache/work/mod_js/apache/include -I../js/include -DMOD_JS  -c mod_js.c
| gcc -funsigned-char -fpic -DSHARED_MODULE
| -I/e/apache/work/mod_js/apache/include -I../js/include -DMOD_JS  -c
| js_apache.c
| ld -Bshareable -o js_apache.o mod_js.o -L../js/lib -ljs -lm
| ../apache/sbin/apxs -i -a -n 'js'
| cp /e/apache/work/mod_js/apache/libexec/
| chmod 755 /e/apache/work/mod_js/apache/libexec/
| ../apache/sbin/apachectl restart
| ../apache/sbin/apachectl restart: httpd restarted
| lynx -mime_header
| HTTP/1.1 200 OK
| Date: Thu, 28 May 1998 15:36:39 GMT
| Server: Apache/1.3b7 (Unix) mod_perl/1.11_01-dev
| Connection: close
| Content-Type: text/html
| Hello World from hello.js
| rse@en1:/e/apache/work/mod_js/mod_js
| :> cat hello.js 
| /* Hello World */
| Apache.print("Hello World from hello.js\n");
| rse@en1:/e/apache/work/mod_js/mod_js
| :> ll 
| -rwxr-xr-x  1 rse  wheel  233472 May 28 17:43
| rse@en1:/e/apache/work/mod_js/mod_js
| :>

As you see it works fine. I just had to implement the Apache.print method via
ap_rputs(). The remaining stuff does the JS implemenation. Cool, isn't it?

I'm busy with my diploma thesis so I cannot hack as much as I want for this
mod_js.c these months but I think I'll make a real JavaScript solution out of
this beast. The user community will like it, I think. I personally
like it because of two reasons:

1. The JavaScript stuff runs in a sandbox of the JavaScript VM.

2. The complete JavaScript modules (including the compiler 
   and VM) is just about 200-300 KB. 

So, is it really worth hacking on this project or 
did I miss some strange fact?
                                       Ralf S. Engelschall

View raw message