END_TEST START_TEST (test_get_params) { NPlugin *plugin = NULL; /* NULL checking */ fail_unless (n_plugin_get_params (plugin) == NULL); plugin = g_new0 (NPlugin, 1); fail_unless (plugin != NULL); NProplist *proplist = NULL; proplist = n_proplist_new (); plugin->params = proplist; const NProplist *receivedParams = NULL; const char *key1 = "key1"; n_proplist_set_int (proplist, key1, -100); receivedParams = n_plugin_get_params (plugin); fail_unless (receivedParams != NULL); fail_unless (n_proplist_match_exact (receivedParams, proplist) == TRUE); n_proplist_free (proplist); proplist = NULL; g_free (plugin); plugin = NULL; }
static void transform_properties_cb (NHook *hook, void *data, void *userdata) { (void) hook; (void) data; (void) userdata; NCore *core = (NCore*) userdata; NContext *context = n_core_get_context (core); NProplist *new_props = NULL; NProplist *props = NULL; GList *iter = NULL; const char *match_str = NULL; ProfileEntry *entry = NULL; NValue *value = NULL; gchar *context_key = NULL; NCoreHookTransformPropertiesData *transform = (NCoreHookTransformPropertiesData*) data; N_DEBUG (LOG_CAT "transforming profile values for request '%s'", n_request_get_name (transform->request)); new_props = n_proplist_new (); props = (NProplist*) n_request_get_properties (transform->request); for (iter = g_list_first (request_keys); iter; iter = g_list_next (iter)) { match_str = n_proplist_get_string (props, (gchar*) iter->data); if (!match_str) continue; entry = g_hash_table_lookup (profile_entries, match_str); if (!entry) continue; /* if this a fallback request, we don't care if there is existing target. otherwise check if the target exists. */ if (!n_request_is_fallback (transform->request) && n_proplist_has_key (props, entry->target)) continue; context_key = construct_context_key (entry->profile, entry->key); value = (NValue*) n_context_get_value (context, context_key); if (value) { N_DEBUG (LOG_CAT "+ transforming profile key '%s' to target '%s'", entry->key, entry->target); n_proplist_set (new_props, entry->target, n_value_copy (value)); } g_free (context_key); } n_proplist_merge (props, new_props); n_proplist_free (new_props); N_DEBUG (LOG_CAT "new properties:") n_proplist_dump (props); }
void n_context_free (NContext *context) { NContextSubscriber *subscriber = NULL; GList *iter = NULL; for (iter = context->subscribers; iter; iter = g_list_next (iter)) { subscriber = (NContextSubscriber*) iter->data; g_free (subscriber->key); g_slice_free (NContextSubscriber, subscriber); } g_list_free (context->subscribers); context->subscribers = NULL; n_proplist_free (context->values); g_free (context); }