Hello All! I want to do something like this (using svn checkout of OpenSER):
switch ($src_ip) { case $var(ip1): # do smth break; case $var(ip2): # do smth break; default: # do smth }
I've got an error message (syntax error). Is it possible to use variables in such manner at all?
Hi Peter,
the "case" syntax does not accept any variables, but only constant values (like in C also :) )
regards, Bogdan
Peter Lemenkov wrote:
Hello All! I want to do something like this (using svn checkout of OpenSER):
switch ($src_ip) { case $var(ip1): # do smth break; case $var(ip2): # do smth break; default: # do smth }
I've got an error message (syntax error). Is it possible to use variables in such manner at all?
Hi Jerome,
you can use strings also - no cast will be done. But the values must be constants.
regards, bogdan
Jerome Martin wrote:
On Mon, 2007-05-14 at 12:12 +0300, Bogdan-Andrei Iancu wrote:
Hi Peter,
the "case" syntax does not accept any variables, but only constant values (like in C also :) )
But is it limited to int or implicitly-castable-to-int values, like in C++ ?
Cheers, Jerome
On Mon, 2007-05-14 at 19:34 +0300, Bogdan-Andrei Iancu wrote:
Hi Jerome,
you can use strings also - no cast will be done. But the values must be constants.
Yes, I knew that, this was just a teaser so you could state that unlike C++ Openser can handle non-int in switch statements :-) (Somehow mitigating the comparison with C for the const requirement ...)
regards, bogdan
Jerome Martin wrote:
On Mon, 2007-05-14 at 12:12 +0300, Bogdan-Andrei Iancu wrote:
Hi Peter,
the "case" syntax does not accept any variables, but only constant values (like in C also :) )
But is it limited to int or implicitly-castable-to-int values, like in C++ ?
Cheers, Jerome
Jérôme Martin | LongPhone Responsable Architecture Réseau 122, rue la Boetie | 75008 Paris Tel : +33 (0)1 56 26 28 44 Fax : +33 (0)1 56 26 28 45 Mail : jmartin@longphone.fr Web : www.longphone.com
hmmm...sounds like a trap :)
ok...it is like in C++ (disclamer - this is based on Jerome's sayings as I mostly parallel with C++ ) ;)
regards, bogdan
Jerome Martin wrote:
On Mon, 2007-05-14 at 19:34 +0300, Bogdan-Andrei Iancu wrote:
Hi Jerome,
you can use strings also - no cast will be done. But the values must be constants.
Yes, I knew that, this was just a teaser so you could state that unlike C++ Openser can handle non-int in switch statements :-) (Somehow mitigating the comparison with C for the const requirement ...)
regards, bogdan
Jerome Martin wrote:
On Mon, 2007-05-14 at 12:12 +0300, Bogdan-Andrei Iancu wrote:
Hi Peter,
the "case" syntax does not accept any variables, but only constant values (like in C also :) )
But is it limited to int or implicitly-castable-to-int values, like in C++ ?
Cheers, Jerome
On Mon, 2007-05-14 at 19:43 +0300, Bogdan-Andrei Iancu wrote:
hmmm...sounds like a trap :)
Well, the kind of trap you're supposed to benefit from once you've fallen in :-)
ok...it is like in C++ (disclamer - this is based on Jerome's sayings as I mostly parallel with C++ ) ;)
I usually do too, but I'm deeeep into sems these days, and well, sems uses and abuses c++ ... I had to even re-read parts of my Strourstrup book. I guess it's inspiring me now :-)