os: generalize Session_label, Session_policy

The utilities in os/session_policy.h used to be tailored for the
matching of session arguments against a server-side policy
configuration. However, the policy-matching part is useful in other
situations, too. This patch removes the tight coupling with the
session-argument parsing (via Arg_string) and the hard-wired use of
'Genode::config()'.

To make the utilities more versatile, the 'Session_label' has become a
'Genode::String' (at the time when we originally introduced the
'Session_label', there was no 'Genode::String'). The parsing of the
session arguments happens in the constructor of this special 'String'.
The constructor of 'Session_policy' now takes a 'Genode::String' as
argument. So it can be used with the 'Session_label' but also with other
'String' types. Furthermore, the implicit use of 'Genode::config()' can
be overridden by explicitly specifying the config node as an argument.
This commit is contained in:
Norman Feske
2015-09-17 16:59:09 +02:00
committed by Christian Helmuth
parent 1f941d1c87
commit dce6e14e3e
2 changed files with 67 additions and 65 deletions

View File

@ -69,7 +69,7 @@ class Session : public Session_list::Element
* Append label separator to match selectors with a trailing
* separator.
*/
char label[Genode::Session_label::MAX_LEN + 4];
char label[Genode::Session_label::capacity() + 4];
Genode::snprintf(label, sizeof(label), "%s ->", _label.string());
return Genode::strcmp(label, selector,
Genode::strlen(selector)) == 0;