Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-26-2012, 05:13 PM   #1
Registered: May 2009
Posts: 291

Rep: Reputation: 6
Web lacking C cgi examples/documentation

I have searched the web for cgi documentation and examples in c and found very little and I was hoping someone could post some in depth examples on cgi programming or maybe direct me to cgi documentation for C. I can multiply post method get variables and I can Create a page that says hello world.
Old 06-26-2012, 10:26 PM   #2
Nominal Animal
Senior Member
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946
The qDecoder library has some useful examples, and it supports just about everything including file uploads. It is also in the public domain, so you can use it in any project you like.

The Common Gateway Interface itself is specified in RFC 3875, I believe, but all implementations (like Apache mod_cgi and mod_cgid) have their differences or extensions, and do behave a bit differently on Windows than on sane OSes, so you'd better rely on that documentation -- and experimentation.

A decade ago the libraries were chock full of fixes for browser bugs. Especially Internet Explorer POST data tended to be all kinds of wonky. I'm not up to date on this, but I'd guess things have stabilized a lot. To really find out, you'd have to dive into e.g. PHP sources, and look at the POST data parsing to see if there are still workarounds applied to browser bugs.

If you are thinking about using C for CGI programming, I'd recommend you pretty quickly move on to FastCGI, perhaps using Apache mod_fcgid. It can provide much higher performance in high-load cases. FastCGI is a separate protocol to CGI, and has some important differences. For example, each process can/should respond to multiple (unrelated) queries, instead of existing only to serve one request. The approach is different.

After a quick search, I only found fastcgi C++ library (download), plus the old devkit at (but check the license terms first).

Currently, programming languages like Python tend to be fast enough to be used for very high volume sites, especially if using FastCGI, so C/C++ CGI/FastCGI programming is a rare thing. Personally, I've considered writing an efficient image upload tool that would use a dedicated user account and automatically generate thumbnail versions of the image -- but it turns out using Python or even PHP via mod_fcgid+SuEXEC makes more sense in the long term. One must consider the maintenance effort needed, too.

I might re-examine that if I ever work with an embedded device with say Nginx, and need a reliable, small-footprint uploader without a full scripting language installation -- but otherwise I think I'll use Python for something like this.

Hope this helps,
Old 06-27-2012, 08:14 AM   #3
Registered: May 2009
Posts: 291

Original Poster
Rep: Reputation: 6
Hey thanks, Anything helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PythonMagick: any documentation, tutorials, or examples? BrianK Programming 5 04-18-2010 01:15 PM
[SOLVED] What can be done to make these code examples work on web Browsers? Larry James Programming 22 03-12-2010 09:04 AM
how can i view the linux documentation using web browser? tianlijian Linux - Newbie 10 11-24-2008 03:07 PM
Documentation, manpages, and examples Minozake General 9 06-30-2008 11:10 AM
lacking binaries - examples gkrellm and racer ungua Linux - Newbie 1 10-19-2004 07:51 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration