aboutsummaryrefslogtreecommitdiff
path: root/docs/examples/10-at-a-time.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-02-11 09:42:38 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-02-11 09:44:45 +0100
commit3a6563d668406df1703edb4202afc038fcf9d30e (patch)
tree0fbb9438d99c13049f72b10c966583e582e4e238 /docs/examples/10-at-a-time.c
parent936d8f07dfbf2ac22ffd216f5363152bcecc2651 (diff)
examples: adhere to curl code style
All plain C examples now (mostly) adhere to the curl code style. While they are only examples, they had diverted so much and contained all sorts of different mixed code styles by now. Having them use a unified style helps users and readability. Also, as they get copy-and-pasted widely by users, making sure they're clean and nice is a good idea. 573 checksrc warnings were addressed.
Diffstat (limited to 'docs/examples/10-at-a-time.c')
-rw-r--r--docs/examples/10-at-a-time.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/docs/examples/10-at-a-time.c b/docs/examples/10-at-a-time.c
index 554d3c066..75f9d5c5b 100644
--- a/docs/examples/10-at-a-time.c
+++ b/docs/examples/10-at-a-time.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -127,41 +127,42 @@ int main(void)
uses */
curl_multi_setopt(cm, CURLMOPT_MAXCONNECTS, (long)MAX);
- for (C = 0; C < MAX; ++C) {
+ for(C = 0; C < MAX; ++C) {
init(cm, C);
}
- while (U) {
+ while(U) {
curl_multi_perform(cm, &U);
- if (U) {
+ if(U) {
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);
- if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
+ if(curl_multi_fdset(cm, &R, &W, &E, &M)) {
fprintf(stderr, "E: curl_multi_fdset\n");
return EXIT_FAILURE;
}
- if (curl_multi_timeout(cm, &L)) {
+ if(curl_multi_timeout(cm, &L)) {
fprintf(stderr, "E: curl_multi_timeout\n");
return EXIT_FAILURE;
}
- if (L == -1)
+ if(L == -1)
L = 100;
- if (M == -1) {
+ if(M == -1) {
#ifdef WIN32
Sleep(L);
#else
sleep(L / 1000);
#endif
- } else {
+ }
+ else {
T.tv_sec = L/1000;
T.tv_usec = (L%1000)*1000;
- if (0 > select(M+1, &R, &W, &E, &T)) {
+ if(0 > select(M+1, &R, &W, &E, &T)) {
fprintf(stderr, "E: select(%i,,,,%li): %i: %s\n",
M+1, L, errno, strerror(errno));
return EXIT_FAILURE;
@@ -169,8 +170,8 @@ int main(void)
}
}
- while ((msg = curl_multi_info_read(cm, &Q))) {
- if (msg->msg == CURLMSG_DONE) {
+ while((msg = curl_multi_info_read(cm, &Q))) {
+ if(msg->msg == CURLMSG_DONE) {
char *url;
CURL *e = msg->easy_handle;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url);
@@ -182,7 +183,7 @@ int main(void)
else {
fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg);
}
- if (C < CNT) {
+ if(C < CNT) {
init(cm, C++);
U++; /* just to prevent it from remaining at 0 if there are more
URLs to get */