Changeset 0349a10 in mainline


Ignore:
Timestamp:
2010-12-25T21:48:41Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af4f86f
Parents:
631ee0c
Message:

Comment style in netecho.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/netecho/netecho.c

    r631ee0c r0349a10  
    117117        int rc;
    118118
    119         // parse the command line arguments
     119        /* Parse command line arguments */
    120120        for (index = 1; index < argc; ++ index) {
    121121                if (argv[index][0] == '-') {
     
    166166                                verbose = 1;
    167167                                break;
    168                         // long options with the double minus sign ('-')
     168                        /* Long options with double dash */
    169169                        case '-':
    170170                                if (str_lcmp(argv[index] + 2, "backlog=", 6) == 0) {
     
    219219        }
    220220
    221         // check the buffer size
     221        /* Check buffer size */
    222222        if (size <= 0) {
    223223                fprintf(stderr, "Receive size too small (%zu). Using 1024 bytes instead.\n", size);
    224224                size = 1024;
    225225        }
    226         // size plus the terminating null (\0)
     226
     227        /* size plus the terminating null character. */
    227228        data = (char *) malloc(size + 1);
    228229        if (!data) {
     
    231232        }
    232233
    233         // set the reply size if set
     234        /* Set the reply size if set */
    234235        reply_length = reply ? str_length(reply) : 0;
    235236
    236         // prepare the address buffer
     237        /* Prepare the address buffer */
    237238        bzero(address_data, max_length);
    238239        switch (family) {
     
    252253        }
    253254
    254         // get a listening socket
     255        /* Get a listening socket */
    255256        listening_id = socket(family, type, 0);
    256257        if (listening_id < 0) {
     
    259260        }
    260261
    261         // if the stream socket is used
     262        /* if the stream socket is used */
    262263        if (type == SOCK_STREAM) {
    263                 // check the backlog
     264                /* Check backlog size */
    264265                if (backlog <= 0) {
    265266                        fprintf(stderr, "Accepted sockets queue size too small (%zu). Using 3 instead.\n", size);
    266267                        backlog = 3;
    267268                }
    268                 // set the backlog
     269
     270                /* Set the backlog */
    269271                rc = listen(listening_id, backlog);
    270272                if (rc != EOK) {
     
    274276        }
    275277
    276         // bind the listenning socket
     278        /* Bind the listening socket */
    277279        rc = bind(listening_id, address, addrlen);
    278280        if (rc != EOK) {
     
    286288        socket_id = listening_id;
    287289
    288         // do count times
    289         // or indefinitely if set to a negative value
     290        /*
     291         * do count times
     292         * or indefinitely if set to a negative value
     293         */
    290294        while (count) {
    291295
    292296                addrlen = max_length;
    293297                if (type == SOCK_STREAM) {
    294                         // acceept a socket if the stream socket is used
     298                        /* Accept a socket if the stream socket is used */
    295299                        socket_id = accept(listening_id, address, &addrlen);
    296300                        if (socket_id <= 0) {
     
    302306                }
    303307
    304                 // if the datagram socket is used or the stream socked was accepted
     308                /* if the datagram socket is used or the stream socked was accepted */
    305309                if (socket_id > 0) {
    306310
    307                         // receive an echo request
     311                        /* Receive a message to echo */
    308312                        value = recvfrom(socket_id, data, size, 0, address, &addrlen);
    309313                        if (value < 0) {
     
    312316                                length = (size_t) value;
    313317                                if (verbose) {
    314                                         // print the header
    315 
    316                                         // get the source port and prepare the address buffer
     318                                        /* Print the header */
     319
     320                                        /* Get the source port and prepare the address buffer */
    317321                                        address_start = NULL;
    318322                                        switch (address->sa_family) {
     
    329333                                                    address->sa_family, address->sa_family);
    330334                                        }
    331                                         // parse the source address
     335               
     336                                        /* Parse source address */
    332337                                        if (address_start) {
    333338                                                rc = inet_ntop(address->sa_family, address_start, address_string, sizeof(address_string));
     
    342347                                }
    343348
    344                                 // answer the request either with the static reply or the original data
     349                                /* Answer the request either with the static reply or the original data */
    345350                                rc = sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen);
    346351                                if (rc != EOK)
     
    348353                        }
    349354
    350                         // close the accepted stream socket
     355                        /* Close accepted stream socket */
    351356                        if (type == SOCK_STREAM) {
    352357                                rc = closesocket(socket_id);
     
    357362                }
    358363
    359                 // decrease the count if positive
     364                /* Decrease count if positive */
    360365                if (count > 0) {
    361366                        count--;
     
    368373                printf("Closing the socket\n");
    369374
    370         // close the listenning socket
     375        /* Close listenning socket */
    371376        rc = closesocket(listening_id);
    372377        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.