Julian Lyndon-Smith
2006-May-31 04:41 UTC
[Asterisk-Users] extra parameter for DB read function
There are often times that I want to read a DB value from the dialplan, and if this family/key pair does not exist, set it to some default value. for example: 1234,1 => Set(EMAILADDR=${DB(x/y)} 1234,2 => GotoIf($["${EMAILADDR}" = ""]?3:4) 1234,3 => Set(EMAILADDR=Someone@test.com) 1234,4 => NoOp(${EMAILADDR}) 1234,5 => Hangup() I have modified the db function to take an extra parameter to set if the key does not exist. So, the dialplan would now look like: 1234,1 => Set(EMAILADDR=${DB(x/y/Someone@test.com)} 1234,2 => NoOp(${EMAILADDR}) 1234,3 => Hangup() It's just a shortcut to acheive the same goal, but with 2 less lines in the dialplan. Now, I am *not* a C programmer, so I may have made some horrendous mistake or potential segfault, so is there someone who would look at the changes before I make a fool of myself and post it to the -dev list or mantis ? Much appreciated :) Julian