MySQL 5.6.14 Source Code Document
|
#include <stdarg.h>
#include <stdlib.h>
Go to the source code of this file.
Classes | |
struct | my_snprintf_service_st |
Functions | |
size_t | my_snprintf (char *to, size_t n, const char *fmt,...) |
size_t | my_vsnprintf (char *to, size_t n, const char *fmt, va_list ap) |
Variables | |
struct my_snprintf_service_st * | my_snprintf_service |
my_snprintf service
Portable and limited vsnprintf() implementation.
This is a portable, limited vsnprintf() implementation, with some extra features. "Portable" means that it'll produce identical result on all platforms (for example, on Windows and Linux system printf e formats the exponent differently, on different systems p either prints leading 0x or not, s may accept null pointer or crash on it). "Limited" means that it does not support all the C89 features. But it supports few extensions, not in any standard.
my_vsnprintf(to, n, fmt, ap)
[out] | to | A buffer to store the result in |
[in] | n | Store up to n-1 characters, followed by an end 0 |
[in] | fmt | printf-like format string |
[in] | ap | Arguments |
Three one-character flags are recognized: '0' has the standard zero-padding semantics; '-' is parsed, but silently ignored; '`' (backtick) is only supported for strings (s) and means that the string will be quoted according to MySQL identifier quoting rules.
Both <width> and <precision> can be specified as numbers or '*'. If an asterisk is used, an argument of type int is consumed.
<length modifier>=""> can be 'l', 'll', or 'z'.
Supported formats are 's' (null pointer is accepted, printed as "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o', 'X', 'p' (works as 0xx).
Standard syntax for positional arguments $n is supported.
Extensions:
Flag '`' (backtick): see above.
Format 'b': binary buffer, prints exactly <precision> bytes from the argument, without stopping at '\0'.
Definition in file service_my_snprintf.h.