/** Allocate and print to string. * * @param strp Address of the pointer where to store the address of * the newly allocated string. * @fmt Format string. * * @return Number of characters printed or a negative error code. * */ int asprintf(char **strp, const char *fmt, ...) { printf_spec_t ps = { asprintf_str_write, asprintf_wstr_write, NULL }; va_list args; va_start(args, fmt); int ret = printf_core(fmt, &ps, args); va_end(args); if (ret > 0) { *strp = malloc(STR_BOUNDS(ret) + 1); if (*strp == NULL) return -1; va_start(args, fmt); vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args); va_end(args); } return ret; }
int vdprintf(int fd, const char *format, va_list ap) { struct _fd_printer fp; fp.fd = fd; fp.err = 0; fp.count = 0; printf_core(fd_printer, &fp, format, ap); return fp.count; }
/** Print formatted text to kio. * * @param fmt Format string * @param ap Format parameters * * \see For more details about format string see printf_core. * */ int kio_vprintf(const char *fmt, va_list ap) { printf_spec_t ps = { kio_vprintf_str_write, kio_vprintf_wstr_write, NULL }; return printf_core(fmt, &ps, ap); }
/** Append a message to the currently being written entry. * * Requires that an entry has been started using log_begin() */ int log_vprintf(const char *fmt, va_list args) { int ret; printf_spec_t ps = { log_printf_str_write, log_printf_wstr_write, NULL }; ret = printf_core(fmt, &ps, args); return ret; }
int vsnprintf(char *s, size_t num, const char *format, va_list args) { struct string_printer_ctx ctx = { s, num }; return printf_core(format, string_printer, &ctx, args); }
int vfprintf(FILE *stream, const char *format, va_list args) { return printf_core(format, file_printer, stream, args); }