#ifndef HAVE_VSNPRINTF
#include <freeradius-devel/ident.h>
RCSIDH(snprintf_h, "$Id$")
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <stdlib.h>
#include <ctype.h>
#define PRIVATE static
#define PUBLIC
#define MAX_INT 99 + 1
#define MAX_FRACT 29 + 1
#ifndef LONG_LONG
# define LONG_LONG long long
#endif
#ifndef LONG_DOUBLE
# define LONG_DOUBLE long double
#endif
#define itoa(n) numtoa(n, 10, 0, (char **)0)
#define otoa(n) numtoa(n, 8, 0, (char **)0)
#define htoa(n) numtoa(n, 16, 0, (char **)0)
#define dtoa(n, p, f) numtoa(n, 10, p, f)
#define SWAP_INT(a,b) {int t; t = (a); (a) = (b); (b) = t;}
struct DATA {
int length;
char *holder;
int counter;
#ifdef __STDC__
const char *pf;
#else
char *pf;
#endif
int width, precision;
int justify; char pad;
int square, space, star_w, star_p, a_long, a_longlong;
};
#ifdef __STDC__
PRIVATE double pow_10(int);
PRIVATE int log_10(double);
PRIVATE double integral(double, double *);
PRIVATE char * numtoa(double, int, int, char **);
PRIVATE void conv_flag(char *, struct DATA *);
PRIVATE void floating(struct DATA *, double);
PRIVATE void exponent(struct DATA *, double);
PRIVATE void decimal(struct DATA *, double);
PRIVATE void octal(struct DATA *, double);
PRIVATE void hexa(struct DATA *, double);
PRIVATE void strings(struct DATA *, char *);
#else
PRIVATE double pow_10();
PRIVATE int log_10();
PRIVATE double integral();
PRIVATE char * numtoa();
PRIVATE void conv_flag();
PRIVATE void floating();
PRIVATE void exponent();
PRIVATE void decimal();
PRIVATE void octal();
PRIVATE void hexa();
PRIVATE void strings();
#endif
#define RIGHT 1
#define LEFT 0
#define NOT_FOUND -1
#define FOUND 1
#define MAX_FIELD 15
#define isflag(c) ((c) == '#' || (c) == ' ' || \
(c) == '*' || (c) == '+' || \
(c) == '-' || (c) == '.' || \
isdigit(c))
#define ROUND(d, p) \
(d < 0.) ? \
d - pow_10(-(p)->precision) * 0.5 : \
d + pow_10(-(p)->precision) * 0.5
#define DEF_PREC(p) \
if ((p)->precision == NOT_FOUND) \
(p)->precision = 6
#define PUT_CHAR(c, p) \
if ((p)->counter < (p)->length) { \
*(p)->holder++ = (c); \
(p)->counter++; \
}
#define PUT_PLUS(d, p) \
if ((d) > 0. && (p)->justify == RIGHT) \
PUT_CHAR('+', p)
#define PUT_SPACE(d, p) \
if ((p)->space == FOUND && (d) > 0.) \
PUT_CHAR(' ', p)
#define PAD_RIGHT(p) \
if ((p)->width > 0 && (p)->justify != LEFT) \
for (; (p)->width > 0; (p)->width--) \
PUT_CHAR((p)->pad, p)
#define PAD_LEFT(p) \
if ((p)->width > 0 && (p)->justify == LEFT) \
for (; (p)->width > 0; (p)->width--) \
PUT_CHAR((p)->pad, p)
#define STAR_ARGS(p) \
if ((p)->star_w == FOUND) \
(p)->width = va_arg(args, int); \
if ((p)->star_p == FOUND) \
(p)->precision = va_arg(args, int)
#endif