Changeset a35b458 in mainline for uspace/app/download/main.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/download/main.c

    r3061bc1 ra35b458  
    8181                goto error;
    8282        }
    83        
     83
    8484        i = 1;
    85        
     85
    8686        if (str_cmp(argv[i], "-o") == 0) {
    8787                ++i;
     
    9191                        goto error;
    9292                }
    93                
     93
    9494                ofname = argv[i++];
    9595                ofile = fopen(ofname, "wb");
     
    100100                }
    101101        }
    102        
     102
    103103        if (argc != i + 1) {
    104104                syntax_print();
     
    106106                goto error;
    107107        }
    108        
     108
    109109        uri = uri_parse(argv[i]);
    110110        if (uri == NULL) {
     
    113113                goto error;
    114114        }
    115        
     115
    116116        if (!uri_validate(uri)) {
    117117                fprintf(stderr, "The URI is invalid\n");
     
    119119                goto error;
    120120        }
    121        
     121
    122122        /* TODO uri_normalize(uri) */
    123        
     123
    124124        if (str_cmp(uri->scheme, "http") != 0) {
    125125                fprintf(stderr, "Only http scheme is supported at the moment\n");
     
    127127                goto error;
    128128        }
    129        
     129
    130130        if (uri->host == NULL) {
    131131                fprintf(stderr, "host not set\n");
     
    133133                goto error;
    134134        }
    135        
     135
    136136        uint16_t port = 80;
    137137        if (uri->port != NULL) {
     
    143143                }
    144144        }
    145        
     145
    146146        const char *path = uri->path;
    147147        if (path == NULL || *path == 0)
     
    163163                }
    164164        }
    165        
     165
    166166        http_request_t *req = http_request_create("GET", server_path);
    167167        free(server_path);
     
    171171                goto error;
    172172        }
    173        
     173
    174174        rc = http_headers_append(&req->headers, "Host", uri->host);
    175175        if (rc != EOK) {
     
    177177                goto error;
    178178        }
    179        
     179
    180180        rc = http_headers_append(&req->headers, "User-Agent", USER_AGENT);
    181181        if (rc != EOK) {
     
    183183                goto error;
    184184        }
    185        
     185
    186186        http = http_create(uri->host, port);
    187187        if (http == NULL) {
     
    190190                goto error;
    191191        }
    192        
     192
    193193        rc = http_connect(http);
    194194        if (rc != EOK) {
     
    197197                goto error;
    198198        }
    199        
     199
    200200        rc = http_send_request(http, req);
    201201        if (rc != EOK) {
     
    204204                goto error;
    205205        }
    206        
     206
    207207        http_response_t *response = NULL;
    208208        rc = http_receive_response(&http->recv_buffer, &response, 16 * 1024,
     
    213213                goto error;
    214214        }
    215        
     215
    216216        if (response->status != 200) {
    217217                fprintf(stderr, "Server returned status %d %s\n", response->status,
     
    224224                        goto error;
    225225                }
    226                
     226
    227227                size_t body_size;
    228228                while ((rc = recv_buffer(&http->recv_buffer, buf, buf_size, &body_size)) == EOK && body_size > 0) {
    229229                        fwrite(buf, 1, body_size, ofile != NULL ? ofile : stdout);
    230230                }
    231                
     231
    232232                if (rc != EOK) {
    233233                        fprintf(stderr, "Failed receiving body: %s", str_error(rc));
    234234                }
    235235        }
    236        
     236
    237237        free(buf);
    238238        http_destroy(http);
Note: See TracChangeset for help on using the changeset viewer.