Commit 55452ebd authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

curl/mprintf.h: remove support for _MPRINTF_REPLACE

The define is not in our name space and is therefore not protected by
our API promises.

It was only really used by libcurl internals but was mostly erased from
there already in 8aabbf5f (March 2015). This is supposedly the final
death blow to that define from everywhere.

As a side-effect, making sure _MPRINTF_REPLACE is gone and not used, I
made the lib tests in tests/libtest/ use curl_printf.h for its redefine
magic and then subsequently the use of sprintf() got banned in the tests
as well (as it is in libcurl internals) and I then replaced them all
with snprintf().

In the unlikely event that any users is actually using this define and
gets sad by this change, it is very easily copied to the user's own
code.
parent 7218b52c
Loading
Loading
Loading
Loading
+3 −9
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" *
.\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
.\" * you should have received as part of this distribution. The terms
@@ -91,15 +91,9 @@ returned string must be free()ed by the receiver.
Like curl_maprintf() but takes a va_list pointer argument instead of a
Like curl_maprintf() but takes a va_list pointer argument instead of a
variable amount of arguments.
variable amount of arguments.
.RE
.RE

To easily use all these cloned functions instead of the normal ones, #define
_MPRINTF_REPLACE before you include the <curl/mprintf.h> file. Then all the
normal names like printf, fprintf, sprintf etc will use the curl-functions
instead.
.SH AVAILABILITY
.SH AVAILABILITY
These function will be removed from the public libcurl API in a near
These functions will be removed from the public libcurl API in the future. Do
future. They will instead be made "available" by source code access only, and
not use them in any new programs or projects.
then as curlx_-prefixed functions. See lib/README.curlx for further details.
.SH RETURN VALUE
.SH RETURN VALUE
The \fBcurl_maprintf\fP and \fBcurl_mvaprintf\fP functions return a pointer to
The \fBcurl_maprintf\fP and \fBcurl_mvaprintf\fP functions return a pointer to
a newly allocated string, or NULL if it failed.
a newly allocated string, or NULL if it failed.
+2 −26
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -24,8 +24,7 @@


#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h> /* needed for FILE */
#include <stdio.h> /* needed for FILE */

#include "curl.h"  /* for CURL_EXTERN */
#include "curl.h"


#ifdef  __cplusplus
#ifdef  __cplusplus
extern "C" {
extern "C" {
@@ -44,29 +43,6 @@ CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);


#ifdef _MPRINTF_REPLACE
# undef printf
# undef fprintf
# undef sprintf
# undef vsprintf
# undef snprintf
# undef vprintf
# undef vfprintf
# undef vsnprintf
# undef aprintf
# undef vaprintf
# define printf curl_mprintf
# define fprintf curl_mfprintf
# define sprintf curl_msprintf
# define vsprintf curl_mvsprintf
# define snprintf curl_msnprintf
# define vprintf curl_mvprintf
# define vfprintf curl_mvfprintf
# define vsnprintf curl_mvsnprintf
# define aprintf curl_maprintf
# define vaprintf curl_mvaprintf
#endif

#ifdef  __cplusplus
#ifdef  __cplusplus
}
}
#endif
#endif
+1 −6
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1999 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1999 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -36,11 +36,6 @@
 */
 */


#include "curl_setup.h"
#include "curl_setup.h"

#if defined(DJGPP) && (DJGPP_MINOR < 4)
#undef _MPRINTF_REPLACE /* don't use x_was_used() here */
#endif

#include <curl/mprintf.h>
#include <curl/mprintf.h>


#include "curl_memory.h"
#include "curl_memory.h"
+3 −2
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -51,7 +51,8 @@ int test(char *URL)
  /* DNS cache injection */
  /* DNS cache injection */
  struct curl_slist *dns_cache_list;
  struct curl_slist *dns_cache_list;


  sprintf(redirect, "google.com:%s:%s", libtest_arg2, libtest_arg3);
  snprintf(redirect, sizeof(redirect), "google.com:%s:%s", libtest_arg2,
           libtest_arg3);


  start_test_timing();
  start_test_timing();


+4 −3
Original line number Original line Diff line number Diff line
@@ -46,7 +46,7 @@ int test(char *URL)


  /* Create fake DNS entries for serverX.example.com for all handles */
  /* Create fake DNS entries for serverX.example.com for all handles */
  for(i=0; i < NUM_HANDLES; i++) {
  for(i=0; i < NUM_HANDLES; i++) {
    sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
    snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, port, address);
    printf("%s\n", dnsentry);
    printf("%s\n", dnsentry);
    slist2 = curl_slist_append(slist, dnsentry);
    slist2 = curl_slist_append(slist, dnsentry);
    if(!slist2) {
    if(!slist2) {
@@ -69,7 +69,8 @@ int test(char *URL)
    /* get an easy handle */
    /* get an easy handle */
    easy_init(curl[i]);
    easy_init(curl[i]);
    /* specify target */
    /* specify target */
    sprintf(target_url, "http://server%d.example.com:%s/path/1506%04i",
    snprintf(target_url, sizeof(target_url),
             "http://server%d.example.com:%s/path/1506%04i",
             i + 1, port, i + 1);
             i + 1, port, i + 1);
    target_url[sizeof(target_url) - 1] = '\0';
    target_url[sizeof(target_url) - 1] = '\0';
    easy_setopt(curl[i], CURLOPT_URL, target_url);
    easy_setopt(curl[i], CURLOPT_URL, target_url);
Loading