Mercurial > urweb
comparison src/c/fastcgi.c @ 1411:38d950c06dce
Using FastCGI debug info
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 22 Jan 2011 12:55:48 -0500 |
parents | add5ae41969e |
children | 740e167cd4eb |
comparison
equal
deleted
inserted
replaced
1410:55d0c8b01d18 | 1411:38d950c06dce |
---|---|
132 } | 132 } |
133 | 133 |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 | 136 |
137 #include <errno.h> | |
138 | |
137 static void write_stderr(FCGI_Output *o, const char *fmt, ...) { | 139 static void write_stderr(FCGI_Output *o, const char *fmt, ...) { |
138 int len; | 140 int len; |
139 va_list ap; | 141 va_list ap; |
140 va_start(ap, fmt); | 142 va_start(ap, fmt); |
141 | 143 |
165 } else | 167 } else |
166 vfprintf(stderr, fmt, ap); | 168 vfprintf(stderr, fmt, ap); |
167 } | 169 } |
168 | 170 |
169 static void log_debug(void *data, const char *fmt, ...) { | 171 static void log_debug(void *data, const char *fmt, ...) { |
172 FCGI_Output *o = (FCGI_Output *)data; | |
173 va_list ap; | |
174 va_start(ap, fmt); | |
175 | |
176 if (o) { | |
177 strcpy((char *)o->r.contentData, "DEBUG: "); | |
178 int len = vsnprintf((char *)o->r.contentData + 7, 65535 - 7, fmt, ap); | |
179 if (len < 0) | |
180 fprintf(stderr, "vsnprintf() failed in log_debug().\n"); | |
181 else if (fastcgi_send(o, FCGI_STDERR, len + 7)) { | |
182 len += 7; | |
183 if (len >= 65535) len = 65534; | |
184 o->r.contentData[len] = 0; | |
185 fputs((char *)o->r.contentData, stderr); | |
186 fflush(stderr); | |
187 } | |
188 } else | |
189 vfprintf(stderr, fmt, ap); | |
170 } | 190 } |
171 | 191 |
172 typedef struct { | 192 typedef struct { |
173 char *name, *value; | 193 char *name, *value; |
174 unsigned name_len, value_len; | 194 unsigned name_len, value_len; |