ossp-pkg/l2/l2_channel.c 1.24 -> 1.25
--- l2_channel.c 2001/11/06 15:02:49 1.24
+++ l2_channel.c 2001/11/07 11:37:18 1.25
@@ -67,14 +67,27 @@
*/
/* create channel */
-l2_result_t l2_channel_create(l2_channel_t **chp, l2_env_t *env, l2_handler_t *h)
+l2_result_t l2_channel_create(l2_channel_t **chp, l2_env_t *env, const char *name)
{
l2_channel_t *ch;
+ l2_handler_t *h;
+ int i;
/* argument sanity check */
- if (h == NULL || env == NULL)
+ if (env == NULL || name == NULL)
return L2_ERR_ARG;
+ /* lookup channel handler */
+ h = NULL;
+ for (i = 0; i < L2_MAX_HANDLERS && env->handlers[i] != NULL; i++) {
+ if (strcmp(env->handlers[i]->name, name) == 0) {
+ h = env->handlers[i];
+ break;
+ }
+ }
+ if (h == NULL)
+ return L2_ERR_CH;
+
/* allocate channel structure */
if ((ch = (l2_channel_t *)malloc(sizeof(l2_channel_t))) == NULL)
return L2_ERR_SYS;
|
|