• 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: 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


  • Follow-Ups:
    • Re: first steps
      • From: Cameron Hayne <email@hidden>
    • RE: first steps
      • From: "Lars Elden" <email@hidden>
References: 
 >RE: first steps (From: Ken Shmidheiser <email@hidden>)

  • Prev by Date: Re: Accurate Money Values in Core Data
  • Next by Date: Re: why does this not work?
  • Previous by thread: Re: subclassing a window
  • Next by thread: RE: first steps
  • Index(es):
    • Date
    • Thread