Message-ID: <36454288.5236639A@flute.rockefeller.edu> Date: Sun, 08 Nov 1998 02:04:41 -0500 From: Francisco Melo Ledermann Organization: The Rockefeller University X-Mailer: Mozilla 4.05 [en] (Win95; U) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com, Fabiano_Zara AT www DOT datasys DOT it Subject: Re: Build CGI programs with DJGPP References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com > It's possible to wite CGI programs with djgpp?. YES. > I use OMNI HTTPD server, WIN95 as OS. Me too. I just finished setting up that. It was quite painful. > Can you give me a hint, or can you show an exemple? > Thank you You need: -a win32 console (provided by RSXNTDJ) -a server that support win32 console (Omni httpd is ok, apache too). - a cgi library for c I use cgic.c programmed by Thomas Boutell (search the web, is free). It is great. I have tried other cgi's but this is the best. It creates a virtual file (called 'cgiout') which will constitutes the standard output. Thus, every output you want to put in the html page by the cgi, you only have to write to the file 'cgiout'. Nice !. Also, your main cgi program MUST include cgiMain and not Main. Read the cgic documentation. Here I attach a simple html form(test_form.html), a c program (test.c) to process that form and the makefile. You only need to download 'cgic.h' and 'cgic.c', to compile and to test it. htttp server: - put test_form.html in c:\httpd\htdocs - put test.exe in c:\httpd\cgi-bin In your browser go to: http://localhost/test_form.html Fill out the form and submit it. It should work. Compilation (makefile) (I use RSX-IDE to compile, very nice !, but you can also compile from the command line of the console rsxwin32 provided with RSXNTDJ that should be located in C:\djgpp\RSXNTDJ\BIN directory): all: test.exe test.exe: test.o cgic.o gcc -Zwin32 -o test.exe test.o cgic.o test.o: test.c gcc -Zwin32 -Wall -c -o test.o test.c cgic.o: cgic.c gcc -Zwin32 -Wall -c -o cgic.o cgic.c test.c /***************************************************************************/ #include #include #include "cgic.h" /* I have included this just in case, because of some warnings in the djgpp documentation */ #define extern int a, b, c; int Obtain_Int_Form_String(char *); int cgiMain() { #if DEBUG /* Load a saved CGI scenario if we're debugging */ cgiReadEnvironment("/home/boutell/public_html/capcgi.dat"); #endif cgiHeaderContentType("text/html"); /* Preparing html page */ fprintf(cgiOut, "\n"); fprintf(cgiOut, "CGI RESULTS\n"); fprintf(cgiOut, "

CGI RESULTS

\n"); fprintf(cgiOut, "\n\n"); /* Processing query form */ a = Obtain_Int_Form_String ("value1"); b = Obtain_Int_Form_String ("value2"); c = a*b; fprintf(cgiOut, "

%d multiplied by %d = %d



\n\n", a, b, c); fprintf(cgiOut, "

That's all !

\n\n"); return (0); } /****** END MAIN ******/ int Obtain_Int_Form_String(char *field) { char array[81]; int value; cgiFormStringNoNewlines(field, array, 81); sscanf (array, "%d", &value); return (value); } /***************************************************************************/ test_form.html MY FIRST SERVER !!! (by Cro)

FORM THAT MULTIPLIES TWO INTEGER VALUES


Enter first value:


Enter second value:



Good luck !, this is the summary of at least one week trying to install djgpp and RSXNTDJ in my computer. Now, all is working fine. Best, Francisco. -- ----------------------------------- Francisco Melo Ledermann Laboratory of Molecular Biophysics. The Rockefeller University. 1230 York Avenue, #270, New York, NY 10021-6399. (1) (212) 879 5404 Home (1) (212) 327 7206 Work (Voice) (1) (212) 327 7540 Work (FAX) www server: http://www.fundp.ac.be/pub/ANOLEA.html home page: http://guitar.rockefeller.edu/~fmelo/index.html