This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dprintf


2005/9/29, Jeff Johnston <jjohnstn@redhat.com>:
> Shaun Jackman wrote:
> > I'm attempting to compile busybox using newlib. busybox uses glibc's
> > dprintf in a number of places. Could/should dprintf be implemented in
> > newlib?
> >
> > Cheers,
> > Shaun
>
> There is dprintf.c in libc/misc
>
> -- Jeff J.

The debugging printf, __dprintf, in libc/misc is somewhat different
than the dprintf that glibc implements and busybox expects. I've
included an implementation of the GNU dprintf in this mail.

Cheers,
Shaun

int vasprintf(char **strp, const char *format, va_list ap);

int vdprintf(int fd, const char *format, va_list ap)
{
	char *p;
	int n = vasprintf(&p, format, ap);
	if (n == -1) return -1;
	n = write(fd, p, n);
	free(p);
	return n;
}

int dprintf(int fd, const char *format, ...)
{
	va_list ap;
	int n;
	va_start(ap, format);
	n = vdprintf(fd, format, ap);
	va_end(ap);
	return n;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]