Index: ossp-pkg/l2/l2.h.in RCS File: /v/ossp/cvs/ossp-pkg/l2/l2.h.in,v rcsdiff -q -kk '-r1.17' '-r1.18' -u '/v/ossp/cvs/ossp-pkg/l2/l2.h.in,v' 2>/dev/null --- l2.h.in 2001/11/05 20:39:35 1.17 +++ l2.h.in 2001/11/06 15:02:49 1.18 @@ -163,8 +163,8 @@ /* list of linking modes */ typedef enum { - L2_LINK_CHILDS, - L2_LINK_SIBLINGS + L2_LINK_CHILD, + L2_LINK_SIBLING } l2_link_t; /* channel handler specification structure */ Index: ossp-pkg/l2/l2_channel.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v rcsdiff -q -kk '-r1.23' '-r1.24' -u '/v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v' 2>/dev/null --- l2_channel.c 2001/11/04 13:55:06 1.23 +++ l2_channel.c 2001/11/06 15:02:49 1.24 @@ -105,55 +105,62 @@ } /* link channels */ -l2_result_t l2_channel_link(l2_channel_t *chR, l2_link_t id, l2_channel_t *chC, ...) +l2_result_t l2_channel_link(l2_channel_t *ch0, l2_link_t id, l2_channel_t *ch, ...) { l2_channel_t *chT; l2_channel_t *chN; va_list ap; /* argument sanity check */ - if (chR == NULL || chC == NULL) + if (ch0 == NULL || ch == NULL) return L2_ERR_ARG; - /* make sure root channel is in state "created" */ - if (chR->state != L2_CHSTATE_CREATED) - return L2_ERR_USE; - - /* make sure root channel is a filter channel */ - if (chR->handler.type != L2_CHANNEL_FILTER) - return L2_ERR_USE; - - /* check childs */ - va_start(ap, chC); - chT = chC; - do { - chN = (l2_channel_t *)va_arg(ap, l2_channel_t *); - if (id == L2_LINK_CHILDS && chN != NULL) - if (chT->handler.type != L2_CHANNEL_FILTER) + /* perform either child or sibling linking operation(s) */ + if (id == L2_LINK_CHILD) { + /* make sure child parents are filters only */ + if (ch0->handler.type != L2_CHANNEL_FILTER) + return L2_ERR_USE; + va_start(ap, ch); + chT = ch; + do { + chN = (l2_channel_t *)va_arg(ap, l2_channel_t *); + if (chN != NULL && chT->handler.type != L2_CHANNEL_FILTER) return L2_ERR_USE; - } while ((chT = chN) != NULL); - va_end(ap); + } while ((chT = chN) != NULL); + va_end(ap); - /* perform link operation(s) */ - va_start(ap, chC); - do { - chC->parent = chR; - chC->sibling = NULL; - chC->child = NULL; - if (chR->child == NULL) - chR->child = chC; - else { - chT = chR->child; - while (chT->sibling != NULL) - chT = chT->sibling; - chT->sibling = chC; - } - if (id == L2_LINK_CHILDS) - chR = chC; - chC = (l2_channel_t *)va_arg(ap, l2_channel_t *); + /* perform link operation(s) */ + va_start(ap, ch); + do { + ch->parent = ch0; + ch->sibling = NULL; + ch->child = NULL; + if (ch0->child == NULL) + ch0->child = ch; + else { + chT = ch0->child; + while (chT->sibling != NULL) + chT = chT->sibling; + chT->sibling = ch; + } + ch0 = ch; + ch = (l2_channel_t *)va_arg(ap, l2_channel_t *); + } while (ch != NULL); + va_end(ap); + } + else if (id == L2_LINK_SIBLING) { + /* perform link operation(s) */ + va_start(ap, ch); + do { + ch0->sibling = ch; + ch->parent = ch0->parent; + ch->sibling = NULL; + ch->child = NULL; + ch0 = ch; + ch = (l2_channel_t *)va_arg(ap, l2_channel_t *); + } while (ch != NULL); + va_end(ap); } - while (chC != NULL); - va_end(ap); return L2_OK; } Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.40' '-r1.41' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/11/05 20:39:35 1.40 +++ l2_test.c 2001/11/06 15:02:49 1.41 @@ -123,10 +123,10 @@ die("failed to level of smtp channel"); /* build channel tree */ - if (l2_channel_link(ch, L2_LINK_CHILDS, chFilter, chPrefix, chBuffer, chFile, NULL) != L2_OK) - die("failed to link channels together as a child sequence"); - if (l2_channel_link(ch, L2_LINK_SIBLINGS, chSyslog, NULL) != L2_OK) - die("failed to link filter channel on top of syslog channel"); + if (l2_channel_link(ch, L2_LINK_CHILD, chFilter, chPrefix, chBuffer, chFile, NULL) != L2_OK) + die("failed to link file-related channels together as a child sequence"); + if (l2_channel_link(ch, L2_LINK_CHILD, chSyslog, NULL) != L2_OK) + die("failed to link syslog-related channels together as a child sequence"); /* open channel tree */ if (l2_channel_open(ch) != L2_OK)