ft_printf
|
Replicate behaviour of printf(3)
functions.
More...
Functions | |
int | ft_printf (const char *format,...) |
Replicates behaviour of printf(3) . More... | |
int | ft_dprintf (int fd, const char *format,...) |
Replicates behaviour of dprintf(3) . More... | |
int | ft_vprintf (const char *format, va_list ap) |
Replicates behaviour of vprintf(3) . More... | |
int | ft_vdprintf (int fd, const char *format, va_list ap) |
Replicates behaviour of vdprintf(3) . More... | |
int | ft_sprintf (char *str, const char *format,...) |
Replicates behaviour of sprintf(3) . More... | |
int | ft_vsprintf (char *str, const char *format, va_list ap) |
Replicates behaviour of vsprintf(3) . More... | |
int | ft_snprintf (char *str, size_t size, const char *format,...) |
Replicates behaviour of snprintf(3) . More... | |
int | ft_vsnprintf (char *str, size_t size, const char *format, va_list ap) |
Replicates behaviour of vsnprintf(3) . More... | |
int | ft_asprintf (char **ret, const char *format,...) |
Replicates behaviour of asprintf(3) . More... | |
int | ft_vasprintf (char **ret, const char *format, va_list ap) |
Replicates behaviour of vasprintf(3) . More... | |
Replicate behaviour of printf(3)
functions.
Support standard field values and combination thereof (where applicable):
#
, 0
, , -
, +
*
optionshh
, h
, l
, ll
, L
, j
c
, s
, p
, %
, d
, i
, o
, u
, x
, X
, f
Custom specifications:
b
type to print in binary format (supports same parameters as i
type)cyan
red
green
yellow
blue
magenta
ft_printf("{red}Color-print. {eoc}Normal print.");
int ft_asprintf | ( | char ** | ret, |
const char * | format, | ||
... | |||
) |
Replicates behaviour of asprintf(3)
.
[out] | ret | Pointer that will be set to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ... | Variadic arguments |
-1
if an error occurs. Additionaly, in case of an error, *ret
is set to be NULL
and errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vasprintf().
int ft_dprintf | ( | int | fd, |
const char * | format, | ||
... | |||
) |
Replicates behaviour of dprintf(3)
.
[in] | fd | File descriptor where to print output. |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ... | Variadic arguments |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vdprintf().
int ft_printf | ( | const char * | format, |
... | |||
) |
Replicates behaviour of printf(3)
.
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ... | Variadic arguments |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported) or other values set by write(2)
. References ft_vprintf().
int ft_snprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
... | |||
) |
Replicates behaviour of snprintf(3)
.
[in] | str | String where to print output. |
[in] | size | Size of the string (at most size - 1 characters are printed and, unless size is 0 , the string is always null-terminated). |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ... | Variadic arguments |
size
were unlimited (not including the final \0
) or -1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vsnprintf().
int ft_sprintf | ( | char * | str, |
const char * | format, | ||
... | |||
) |
Replicates behaviour of sprintf(3)
.
[in] | str | String where to print output. |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ... | Variadic arguments |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vsnprintf().
int ft_vasprintf | ( | char ** | ret, |
const char * | format, | ||
va_list | ap | ||
) |
Replicates behaviour of vasprintf(3)
.
[out] | ret | Pointer that will be set to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ap | A variable used by stdarg(3) to step through a list of variadic arguments. |
-1
if an error occurs. Additionaly, in case of an error, *ret
is set to be NULL
and errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vsnprintf(), and ft_vsprintf().
int ft_vdprintf | ( | int | fd, |
const char * | format, | ||
va_list | ap | ||
) |
Replicates behaviour of vdprintf(3)
.
[in] | fd | File descriptor where to print output |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ap | A variable used by stdarg(3) to step through a list of variadic arguments. |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported) or other values set by write(2)
(e.g. due to an invalid file descriiptor). References ft_vprintf().
int ft_vprintf | ( | const char * | format, |
va_list | ap | ||
) |
Replicates behaviour of vprintf(3)
.
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ap | A variable used by stdarg(3) to step through a list of variadic arguments. |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported) or other values set by write(2)
(e.g. due to an invalid file descriiptor). int ft_vsnprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
va_list | ap | ||
) |
Replicates behaviour of vsnprintf(3)
.
[in] | str | String where to print output. |
[in] | size | Size of the string (at most size - 1 characters are printed and, unless size is 0 , the string is always null-terminated). |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ap | A variable used by stdarg(3) to step through a list of variadic arguments. |
size
were unlimited (not including the final \0
) or -1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vprintf().
int ft_vsprintf | ( | char * | str, |
const char * | format, | ||
va_list | ap | ||
) |
Replicates behaviour of vsprintf(3)
.
[in] | str | String where to print output. |
[in] | format | Format string that specifies how subsequent arguments are converted for output |
[in] | ap | A variable used by stdarg(3) to step through a list of variadic arguments. |
-1
if an error occurs. Additionaly, in case of an error, errno
is set to ENOMEM
(memory allocation error), EINVAL
(invalid format placeholder specification), ENOTSUP
(type field value not supported). References ft_vprintf().