68#define SPRINTF_WIDTH 1
69#define SPRINTF_PRECISION 2
70#define SPRINTF_LENGTH 3
71#define SPRINTF_CONVERSION 4
72 int i,
state = -1, argcount = 0;
73 char *formatstart =
NULL, *bufptr =
buf;
74 char formatbuf[256] =
"";
85 for (i = 0; arg.format[i]; i++) {
88 if (strchr(
"#0- +'I", arg.format[i]))
92 if (arg.format[i] >=
'0' && arg.format[i] <=
'9')
96 if (arg.format[i] ==
'.') {
104 if (arg.format[i] >=
'0' && arg.format[i] <=
'9')
108 if (strchr(
"hl", arg.format[i])) {
109 if (arg.format[i + 1] == arg.format[i])
113 }
else if (strchr(
"Lqjzt", arg.format[i])) {
119 if (strchr(
"diouxXc", arg.format[i])) {
124 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
127 if (arg.var[argcount]) {
128 if (sscanf(arg.var[argcount++],
"%30d", &tmpi) != 1) {
129 ast_log(
LOG_ERROR,
"Argument '%s' is not an integer number for format '%s'\n", arg.var[argcount - 1], formatbuf);
133 ast_log(
LOG_ERROR,
"SPRINTF() has more format specifiers than arguments!\n");
138 snprintf(bufptr,
buf +
len - bufptr, formatbuf, tmpi);
141 bufptr = strchr(
buf,
'\0');
142 }
else if (strchr(
"eEfFgGaA", arg.format[i])) {
147 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
150 if (arg.var[argcount]) {
151 if (sscanf(arg.var[argcount++],
"%30lf", &tmpd) != 1) {
152 ast_log(
LOG_ERROR,
"Argument '%s' is not a floating point number for format '%s'\n", arg.var[argcount - 1], formatbuf);
156 ast_log(
LOG_ERROR,
"SPRINTF() has more format specifiers than arguments!\n");
161 snprintf(bufptr,
buf +
len - bufptr, formatbuf, tmpd);
164 bufptr = strchr(
buf,
'\0');
165 }
else if (arg.format[i] ==
's') {
170 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
173 snprintf(bufptr,
buf +
len - bufptr, formatbuf, arg.var[argcount++]);
176 bufptr = strchr(
buf,
'\0');
177 }
else if (arg.format[i] ==
'%') {
179 *bufptr++ = arg.format[i];
185 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
187 ast_log(
LOG_ERROR,
"Format type not supported: '%s' with argument '%s'\n", formatbuf, arg.var[argcount++]);
193 if (arg.format[i] ==
'%') {
195 formatstart = &arg.format[i];
199 *bufptr++ = arg.format[i];
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
static struct ast_threadstorage result_buf
#define SPRINTF_CONVERSION
static int acf_sprintf(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function sprintf_function
#define SPRINTF_PRECISION
static int load_module(void)
static int unload_module(void)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.