Mercurial > urweb
comparison src/c/http.c @ 1134:b08b73591d2c
Switch to gcc -Wall
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 28 Jan 2010 13:32:26 -0500 |
parents | 0cee0c8d8c37 |
children | b7118ffd32ae |
comparison
equal
deleted
inserted
replaced
1133:482815817e99 | 1134:b08b73591d2c |
---|---|
23 static char *get_header(void *data, const char *h) { | 23 static char *get_header(void *data, const char *h) { |
24 char *s = data; | 24 char *s = data; |
25 int len = strlen(h); | 25 int len = strlen(h); |
26 char *p; | 26 char *p; |
27 | 27 |
28 while (p = strchr(s, ':')) { | 28 while ((p = strchr(s, ':'))) { |
29 if (p - s == len && !strncasecmp(s, h, len)) { | 29 if (p - s == len && !strncasecmp(s, h, len)) { |
30 return p + 2; | 30 return p + 2; |
31 } else { | 31 } else { |
32 if ((s = strchr(p, 0)) && s[1] != 0) | 32 if ((s = strchr(p, 0)) && s[1] != 0) |
33 s += 2; | 33 s += 2; |
167 close(sock); | 167 close(sock); |
168 goto done; | 168 goto done; |
169 } | 169 } |
170 path = s; | 170 path = s; |
171 | 171 |
172 if (s = strchr(path, ' ')) | 172 if ((s = strchr(path, ' '))) |
173 *s = 0; | 173 *s = 0; |
174 | 174 |
175 if (s = strchr(path, '?')) { | 175 if ((s = strchr(path, '?'))) { |
176 *s = 0; | 176 *s = 0; |
177 query_string = s+1; | 177 query_string = s+1; |
178 } | 178 } |
179 else | 179 else |
180 query_string = NULL; | 180 query_string = NULL; |
181 | 181 |
182 s = headers; | 182 s = headers; |
183 while (s2 = strchr(s, '\r')) { | 183 while ((s2 = strchr(s, '\r'))) { |
184 s = s2; | 184 s = s2; |
185 | 185 |
186 if (s[1] == 0) | 186 if (s[1] == 0) |
187 break; | 187 break; |
188 | 188 |
226 int main(int argc, char *argv[]) { | 226 int main(int argc, char *argv[]) { |
227 // The skeleton for this function comes from Beej's sockets tutorial. | 227 // The skeleton for this function comes from Beej's sockets tutorial. |
228 int sockfd; // listen on sock_fd | 228 int sockfd; // listen on sock_fd |
229 struct sockaddr_in my_addr; | 229 struct sockaddr_in my_addr; |
230 struct sockaddr_in their_addr; // connector's address information | 230 struct sockaddr_in their_addr; // connector's address information |
231 int sin_size, yes = 1; | 231 socklen_t sin_size; |
232 int uw_port = 8080, nthreads = 1, i, *names, opt; | 232 int yes = 1, uw_port = 8080, nthreads = 1, i, *names, opt; |
233 | 233 |
234 signal(SIGINT, sigint); | 234 signal(SIGINT, sigint); |
235 signal(SIGPIPE, SIG_IGN); | 235 signal(SIGPIPE, SIG_IGN); |
236 | 236 |
237 while ((opt = getopt(argc, argv, "hp:t:")) != -1) { | 237 while ((opt = getopt(argc, argv, "hp:t:")) != -1) { |
304 | 304 |
305 printf("Listening on port %d....\n", uw_port); | 305 printf("Listening on port %d....\n", uw_port); |
306 | 306 |
307 { | 307 { |
308 pthread_t thread; | 308 pthread_t thread; |
309 int name; | |
310 | 309 |
311 if (pthread_create(&thread, NULL, client_pruner, &ls)) { | 310 if (pthread_create(&thread, NULL, client_pruner, &ls)) { |
312 fprintf(stderr, "Error creating pruner thread\n"); | 311 fprintf(stderr, "Error creating pruner thread\n"); |
313 return 1; | 312 return 1; |
314 } | 313 } |