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