Index: ossp-pkg/l2/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/l2/Makefile.in,v rcsdiff -q -kk '-r1.27' '-r1.28' -u '/v/ossp/cvs/ossp-pkg/l2/Makefile.in,v' 2>/dev/null --- Makefile.in 2001/11/04 13:21:17 1.27 +++ Makefile.in 2001/11/04 14:08:24 1.28 @@ -65,6 +65,7 @@ OBJS = \ l2_env.lo \ l2_channel.lo \ + l2_ch_nop.lo \ l2_ch_fd.lo \ l2_ch_file.lo \ l2_ch_pipe.lo \ @@ -88,6 +89,7 @@ SRCS = \ l2_env.c \ l2_channel.c \ + l2_ch_nop.c \ l2_ch_fd.c \ l2_ch_file.c \ l2_ch_pipe.c \ Index: ossp-pkg/l2/l2.h.in RCS File: /v/ossp/cvs/ossp-pkg/l2/l2.h.in,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/l2/l2.h.in,v' 2>/dev/null --- l2.h.in 2001/11/04 13:21:17 1.15 +++ l2.h.in 2001/11/04 14:08:24 1.16 @@ -200,6 +200,7 @@ extern l2_handler_t l2_handler_smtp; /* list of shipped (filter) channel handlers */ +extern l2_handler_t l2_handler_nop; extern l2_handler_t l2_handler_filter; extern l2_handler_t l2_handler_prefix; extern l2_handler_t l2_handler_buffer; Index: ossp-pkg/l2/l2_ch_nop.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_ch_nop.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_ch_nop.c,v' | diff -u /dev/null - -L'ossp-pkg/l2/l2_ch_nop.c' 2>/dev/null --- ossp-pkg/l2/l2_ch_nop.c +++ - 2024-04-19 22:23:33.821651036 +0200 @@ -0,0 +1,42 @@ +/* +** L2 - OSSP Logging Library +** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) +** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) +** +** This file is part of OSSP L2, a flexible logging library which +** can be found at http://www.ossp.org/pkg/l2/. +** +** Permission to use, copy, modify, and distribute this software for +** any purpose with or without fee is hereby granted, provided that +** the above copyright notice and this permission notice appear in all +** copies. +** +** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +** SUCH DAMAGE. +** +** l2_ch_nop.c: no-operation channel implementation +*/ + +#include "l2.h" + +l2_handler_t l2_handler_nop = { + L2_CHANNEL_FILTER, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + Index: ossp-pkg/l2/l2_ch_null.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_null.c,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_null.c,v' 2>/dev/null --- l2_ch_null.c 2001/09/12 09:42:34 1.8 +++ l2_ch_null.c 2001/11/04 14:08:24 1.9 @@ -24,54 +24,19 @@ ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** -** l2_ch_null.c: null channel implementation +** l2_ch_null.c: null/discard channel implementation */ #include "l2.h" -static l2_result_t hook_create(l2_context_t *ctx, l2_channel_t *ch) -{ - return L2_OK; -} - -static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap) -{ - return L2_OK; -} - -static l2_result_t hook_open(l2_context_t *ctx, l2_channel_t *ch) -{ - return L2_OK; -} - -static l2_result_t hook_write(l2_context_t *ctx, l2_channel_t *ch, l2_level_t level, const char *buf, size_t buf_size) -{ - return L2_OK; -} - -static l2_result_t hook_flush(l2_context_t *ctx, l2_channel_t *ch) -{ - return L2_OK; -} - -static l2_result_t hook_close(l2_context_t *ctx, l2_channel_t *ch) -{ - return L2_OK; -} - -static l2_result_t hook_destroy(l2_context_t *ctx, l2_channel_t *ch) -{ - return L2_OK; -} - l2_handler_t l2_handler_null = { L2_CHANNEL_OUTPUT, - hook_create, - hook_configure, - hook_open, - hook_write, - hook_flush, - hook_close, - hook_destroy + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL }; Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.38' '-r1.39' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/11/04 13:21:17 1.38 +++ l2_test.c 2001/11/04 14:08:24 1.39 @@ -57,6 +57,7 @@ int main(int argc, char *argv[]) { + l2_channel_t *ch; l2_channel_t *chFilter; l2_channel_t *chPrefix; l2_channel_t *chBuffer; @@ -73,6 +74,10 @@ if (l2_env_formatter(env, 'S', l2_util_fmt_dump, NULL) != L2_OK) die("failed to configure formatter for %%S"); + /* create nop channel */ + if ((l2_channel_create(&ch, env, &l2_handler_nop)) != L2_OK) + die("failed to create nop channel"); + /* create prefix channel */ if ((l2_channel_create(&chPrefix, env, &l2_handler_prefix)) != L2_OK) die("failed to create prefix channel"); @@ -118,28 +123,28 @@ die("failed to level of smtp channel"); /* build channel tree */ - if (l2_channel_link(chFilter, L2_LINK_CHILDS, chPrefix, chBuffer, chFile, NULL) != L2_OK) + 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(chFilter, L2_LINK_SIBLINGS, chSyslog, NULL) != L2_OK) + if (l2_channel_link(ch, L2_LINK_SIBLINGS, chSyslog, NULL) != L2_OK) die("failed to link filter channel on top of syslog channel"); /* open channel tree */ - if (l2_channel_open(chFilter) != L2_OK) + if (l2_channel_open(ch) != L2_OK) die("failed to open channel tree"); /* perform a few log operations */ - if (l2_channel_log(chFilter, L2_LEVEL_PANIC, "1: Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) + if (l2_channel_log(ch, L2_LEVEL_PANIC, "1: Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) die("failed to log message #1 to channel"); - if (l2_channel_log(chFilter, L2_LEVEL_PANIC, "2: Shecking\n") != L2_OK) + if (l2_channel_log(ch, L2_LEVEL_PANIC, "2: Shecking\n") != L2_OK) die("failed to log message #2 to channel"); - if (l2_channel_log(chFilter, L2_LEVEL_PANIC, "3: Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) + if (l2_channel_log(ch, L2_LEVEL_PANIC, "3: Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) die("failed to log message #3 to channel"); - if (l2_channel_log(chFilter, L2_LEVEL_PANIC, "4: Shecking\n") != L2_OK) + if (l2_channel_log(ch, L2_LEVEL_PANIC, "4: Shecking\n") != L2_OK) die("failed to log message #4 to channel"); /* destroy channel tree */ - if (l2_channel_destroy(chFilter) != L2_OK) - die("failed to destroy stream"); + if (l2_channel_destroy(ch) != L2_OK) + die("failed to destroy channel tree"); return 0; }