1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/dbm/src/snprintf.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +#ifndef HAVE_SNPRINTF 1.5 + 1.6 +#include <sys/types.h> 1.7 +#include <stddef.h> 1.8 +#include <stdio.h> 1.9 + 1.10 +#ifdef HAVE_SYS_CDEFS_H 1.11 +#include <sys/cdefs.h> 1.12 +#else 1.13 +#include "cdefs.h" 1.14 +#endif 1.15 + 1.16 +#include "prtypes.h" 1.17 + 1.18 +#include <ncompat.h> 1.19 + 1.20 +#ifdef __STDC__ 1.21 +#include <stdarg.h> 1.22 +#else 1.23 +#include <varargs.h> 1.24 +#endif 1.25 + 1.26 +int 1.27 +#ifdef __STDC__ 1.28 +snprintf(char *str, size_t n, const char *fmt, ...) 1.29 +#else 1.30 +snprintf(str, n, fmt, va_alist) 1.31 + char *str; 1.32 + size_t n; 1.33 + const char *fmt; 1.34 + va_dcl 1.35 +#endif 1.36 +{ 1.37 + va_list ap; 1.38 +#ifdef VSPRINTF_CHARSTAR 1.39 + char *rp; 1.40 +#else 1.41 + int rval; 1.42 +#endif 1.43 +#ifdef __STDC__ 1.44 + va_start(ap, fmt); 1.45 +#else 1.46 + va_start(ap); 1.47 +#endif 1.48 +#ifdef VSPRINTF_CHARSTAR 1.49 + rp = vsprintf(str, fmt, ap); 1.50 + va_end(ap); 1.51 + return (strlen(rp)); 1.52 +#else 1.53 + rval = vsprintf(str, fmt, ap); 1.54 + va_end(ap); 1.55 + return (rval); 1.56 +#endif 1.57 +} 1.58 + 1.59 +int 1.60 +vsnprintf(str, n, fmt, ap) 1.61 + char *str; 1.62 + size_t n; 1.63 + const char *fmt; 1.64 + va_list ap; 1.65 +{ 1.66 +#ifdef VSPRINTF_CHARSTAR 1.67 + return (strlen(vsprintf(str, fmt, ap))); 1.68 +#else 1.69 + return (vsprintf(str, fmt, ap)); 1.70 +#endif 1.71 +} 1.72 + 1.73 +#endif /* HAVE_SNPRINTF */ 1.74 + 1.75 +/* Some compilers don't like an empty source file. */ 1.76 +static int dummy = 0;