wget2 2.1.0
Loading...
Searching...
No Matches
Libwget printf functions

Functions

size_t wget_vasprintf (char **strp, const char *fmt, va_list args)
 
size_t wget_asprintf (char **strp, const char *fmt,...)
 
char * wget_vaprintf (const char *fmt, va_list args)
 
char * wget_aprintf (const char *fmt,...)
 
size_t wget_vfprintf (FILE *fp, const char *fmt, va_list args)
 
size_t wget_fprintf (FILE *fp, const char *fmt,...)
 
size_t wget_printf (const char *fmt,...)
 
size_t wget_vsnprintf (char *str, size_t size, const char *fmt, va_list args)
 
size_t wget_snprintf (char *str, size_t size, const char *fmt,...)
 

Detailed Description

This is a collection of printf-style functions that are used with libwget and/or Wget2 code. They may be useful to other developers that is why they are exported.

Function Documentation

◆ wget_vasprintf()

size_t wget_vasprintf ( char **  strp,
const char *  fmt,
va_list  args 
)
Parameters
[in]strpPointer to hold the string output
[in]fmtPrintf-like format specifier
[in]argsva_list of arguments
Returns
Length of the string returned via strp or (size_t) -1 on error

Prints arguments to allocated memory and 0-terminates it. The string is returned via the first argument. It has to be free()'d by the caller when it is no longer needed.

◆ wget_asprintf()

size_t wget_asprintf ( char **  strp,
const char *  fmt,
  ... 
)
Parameters
[in]strpPointer to hold the string output
[in]fmtPrintf-like format specifier
[in]...List of arguments
Returns
Length of the string returned via strp

Prints arguments to allocated memory and 0-terminates it. The string is returned via the first argument. It has to be free()'d by the caller when it is no longer needed.

◆ wget_vaprintf()

char * wget_vaprintf ( const char *  fmt,
va_list  args 
)
Parameters
[in]fmtPrintf-like format specifier
[in]argsva_list of arguments
Returns
Pointer to 0-terminated string in memory

Prints arguments to memory and returns a pointer to allocated and 0-terminated chunk of memory. The return value has to be free()'d by the caller when it is no longer needed.

◆ wget_aprintf()

char * wget_aprintf ( const char *  fmt,
  ... 
)
Parameters
[in]fmtPrintf-like format specifier
[in]...List of arguments
Returns
Pointer to 0-terminated string in memory

Prints arguments to memory and returns a pointer to allocated and 0-terminated chunk of memory. The return value has to be free()'d by the caller when it is no longer needed.

◆ wget_vfprintf()

size_t wget_vfprintf ( FILE *  fp,
const char *  fmt,
va_list  args 
)
Parameters
[in]fpFILE pointer
[in]fmtPrintf-like format specifier
[in]argsList of arguments
Returns
Number of bytes written or -1 on error

Prints arguments to stream fp and returns number of bytes written.

◆ wget_fprintf()

size_t wget_fprintf ( FILE *  fp,
const char *  fmt,
  ... 
)
Parameters
[in]fpFILE pointer
[in]fmtPrintf-like format specifier
[in]...List of arguments
Returns
Number of bytes written or -1 on error

Prints arguments to stream fp and returns number of bytes written.

◆ wget_printf()

size_t wget_printf ( const char *  fmt,
  ... 
)
Parameters
[in]fmtPrintf-like format specifier
[in]...List of arguments
Returns
Number of bytes written or -1 on error

Prints arguments to stdout and returns number of bytes written.

◆ wget_vsnprintf()

size_t wget_vsnprintf ( char *  str,
size_t  size,
const char *  fmt,
va_list  args 
)
Parameters
[in]strDestination buffer
[in]sizeSize of str
[in]fmtPrintf-like format specifier
[in]argsList of arguments
Returns
Number of bytes written, or, on truncation, that would have been written

Prints arguments to buffer str and returns number of bytes written, or on truncation: that would have been written.

If str is NULL the return value are the number of bytes that would have been written.

◆ wget_snprintf()

size_t wget_snprintf ( char *  str,
size_t  size,
const char *  fmt,
  ... 
)
Parameters
[in]strDestination buffer
[in]sizeSize of str
[in]fmtPrintf-like format specifier
[in]...List of arguments
Returns
Number of bytes written, or, on truncation, that would have been written

Prints arguments to buffer str and returns number of bytes written, or on truncation: that would have been written.

If str is NULL the return value are the number of bytes that would have been written.