snprintf.c File Reference

#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>

Go to the source code of this file.

Defines

#define NULL   0
#define LDOUBLE   double
#define LLONG   long
#define VA_COPY(dest, src)   (dest) = (src)
#define DP_S_DEFAULT   0
#define DP_S_FLAGS   1
#define DP_S_MIN   2
#define DP_S_DOT   3
#define DP_S_MAX   4
#define DP_S_MOD   5
#define DP_S_CONV   6
#define DP_S_DONE   7
#define DP_F_MINUS   (1 << 0)
#define DP_F_PLUS   (1 << 1)
#define DP_F_SPACE   (1 << 2)
#define DP_F_NUM   (1 << 3)
#define DP_F_ZERO   (1 << 4)
#define DP_F_UP   (1 << 5)
#define DP_F_UNSIGNED   (1 << 6)
#define DP_C_SHORT   1
#define DP_C_LONG   2
#define DP_C_LDOUBLE   3
#define DP_C_LLONG   4
#define char_to_int(p)   ((p)- '0')
#define MAX(p, q)   (((p) >= (q)) ? (p) : (q))
#define vsnprintf   smb_vsnprintf
#define snprintf   smb_snprintf

Functions

static size_t dopr (char *buffer, size_t maxlen, const char *format, va_list args_in)
static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max)
static void fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags)
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags)
static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
static LDOUBLE abs_val (LDOUBLE value)
static LDOUBLE POW10 (int exp)
static LLONG ROUND (LDOUBLE value)
static double my_modf (double x0, double *iptr)
int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
int smb_snprintf (char *str, size_t count, const char *fmt,...)
int vasprintf (char **ptr, const char *format, va_list ap)
int asprintf (char **ptr, const char *format,...)


Define Documentation

#define char_to_int ( p   )     ((p)- '0')

Definition at line 175 of file snprintf.c.

Referenced by dopr().

#define DP_C_LDOUBLE   3

Definition at line 172 of file snprintf.c.

Referenced by dopr().

#define DP_C_LLONG   4

Definition at line 173 of file snprintf.c.

Referenced by dopr().

#define DP_C_LONG   2

Definition at line 171 of file snprintf.c.

Referenced by dopr().

#define DP_C_SHORT   1

Definition at line 170 of file snprintf.c.

Referenced by dopr().

#define DP_F_MINUS   (1 << 0)

Definition at line 161 of file snprintf.c.

Referenced by dopr(), fmtfp(), fmtint(), and fmtstr().

#define DP_F_NUM   (1 << 3)

Definition at line 164 of file snprintf.c.

Referenced by dopr().

#define DP_F_PLUS   (1 << 1)

Definition at line 162 of file snprintf.c.

Referenced by dopr(), fmtfp(), and fmtint().

#define DP_F_SPACE   (1 << 2)

Definition at line 163 of file snprintf.c.

Referenced by dopr(), fmtfp(), and fmtint().

#define DP_F_UNSIGNED   (1 << 6)

Definition at line 167 of file snprintf.c.

Referenced by dopr(), and fmtint().

#define DP_F_UP   (1 << 5)

Definition at line 166 of file snprintf.c.

Referenced by dopr(), fmtfp(), and fmtint().

#define DP_F_ZERO   (1 << 4)

Definition at line 165 of file snprintf.c.

Referenced by dopr(), fmtfp(), and fmtint().

#define DP_S_CONV   6

Definition at line 157 of file snprintf.c.

Referenced by dopr().

#define DP_S_DEFAULT   0

Definition at line 151 of file snprintf.c.

Referenced by dopr().

#define DP_S_DONE   7

Definition at line 158 of file snprintf.c.

Referenced by dopr().

#define DP_S_DOT   3

Definition at line 154 of file snprintf.c.

Referenced by dopr().

#define DP_S_FLAGS   1

Definition at line 152 of file snprintf.c.

Referenced by dopr().

#define DP_S_MAX   4

Definition at line 155 of file snprintf.c.

Referenced by dopr().

#define DP_S_MIN   2

Definition at line 153 of file snprintf.c.

Referenced by dopr().

#define DP_S_MOD   5

Definition at line 156 of file snprintf.c.

