Added a hexadecimal conversion function in regexroute.
git-svn-id: http://yate.null.ro/svn/yate/trunk@4098 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
5dfbbc7a54
commit
479445bc21
|
@ -29,6 +29,7 @@
|
|||
; $(upper,STRING) = STRING converted to upper case
|
||||
; $(lower,STRING) = STRING converted to lower case
|
||||
; $(chr,N) = character with numeric code N
|
||||
; $(hex,N[,LEN]) = little endian hexadecimal value of N with space between octets
|
||||
; $(add,VAL1,VAL2[,LEN]) = VAL1+VAL2 left filled to LEN or length of VAL1
|
||||
; $(sub,VAL1,VAL2[,LEN]) = VAL1-VAL2 left filled to LEN or length of VAL1
|
||||
; $(mul,VAL1,VAL2[,LEN]) = VAL1*VAL2 left filled to LEN or length of VAL1
|
||||
|
|
|
@ -214,6 +214,32 @@ static void evalFunc(String& str)
|
|||
str << par.at(i);
|
||||
}
|
||||
}
|
||||
else if (str == "hex") {
|
||||
int len = 0;
|
||||
if (sep >= 0) {
|
||||
len = par.substr(sep+1).toInteger();
|
||||
par = par.substr(0,sep);
|
||||
}
|
||||
int val = par.toInteger();
|
||||
unsigned char buf[4];
|
||||
buf[0] = (unsigned char)val;
|
||||
buf[1] = (unsigned char)(val >> 8);
|
||||
buf[2] = (unsigned char)(val >> 16);
|
||||
buf[3] = (unsigned char)(val >> 24);
|
||||
if (len > 4)
|
||||
len = 4;
|
||||
else if (len <= 0) {
|
||||
if (buf[3])
|
||||
len = 4;
|
||||
else if (buf[2])
|
||||
len = 3;
|
||||
else if (buf[1])
|
||||
len = 2;
|
||||
else
|
||||
len = 1;
|
||||
}
|
||||
str.hexify(&buf,len,' ');
|
||||
}
|
||||
else if ((sep > 0) && ((str == "index") || (str == "rotate"))) {
|
||||
bool rotate = (str == "rotate");
|
||||
String vname;
|
||||
|
|
Loading…
Reference in New Issue