pr_netio_stream_t *pr_netio_open(pool *parent_pool, int strm_type, int fd, int mode) { pr_netio_stream_t *nstrm = NULL; if (!parent_pool) { errno = EINVAL; return NULL; } /* Create a new stream object, then pass that the NetIO open handler. */ nstrm = netio_stream_alloc(parent_pool); if (strm_type == PR_NETIO_STRM_CTRL) { nstrm->strm_type = PR_NETIO_STRM_CTRL; nstrm->strm_mode = mode; return ctrl_netio ? ctrl_netio->open(nstrm, fd, mode) : core_ctrl_netio->open(nstrm, fd, mode); } if (strm_type == PR_NETIO_STRM_DATA) { nstrm->strm_type = PR_NETIO_STRM_DATA; nstrm->strm_mode = mode; return data_netio ? data_netio->open(nstrm, fd, mode) : core_data_netio->open(nstrm, fd, mode); } if (strm_type == PR_NETIO_STRM_OTHR) { nstrm->strm_type = PR_NETIO_STRM_OTHR; nstrm->strm_mode = mode; return othr_netio ? othr_netio->open(nstrm, fd, mode) : core_othr_netio->open(nstrm, fd, mode); } destroy_pool(nstrm->strm_pool); errno = EPERM; return NULL; }
pr_netio_stream_t *pr_netio_open(pool *parent_pool, int strm_type, int fd, int mode) { pr_netio_stream_t *nstrm = NULL; if (parent_pool == NULL) { errno = EINVAL; return NULL; } /* Create a new stream object, then pass that the NetIO open handler. */ nstrm = netio_stream_alloc(parent_pool); switch (strm_type) { case PR_NETIO_STRM_CTRL: nstrm->strm_type = PR_NETIO_STRM_CTRL; nstrm->strm_mode = mode; if (ctrl_netio != NULL) { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), ctrl_netio, sizeof(pr_netio_t *)); return (ctrl_netio->open)(nstrm, fd, mode); } else { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), default_ctrl_netio, sizeof(pr_netio_t *)); return (default_ctrl_netio->open)(nstrm, fd, mode); } case PR_NETIO_STRM_DATA: nstrm->strm_type = PR_NETIO_STRM_DATA; nstrm->strm_mode = mode; if (data_netio != NULL) { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), data_netio, sizeof(pr_netio_t *)); return (data_netio->open)(nstrm, fd, mode); } else { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), default_data_netio, sizeof(pr_netio_t *)); return (default_data_netio->open)(nstrm, fd, mode); } case PR_NETIO_STRM_OTHR: nstrm->strm_type = PR_NETIO_STRM_OTHR; nstrm->strm_mode = mode; if (othr_netio != NULL) { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), othr_netio, sizeof(pr_netio_t *)); return (othr_netio->open)(nstrm, fd, mode); } else { pr_table_add(nstrm->notes, pstrdup(nstrm->strm_pool, "core.netio"), default_othr_netio, sizeof(pr_netio_t *)); return (default_othr_netio->open)(nstrm, fd, mode); } } destroy_pool(nstrm->strm_pool); nstrm->strm_pool = NULL; errno = EPERM; return NULL; }