Referenced by dopr().

#define LDOUBLE   double

Definition at line 126 of file snprintf.c.

Referenced by abs_val(), dopr(), and POW10().

#define LLONG   long

Definition at line 132 of file snprintf.c.

Referenced by dopr(), and ROUND().

#define MAX ( p,
q   )     (((p) >= (q)) ? (p) : (q))

Definition at line 177 of file snprintf.c.

#define NULL   0

Definition at line 94 of file snprintf.c.

Referenced by _glewStrCLen(), _glewStrLen(), _glewStrSame(), _glewStrSame1(), _glewStrSame2(), _glewStrSame3(), ARGParser::addEntry(), ARGParser::addNonParamEntry(), adjust_varargs(), Arith(), asprintf(), atomic(), aux_upvalue(), auxgetinfo(), auxupvalue(), close_func(), collectargs(), collectvalidlines(), MeshLODVector::computeEdgeCostAtVertex(), correctstack(), GLTexture::create(), GLTexture::createBufferTexture(), createmeta(), createScorchedWindow(), db_gethook(), db_sethook(), S3D::dialogMessage(), doargs(), dotty(), Water2Patch::draw(), LandVisibilityPatch::draw(), VisibilityPatchGrid::drawWater(), DumpFunction(), DumpString(), end_capture(), exprstat(), f_flush(), f_seek(), f_setvbuf(), findfile(), findlocal(), g_iofile(), g_read(), g_write(), gctm(), GCTM(), generic_reader(), get_compTM(), get_prompt(), getF(), getfreepos(), getfuncname(), getiofile(), Keyboard::getkeyboardbuffer(), getluaproto(), getobjname(), SecureID::GetPrivateKey(), getS(), glewGetString(), glxewGetExtension(), gmatch_aux(), handle_luainit(), handle_script(), indexupvalue(), io_fclose(), io_flush(), io_gc(), io_lines(), io_open(), io_pclose(), io_popen(), io_readline(), io_tmpfile(), io_tostring(), io_type(), l_alloc(), ll_load(), ll_loadfunc(), ll_module(), ll_register(), ll_sym(), llex(), lmemfind(), LoadConstants(), LoadDebug(), loader_C(), loader_Croot(), loader_Lua(), ImagePng::loadFromBuffer(), LoadFunction(), LoadString(), lstop(), lua_close(), lua_getinfo(), lua_getmetatable(), lua_newstate(), lua_pushstring(), lua_sethook(), lua_setmetatable(), lua_tocfunction(), lua_tolstring(), lua_topointer(), lua_tothread(), lua_touserdata(), luaB_collectgarbage(), luaB_dofile(), luaB_load(), luaB_loadfile(), luaB_print(), luaC_fullgc(), luaC_separateudata(), luaE_freethread(), luaF_close(), luaF_findupval(), luaF_getlocalname(), luaF_newLclosure(), luaF_newproto(), luaG_aritherror(), luaG_typeerror(), luaH_new(), luaI_openlib(), luaL_argerror(), luaL_checkudata(), luaL_findtable(), luaL_gsub(), luaL_loadfile(), luaL_newstate(), luaM_realloc_(), luaM_toobig(), luaO_pushvfstring(), luaopen_package(), luaS_newlstr(), luaS_newudata(), luaS_resize(), luaT_gettm(), luaU_dump(), luaV_equalval(), luaV_gettable(), luaV_settable(), luaV_tonumber(), luaX_setinput(), luaY_parser(), luaZ_fill(), luaZ_init(), main(), markroot(), match(), match_capture(), matchbalance(), max_expand(), min_expand(), modinit(), newfile(), newkey(), open_func(), os_date(), os_execute(), os_setlocale(), os_time(), pmain(), preinit_state(), print_version(), PrintUpvalues(), pushclosure(), pushnexttemplate(), read_line(), readable(), FileList::readFiles(), DisplayFrame::refreshResolutions(), registerlocalvar(), report(), resetstack(), runargs(), scanformat(), setnodevector(), setpath(), showMainDialog(), singlestep(), singlevaraux(), NetServerTCP3::start(), NetServerTCP2::start(), NetServerTCP::start(), start_capture(), str_find_aux(), sweeplist(), test_eof(), tofile(), traversetable(), vasprintf(), and ImagePng::writeToBuffer().

