Changeset eb083ad in mainline for uspace/app/websrv/websrv.c
- Timestamp:
- 2012-05-17T21:09:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8fde078
- Parents:
- a8b8086 (diff), 3e67ab1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/websrv/websrv.c
ra8b8086 reb083ad 1 1 /* 2 * Copyright (c) 201 1Jiri Svoboda2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <stdlib.h> 42 42 #include <fcntl.h> 43 #include <task.h> 43 44 44 45 #include <net/in.h> … … 71 72 72 73 static char fbuf[BUFFER_SIZE]; 74 75 static bool verbose = false; 73 76 74 77 /** Responses to send to client. */ … … 187 190 size_t response_size = str_size(msg); 188 191 189 fprintf(stderr, "Sending response\n"); 192 if (verbose) 193 fprintf(stderr, "Sending response\n"); 194 190 195 ssize_t rc = send(conn_sd, (void *) msg, response_size, 0); 191 196 if (rc < 0) { … … 251 256 } 252 257 253 fprintf(stderr, "Request: %s", lbuf); 258 if (verbose) 259 fprintf(stderr, "Request: %s", lbuf); 254 260 255 261 if (str_lcmp(lbuf, "GET ", 4) != 0) { … … 266 272 267 273 *end_uri = '\0'; 268 fprintf(stderr, "Requested URI: %s\n", uri); 274 if (verbose) 275 fprintf(stderr, "Requested URI: %s\n", uri); 269 276 270 277 if (!uri_is_valid(uri)) { … … 287 294 "\n" 288 295 "-h | --help\n" 289 "\tShow this application help.\n"); 296 "\tShow this application help.\n" 297 "-v | --verbose\n" 298 "\tVerbose mode\n"); 290 299 } 291 300 … … 306 315 307 316 port = (uint16_t) value; 317 break; 318 case 'v': 319 verbose = true; 308 320 break; 309 321 /* Long options with double dash */ … … 318 330 319 331 port = (uint16_t) value; 332 } else if (str_cmp(argv[*index] +2, "verbose") == 0) { 333 verbose = true; 320 334 } else { 321 335 usage(); … … 358 372 } 359 373 360 fprintf(stderr, "Creating socket\n"); 374 printf("%s: HelenOS web server\n", NAME); 375 376 if (verbose) 377 fprintf(stderr, "Creating socket\n"); 361 378 362 379 int listen_sd = socket(PF_INET, SOCK_STREAM, 0); … … 380 397 } 381 398 382 fprintf(stderr, "Listening for connections at port %" PRIu16 "\n", 383 port); 399 fprintf(stderr, "%s: Listening for connections at port %" PRIu16 "\n", 400 NAME, port); 401 402 task_retval(0); 403 384 404 while (true) { 385 405 struct sockaddr_in raddr; … … 393 413 } 394 414 395 fprintf(stderr, "Connection accepted (sd=%d), " 396 "waiting for request\n", conn_sd); 415 if (verbose) { 416 fprintf(stderr, "Connection accepted (sd=%d), " 417 "waiting for request\n", conn_sd); 418 } 397 419 398 420 rbuf_out = 0; … … 412 434 } 413 435 414 fprintf(stderr, "Connection closed\n"); 436 if (verbose) 437 fprintf(stderr, "Connection closed\n"); 415 438 } 416 439
Note:
See TracChangeset
for help on using the changeset viewer.