build: tidy up deprecation suppression, enable warnings for clang

Suppress deprecation warnings the closest to the deprecated code, using
`CURL_IGNORE_DEPRECATION()`. Then drop build-specific suppressions, and
file-wide ones. The latter is not compatible with Unity mode. Also
replace manual suppressions with a macro to apply to all compilers with
deprecation warning support. Also enable deprecation warnings for clang.

- curl/curl.h: enable deprecation warnings for clang.

- docs/examples: stop setting `CURL_DISABLE_DEPRECATION` with autotools.
  Suppression moved to C-level earlier. Syncs with cmake.
  Follow-up to 5fc61a37c1 #14123

- tests/http/clients: stop setting `CURL_DISABLE_DEPRECATION` in
  autotools. If it becomes necessary in the future, it can be done in
  C via the macro. Syncs with cmake.

- lib1545: stop setting `CURL_DISABLE_DEPRECATION` in autotools.
  Drop guard from test source.
  Follow-up to 0f10360073 #12444

- libtest, unit: replace `CURL_DISABLE_DEPRECATION` with
  `CURL_IGNORE_DEPRECATION()`.

- docs/examples: replace pragmas with `CURL_IGNORE_DEPRECATION()`.

Closes #14789
This commit is contained in:
Viktor Szakats 2024-09-05 02:11:35 +02:00
parent e1ab01d1bd
commit 5cefda1b93
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
13 changed files with 280 additions and 239 deletions

View File

@ -34,8 +34,7 @@ EXTRA_DIST = README.md Makefile.example Makefile.mk CMakeLists.txt \
#
# $(top_srcdir)/include is for libcurl's external include files
AM_CPPFLAGS = -I$(top_srcdir)/include \
-DCURL_DISABLE_DEPRECATION
AM_CPPFLAGS = -I$(top_srcdir)/include
LIBDIR = $(top_builddir)/lib

View File

