Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read scenario fixed #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/fcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static size_t write_callback(char *buffer, size_t size, size_t nitems,
size_t n_copytouser = MIN(size, n_remainuser);

/* space left in the user buffer, copy as much as possible to there */
memcpy(h->user.p, buffer, n_copytouser);
memcpy(h->user.p + h->user.used, buffer, n_copytouser);

buffer += n_copytouser;
size -= n_copytouser;
Expand Down Expand Up @@ -196,6 +196,8 @@ int fcurl_close(struct fcurl_handle *h)
/* cleanup */
curl_easy_cleanup(h->curl);

curl_multi_cleanup(h->mh);

free(h->b.p);
free(h);

Expand All @@ -204,11 +206,8 @@ int fcurl_close(struct fcurl_handle *h)

int fcurl_eof(struct fcurl_handle *h)
{
int ret=0;

/* add code here */

return ret;
/* Still does not make difference between EOF and errors */
return (h->transfer_complete && 0 == h->b.used);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds an feof() version

Copy link
Author

@Bylon2 Bylon2 Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a basic one, still does not make difference eof/error, but is needed in a classic while(eof) { read; write; } loop. Without an "eof", the "read scenario" (in which I include the loop, so it is a question of how you define "scenario" !) does not work. But agreed, a single read would work without this addition.

}

/*
Expand Down