OSSP CVS Repository

ossp - Check-in [1253]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1253
Date: 2001-Nov-04 15:08:24 (local)
2001-Nov-04 14:08:24 (UTC)
User:rse
Branch:
Comment: Simplify "null" (discard) output channel to minimum implementation and provide an additional "nop" (no-operation) filter channel for typical use as the root channel in a channel tree.
Tickets:
Inspections:
Files:
ossp-pkg/l2/Makefile.in      1.27 -> 1.28     2 inserted, 0 deleted
ossp-pkg/l2/l2.h.in      1.15 -> 1.16     1 inserted, 0 deleted
ossp-pkg/l2/l2_ch_nop.c      added-> 1.1
ossp-pkg/l2/l2_ch_null.c      1.8 -> 1.9     8 inserted, 43 deleted
ossp-pkg/l2/l2_test.c      1.38 -> 1.39     14 inserted, 9 deleted

ossp-pkg/l2/Makefile.in 1.27 -> 1.28

--- 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 \


ossp-pkg/l2/l2.h.in 1.15 -> 1.16

--- 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;


ossp-pkg/l2/l2_ch_nop.c -> 1.1

*** /dev/null    Tue Mar 19 04:22:11 2024
--- -    Tue Mar 19 04:27:24 2024
***************
*** 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
+ };
+ 


ossp-pkg/l2/l2_ch_null.c 1.8 -> 1.9

--- 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
 };
 


ossp-pkg/l2/l2_test.c 1.38 -> 1.39

--- 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;
 }

CVSTrac 2.0.1