Moved stdio replacements from liblutil lutil_* to liblber ber_pvt_*.

This commit is contained in:
Howard Chu 2002-09-10 00:47:32 +00:00
parent e6fdfd4cee
commit 890d4b9449
6 changed files with 33 additions and 32 deletions

View file

@ -100,12 +100,12 @@
* vsnprintf and snprintf are used too, but they are already * vsnprintf and snprintf are used too, but they are already
* checked by the configure script * checked by the configure script
*/ */
#define fputs lutil_fputs #define fputs ber_pvt_fputs
#define fgets lutil_fgets #define fgets ber_pvt_fgets
#define printf lutil_printf #define printf ber_pvt_printf
#define fprintf lutil_fprintf #define fprintf ber_pvt_fprintf
#define vfprintf lutil_vfprintf #define vfprintf ber_pvt_vfprintf
#define vsprintf lutil_vsprintf #define vsprintf ber_pvt_vsprintf
#endif #endif
#include "ldap_cdefs.h" #include "ldap_cdefs.h"

4
configure vendored
View file

@ -22256,13 +22256,13 @@ if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
LIBOBJS="$LIBOBJS stdio.o" LIBOBJS="$LIBOBJS stdio.o"
if test "$ac_cv_func_snprintf" != yes; then if test "$ac_cv_func_snprintf" != yes; then
cat >> confdefs.h <<\EOF cat >> confdefs.h <<\EOF
#define snprintf lutil_snprintf #define snprintf ber_pvt_snprintf
EOF EOF
fi fi
if test "$ac_cv_func_vsnprintf" != yes; then if test "$ac_cv_func_vsnprintf" != yes; then
cat >> confdefs.h <<\EOF cat >> confdefs.h <<\EOF
#define vsnprintf lutil_vsnprintf #define vsnprintf ber_pvt_vsnprintf
EOF EOF
fi fi

View file

@ -2491,10 +2491,10 @@ if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
LIBSRCS="$LIBSRCS stdio.c" LIBSRCS="$LIBSRCS stdio.c"
LIBOBJS="$LIBOBJS stdio.o" LIBOBJS="$LIBOBJS stdio.o"
if test "$ac_cv_func_snprintf" != yes; then if test "$ac_cv_func_snprintf" != yes; then
AC_DEFINE(snprintf, lutil_snprintf, [define to snprintf routine]) AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
fi fi
if test "$ac_cv_func_vsnprintf" != yes; then if test "$ac_cv_func_vsnprintf" != yes; then
AC_DEFINE(vsnprintf, lutil_vsnprintf, [define to snprintf routine]) AC_DEFINE(vsnprintf, ber_pvt_vsnprintf, [define to snprintf routine])
fi fi
fi fi

View file

@ -1030,12 +1030,12 @@
* vsnprintf and snprintf are used too, but they are already * vsnprintf and snprintf are used too, but they are already
* checked by the configure script * checked by the configure script
*/ */
#define fputs lutil_fputs #define fputs ber_pvt_fputs
#define fgets lutil_fgets #define fgets ber_pvt_fgets
#define printf lutil_printf #define printf ber_pvt_printf
#define fprintf lutil_fprintf #define fprintf ber_pvt_fprintf
#define vfprintf lutil_vfprintf #define vfprintf ber_pvt_vfprintf
#define vsprintf lutil_vsprintf #define vsprintf ber_pvt_vsprintf
#endif #endif
#include "ldap_cdefs.h" #include "ldap_cdefs.h"

View file

@ -10,6 +10,9 @@ LIBRARY = liblber.la
NT_SRCS = nt_err.c NT_SRCS = nt_err.c
NT_OBJS = nt_err.lo NT_OBJS = nt_err.lo
UNIX_SRCS = stdio.c
UNIX_OBJS = stdio.lo
LIB_DEFS = -DLBER_LIBRARY LIB_DEFS = -DLBER_LIBRARY
SRCS= assert.c decode.c encode.c io.c bprint.c debug.c \ SRCS= assert.c decode.c encode.c io.c bprint.c debug.c \

View file

