cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_mprintf questions

From: Mohun Biswas <m_biswas_at_mailinator.com>
Date: Fri, 02 Jun 2006 10:55:29 -0400

I need to represent an integral value in base 36. Since I'm already
using libcurl, I figured I could use Daniel's enhanced printf functions
to do so but I'm having trouble and wonder if I'm doing something wrong.
I'm using 7.15.3 on Solaris/Linux/Mac/Windows and eventually others:

Q1: According to the README, curl_m*printf is deprecated in favor of
curlx_m*printf. In order to use these it seems I must include
"curl/curlx.h". But when I do so it then expects additional headers
"curl/strequal.h", "curl/timeval.h", etc. These create additional
conflicts; in particular the struct timeval declared conflicts with the
version in <sys/time.h>. How can I cleanly use the curlx_* functions?

Q2: If I understand correctly, these mprintf functions are an early
version of trio. The only documentation I can find is for trio, and that
shows the following printing 42 in binary:

        trio_printf("|%10.8.2i|%10..2i|%..2i|", 42, 42, 42);
        | 00101010| 101010|101010|

When I try this with curl_mprintf it fails:

% cat mprintf.c
#include <stdio.h>
#include <curl/mprintf.h>

int
main(void)
{
     curl_mprintf("|%10.8.2i|%10..2i|%..2i|\n", 42, 42, 42);
     return 0;
}

% ./mprintf
| 42| 42|42|

So is the curl_mprintf suite capable of doing radix conversion or would
I have to get trio separately? Which I'd rather not do due to the burden
of building and maintaining it on lots of platforms, while I've already
assumed that burden for libcurl (and happily, I might add, since curl is
a great piece of work).

Thanks,
MB
Received on 2006-06-02