LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-26-2012, 04:13 PM   #1
errigour
Member
 
Registered: May 2009
Posts: 366

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, 09:26 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
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 fastcgi.com (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, 07:14 AM   #3
errigour
Member
 
Registered: May 2009
Posts: 366

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


Reply


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 12:15 PM
[SOLVED] What can be done to make these code examples work on web Browsers? Larry James Programming 22 03-12-2010 08:04 AM
how can i view the linux documentation using web browser? tianlijian Linux - Newbie 10 11-24-2008 02:07 PM
Documentation, manpages, and examples Minozake General 9 06-30-2008 10:10 AM
lacking binaries - examples gkrellm and racer ungua Linux - Newbie 1 10-19-2004 06:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:53 AM.

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