@ -36,11 +36,6 @@
#include <curl/curl.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
int main(void)
{
CURL *curl;
@ -53,27 +48,29 @@ int main(void)
struct curl_slist *headerlist = NULL;
static const char buf[] = "Expect:";
/* Fill in the file upload field. This makes libcurl load data from
the given file name when curl_easy_perform() is called. */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_FILE, "multi-formadd.c",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Fill in the file upload field. This makes libcurl load data from
the given file name when curl_easy_perform() is called. */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_FILE, "multi-formadd.c",
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "multi-formadd.c",
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "multi-formadd.c",
CURLFORM_END);
/* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_END);
/* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_END);
)
curl = curl_easy_init();
multi_handle = curl_multi_init();
@ -88,7 +85,9 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
)
curl_multi_add_handle(multi_handle, curl);
@ -109,15 +108,13 @@ int main(void)
/* always cleanup */
curl_easy_cleanup(curl);
/* then cleanup the formpost chain */
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
/* then cleanup the formpost chain */
curl_formfree(formpost);
)
/* free slist */
curl_slist_free_all(headerlist);
}
return 0;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -47,11 +47,6 @@
#include <curl/curl.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
int main(int argc, char *argv[])
{
CURL *curl;
@ -64,27 +59,29 @@ int main(int argc, char *argv[])
curl_global_init(CURL_GLOBAL_ALL);
/* Fill in the file upload field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_FILE, "postit2-formadd.c",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Fill in the file upload field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_FILE, "postit2-formadd.c",
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "postit2-formadd.c",
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "postit2-formadd.c",
CURLFORM_END);
/* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_END);
/* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_END);
)
curl = curl_easy_init();
/* initialize custom header list (stating that Expect: 100-continue is not
@ -96,7 +93,9 @@ int main(int argc, char *argv[])
if((argc == 2) && (!strcmp(argv[1], "noexpectheader")))
/* only disable 100-continue header if explicitly requested */
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
)
/* Perform the request, res gets the return code */
res = curl_easy_perform(curl);
@ -108,14 +107,13 @@ int main(int argc, char *argv[])
/* always cleanup */
curl_easy_cleanup(curl);
/* then cleanup the formpost chain */
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
/* then cleanup the formpost chain */
curl_formfree(formpost);
)
/* free slist */
curl_slist_free_all(headerlist);
}
return 0;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -34,10 +34,11 @@
#endif
/* Compile-time deprecation macros. */
#if (defined(__GNUC__) && \
((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1 ))) || \
defined(__IAR_SYSTEMS_ICC__)) && \
!defined(__INTEL_COMPILER) && \
#if (defined(__GNUC__) && \
((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1))) || \
(defined(__clang__) && __clang_major__ >= 3) || \
defined(__IAR_SYSTEMS_ICC__)) && \
!defined(__INTEL_COMPILER) && \
!defined(CURL_DISABLE_DEPRECATION) && !defined(BUILDING_LIBCURL)
#define CURL_DEPRECATED(version, message) \
__attribute__((deprecated("since " # version ". " message)))

View File

@ -35,8 +35,7 @@ EXTRA_DIST = CMakeLists.txt
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-DCURL_DISABLE_DEPRECATION
-I$(top_srcdir)/lib
LIBDIR = $(top_builddir)/lib

View File

@ -477,7 +477,6 @@ lib1543_SOURCES = lib1518.c $(SUPPORTFILES)
lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543
lib1545_SOURCES = lib1545.c $(SUPPORTFILES)
lib1545_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_DISABLE_DEPRECATION
lib1550_SOURCES = lib1550.c $(SUPPORTFILES)

View File

@ -21,9 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#ifndef CURL_DISABLE_DEPRECATION
#define CURL_DISABLE_DEPRECATION /* Using and testing the form api */
#endif
#include "test.h"
CURLcode test(char *URL)
@ -38,17 +35,20 @@ CURLcode test(char *URL)
easy_init(eh);
easy_setopt(eh, CURLOPT_URL, URL);
curl_formadd(&m_formpost, &lastptr, CURLFORM_COPYNAME, "file",
CURLFORM_FILE, "missing-file", CURLFORM_END);
curl_easy_setopt(eh, CURLOPT_HTTPPOST, m_formpost);
CURL_IGNORE_DEPRECATION(
curl_formadd(&m_formpost, &lastptr, CURLFORM_COPYNAME, "file",
CURLFORM_FILE, "missing-file", CURLFORM_END);
curl_easy_setopt(eh, CURLOPT_HTTPPOST, m_formpost);
)
(void)curl_easy_perform(eh);
(void)curl_easy_perform(eh);
test_cleanup:
curl_formfree(m_formpost);
CURL_IGNORE_DEPRECATION(
curl_formfree(m_formpost);
)
curl_easy_cleanup(eh);
curl_global_cleanup();

View File

@ -21,7 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#define CURL_DISABLE_DEPRECATION /* Using and testing the form api */
#include "test.h"
#include "memdebug.h"
@ -76,23 +75,27 @@ static CURLcode once(char *URL, bool oldstyle)
/* Fill in the file upload field */
if(oldstyle) {
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
CURLFORM_FILENAME, "postit2.c",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
CURLFORM_FILENAME, "postit2.c",
CURLFORM_END);
)
}
else {
/* new style */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile alternative",
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
CURLFORM_FILENAME, "file name 2",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* new style */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile alternative",
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
CURLFORM_FILENAME, "file name 2",
CURLFORM_END);
)
}
if(formrc)
@ -104,52 +107,58 @@ static CURLcode once(char *URL, bool oldstyle)
pooh2.readptr = data;
pooh2.sizeleft = strlen(data);
/* Fill in the file upload field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "callbackdata",
CURLFORM_STREAM, &pooh2,
CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Fill in the file upload field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "callbackdata",
CURLFORM_STREAM, &pooh2,
CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
CURLFORM_END);
)
if(formrc)
printf("curl_formadd(2) = %d\n", (int)formrc);
/* Fill in the filename field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "postit2.c",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Fill in the filename field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "postit2.c",
CURLFORM_END);
)
if(formrc)
printf("curl_formadd(3) = %d\n", (int)formrc);
/* Fill in a submit field too */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_CONTENTTYPE, "text/plain",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Fill in a submit field too */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "send",
CURLFORM_CONTENTTYPE, "text/plain",
CURLFORM_END);
)
if(formrc)
printf("curl_formadd(4) = %d\n", (int)formrc);
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "somename",
CURLFORM_BUFFER, "somefile.txt",
CURLFORM_BUFFERPTR, "blah blah",
CURLFORM_BUFFERLENGTH, (long)9,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "somename",
CURLFORM_BUFFER, "somefile.txt",
CURLFORM_BUFFERPTR, "blah blah",
CURLFORM_BUFFERLENGTH, (long)9,
CURLFORM_END);
)
if(formrc)
printf("curl_formadd(5) = %d\n", (int)formrc);
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
curl_formfree(formpost);
)
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
@ -166,8 +175,10 @@ static CURLcode once(char *URL, bool oldstyle)
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
)
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
@ -180,11 +191,15 @@ static CURLcode once(char *URL, bool oldstyle)
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
CURL_IGNORE_DEPRECATION(
/* always cleanup */
curl_easy_cleanup(curl);
)
/* now cleanup the formpost chain */
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
/* now cleanup the formpost chain */
curl_formfree(formpost);
)
return res;
}

View File

