if needed. Same check for snprintf.
 
 if test $ac_cv_func_vprintf = yes ; then
        dnl check for vsnprintf
-       AC_CHECK_FUNCS(vsnprintf vsprintf)
+       AC_CHECK_FUNCS(snprintf vsnprintf)
 fi
 
 AC_CHECK_FUNCS(                \
 if test "$ac_cv_func_getopt" != yes; then
        LIBSRCS="$LIBSRCS getopt.c"
 fi
+if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
+       LIBSRCS="$LIBSRCS stdio.c"
+       LIBOBJS="$LIBOBJS stdio.o"
+       if test "$ac_cv_func_snprintf" != yes; then
+               AC_DEFINE(snprintf, lutil_snprintf, [define to snprintf routine])
+       fi
+       if test "$ac_cv_func_vsnprintf" != yes; then
+               AC_DEFINE(vsnprintf, lutil_vsnprintf, [define to snprintf routine])
+       fi
+fi
 
 dnl ----------------------------------------------------------------
 # Check Configuration
 
        {
             int level;
             ber_get_option( NULL, LBER_OPT_BER_DEBUG, &level );
-#ifdef HAVE_VSNPRINTF
             buf[sizeof(buf) - 1] = '\0';
             vsnprintf( buf, sizeof(buf)-1, fmt, vl );
-#elif HAVE_VSPRINTF
-            vsprintf( buf, fmt, vl ); /* hope it's not too long */
-#else
-                /* use doprnt() */
-#error "vsprintf() required.";
-#endif
             if ( ber_log_check( LDAP_DEBUG_BER, level ) )
                 (*ber_pvt_log_print)( buf );
         }
 
        va_start( ap, fmt );
 
-#ifdef HAVE_VSNPRINTF
        buf[sizeof(buf) - 1] = '\0';
        vsnprintf( buf, sizeof(buf)-1, fmt, ap );
-#elif HAVE_VSPRINTF
-       vsprintf( buf, fmt, ap ); /* hope it's not too long */
-#else
-       /* use doprnt() */
-#error "vsprintf() required."
-#endif
 
        va_end(ap);
 
 
 #endif
        va_start( vl, fmt );
 
-#ifdef HAVE_VSNPRINTF
        vsnprintf( buffer, sizeof(buffer), fmt, vl );
-#else
-       vsprintf( buffer, fmt, vl );
-#endif
        buffer[sizeof(buffer)-1] = '\0';
 
        if( log_file != NULL ) {
 
 
        va_start( ap, fmt );
 
-#ifdef HAVE_VSNPRINTF
        buf[sizeof(buf) - 1] = '\0';
        vsnprintf( buf, sizeof(buf)-1, fmt, ap );
-#elif HAVE_VSPRINTF
-       vsprintf( buf, fmt, ap ); /* hope it's not too long */
-#else
-       /* use doprnt() */
-       chokeme = "choke me! I don't have a doprnt manual handy!";
-#endif
 
        va_end(ap);
 
 
 
        va_start(ap, fmt);
 
-#ifdef HAVE_VSNPRINTF
        buf[sizeof(buf) - 1] = '\0';
        vsnprintf( buf, sizeof(buf)-1, fmt, ap );
-#elif HAVE_VPRINTF
-       vsprintf( buf, fmt, ap ); /* hope it's not too long */
-#else
-       /* use doprnt() */
-       chokeme = "choke me!  I don't have a doprnt() manual handy";
-#endif
 
        va_end(ap);
 
 
 
 #include <lutil.h>
 
-#ifndef HAVE_VSNPRINTF
+#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_EBCDIC)
 /* Write at most n characters to the buffer in str, return the
  * number of chars written or -1 if the buffer would have been
  * overflowed.
  * broken pipe, and the write will be terminated.
  * -- hyc, 2002-07-19
  */
-#ifndef HAVE_EBCDIC
 /* This emulation uses vfprintf; on OS/390 we're also emulating
  * that function so it's more efficient just to have a separate
  * version of vsnprintf there.
  */
 #include <ac/signal.h>
-int vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
+int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
 {
        int fds[2], res;
        FILE *f;
 }
 #endif
 
-int snprintf( char *str, size_t n, const char *fmt, ... )
+#ifndef HAVE_SNPRINTF
+int lutil_snprintf( char *str, size_t n, const char *fmt, ... )
 {
        va_list ap;
        int res;
  * may need to be extended to recognize other qualifiers but so
  * far this seems to be enough.
  */
-int vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
+int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
 {
        char *ptr, *pct, *s2, *f2, *end;
        char fm2[64];