Subject: SunOS host build of NetBSD
To: None <,>
From: Michael Richardson <>
List: port-sun3
Date: 12/21/1993 22:10:16
  I've picked up work on the sun3 port of NetBSD. My working
environment is SunOS 4.1.0. It would, yes, be better to be working
under some existing *BSD port... alas, my 386 was running 0.8, but its
IDE disk died just as I was upgrading it a couple of months ago. I
haven't the money for a SCSI controller for it, or I'd hook up this
250Mb disk that is sitting here to it.  

  Anyway, I've just started to build BSD make under SunOS. snprintf
looks like it will be a pain. (Other problems, like lack of setenv(),
and a strerror() that doesn't quite exist if you rebuild the shared
SunOS libc, are solvable...)
  Having taken a guess at making the BSD code work under SunOS libc,
and gotten a core dump, I figured I'd ask if anyone has put together a
"compatibility" library first.
  Looking, and comparing stdio.h's, I came up with this. It dies

#if __STDC__
snprintf(char *str, size_t n, char const *fmt, ...)
snprintf(str, n, fmt, va_alist)
	char *str;
	size_t n;
	char *fmt;
	int ret;
	va_list ap;
	FILE f;

	if ((int)n < 1)
		return (EOF);
#if __STDC__
	va_start(ap, fmt);
	f._flag = _IOWRT | _IOSTRG;
	f._base   = (unsigned char *)str;
	f._bufsiz = n - 1;
	ret = vfprintf(&f, fmt, ap);
	return (ret);