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