147 char *mvalue1, *mvalue2 = NULL, *mtype_of_result;
155 ast_log(
LOG_WARNING,
"Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
162 ast_log(
LOG_WARNING,
"Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
166 mvalue1 =
args.argv0;
168 if (mvalue1[0] ==
'-') {
173 if ((op = strchr(mvalue1,
'*'))) {
176 }
else if ((op = strchr(mvalue1,
'/'))) {
179 }
else if ((op = strchr(mvalue1,
'%'))) {
182 }
else if ((op = strchr(mvalue1,
'^'))) {
185 }
else if ((op = strstr(mvalue1,
"AND"))) {
189 }
else if ((op = strstr(mvalue1,
"XOR"))) {
193 }
else if ((op = strstr(mvalue1,
"OR"))) {
197 }
else if ((op = strchr(mvalue1,
'>'))) {
200 if (*(op + 1) ==
'=') {
203 }
else if (*(op + 1) ==
'>') {
207 }
else if ((op = strchr(mvalue1,
'<'))) {
210 if (*(op + 1) ==
'=') {
213 }
else if (*(op + 1) ==
'<') {
217 }
else if ((op = strchr(mvalue1,
'='))) {
219 if (*(op + 1) ==
'=') {
224 }
else if ((op = strchr(mvalue1,
'+'))) {
227 }
else if ((op = strchr(mvalue1,
'-'))) {
236 mtype_of_result =
args.argv1;
237 if (mtype_of_result) {
238 if (!strcasecmp(mtype_of_result,
"float")
239 || !strcasecmp(mtype_of_result,
"f"))
241 else if (!strcasecmp(mtype_of_result,
"int")
242 || !strcasecmp(mtype_of_result,
"i"))
244 else if (!strcasecmp(mtype_of_result,
"hex")
245 || !strcasecmp(mtype_of_result,
"h"))
247 else if (!strcasecmp(mtype_of_result,
"char")
248 || !strcasecmp(mtype_of_result,
"c"))
259 "Supply all the parameters - just this once, please\n");
263 if (sscanf(mvalue1,
"%30lf", &fnum1) != 1) {
268 if (sscanf(mvalue2,
"%30lf", &fnum2) != 1) {
278 ftmp = fnum1 + fnum2;
284 ftmp = (fnum1 / fnum2);
287 ftmp = (fnum1 * fnum2);
290 ftmp = (fnum1 - fnum2);
300 ftmp = (inum1 % inum2);
306 ftmp = pow(fnum1, fnum2);
313 ftmp = (inum1 << inum2);
321 ftmp = (inum1 >> inum2);
328 ftmp = (inum1 & inum2);
335 ftmp = (inum1 ^ inum2);
342 ftmp = (inum1 | inum2);
362 "Something happened that neither of us should be proud of %d\n",
367 if (iaction < GTFUNCTION || iaction >
EQFUNCTION) {
369 snprintf(buf,
len,
"%f", ftmp);
371 snprintf(buf,
len,
"%i", (
int) ftmp);
373 snprintf(buf,
len,
"%x", (
unsigned int) ftmp);
375 snprintf(buf,
len,
"%c", (
unsigned char) ftmp);
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
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...
static void parse(struct mgcp_request *req)
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.