curl_formdata: fix to pass long where missing, document CURLFORM_NAMELENGTH

- lib650: pass `long` to `CURLFORM_NAMELENGTH` in test.
  Spotted by Copilot.
  https://github.com/curl/curl/pull/22011#discussion_r3412407235
  Follow-up to 3620e569b3

- lib650: drop an interim variable, and interim casts.
  Follow-up to 60776a0515 #2747

- curl_formdata.md: document `CURLFORM_NAMELENGTH` on man page.

- curl_formdata.md: pass `long` to `CURLFORM_BUFFERLENGTH` on man page.

- formdata: pass `long` to `CURLFORM_CONTENTSLENGTH` in comment.

Closes #22017
This commit is contained in:
Viktor Szakats 2026-06-15 11:47:05 +02:00
parent 0dae3b2690
commit adb606eae7
No known key found for this signature in database
3 changed files with 10 additions and 7 deletions

View file

@ -112,6 +112,12 @@ If you pass a 0 (zero) for this option, libcurl calls strlen() on the contents
to figure out the size. If you really want to send a zero byte content then
you must make sure strlen() on the data pointer returns zero.
## CURLFORM_NAMELENGTH
followed by a long giving the length of the name. Pass this option to set
the length of *CURLFORM_COPYNAME* and *CURLFORM_PTRNAME* strings, if they are
not null-terminated.
## CURLFORM_FILECONTENT
followed by a filename, causes that file to be read and its contents used
@ -278,7 +284,7 @@ int main(void)
CURLFORM_COPYNAME, "name",
CURLFORM_BUFFER, "data",
CURLFORM_BUFFERPTR, record,
CURLFORM_BUFFERLENGTH, sizeof(record),
CURLFORM_BUFFERLENGTH, (long)sizeof(record),
CURLFORM_END);
/* no option needed for the end marker */