atom feed24 messages in org.freebsd.freebsd-archRe: kernel printf %i?
FromSent OnAttachments
Alfred PerlsteinJul 10, 2000 3:05 pm 
Brian Fundakowski FeldmanJul 10, 2000 5:16 pm 
Alfred PerlsteinJul 10, 2000 5:35 pm 
Matthew JacobJul 10, 2000 5:50 pm 
Mike SmithJul 10, 2000 5:57 pm 
Alfred PerlsteinJul 10, 2000 6:15 pm 
Greg LeheyJul 10, 2000 6:41 pm 
Assar WesterlundJul 10, 2000 8:04 pm 
Sheldon HearnJul 11, 2000 1:20 am 
Alfred PerlsteinJul 11, 2000 1:32 am 
Mike PritchardJul 11, 2000 2:13 am 
Bruce EvansJul 11, 2000 3:03 am 
Alfred PerlsteinJul 11, 2000 3:18 am 
Bruce EvansJul 11, 2000 9:32 am 
Marius BendiksenJul 11, 2000 1:30 pm 
Dag-Erling SmorgravJul 12, 2000 12:29 am 
Thomas M. SommersJul 12, 2000 2:59 pm 
Thomas M. SommersJul 12, 2000 4:08 pm 
John-Mark GurneyJul 12, 2000 8:53 pm 
Alexander LangerJul 17, 2000 1:24 am 
Alfred PerlsteinJul 17, 2000 2:40 am 
Alexander LangerJul 17, 2000 2:43 am 
Bruce EvansJul 18, 2000 3:29 am 
Alexander LangerJul 18, 2000 3:32 am 
Subject:Re: kernel printf %i?
From:Thomas M. Sommers (tm@mail.ptd.net)
Date:Jul 12, 2000 4:08:29 pm
List:org.freebsd.freebsd-arch

"Thomas M. Sommers" wrote:

Dag-Erling Smorgrav wrote:

Speaking of printf(), there are two things I'd like to see added:

- in libc, a *dprintf() family similar to *fprintf() except that they write to a file descriptor instead of a FILE *.

How about something like this:

<bad code snipped>

Or better yet, this:

#include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h>

int dprintf(int fd, const char *format, ...) { char *buf; int err = -1; int len; va_list args;

va_start(args, format); len = vasprintf(&buf, format, args); va_end(args);

if ( len != -1 ) { err = write(fd, buf, len); free(buf); } else { errno = ENOMEM; }

return err; }

Thanks to Steve Kargl <sg@troutmask.apl.washington.edu> for pointing out my error.

To Unsubscribe: send mail to majo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message