Example #1
0
/** 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;
}
Example #2
0
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;
}
Example #3
0
/** 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);
}
Example #4
0
/** 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;
}
Example #5
0
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);
}
Example #6
0
int
vfprintf(FILE *stream, const char *format, va_list args)
{
    return printf_core(format, file_printer, stream, args);
}