aboutsummaryrefslogtreecommitdiff
path: root/docs/examples/sendrecv.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/sendrecv.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/sendrecv.c')
-rw-r--r--docs/examples/sendrecv.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c
index 728b5fd65..46daf80e7 100644
--- a/docs/examples/sendrecv.c
+++ b/docs/examples/sendrecv.c
@@ -44,12 +44,10 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
FD_SET(sockfd, &errfd); /* always check for error */
- if(for_recv)
- {
+ if(for_recv) {
FD_SET(sockfd, &infd);
}
- else
- {
+ else {
FD_SET(sockfd, &outfd);
}
@@ -84,8 +82,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl);
- if(CURLE_OK != res)
- {
+ if(CURLE_OK != res) {
printf("Error: %s\n", strerror(res));
return 1;
}
@@ -96,8 +93,7 @@ int main(void)
*/
res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockextr);
- if(CURLE_OK != res)
- {
+ if(CURLE_OK != res) {
printf("Error: %s\n", curl_easy_strerror(res));
return 1;
}
@@ -105,8 +101,7 @@ int main(void)
sockfd = sockextr;
/* wait for the socket to become ready for sending */
- if(!wait_on_socket(sockfd, 0, 60000L))
- {
+ if(!wait_on_socket(sockfd, 0, 60000L)) {
printf("Error: timeout.\n");
return 1;
}
@@ -116,16 +111,14 @@ int main(void)
* to see if all the request has been sent */
res = curl_easy_send(curl, request, strlen(request), &iolen);
- if(CURLE_OK != res)
- {
+ if(CURLE_OK != res) {
printf("Error: %s\n", curl_easy_strerror(res));
return 1;
}
puts("Reading response.");
/* read the response */
- for(;;)
- {
+ for(;;) {
char buf[1024];
wait_on_socket(sockfd, 1, 60000L);