@ -21,7 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#define CURL_DISABLE_DEPRECATION /* Using and testing the form api */
#include "test.h"
#include "memdebug.h"
@ -80,12 +79,13 @@ CURLcode test(char *URL)
goto test_cleanup;
}
headers = headers2;
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, &name,
CURLFORM_COPYCONTENTS, &data,
CURLFORM_CONTENTHEADER, headers,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, &name,
CURLFORM_COPYCONTENTS, &data,
CURLFORM_CONTENTHEADER, headers,
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(1) = %d\n", (int) formrc);
goto test_cleanup;
@ -93,21 +93,22 @@ CURLcode test(char *URL)
contentlength = (long)(strlen(data) - 1);
/* Use a form array for the non-copy test. */
formarray[0].option = CURLFORM_PTRCONTENTS;
formarray[0].value = data;
formarray[1].option = CURLFORM_CONTENTSLENGTH;
formarray[1].value = (char *)(size_t)contentlength;
formarray[2].option = CURLFORM_END;
formarray[2].value = NULL;
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_PTRNAME, name,
CURLFORM_NAMELENGTH, strlen(name) - 1,
CURLFORM_ARRAY, formarray,
CURLFORM_FILENAME, "remotefile.txt",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Use a form array for the non-copy test. */
formarray[0].option = CURLFORM_PTRCONTENTS;
formarray[0].value = data;
formarray[1].option = CURLFORM_CONTENTSLENGTH;
formarray[1].value = (char *)(size_t)contentlength;
formarray[2].option = CURLFORM_END;
formarray[2].value = NULL;
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_PTRNAME, name,
CURLFORM_NAMELENGTH, strlen(name) - 1,
CURLFORM_ARRAY, formarray,
CURLFORM_FILENAME, "remotefile.txt",
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(2) = %d\n", (int) formrc);
goto test_cleanup;
@ -118,57 +119,65 @@ CURLcode test(char *URL)
CURLOPT_PTRNAME actually copies the name thus we do not test this here. */
data[0]++;
/* Check multi-files and content type propagation. */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "multifile",
CURLFORM_FILE, libtest_arg2, /* Set in first.c. */
CURLFORM_FILE, libtest_arg2,
CURLFORM_CONTENTTYPE, "text/whatever",
CURLFORM_FILE, libtest_arg2,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Check multi-files and content type propagation. */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "multifile",
CURLFORM_FILE, libtest_arg2, /* Set in first.c. */
CURLFORM_FILE, libtest_arg2,
CURLFORM_CONTENTTYPE, "text/whatever",
CURLFORM_FILE, libtest_arg2,
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(3) = %d\n", (int) formrc);
goto test_cleanup;
}
/* Check data from file content. */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filecontents",
CURLFORM_FILECONTENT, libtest_arg2,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Check data from file content. */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filecontents",
CURLFORM_FILECONTENT, libtest_arg2,
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(4) = %d\n", (int) formrc);
goto test_cleanup;
}
/* Measure the current form length.
* This is done before including stdin data because we want to reuse it
* and stdin cannot be rewound.
*/
curl_formget(formpost, (void *) &formlength, count_chars);
CURL_IGNORE_DEPRECATION(
/* Measure the current form length.
* This is done before including stdin data because we want to reuse it
* and stdin cannot be rewound.
*/
curl_formget(formpost, (void *) &formlength, count_chars);
)
/* Include length in data for external check. */
curl_msnprintf(flbuf, sizeof(flbuf), "%lu", (unsigned long) formlength);
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "formlength",
CURLFORM_COPYCONTENTS, &flbuf,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "formlength",
CURLFORM_COPYCONTENTS, &flbuf,
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(5) = %d\n", (int) formrc);
goto test_cleanup;
}
/* Check stdin (may be problematic on some platforms). */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "standardinput",
CURLFORM_FILE, "-",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Check stdin (may be problematic on some platforms). */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "standardinput",
CURLFORM_FILE, "-",
CURLFORM_END);
)
if(formrc) {
printf("curl_formadd(6) = %d\n", (int) formrc);
goto test_cleanup;
@ -183,8 +192,10 @@ CURLcode test(char *URL)
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
)
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
@ -203,8 +214,10 @@ test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
/* now cleanup the formpost chain */
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
/* now cleanup the formpost chain */
curl_formfree(formpost);
)
curl_slist_free_all(headers);
curl_global_cleanup();

View File

@ -21,7 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#define CURL_DISABLE_DEPRECATION /* Using and testing the form api */
#include "test.h"
#include "memdebug.h"
@ -50,12 +49,13 @@ CURLcode test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
/* Check proper name and data copying. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "hello",
CURLFORM_COPYCONTENTS, buffer,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Check proper name and data copying. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "hello",
CURLFORM_COPYCONTENTS, buffer,
CURLFORM_END);
)
if(formrc)
printf("curl_formadd(1) = %d\n", (int) formrc);
@ -63,7 +63,9 @@ CURLcode test(char *URL)
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
curl_formfree(formpost);
)
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
@ -71,8 +73,10 @@ CURLcode test(char *URL)
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
)
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
@ -88,8 +92,10 @@ test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
/* now cleanup the formpost chain */
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
/* now cleanup the formpost chain */
curl_formfree(formpost);
)
curl_global_cleanup();

