-1

How to create DHTML pages using C language? Please give me some web site where I can find the step by step procedure to create DHTML pages using C.

Regards, NM

Malar
  • 9
  • 1
  • 1
  • Do you want to actually generate the HTML page in C? Or do you want to have Ajax calling a C program? –  Nov 26 '09 at 05:52
  • I will explain what exactly I am doing. I am developing a functionality which has to be embedded in the web-server (nginx). I have the core functionality implemented in C. I have used php script to interface the C code to display the result on the page. I have also used the ajax call for dynamic updates. My problem is, I have to cross-compile the C code, nginx web server source and php interpreter source for windriver linux. But I am not able to cross-compile php and nginx. So I got some suggestion that I can use C to create DHTML pages. Please give me some suggestion how to proceed. – Malar Nov 27 '09 at 03:52

7 Answers7

4

Assuming your application will be executed as a CGI of apache or another HTTP server, you only need to print the HTTP headers and the content of the page to stdout.

The minimal headers expected are:

Content-type: text/html\r\n\r\n

(do not forget the double \r\n)

then write your page.

eyalm
  • 3,366
  • 19
  • 21
3

C? Not so suitable language for that.

But, someone did CMS with that, called Tokyopromenade, Opensource

http://1978th.net/tokyopromenade/

Just for your information

YOU
  • 120,166
  • 34
  • 186
  • 219
3

For using C to generate (D|X)HTML, you will have to write CGI programs. CGI programs should output the Content-type: text/html or equivalent before HTML is output.

After that, you can upload the program to the cgi-bin/ or equivalent directory. Remember to set the execution bit on the file.

Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127
1

Have your C program write Content-type: text/html\n\n to stdout before anything else, and you can then generate whatever HTML you wish. The empty line is critical!

Matt Stephenson
  • 8,442
  • 1
  • 19
  • 19
1

"DHTML" is mostly used to describe client-side functionality, and you use Javascript for that.

But if you mean dynamic web pages (server-side functionality), and you must use C, you can use CGI (Common Gateway Interface, RFC3875):

http://hoohoo.ncsa.illinois.edu/cgi/primer.html

However, using C for web pages is not a good choice. It would be better to use a scripting language like Python or Ruby, and either study the CGI support in that language or go for a framework like Ruby on Rails.

kek
  • 342
  • 1
  • 9
0

To create dynamic webpages using C, there are a couple of ways you can go about this (this is not an exhaustive list):

  1. You use CGI, an old standard for creating dynamic webpages. The way this works is that for each request to your site, your webserver creates a new process, invokes your program (passing information about the request to your program using environmental variables and stdin), and feeds the output from your program to the web browser. As other replies have noted, CGI requires your program to specify the HTTP response headers to the browser.

  2. If you're interesting in using C for performance reasons when developing webpages (this is sort of diving into insanity), CGI clearly isn't an option. If you're this much of a masochist, you should probably look into linking with FastCGI or creating an Apache module. In fact, since you like pain this much, you might as well just start with thttpd and insert your code where needed.

Good luck. You might also consider seeing a shrink.

Conrad Meyer
  • 2,851
  • 21
  • 24
0

Search "C library for web applications" here on stackoverflow, it has some good answers.

I haven't tried it, maybe someone would find it usefull: klone. It is a framework for building standalone web serververs and html templating with embedded C.

hipe
  • 802
  • 6
  • 8