apr  1.7.0
About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).
  Fossies Dox: apr-1.7.0.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

apr_snprintf.c File Reference
#include "apr.h"
#include "apr_private.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_network_io.h"
#include "apr_portable.h"
#include "apr_errno.h"
#include <math.h>
Include dependency graph for apr_snprintf.c:

Go to the source code of this file.

Macros

#define FALSE   0
 
#define TRUE   1
 
#define NUL   '\0'
 
#define S_NULL   ((char *)null_string)
 
#define S_NULL_LEN   6
 
#define FLOAT_DIGITS   6
 
#define EXPONENT_LENGTH   10
 
#define NUM_BUF_SIZE   512
 
#define NDIG   80
 
#define INS_CHAR(c, sp, bep, cc)
 
#define NUM(c)   (c - '0')
 
#define STR_TO_DEC(str, num)
 
#define FIX_PRECISION(adjust, precision, s, s_len)
 
#define PAD(width, len, ch)
 
#define PREFIX(str, length, ch)
 

Enumerations

enum  boolean_e { NO = 0, YES = 1 }
 

Functions

static char * apr_cvt (double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
 
static char * apr_ecvt (double arg, int ndigits, int *decpt, int *sign, char *buf)
 
static char * apr_fcvt (double arg, int ndigits, int *decpt, int *sign, char *buf)
 
static char * apr_gcvt (double number, int ndigit, char *buf, boolean_e altform)
 
static char * conv_10 (register apr_int32_t num, register int is_unsigned, register int *is_negative, char *buf_end, register apr_size_t *len)
 
static char * conv_10_quad (apr_int64_t num, register int is_unsigned, register int *is_negative, char *buf_end, register apr_size_t *len)
 
static char * conv_in_addr (struct in_addr *ia, char *buf_end, apr_size_t *len)
 
static char * conv_apr_sockaddr (apr_sockaddr_t *sa, char *buf_end, apr_size_t *len)
 
static char * conv_fp (register char format, register double num, boolean_e add_dp, int precision, int *is_negative, char *buf, apr_size_t *len)
 
static char * conv_p2 (register apr_uint32_t num, register int nbits, char format, char *buf_end, register apr_size_t *len)
 
static char * conv_p2_quad (apr_uint64_t num, register int nbits, char format, char *buf_end, register apr_size_t *len)
 
 APR_DECLARE (int)
 
static int snprintf_flush (apr_vformatter_buff_t *vbuff)
 
 APR_DECLARE_NONSTD (int)
 

Variables

static const char null_string [] = "(null)"
 

Macro Definition Documentation

◆ EXPONENT_LENGTH

#define EXPONENT_LENGTH   10

Definition at line 62 of file apr_snprintf.c.

◆ FALSE

#define FALSE   0

Definition at line 50 of file apr_snprintf.c.

◆ FIX_PRECISION

#define FIX_PRECISION (   adjust,
  precision,
  s,
  s_len 
)
Value:
if (adjust) { \
apr_size_t p = (precision + 1 < NUM_BUF_SIZE) \
? precision : NUM_BUF_SIZE - 1; \
while (s_len < p) \
{ \
*--s = '0'; \
s_len++; \
} \
}

Definition at line 279 of file apr_snprintf.c.

◆ FLOAT_DIGITS

#define FLOAT_DIGITS   6

Definition at line 61 of file apr_snprintf.c.

◆ INS_CHAR

#define INS_CHAR (   c,
  sp,
  bep,
  cc 
)
Value:
{ \
if (sp) { \
if (sp >= bep) { \
vbuff->curpos = sp; \
if (flush_func(vbuff)) \
return -1; \
sp = vbuff->curpos; \
bep = vbuff->endpos; \
} \
*sp++ = (c); \
} \
cc++; \
}

Definition at line 244 of file apr_snprintf.c.

◆ NDIG

#define NDIG   80

Definition at line 83 of file apr_snprintf.c.

◆ NUL

#define NUL   '\0'

Definition at line 55 of file apr_snprintf.c.

◆ NUM

#define NUM (   c)    (c - '0')

Definition at line 259 of file apr_snprintf.c.

◆ NUM_BUF_SIZE

#define NUM_BUF_SIZE   512

Definition at line 69 of file apr_snprintf.c.

◆ PAD

#define PAD (   width,
  len,
  ch 
)
Value:
do \
{ \
INS_CHAR(ch, sp, bep, cc); \
width--; \
} \
while (width > len)

Definition at line 294 of file apr_snprintf.c.

◆ PREFIX

#define PREFIX (   str,
  length,
  ch 
)
Value:
*--str = ch; \
length++; \
has_prefix=YES;

Definition at line 307 of file apr_snprintf.c.

◆ S_NULL

#define S_NULL   ((char *)null_string)

Definition at line 58 of file apr_snprintf.c.

◆ S_NULL_LEN

#define S_NULL_LEN   6

Definition at line 59 of file apr_snprintf.c.

◆ STR_TO_DEC

#define STR_TO_DEC (   str,
  num 
)
Value:
num = NUM(*str++); \
while (apr_isdigit(*str)) \
{ \
num *= 10 ; \
num += NUM(*str++); \
}

