Re: first steps
Re: first steps
- Subject: Re: first steps
- From: Robert Dell <email@hidden>
- Date: Tue, 07 Feb 2006 04:43:41 -0500
Ken Shmidheiser wrote:
In this thread, Lars wrote:
int main( int argc, char *argv[] )
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 following was done with the assistance of Dale Walsh)
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");
if(getenv("Validator"))
validator = 1;
if (cp && !strcmp(cp, "POST"))
{
print_table = 1;
//printf("Request Method = POST\n");
if (ip)
{
length = atoi(ip);
if ((length > 10) && (length < 8192))
{
if ((line = (char *)malloc (length+2)) == NULL)
{
line = NULL;
return;
}
fgets(line, length+1, stdin);
}
else
{
line = NULL;
return;
}
}
else
{
line = NULL;
return;
}
}
else if (cp && !strcmp(cp, "GET"))
{
print_table = 0;
//printf("Request Method = GET\n");
esp = getenv("QUERY_STRING");
if (esp && strlen(esp))
{
if ((line = (char *)malloc (strlen(esp)+2)) == NULL)
{
line = NULL;
return;
}
sprintf (line, "%s", esp);
if (locateString("skills=") != NULL)
{
*line = 0;
print_table = 1;
}
}
else
{
line = NULL;
return;
}
}
line = cgiDecodeString(line);
/*
* From now on all cgi variables are stored in the variable line
* and look like foo=bar&foobar=barfoo&foofoo=
*/
for (cp=line; *cp; cp++)
{
if (*cp == '+')
*cp = ' ';
*cp = tolower(*cp);
}
};
ok, you can now tell me that i'm off topic because this is c not objective-c or cocoa...
p.s. trivia question ... does anybody other than me know where "foobar" came from originally? most of you can figure out what it means.
_______________________________________________
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