@ -10,8 +10,6 @@
#include <ac/stdarg.h> #include <ac/stdarg.h>
#include <ac/string.h> #include <ac/string.h>
#include <lutil.h>
#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_EBCDIC) #if !defined(HAVE_VSNPRINTF) && !defined(HAVE_EBCDIC)
/* Write at most n characters to the buffer in str, return the /* Write at most n characters to the buffer in str, return the
* number of chars written or -1 if the buffer would have been * number of chars written or -1 if the buffer would have been
@ -35,7 +33,7 @@
* version of vsnprintf there. * version of vsnprintf there.
*/ */
#include <ac/signal.h> #include <ac/signal.h>
int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) int ber_pvt_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
{ {
int fds[2], res; int fds[2], res;
FILE *f; FILE *f;
@ -62,7 +60,7 @@ int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
#endif #endif
#ifndef HAVE_SNPRINTF #ifndef HAVE_SNPRINTF
int lutil_snprintf( char *str, size_t n, const char *fmt, ... ) int ber_pvt_snprintf( char *str, size_t n, const char *fmt, ... )
{ {
va_list ap; va_list ap;
int res; int res;
@ -91,14 +89,14 @@ int lutil_snprintf( char *str, size_t n, const char *fmt, ... )
#undef fputs #undef fputs
#undef fgets #undef fgets
char *lutil_fgets( char *s, int n, FILE *fp ) char *ber_pvt_fgets( char *s, int n, FILE *fp )
{ {
s = (char *)fgets( s, n, fp ); s = (char *)fgets( s, n, fp );
if ( s ) __etoa( s ); if ( s ) __etoa( s );
return s; return s;
} }
int lutil_fputs( const char *str, FILE *fp ) int ber_pvt_fputs( const char *str, FILE *fp )
{ {
char buf[8192]; char buf[8192];
@ -116,7 +114,7 @@ int lutil_fputs( const char *str, FILE *fp )
* may need to be extended to recognize other qualifiers but so * may need to be extended to recognize other qualifiers but so
* far this seems to be enough. * far this seems to be enough.
*/ */
int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) int ber_pvt_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
{ {
char *ptr, *pct, *s2, *f2, *end; char *ptr, *pct, *s2, *f2, *end;
char fm2[64]; char fm2[64];
@ -137,7 +135,7 @@ int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
if (rem < 1) return -1; if (rem < 1) return -1;
if (rem < len) len = rem; if (rem < len) len = rem;
} }
s2 = lutil_strncopy( s2, ptr, len ); s2 = ber_pvt_strncopy( s2, ptr, len );
/* Did we cheat the length above? If so, bail out */ /* Did we cheat the length above? If so, bail out */
if (len < pct-ptr) return -1; if (len < pct-ptr) return -1;
for (pct++, f2 = fm2+1; isdigit(*pct);) *f2++ = *pct++; for (pct++, f2 = fm2+1; isdigit(*pct);) *f2++ = *pct++;
@ -172,17 +170,17 @@ int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
rem = end-s2; rem = end-s2;
if (rem > 0) { if (rem > 0) {
len = strlen(ptr); len = strlen(ptr);
s2 = lutil_strncopy( s2, ptr, rem ); s2 = ber_pvt_strncopy( s2, ptr, rem );
rem -= len; rem -= len;
} }
if (rem < 0) return -1; if (rem < 0) return -1;
} else { } else {
s2 = lutil_strcopy( s2, ptr ); s2 = ber_pvt_strcopy( s2, ptr );
} }
return s2 - str; return s2 - str;
} }
int lutil_vsprintf( char *str, const char *fmt, va_list ap ) int ber_pvt_vsprintf( char *str, const char *fmt, va_list ap )
{ {
return vsnprintf( str, 0, fmt, ap ); return vsnprintf( str, 0, fmt, ap );
} }
@ -192,7 +190,7 @@ int lutil_vsprintf( char *str, const char *fmt, va_list ap )
* Hopefully we never try to write something bigger than this * Hopefully we never try to write something bigger than this
* in a log msg... * in a log msg...
*/ */
int lutil_vfprintf( FILE *fp, const char *fmt, va_list ap ) int ber_pvt_vfprintf( FILE *fp, const char *fmt, va_list ap )
{ {
char buf[8192]; char buf[8192];
int res; int res;
@ -204,24 +202,24 @@ int lutil_vfprintf( FILE *fp, const char *fmt, va_list ap )
return res; return res;
} }
int lutil_printf( const char *fmt, ... ) int ber_pvt_printf( const char *fmt, ... )
{ {
va_list ap; va_list ap;
int res; int res;
va_start( ap, fmt ); va_start( ap, fmt );
res = lutil_vfprintf( stdout, fmt, ap ); res = ber_pvt_vfprintf( stdout, fmt, ap );
va_end( ap ); va_end( ap );
return res; return res;
} }
int lutil_fprintf( FILE *fp, const char *fmt, ... ) int ber_pvt_fprintf( FILE *fp, const char *fmt, ... )
{ {
va_list ap; va_list ap;
int res; int res;
va_start( ap, fmt ); va_start( ap, fmt );
res = lutil_vfprintf( fp, fmt, ap ); res = ber_pvt_vfprintf( fp, fmt, ap );
va_end( ap ); va_end( ap );
return res; return res;
} }