mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
Add power and right/left shift functions (Issue 7959)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -31,6 +31,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
@@ -47,6 +48,9 @@ enum TypeOfFunctions {
|
|||||||
MULTIPLYFUNCTION,
|
MULTIPLYFUNCTION,
|
||||||
SUBTRACTFUNCTION,
|
SUBTRACTFUNCTION,
|
||||||
MODULUSFUNCTION,
|
MODULUSFUNCTION,
|
||||||
|
POWFUNCTION,
|
||||||
|
SHLEFTFUNCTION,
|
||||||
|
SHRIGHTFUNCTION,
|
||||||
GTFUNCTION,
|
GTFUNCTION,
|
||||||
LTFUNCTION,
|
LTFUNCTION,
|
||||||
GTEFUNCTION,
|
GTEFUNCTION,
|
||||||
@@ -105,12 +109,18 @@ static int math(struct ast_channel *chan, char *cmd, char *parse,
|
|||||||
} else if ((op = strchr(mvalue1, '%'))) {
|
} else if ((op = strchr(mvalue1, '%'))) {
|
||||||
iaction = MODULUSFUNCTION;
|
iaction = MODULUSFUNCTION;
|
||||||
*op = '\0';
|
*op = '\0';
|
||||||
|
} else if ((op = strchr(mvalue1, '^'))) {
|
||||||
|
iaction = POWFUNCTION;
|
||||||
|
*op = '\0';
|
||||||
} else if ((op = strchr(mvalue1, '>'))) {
|
} else if ((op = strchr(mvalue1, '>'))) {
|
||||||
iaction = GTFUNCTION;
|
iaction = GTFUNCTION;
|
||||||
*op = '\0';
|
*op = '\0';
|
||||||
if (*(op + 1) == '=') {
|
if (*(op + 1) == '=') {
|
||||||
*++op = '\0';
|
*++op = '\0';
|
||||||
iaction = GTEFUNCTION;
|
iaction = GTEFUNCTION;
|
||||||
|
} else if (*(op + 1) == '>') {
|
||||||
|
*++op = '\0';
|
||||||
|
iaction = SHRIGHTFUNCTION;
|
||||||
}
|
}
|
||||||
} else if ((op = strchr(mvalue1, '<'))) {
|
} else if ((op = strchr(mvalue1, '<'))) {
|
||||||
iaction = LTFUNCTION;
|
iaction = LTFUNCTION;
|
||||||
@@ -118,6 +128,9 @@ static int math(struct ast_channel *chan, char *cmd, char *parse,
|
|||||||
if (*(op + 1) == '=') {
|
if (*(op + 1) == '=') {
|
||||||
*++op = '\0';
|
*++op = '\0';
|
||||||
iaction = LTEFUNCTION;
|
iaction = LTEFUNCTION;
|
||||||
|
} else if (*(op + 1) == '<') {
|
||||||
|
*++op = '\0';
|
||||||
|
iaction = SHLEFTFUNCTION;
|
||||||
}
|
}
|
||||||
} else if ((op = strchr(mvalue1, '='))) {
|
} else if ((op = strchr(mvalue1, '='))) {
|
||||||
*op = '\0';
|
*op = '\0';
|
||||||
@@ -192,6 +205,25 @@ static int math(struct ast_channel *chan, char *cmd, char *parse,
|
|||||||
|
|
||||||
ftmp = (inum1 % inum2);
|
ftmp = (inum1 % inum2);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case POWFUNCTION:
|
||||||
|
ftmp = pow(fnum1, fnum2);
|
||||||
|
break;
|
||||||
|
case SHLEFTFUNCTION:
|
||||||
|
{
|
||||||
|
int inum1 = fnum1;
|
||||||
|
int inum2 = fnum2;
|
||||||
|
|
||||||
|
ftmp = (inum1 << inum2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SHRIGHTFUNCTION:
|
||||||
|
{
|
||||||
|
int inum1 = fnum1;
|
||||||
|
int inum2 = fnum2;
|
||||||
|
|
||||||
|
ftmp = (inum1 >> inum2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GTFUNCTION:
|
case GTFUNCTION:
|
||||||
|
Reference in New Issue
Block a user