#define snprintf   smb_snprintf

Definition at line 831 of file snprintf.c.

#define VA_COPY ( dest,
src   )     (dest) = (src)

Definition at line 142 of file snprintf.c.

Referenced by dopr(), and vasprintf().

#define vsnprintf   smb_vsnprintf

Definition at line 811 of file snprintf.c.


Function Documentation

static LDOUBLE abs_val ( LDOUBLE  value  )  [static]

Definition at line 578 of file snprintf.c.

References LDOUBLE.

Referenced by fmtfp().

int asprintf ( char **  ptr,
const char *  format,
  ... 
)

Definition at line 860 of file snprintf.c.

References NULL, and vasprintf().

static size_t dopr ( char *  buffer,
size_t  maxlen,
const char *  format,
va_list  args_in 
) [static]

Definition at line 193 of file snprintf.c.

References char_to_int, dopr_outch(), DP_C_LDOUBLE, DP_C_LLONG, DP_C_LONG, DP_C_SHORT, DP_F_MINUS, DP_F_NUM, DP_F_PLUS, DP_F_SPACE, DP_F_UNSIGNED, DP_F_UP, DP_F_ZERO, DP_S_CONV, DP_S_DEFAULT, DP_S_DONE, DP_S_DOT, DP_S_FLAGS, DP_S_MAX, DP_S_MIN, DP_S_MOD, fmtfp(), fmtint(), fmtstr(), LDOUBLE, LLONG, LangStringUtil::strlen(), and VA_COPY.

Referenced by smb_vsnprintf().

static void dopr_outch ( char *  buffer,
size_t *  currlen,
size_t  maxlen,
char  c 
) [static]

Definition at line 799 of file snprintf.c.

Referenced by dopr(), fmtfp(), fmtint(), and fmtstr().

static void fmtfp ( char *  buffer,
size_t *  currlen,
size_t  maxlen,
LDOUBLE  fvalue,
int  min,
int  max,
int  flags 
) [static]

Definition at line 647 of file snprintf.c.

References abs_val(), dopr_outch(), DP_F_MINUS, DP_F_PLUS, DP_F_SPACE, DP_F_UP, DP_F_ZERO, int(), my_modf(), POW10(), and ROUND().

Referenced by dopr().

static void fmtint ( char *  buffer,
size_t *  currlen,
size_t  maxlen,
long  value,
int  base,
int  min,
int  max,
int  flags 
) [static]

Definition at line 494 of file snprintf.c.

References dopr_outch(), DP_F_MINUS, DP_F_PLUS, DP_F_SPACE, DP_F_UNSIGNED, DP_F_UP, DP_F_ZERO, MAX, and uvalue.

Referenced by dopr().

static void fmtstr ( char *  buffer,
size_t *  currlen,
size_t  maxlen,
char *  value,
int  flags,
int  min,
int  max 
) [static]

Definition at line 456 of file snprintf.c.

References dopr_outch(), and DP_F_MINUS.

Referenced by dopr().

static double my_modf ( double  x0,
double *  iptr 
) [static]

Definition at line 613 of file snprintf.c.

Referenced by fmtfp().

static LDOUBLE POW10 ( int  exp  )  [static]

Definition at line 588 of file snprintf.c.

References LDOUBLE.

Referenced by fmtfp().

static LLONG ROUND ( LDOUBLE  value  )  [static]

Definition at line 600 of file snprintf.c.

References LLONG.

Referenced by fmtfp().

int smb_snprintf ( char *  str,
size_t  count,
const char *  fmt,
  ... 
)

Definition at line 821 of file snprintf.c.

References vsnprintf.

int smb_vsnprintf ( char *  str,
size_t  count,
const char *  fmt,
va_list  args 
)

Definition at line 807 of file snprintf.c.

References dopr().

int vasprintf ( char **  ptr,
const char *  format,
va_list  ap 
)

Definition at line 837 of file snprintf.c.

References NULL, VA_COPY, and vsnprintf.

Referenced by asprintf().


Generated on Mon Feb 16 15:14:57 2009 for Scorched3D by  doxygen 1.5.3