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