The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions
snprintf.h File Reference

Unix snprintf implementation. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <varargs.h>
#include <ctype.h>
#include <stdlib.h>
+ Include dependency graph for snprintf.h:

Go to the source code of this file.

Data Structures

struct  DATA
 

Macros

#define DEF_PREC(p)
 
#define dtoa(n, p, f)   numtoa(n, 10, p, f)
 
#define FOUND   1
 
#define htoa(n)   numtoa(n, 16, 0, (char **)0)
 
#define isflag(c)
 
#define itoa(n)   numtoa(n, 10, 0, (char **)0)
 
#define LEFT   0
 
#define LONG_DOUBLE   long double
 
#define LONG_LONG   long long
 
#define MAX_FIELD   15
 
#define MAX_FRACT   29 + 1
 
#define MAX_INT   99 + 1 /* 1 for the null */
 
#define NOT_FOUND   -1
 
#define otoa(n)   numtoa(n, 8, 0, (char **)0)
 
#define PAD_LEFT(p)
 
#define PAD_RIGHT(p)
 
#define PRIVATE   static
 
#define PUBLIC
 
#define PUT_CHAR(c, p)
 
#define PUT_PLUS(d, p)
 
#define PUT_SPACE(d, p)
 
#define RIGHT   1
 
#define ROUND(d, p)
 
#define STAR_ARGS(p)
 
#define SWAP_INT(a, b)   {int t; t = (a); (a) = (b); (b) = t;}
 

Functions

PRIVATE void conv_flag ()
 
PRIVATE void exponent ()
 
PRIVATE void float64 ()
 
PRIVATE void floating ()
 
PRIVATE void hexa ()
 
PRIVATE double integral ()
 
PRIVATE int log_10 ()
 
PRIVATE char * numtoa ()
 
PRIVATE void octal ()
 
PRIVATE double pow_10 ()
 
PRIVATE void strings ()
 

Detailed Description

Unix snprintf implementation.

Version 1.4

  1.4:
    *       integrate in FreeRADIUS's libradius:
    *       Fetched from: http://savannah.gnu.org/cgi-bin/viewcvs/mailutils/mailutils/lib/snprintf.c?rev=1.4
    *       Fetched from: http://savannah.gnu.org/cgi-bin/viewcvs/mailutils/mailutils/lib/snprintf.h?rev=1.4
    *       Replace config.h with autoconf.h
    *       Protect with HAVE_SNPRINTF and HAVE_VSNPRINTF
  1.3:
    *       add #include <config.h> ifdef HAVE_CONFIG_H
    *       cosmetic change, when exponent is 0 print xxxE+00
  instead of xxxE-00
  1.2:
    *       put the program under LGPL.

  1.1:
    *       added changes from Miles Bader
    *       corrected a bug with %f
    *       added support for %#g
    *       added more comments :-)
  1.0:
    *       supporting must ANSI syntaxic_sugars
  0.0:
    *       support %s %c %d

THANKS(for the patches and ideas): Miles Bader Cyrille Rustom Jacek Slabocewiz Mike Parker(mouse)

Version 1.4

THANKS(for the patches and ideas): Miles Bader Cyrille Rustom Jacek Slabocewiz Mike Parker(mouse)

Definition in file snprintf.h.


Data Structure Documentation

◆ DATA

struct DATA

Definition at line 112 of file snprintf.h.

Data Fields
int a_long
int a_longlong
int counter
char * holder
int justify
int length
char pad
char * pf
int precision
int space
int square
int star_p
int star_w
int width

Macro Definition Documentation

◆ DEF_PREC

#define DEF_PREC (   p)
Value:
if ((p)->precision == NOT_FOUND) \
(p)->precision = 6
#define NOT_FOUND
Definition: snprintf.h:166

Definition at line 183 of file snprintf.h.

◆ dtoa

#define dtoa (   n,
  p,
 
)    numtoa(n, 10, p, f)

Definition at line 107 of file snprintf.h.

◆ FOUND

#define FOUND   1

Definition at line 167 of file snprintf.h.

◆ htoa

#define htoa (   n)    numtoa(n, 16, 0, (char **)0)

Definition at line 106 of file snprintf.h.

◆ isflag

#define isflag (   c)
Value:
((c) == '#' || (c) == ' ' || \
(c) == '*' || (c) == '+' || \
(c) == '-' || (c) == '.' || \
isdigit(c))

Definition at line 171 of file snprintf.h.

◆ itoa

#define itoa (   n)    numtoa(n, 10, 0, (char **)0)

Definition at line 104 of file snprintf.h.

◆ LEFT

#define LEFT   0

Definition at line 165 of file snprintf.h.

◆ LONG_DOUBLE

#define LONG_DOUBLE   long double

Definition at line 96 of file snprintf.h.

◆ LONG_LONG

#define LONG_LONG   long long

Definition at line 88 of file snprintf.h.

◆ MAX_FIELD

#define MAX_FIELD   15

Definition at line 168 of file snprintf.h.

◆ MAX_FRACT

#define MAX_FRACT   29 + 1

Definition at line 82 of file snprintf.h.

◆ MAX_INT

#define MAX_INT   99 + 1 /* 1 for the null */

Definition at line 81 of file snprintf.h.

◆ NOT_FOUND

#define NOT_FOUND   -1

Definition at line 166 of file snprintf.h.

◆ otoa

#define otoa (   n)    numtoa(n, 8, 0, (char **)0)

Definition at line 105 of file snprintf.h.

◆ PAD_LEFT

#define PAD_LEFT (   p)
Value:
if ((p)->width > 0 && (p)->justify == LEFT) \
for (; (p)->width > 0; (p)->width--) \
PUT_CHAR((p)->pad, p)
#define LEFT
Definition: snprintf.h:165

Definition at line 209 of file snprintf.h.

◆ PAD_RIGHT

#define PAD_RIGHT (   p)
Value:
if ((p)->width > 0 && (p)->justify != LEFT) \
for (; (p)->width > 0; (p)->width--) \
PUT_CHAR((p)->pad, p)

Definition at line 203 of file snprintf.h.

◆ PRIVATE

#define PRIVATE   static

Definition at line 52 of file snprintf.h.

◆ PUBLIC

#define PUBLIC

Definition at line 53 of file snprintf.h.

◆ PUT_CHAR

#define PUT_CHAR (   c,
 
)
Value:
if ((p)->counter < (p)->length) { \
*(p)->holder++ = (c); \
(p)->counter++; \
}

Definition at line 188 of file snprintf.h.

◆ PUT_PLUS

#define PUT_PLUS (   d,
 
)
Value:
if ((d) > 0. && (p)->justify == RIGHT) \
PUT_CHAR('+', p)
#define RIGHT
Definition: snprintf.h:164

Definition at line 194 of file snprintf.h.

◆ PUT_SPACE

#define PUT_SPACE (   d,
 
)
Value:
if ((p)->space == FOUND && (d) > 0.) \
PUT_CHAR(' ', p)
#define FOUND
Definition: snprintf.h:167

Definition at line 198 of file snprintf.h.

◆ RIGHT

#define RIGHT   1

Definition at line 164 of file snprintf.h.

◆ ROUND

#define ROUND (   d,
 
)
Value:
(d < 0.) ? \
d - pow_10(-(p)->precision) * 0.5 : \
d + pow_10(-(p)->precision) * 0.5
PRIVATE double pow_10()

Definition at line 177 of file snprintf.h.

◆ STAR_ARGS

#define STAR_ARGS (   p)
Value:
if ((p)->star_w == FOUND) \
(p)->width = va_arg(args, int); \
if ((p)->star_p == FOUND) \
(p)->precision = va_arg(args, int)
va_list args
Definition: acutest.h:770

Definition at line 215 of file snprintf.h.

◆ SWAP_INT

#define SWAP_INT (   a,
 
)    {int t; t = (a); (a) = (b); (b) = t;}

Definition at line 109 of file snprintf.h.

Function Documentation

◆ conv_flag()

PRIVATE void conv_flag ( )

◆ exponent()

PRIVATE void exponent ( )

◆ float64()

PRIVATE void float64 ( )

◆ floating()

PRIVATE void floating ( )

◆ hexa()

PRIVATE void hexa ( )

◆ integral()

PRIVATE double integral ( )

◆ log_10()

PRIVATE int log_10 ( )

◆ numtoa()

PRIVATE char* numtoa ( )

◆ octal()

PRIVATE void octal ( )

◆ pow_10()

PRIVATE double pow_10 ( )

◆ strings()

PRIVATE void strings ( )