Definition at line 261 of file apr_snprintf.c.

◆ TRUE

#define TRUE   1

Definition at line 53 of file apr_snprintf.c.

Enumeration Type Documentation

◆ boolean_e

enum boolean_e
Enumerator
NO 
YES 

Definition at line 45 of file apr_snprintf.c.

Function Documentation

◆ apr_cvt()

static char* apr_cvt ( double  arg,
int  ndigits,
int decpt,
int sign,
int  eflag,
char *  buf 
)
static

Definition at line 86 of file apr_snprintf.c.

References buf, int(), NDIG, and p.

Referenced by apr_ecvt(), and apr_fcvt().

◆ apr_ecvt()

static char* apr_ecvt ( double  arg,
int  ndigits,
int decpt,
int sign,
char *  buf 
)
static

Definition at line 160 of file apr_snprintf.c.

References apr_cvt(), and buf.

Referenced by apr_gcvt(), and conv_fp().

◆ apr_fcvt()

static char* apr_fcvt ( double  arg,
int  ndigits,
int decpt,
int sign,
char *  buf 
)
static

Definition at line 165 of file apr_snprintf.c.

References apr_cvt(), and buf.

Referenced by conv_fp().

◆ apr_gcvt()

static char* apr_gcvt ( double  number,
int  ndigit,
char *  buf,
boolean_e  altform 
)
static

Definition at line 175 of file apr_snprintf.c.

References apr_ecvt(), buf, and NDIG.

Referenced by APR_DECLARE().

◆ conv_10()

static char* conv_10 ( register apr_int32_t  num,
register int  is_unsigned,
register int is_negative,
char *  buf_end,
register apr_size_t *  len 
)
static

Definition at line 329 of file apr_snprintf.c.

References FALSE, len, num, p, and t.

Referenced by APR_DECLARE(), conv_10_quad(), conv_apr_sockaddr(), conv_fp(), and conv_in_addr().

◆ conv_10_quad()

static char* conv_10_quad ( apr_int64_t  num,
register int  is_unsigned,
register int is_negative,
char *  buf_end,
register apr_size_t *  len 
)
static

Definition at line 372 of file apr_snprintf.c.

References conv_10(), FALSE, len, num, p, and t.

Referenced by APR_DECLARE().

◆ conv_apr_sockaddr()

static char* conv_apr_sockaddr ( apr_sockaddr_t sa,
char *  buf_end,
apr_size_t *  len 
)
static

◆ conv_fp()

static char* conv_fp ( register char  format,
register double  num,
boolean_e  add_dp,
int  precision,
int is_negative,
char *  buf,
apr_size_t *  len 
)
static

Definition at line 516 of file apr_snprintf.c.

References apr_ecvt(), apr_fcvt(), apr_isalpha, buf, conv_10(), EXPONENT_LENGTH, FALSE, format, len, NDIG, num, p, and s.

Referenced by APR_DECLARE().

◆ conv_in_addr()

static char* conv_in_addr ( struct in_addr ia,
char *  buf_end,
apr_size_t *  len 
)
static

Definition at line 424 of file apr_snprintf.c.

References addr, conv_10(), len, p, in_addr::s_addr, and TRUE.

Referenced by APR_DECLARE().

◆ conv_p2()

static char* conv_p2 ( register apr_uint32_t  num,
register int  nbits,
char  format,
char *  buf_end,
register apr_size_t *  len 
)
static

Definition at line 615 of file apr_snprintf.c.

References format, len, num, and p.

Referenced by APR_DECLARE(), and conv_p2_quad().

◆ conv_p2_quad()

static char* conv_p2_quad ( apr_uint64_t  num,
register int  nbits,
char  format,
char *  buf_end,
register apr_size_t *  len 
)
static

Definition at line 634 of file apr_snprintf.c.

References conv_p2(), format, len, num, and p.

Referenced by APR_DECLARE().

◆ snprintf_flush()

static int snprintf_flush ( apr_vformatter_buff_t vbuff)
static

Definition at line 1346 of file apr_snprintf.c.

Referenced by APR_DECLARE_NONSTD().

Variable Documentation

◆ null_string

const char null_string[] = "(null)"
static

Definition at line 57 of file apr_snprintf.c.

str
char ** str
Definition: apr_cstr.h:125
apr_isdigit
#define apr_isdigit(c)
Definition: apr_lib.h:209
p
const char apr_int32_t apr_pool_t * p
Definition: apr_file_info.h:337
c
apr_vformatter_buff_t * c
Definition: apr_lib.h:175
len
const char apr_ssize_t int apr_size_t * len
Definition: apr_encode.h:162
s
const char * s
Definition: apr_strings.h:95
YES
Definition: apr_snprintf.c:46
NUM
#define NUM(c)
Definition: apr_snprintf.c:259
num
apr_interval_time_t apr_int32_t * num
Definition: apr_poll.h:281
NUM_BUF_SIZE
#define NUM_BUF_SIZE
Definition: apr_snprintf.c:69