src: stop overriding system printf symbols

Also:
- tool_operate: use the socket printf mask, drop cast.

Follow-up to 4deea9396b #18814

Closes #18844
This commit is contained in:
Viktor Szakats 2025-10-04 12:24:57 +02:00
parent 34ad78da89
commit db98daab05
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
25 changed files with 203 additions and 207 deletions

View file

@ -100,7 +100,7 @@ static void print_category(unsigned int category, unsigned int cols)
else
opt = 0;
}
printf(" %-*s %s\n", (int)opt, helptext[i].opt, helptext[i].desc);
curl_mprintf(" %-*s %s\n", (int)opt, helptext[i].opt, helptext[i].desc);
}
}
@ -110,7 +110,7 @@ static int get_category_content(const char *category, unsigned int cols)
unsigned int i;
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
if(curl_strequal(categories[i].opt, category)) {
printf("%s: %s\n", categories[i].opt, categories[i].desc);
curl_mprintf("%s: %s\n", categories[i].opt, categories[i].desc);
print_category(categories[i].category, cols);
return 0;
}
@ -122,7 +122,7 @@ static void get_categories(void)
{
unsigned int i;
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
printf(" %-11s %s\n", categories[i].opt, categories[i].desc);
curl_mprintf(" %-11s %s\n", categories[i].opt, categories[i].desc);
}
/* Prints all categories as a comma-separated list of given width */
@ -135,18 +135,18 @@ static void get_categories_list(unsigned int width)
if(i == CURL_ARRAYSIZE(categories) - 1) {
/* final category */
if(col + len + 1 < width)
printf("%s.\n", categories[i].opt);
curl_mprintf("%s.\n", categories[i].opt);
else
/* start a new line first */
printf("\n%s.\n", categories[i].opt);
curl_mprintf("\n%s.\n", categories[i].opt);
}
else if(col + len + 2 < width) {
printf("%s, ", categories[i].opt);
curl_mprintf("%s, ", categories[i].opt);
col += len + 2;
}
else {
/* start a new line first */
printf("\n%s, ", categories[i].opt);
curl_mprintf("\n%s, ", categories[i].opt);
col = len + 2;
}
}
@ -268,17 +268,17 @@ void tool_help(const char *category)
else if(!category[2])
a = findshortopt(category[1]);
if(!a) {
fprintf(tool_stderr, "Incorrect option name to show help for,"
" see curl -h\n");
curl_mfprintf(tool_stderr, "Incorrect option name to show help for,"
" see curl -h\n");
}
else {
char cmdbuf[80];
if(a->letter != ' ')
msnprintf(cmdbuf, sizeof(cmdbuf), "\n -%c, --", a->letter);
curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n -%c, --", a->letter);
else if(a->desc & ARG_NO)
msnprintf(cmdbuf, sizeof(cmdbuf), "\n --no-%s", a->lname);
curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n --no-%s", a->lname);
else
msnprintf(cmdbuf, sizeof(cmdbuf), "\n %s", category);
curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n %s", category);
#ifdef USE_MANUAL
if(a->cmd == C_XATTR)
/* this is the last option, which then ends when FILES starts */
@ -288,8 +288,8 @@ void tool_help(const char *category)
#endif
}
#else
fprintf(tool_stderr, "Cannot comply. "
"This curl was built without built-in manual\n");
curl_mfprintf(tool_stderr, "Cannot comply. "
"This curl was built without built-in manual\n");
#endif
}
/* Otherwise print category and handle the case if the cat was not found */
@ -312,15 +312,15 @@ void tool_version_info(void)
{
const char *const *builtin;
if(is_debug())
fprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, "
"do not use in production\n\n");
curl_mfprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, "
"do not use in production\n\n");
printf(CURL_ID "%s\n", curl_version());
curl_mprintf(CURL_ID "%s\n", curl_version());
#ifdef CURL_PATCHSTAMP
printf("Release-Date: %s, security patched: %s\n",
LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
curl_mprintf("Release-Date: %s, security patched: %s\n",
LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
#else
printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
curl_mprintf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
#endif
if(built_in_protos[0]) {
#ifndef CURL_DISABLE_IPFS
@ -339,15 +339,15 @@ void tool_version_info(void)
}
}
#endif /* !CURL_DISABLE_IPFS */
printf("Protocols:");
curl_mprintf("Protocols:");
for(builtin = built_in_protos; *builtin; ++builtin) {
/* Special case: do not list rtmp?* protocols.
They may only appear together with "rtmp" */
if(!curl_strnequal(*builtin, "rtmp", 4) || !builtin[0][4])
printf(" %s", *builtin);
curl_mprintf(" %s", *builtin);
#ifndef CURL_DISABLE_IPFS
if(insert && insert == *builtin) {
printf(" ipfs ipns");
curl_mprintf(" ipfs ipns");
insert = NULL;
}
#endif /* !CURL_DISABLE_IPFS */
@ -371,16 +371,16 @@ void tool_version_info(void)
feat_ext[feat_ext_count] = NULL;
qsort((void *)feat_ext, feat_ext_count, sizeof(*feat_ext),
struplocompare4sort);
printf("Features:");
curl_mprintf("Features:");
for(builtin = feat_ext; *builtin; ++builtin)
printf(" %s", *builtin);
curl_mprintf(" %s", *builtin);
puts(""); /* newline */
free((void *)feat_ext);
}
}
if(strcmp(CURL_VERSION, curlinfo->version)) {
printf("WARNING: curl and libcurl versions do not match. "
"Functionality may be affected.\n");
curl_mprintf("WARNING: curl and libcurl versions do not match. "
"Functionality may be affected.\n");
}
}
@ -395,7 +395,7 @@ void tool_list_engines(void)
puts("Build-time engines:");
if(engines) {
for(; engines; engines = engines->next)
printf(" %s\n", engines->data);
curl_mprintf(" %s\n", engines->data);
}
else {
puts(" <none>");