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

CURLOPT_PREQUOTE #4736

Closed
Bylon2 opened this issue Dec 18, 2019 · 2 comments
Closed

CURLOPT_PREQUOTE #4736

Bylon2 opened this issue Dec 18, 2019 · 2 comments

Comments

@Bylon2
Copy link

Bylon2 commented Dec 18, 2019

I did this

Copie/Paste the example...

I expected the following

I expect the example to work... it does not!

In fact there is a typo (same one in POSTQUOTE and QUOTE)

struct curl_slist *h = NULL;
h = curl_slist_append(h, "SYST");
 
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
 
  /* pass in the FTP commands to run */
  curl_easy_setopt(curl, CURLOPT_PREQUOTE, headerlist);
 
  ret = curl_easy_perform(curl);
 
  curl_easy_cleanup(curl);
}

$ gcc -Wall -std=c11 example.c -o example $(curl-config --cflags --libs)
example.c: In function ‘main’:

In file included from /usr/include/curl/curl.h:2402:0,
                 from example.c:3:
example.c:39:49: error: ‘headerlist’ undeclared (first use in this function)
  res = curl_easy_setopt(curl, CURLOPT_PREQUOTE, headerlist);

The curl_easy_setopt call should be instead:
curl_easy_setopt(curl, CURLOPT_PREQUOTE, h);

Alternatively, the example could start with:

struct curl_slist *headerlist = NULL;
headerlist = curl_slist_append(headerlist, "SYST");

... which is probably a better option because 'headerlist' is a more self descriptive variable than 'h':

@jay
Copy link
Member

jay commented Dec 18, 2019

Thanks. I renamed it to cmdlist since it's not a headerlist.

@Bylon2
Copy link
Author

Bylon2 commented Dec 18, 2019

Excellent, thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants