const NValue* n_context_get_value (NContext *context, const char *key) { if (!context || !key) return NULL; return (const NValue*) n_proplist_get (context->values, key); }
void n_context_set_value (NContext *context, const char *key, NValue *value) { NValue *old_value = NULL; if (!context || !key) return; old_value = n_value_copy (n_proplist_get (context->values, key)); n_proplist_set (context->values, key, value); n_context_broadcast_change (context, key, old_value, value); n_value_free (old_value); }
static void n_core_match_event_rule_cb (const char *key, const NValue *value, gpointer userdata) { NEventMatchResult *result = (NEventMatchResult*) userdata; NRequest *request = result->request; NValue *match_value = NULL; const char *context_key = NULL; const char *str = NULL; if (result->skip_rest) return; /* assume positive result */ result->has_match = TRUE; /* if the key has a context@ prefix, then we will lookup the value from the current context. */ context_key = n_core_match_and_strip_prefix (key, "context@"); match_value = context_key ? (NValue*) n_context_get_value (result->context, context_key) : (NValue*) n_proplist_get (request->properties, key); /* if match value has a *, then any value for request will do. */ str = n_value_get_string ((NValue*) value); if (str && g_str_equal (str, "*")) return; /* the moment we find a key and value that does not match, we're done here. */ if (!match_value || !n_value_equals (value, match_value)) { result->has_match = FALSE; result->skip_rest = TRUE; } }