69 #define SPRINTF_FLAG 0
70 #define SPRINTF_WIDTH 1
71 #define SPRINTF_PRECISION 2
72 #define SPRINTF_LENGTH 3
73 #define SPRINTF_CONVERSION 4
74 int i,
state = -1, argcount = 0;
75 char *formatstart = NULL, *bufptr = buf;
76 char formatbuf[256] =
"";
87 for (i = 0; arg.format[i]; i++) {
90 if (strchr(
"#0- +'I", arg.format[i]))
94 if (arg.format[i] >=
'0' && arg.format[i] <=
'9')
98 if (arg.format[i] ==
'.') {
106 if (arg.format[i] >=
'0' && arg.format[i] <=
'9')
110 if (strchr(
"hl", arg.format[i])) {
111 if (arg.format[i + 1] == arg.format[i])
115 }
else if (strchr(
"Lqjzt", arg.format[i])) {
121 if (strchr(
"diouxXc", arg.format[i])) {
126 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
129 if (arg.var[argcount]) {
130 if (sscanf(arg.var[argcount++],
"%30d", &tmpi) != 1) {
131 ast_log(
LOG_ERROR,
"Argument '%s' is not an integer number for format '%s'\n", arg.var[argcount - 1], formatbuf);
135 ast_log(
LOG_ERROR,
"SPRINTF() has more format specifiers than arguments!\n");
140 snprintf(bufptr, buf +
len - bufptr, formatbuf, tmpi);
143 bufptr = strchr(buf,
'\0');
144 }
else if (strchr(
"eEfFgGaA", arg.format[i])) {
149 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
152 if (arg.var[argcount]) {
153 if (sscanf(arg.var[argcount++],
"%30lf", &tmpd) != 1) {
154 ast_log(
LOG_ERROR,
"Argument '%s' is not a floating point number for format '%s'\n", arg.var[argcount - 1], formatbuf);
158 ast_log(
LOG_ERROR,
"SPRINTF() has more format specifiers than arguments!\n");
163 snprintf(bufptr, buf +
len - bufptr, formatbuf, tmpd);
166 bufptr = strchr(buf,
'\0');
167 }
else if (arg.format[i] ==
's') {
172 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
175 snprintf(bufptr, buf +
len - bufptr, formatbuf, arg.var[argcount++]);
178 bufptr = strchr(buf,
'\0');
179 }
else if (arg.format[i] ==
'%') {
181 *bufptr++ = arg.format[i];
187 formatbuf[&arg.format[i] - formatstart + 1] =
'\0';
189 ast_log(
LOG_ERROR,
"Format type not supported: '%s' with argument '%s'\n", formatbuf, arg.var[argcount++]);
195 if (arg.format[i] ==
'%') {
197 formatstart = &arg.format[i];
201 *bufptr++ = arg.format[i];
#define SPRINTF_PRECISION
#define SPRINTF_CONVERSION
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static snd_pcm_format_t format