+/* An interpreter factory. Maps an interpreter name to the factory
+ function that instantiates an interpreter by that name. */
+
+struct interp_factory
+{
+ /* This is the name in "-i=INTERP" and "interpreter-exec INTERP". */
+ const char *name;
+
+ /* The function that creates the interpreter. */
+ interp_factory_func func;
+};
+
+typedef struct interp_factory *interp_factory_p;
+DEF_VEC_P(interp_factory_p);
+
+/* The registered interpreter factories. */
+static VEC(interp_factory_p) *interpreter_factories = NULL;
+
+/* See interps.h. */
+
+void
+interp_factory_register (const char *name, interp_factory_func func)
+{
+ struct interp_factory *f;
+ int ix;
+
+ /* Assert that no factory for NAME is already registered. */
+ for (ix = 0;
+ VEC_iterate (interp_factory_p, interpreter_factories, ix, f);
+ ++ix)
+ if (strcmp (f->name, name) == 0)
+ {
+ internal_error (__FILE__, __LINE__,
+ _("interpreter factory already registered: \"%s\"\n"),
+ name);
+ }
+
+ f = XNEW (struct interp_factory);
+ f->name = name;
+ f->func = func;
+ VEC_safe_push (interp_factory_p, interpreter_factories, f);
+}
+