MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
service_my_snprintf.h File Reference
#include <stdarg.h>
#include <stdlib.h>
Include dependency graph for service_my_snprintf.h:
This graph shows which files directly or indirectly include this file:

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_stmy_snprintf_service

Detailed Description

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)

Parameters
[out]toA buffer to store the result in
[in]nStore up to n-1 characters, followed by an end 0
[in]fmtprintf-like format string
[in]apArguments
Returns
a number of bytes written to a buffer excluding terminating '\0'
Postcondition
The syntax of a format string is generally the same: % <flag> <width> <precision> <length modifier>=""> <format> where everithing but the format is optional.

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.