Directory listing

Makefile
README.html
display.c
maple_cgi_linux.c
maple_linux.html

Project description

The programming task is to create a cgi-bin program to interface a web browser (Netscape, IExplorer) with Maple. The browser is thought as a client and Maple as a server. Your C program is the ``glue'' between them. Your program takes input (in the QUERY_STRING environment variable, transmitted by the browser) from a form like this one

* + * =
a1,1
x1
a1,2
x2
b1

* x1 + * x2 =
a2,1


a2,2


b2
and upon clicking the ``compute solution'' button returns the answer

X = ..., Y = ...

in a separate window. The answer should be compute by Maple, so ai,j can contain symbolic data. Note that the above ``compute solution'' button performs a different action in this document: it lists the shell environment variables and stdin (which is empty under <form method="get">). The source code for this cgi action is in display.c.

Example

The file maple_cgi_linux.c is an example of such a program. It gets the input from maple_linux.html, launches Maple, and processes Maple's answer: it simply copies it back. You may view the page sources of maple_linux.html and of this page for how the forms are set up, and the online documentation for html. In maple_linux.html, the action after submission is to run the program CExamples/maple_cgi_linux from the server's (http://redbox.math.ncsu.edu/cgi-bin) your_subdir directory. Here are the files in /usr/lib/cgi-bin:

kaltofen@redbox:/usr/lib/cgi-bin$ ls -la
total 112
drwxrwxrwx   4 root     root      4096 2008-02-26 13:21 .
drwxr-xr-x 158 root     root     45056 2008-02-19 11:18 ..
-rwxr-xr-x   1 kaltofen kaltofen  7316 2008-02-06 15:18 display
-rw-------   1 kaltofen kaltofen   717 2008-02-06 15:01 display.c
-rwxr-xr-x   1 root     root      6725 2008-02-05 11:05 first_pgm_cgi
-rw-r--r--   1 root     root       550 2000-08-29 14:53 first_pgm_cgi.c
-rwxr-xr-x   1 root     root      6860 2008-02-06 11:52 first_pgm_cgi_get
-rw-r--r--   1 root     root       687 2003-08-25 15:37 first_pgm_cgi_get.c
-rwxr-xr-x   1 www-data www-data    57 2008-02-06 15:06 .flexlmrc
-rwxr-xr-x   1 kaltofen kaltofen  8979 2008-02-06 15:17 maple_cgi_linux
-rw-------   1 kaltofen kaltofen  3233 2008-02-06 15:41 maple_cgi_linux.c
drwxr-xr-x   3 michael  michael   4096 2008-02-26 08:38 nehring
lrwxrwxrwx   1 butcher  root        21 2008-02-15 11:48 Stapleton -> /home/boxer/Project2/
drwxr-xr-x   2 butcher  root      4096 2008-02-12 11:42 test

You obtain an account and password on redbox from Michael Nehring from me during class, or you can call me during my office hours. In order for the executable file to be accessible, the afs permissions of your subdirectory must be set
fs sa . system:anyuser rl
Furthermore, you will have to make your file executable under Unix:
chmod ugo+rx maple_cgi_linux
(See the Makefile.)

Before you start with programming try to compile my maple_cgi_get.c and install it in your www directory and launch it from you own maple_linux.html.

What to submit

Please submit the C source files for your cgi program, a Makefile, the html form file, and any auxiliary files from which the program reads---if any (it may be useful to prepare the text of html, which is returned to the browser on stdout, from lines in a file rather than by printf's). Please place the html form file in your www directory under the name www/maple.html. You help me locate it by making a link to it from your homepage.

How to design your program

This time you are on your own in breaking up the tasks into individual subproblems and C functions. You may search the web for C libraries for parsing cgi input supplied in QUERY_STRING, which your program can use. Please make sure that your code can handle symbolic ai,j, in which case you may have to let Maple linearize its output before you parse it.

Common problems

In general, do not debug your program from the browser until you know that all the file manipulation is correct. See the tracing commands in my program, which simply copy things without executing Maple. Furthermore, you should be able to run your maple_cgi stand-alone by performing export QUERY_STRING="..." on redbox before. Note that /tmp/... then is accessible on redbox to you. You can look what's in the files, and you can delete them. Only after all that works, try to execute your program from the browser.

License considerations:

This exercise is intended for learning only. The license agreement with Waterloo Maple actually does not permit us to deliver services based on Maple computations for free over the Internet.