• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: first steps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: first steps


  • Subject: Re: first steps
  • From: Cameron Hayne <email@hidden>
  • Date: Tue, 7 Feb 2006 07:06:21 -0500

On 7-Feb-06, at 4:43 AM, Robert Dell wrote:
Actually, I strongly suggest the following:
int main (int argc, char * argv[], char *env[])
this way you can check environment variables and set yourself up according with those. especially useful if your compiled code is going to be used within a cgi program for the web.

The three argument form of 'main' is actually non-standard and hence not recommended.
And I note that your example code (see below) doesn't even use the 'env' argument. it correctly uses the 'getenv' function to retrieve the values of environment variables. There is no need for the three argument form of 'main'.


void cgiReadVariables ()
{
long length; // use long instead of int because ints are 16 bits and somebody could send a long to your machine and crash it and force a reboot. At the very least, it will force the web app to crash.
char *cp, *ip, *esp;


	cp = getenv("REQUEST_METHOD");
	ip = getenv("CONTENT_LENGTH");

The comment about 'int's being 16 bit is misleading at least. On almost all modern systems, 'int's are 32 bit. Nevertheless, it is correct to declare 'length' as a 'long' for portability.


But most importantly, I would recommend that you not reinvent the wheel by writing your own CGI-processing code. Instead you should use one of the libraries that provides CGI processing functions.
E.g. the GNU C++ library "cgicc" : http://www.gnu.org/software/cgicc/ cgicc.html
(There are several others, some in plain C, and with different licensing)


--
Cameron Hayne
email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • modal windows
      • From: "Lars Elden" <email@hidden>
References: 
 >RE: first steps (From: Ken Shmidheiser <email@hidden>)
 >Re: first steps (From: Robert Dell <email@hidden>)

  • Prev by Date: RE: Searching for socket API thread based
  • Next by Date: How to change the strings in application Main menu
  • Previous by thread: RE: first steps
  • Next by thread: modal windows
  • Index(es):
    • Date
    • Thread