Hello,
'switch' statements can be used now in configuration file to test the last returned code ('retcode') - CVS head version. This should simplify a lot the scripting for testing 'retcode' and should make the file better structured and easier to understand (hopefully :-) ).
It is similar with C 'switch' construct, but it uses 'sbreak' instead of C-'break', because in openser the keyword 'break' is already used for other meaning. I am not fully convinced whether to use this 'sbreak' keyword, or better 'esac' (shell-like), any better idea?
An example of usage is posted on dokuwiki page: http://www.openser.org/dokuwiki/doku.php?id=openser_core_cookbook#switch
Daniel
Daniel-Constantin Mierla writes:
It is similar with C 'switch' construct, but it uses 'sbreak' instead of C-'break', because in openser the keyword 'break' is already used for other meaning. I am not fully convinced whether to use this 'sbreak' keyword, or better 'esac' (shell-like), any better idea?
since the language is changing anyway, why not introduce "return" that returns from a route block and then use break to beak from switch and possibly other statements you come up with. then semantics would be the same as in c.
-- juha
On 07/11/05 21:52, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
It is similar with C 'switch' construct, but it uses 'sbreak' instead of C-'break', because in openser the keyword 'break' is already used for other meaning. I am not fully convinced whether to use this 'sbreak' keyword, or better 'esac' (shell-like), any better idea?
since the language is changing anyway, why not introduce "return" that returns from a route block and then use break to beak from switch and possibly other statements you come up with. then semantics would be the same as in c.
this is an option, too. But I am afraid that some users will be scared when they will see that compatibility is broken and they will not easily test the development version using their old config file. Maybe a intermediary version that display warnings at startup that 'break' is obsolete and will be dropped soon in favor of 'return' would be better;
'esac' seems more appropriate to avoid more mess up between 'break' and 'sbreak'.
Daniel
-- juha
Hi everybody,
form consistency point of view, I totally agree with Juha's suggestion - go for a C-like language and use break only for switch and return for exiting the routes. on the other hand, I worry about backward compatibility - the change will have quite an impact - and SER compatibility (SER scripts will not work on OpenSER).
IMHO we should go for a middle stage (as Daniel suggested): the syntax will accept break outside switch, but generating a warning and converting it internally to return(1); break will be normally accepted in switches.
regards, bogdan
Daniel-Constantin Mierla wrote:
On 07/11/05 21:52, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
It is similar with C 'switch' construct, but it uses 'sbreak'
instead of > C-'break', because in openser the keyword 'break' is already used for > other meaning. I am not fully convinced whether to use this 'sbreak' > keyword, or better 'esac' (shell-like), any better idea?
since the language is changing anyway, why not introduce "return" that returns from a route block and then use break to beak from switch and possibly other statements you come up with. then semantics would be the same as in c.
this is an option, too. But I am afraid that some users will be scared when they will see that compatibility is broken and they will not easily test the development version using their old config file. Maybe a intermediary version that display warnings at startup that 'break' is obsolete and will be dropped soon in favor of 'return' would be better;
'esac' seems more appropriate to avoid more mess up between 'break' and 'sbreak'.
Daniel
-- juha
Devel mailing list Devel@openser.org http://openser.org/cgi-bin/mailman/listinfo/devel