Re: int urldecode(char *src, char *last, char *dest)
- From: "Old Wolf" <oldwolf@xxxxxxxxxxxxxx>
- Date: 15 Feb 2007 14:12:15 -0800
On Feb 16, 7:18 am, "gert" <gert.cuyk...@xxxxxxxxx> wrote:
#include <fcgi_stdio.h>
#include <stdlib.h>
char *post(void){
char *input;
char *lenstr;
long len;
lenstr=getenv("CONTENT_LENGTH");
if (lenstr != NULL && sscanf(lenstr,"%ld",&len)==1 ) {
input = malloc(len+1);
fgets(input, len+1, stdin);
//urldecode(); IMPLEMENT LATER NEED SLEEP FIRST
printf("Content-Type: text/xml; charset=utf-8"
"\r\n"
"\r\n"
"<xml>%s %d</xml>"
"\n"
,input,len);
free(input);
}
return 0;
}
int main (void){
char * input;
while (FCGI_Accept() >= 0) {
post();
}
return 0;
}
Is this Wolf approved, meaning safety code with no memory leaks or
other memory violations ?
Not quite; you use %d to print a long, and you don't
check the result of malloc() for failure.
I can't comment on the non-standard things (ie. whether
or not the output is actually valid, and the behaviour
of the getenv() function), so I'll assume you know what
you're doing there.
.
- Follow-Ups:
- Re: int urldecode(char *src, char *last, char *dest)
- From: CBFalconer
- Re: int urldecode(char *src, char *last, char *dest)
- From: gert
- Re: int urldecode(char *src, char *last, char *dest)
- References:
- int urldecode(char *src, char *last, char *dest)
- From: gert
- Re: int urldecode(char *src, char *last, char *dest)
- From: Old Wolf
- Re: int urldecode(char *src, char *last, char *dest)
- From: gert
- int urldecode(char *src, char *last, char *dest)
- Prev by Date: Re: function system() from stdlib.h
- Next by Date: Re: function system() from stdlib.h
- Previous by thread: Re: int urldecode(char *src, char *last, char *dest)
- Next by thread: Re: int urldecode(char *src, char *last, char *dest)
- Index(es):
Relevant Pages
|