+/* Returns 0 if 'name' is a pstream name in the form "TYPE:ARGS" and TYPE is
+ * a supported pstream type, otherwise EAFNOSUPPORT. */
+int
+pstream_verify_name(const char *name)
+{
+ struct pstream_class *class;
+ return pstream_lookup_class(name, &class);
+}
+
+/* Attempts to start listening for remote stream connections. 'name' is a
+ * connection name in the form "TYPE:ARGS", where TYPE is an passive stream
+ * class's name and ARGS are stream class-specific.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. If successful,
+ * stores a pointer to the new connection in '*pstreamp', otherwise a null
+ * pointer. */
+int
+pstream_open(const char *name, struct pstream **pstreamp)
+{
+ struct pstream_class *class;
+ struct pstream *pstream;
+ char *suffix_copy;
+ int error;
+
+ COVERAGE_INC(pstream_open);
+
+ /* Look up the class. */
+ error = pstream_lookup_class(name, &class);
+ if (!class) {
+ goto error;
+ }
+
+ /* Call class's "open" function. */
+ suffix_copy = xstrdup(strchr(name, ':') + 1);
+ error = class->listen(name, suffix_copy, &pstream);
+ free(suffix_copy);
+ if (error) {
+ goto error;
+ }
+
+ /* Success. */
+ *pstreamp = pstream;
+ return 0;
+
+error:
+ *pstreamp = NULL;
+ return error;
+}
+