+gras_error_t
+gras_trp_plugin_new(const char *name, gras_trp_setup_t setup);
+
+gras_error_t
+gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
+ gras_error_t errcode;
+
+ gras_trp_plugin_t *plug = malloc(sizeof(gras_trp_plugin_t));
+
+ DEBUG1("Create plugin %s",name);
+
+ if (!plug)
+ RAISE_MALLOC;
+
+ memset(plug,0,sizeof(gras_trp_plugin_t));
+
+ plug->name=strdup(name);
+ if (!plug->name)
+ RAISE_MALLOC;
+
+ errcode = setup(plug);
+ switch (errcode) {
+ case mismatch_error:
+ /* SG plugin return mismatch when in RL mode (and vice versa) */
+ free(plug->name);
+ free(plug);
+ break;
+
+ case no_error:
+ TRY(gras_dict_set(_gras_trp_plugins,
+ name, plug, gras_trp_plugin_free));
+ break;
+
+ default:
+ free(plug);
+ return errcode;
+ }
+ return no_error;
+}
+