View File

@ -21,11 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#if !defined(LIB670) && !defined(LIB671)
#define CURL_DISABLE_DEPRECATION /* Using and testing the form api */
#endif
#include "test.h"
#include <time.h>
@ -159,12 +154,14 @@ CURLcode test(char *URL)
if(res == CURLE_OK)
test_setopt(pooh.easy, CURLOPT_MIMEPOST, mime);
#else
/* Build the form. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, name,
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTLEN, (curl_off_t) 2,
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
/* Build the form. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, name,
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTLEN, (curl_off_t) 2,
CURLFORM_END);
)
if(formrc) {
fprintf(stderr, "curl_formadd() = %d\n", (int) formrc);
goto test_cleanup;
@ -173,8 +170,10 @@ CURLcode test(char *URL)
/* We want to use our own read function. */
test_setopt(pooh.easy, CURLOPT_READFUNCTION, read_callback);
/* Send a multi-part formpost. */
test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
CURL_IGNORE_DEPRECATION(
/* Send a multi-part formpost. */
test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
)
#endif
#if defined(LIB670) || defined(LIB672)
@ -253,7 +252,9 @@ test_cleanup:
#if defined(LIB670) || defined(LIB671)
curl_mime_free(mime);
#else
curl_formfree(formpost);
CURL_IGNORE_DEPRECATION(
curl_formfree(formpost);
)
#endif
curl_global_cleanup();

View File

@ -195,7 +195,6 @@ print <<HEADER
* SPDX-License-Identifier: curl
*
***************************************************************************/
#define CURL_DISABLE_DEPRECATION /* Deprecated options are tested too */
#include "test.h"
#include "memdebug.h"
#include <limits.h>
@ -352,6 +351,8 @@ CURLcode test(char *URL)
res = CURLE_OUT_OF_MEMORY;
goto test_cleanup;
}
CURL_IGNORE_DEPRECATION(
HEADER
;
@ -584,6 +585,8 @@ MOO
print <<FOOTER
)
curl_easy_setopt(curl, (CURLoption)1, 0);
res = CURLE_OK;
test_cleanup:

View File

@ -21,7 +21,6 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#define CURL_DISABLE_DEPRECATION /* Testing the form api */
#include "curlcheck.h"
#include <curl/curl.h>
@ -51,49 +50,60 @@ UNITTEST_START
size_t total_size = 0;
char buffer[] = "test buffer";
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
CURL_IGNORE_DEPRECATION(
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
)
fail_unless(rc == 0, "curl_formadd returned error");
/* after the first curl_formadd when there's a single entry, both pointers
should point to the same struct */
fail_unless(post == last, "post and last weren't the same");
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
CURLFORM_COPYCONTENTS, "<HTML></HTML>",
CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
CURL_IGNORE_DEPRECATION(
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
CURLFORM_COPYCONTENTS, "<HTML></HTML>",
CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
)
fail_unless(rc == 0, "curl_formadd returned error");
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
CURL_IGNORE_DEPRECATION(
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
)
fail_unless(rc == 0, "curl_formadd returned error");
res = curl_formget(post, &total_size, print_httppost_callback);
CURL_IGNORE_DEPRECATION(
res = curl_formget(post, &total_size, print_httppost_callback);
)
fail_unless(res == 0, "curl_formget returned error");
fail_unless(total_size == 518, "curl_formget got wrong size back");
curl_formfree(post);
CURL_IGNORE_DEPRECATION(
curl_formfree(post);
)
/* start a new formpost with a file upload and formget */
post = last = NULL;
rc = curl_formadd(&post, &last,
CURLFORM_PTRNAME, "name of file field",
CURLFORM_FILE, arg,
CURLFORM_FILENAME, "custom named file",
CURLFORM_END);
CURL_IGNORE_DEPRECATION(
rc = curl_formadd(&post, &last,
CURLFORM_PTRNAME, "name of file field",
CURLFORM_FILE, arg,
CURLFORM_FILENAME, "custom named file",
CURLFORM_END);
)
fail_unless(rc == 0, "curl_formadd returned error");
res = curl_formget(post, &total_size, print_httppost_callback);
CURL_IGNORE_DEPRECATION(
res = curl_formget(post, &total_size, print_httppost_callback);
)
fail_unless(res == 0, "curl_formget returned error");
fail_unless(total_size == 899, "curl_formget got wrong size back");
curl_formfree(post);
CURL_IGNORE_DEPRECATION(
curl_formfree(post);
)
UNITTEST_STOP