67 #define SPRINTF_FLAG 0 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];
#define SPRINTF_PRECISION
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define SPRINTF_CONVERSION
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static snd_pcm_format_t format
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.