OSSP CVS Repository

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

Check-in Number: 1292
Date: 2001-Nov-10 15:01:47 (local)
2001-Nov-10 14:01:47 (UTC)
User:rse
Branch:
Comment: First cut for the L2 command line tool which allows us very easy testing through the new channel tree specification parser.
Tickets:
Inspections:
Files:
ossp-pkg/l2/.cvsignore      1.11 -> 1.12     2 inserted, 0 deleted
ossp-pkg/l2/Makefile.in      1.36 -> 1.37     15 inserted, 5 deleted
ossp-pkg/l2/l2tool.c      added-> 1.1
ossp-pkg/l2/l2tool.pod      added-> 1.1

ossp-pkg/l2/.cvsignore 1.11 -> 1.12

--- .cvsignore   2001/11/07 16:17:09     1.11
+++ .cvsignore   2001/11/10 14:01:47     1.12
@@ -23,3 +23,5 @@
 l2_spec_parse.c
 l2_spec_parse.h
 l2_spec_scan.c
+l2tool
+l2tool.1


ossp-pkg/l2/Makefile.in 1.36 -> 1.37

--- Makefile.in  2001/11/08 21:58:00     1.36
+++ Makefile.in  2001/11/10 14:01:47     1.37
@@ -58,10 +58,10 @@
 SHTOOL      = ./shtool
 LIBTOOL     = ./libtool
 
-TARGET       = $(TARGET_LIBS) $(TARGET_MANS) $(TARGET_TESTS)
+TARGET       = $(TARGET_LIBS) $(TARGET_MANS) $(TARGET_PROGS)
 TARGET_LIBS  = libl2.la @LIBL2XX_LA@
-TARGET_MANS  = l2-config.1 l2.3 @L2XX_3@
-TARGET_TESTS = l2_test @L2_TESTXX@
+TARGET_MANS  = l2tool.1 l2-config.1 l2.3 @L2XX_3@
+TARGET_PROGS = l2tool l2_test @L2_TESTXX@
 
 #   list of library object files
 OBJS = \
@@ -162,7 +162,9 @@
 @M@l2_spec_parse.c l2_spec_parse.h: l2_spec_parse.y
 @M@     $(BISON) -d -k -pl2_spec_ -ol2_spec_parse.c l2_spec_parse.y
 
-#   build test suite programs
+#   build programs
+l2tool: l2tool.o libl2.la
+        $(LIBTOOL) --mode=link --quiet $(CC) $(LDFLAGS) -o l2tool l2tool.o libl2.la $(LIBS)
 l2_test: l2_test.o libl2.la
         $(LIBTOOL) --mode=link --quiet $(CC) $(LDFLAGS) -o l2_test l2_test.o libl2.la $(LIBS)
 l2_test++: l2_test++.o libl2++.la
@@ -171,6 +173,10 @@
         $(LIBTOOL) --mode=link --quiet $(CC) $(LDFLAGS) -o l2_sockmon l2_sockmon.o $(LIBS)
 
 #   build Unix manual pages
+l2tool.1: l2tool.pod l2_version.c
+        BASENAME="l2tool"; SEC=1; \
+        NAME="L2"; ONELINE="Logging Tool"; \
+        $(_MANPAGE)
 l2-config.1: l2-config.pod l2_version.c
         BASENAME="l2-config"; SEC=1; \
         NAME="L2"; ONELINE="Logging Library"; \
@@ -203,6 +209,8 @@
         $(SHTOOL) mkdir -p -f -m 755 $(DESTDIR)$(mandir)/man3
         $(SHTOOL) install -c -m 755 l2-config $(DESTDIR)$(bindir)/l2-config
         $(SHTOOL) install -c -m 644 l2-config.1 $(DESTDIR)$(mandir)/man1/l2-config.1
+        $(SHTOOL) install -c -m 755 l2tool $(DESTDIR)$(bindir)/l2tool
+        $(SHTOOL) install -c -m 644 l2tool.1 $(DESTDIR)$(mandir)/man1/l2tool.1
 install-c:
         $(SHTOOL) install -c -m 644 l2.3 $(DESTDIR)$(mandir)/man3/l2.3
         $(SHTOOL) install -c -m 644 l2.h $(DESTDIR)$(includedir)/l2.h
@@ -226,6 +234,8 @@
         $(RM) $(DESTDIR)$(includedir)/l2.h
         $(RM) $(DESTDIR)$(mandir)/man3/l2.3
 uninstall-std:
+        $(RM) $(DESTDIR)$(mandir)/man1/l2tool.1
+        $(RM) $(DESTDIR)$(bindir)/l2tool
         $(RM) $(DESTDIR)$(mandir)/man1/l2-config.1
         $(RM) $(DESTDIR)$(bindir)/l2-config
         $(RMDIR) $(DESTDIR)$(mandir)/man3
@@ -242,7 +252,7 @@
         $(RM) .libs/*
         -$(RMDIR) .libs >/dev/null 2>&1 || $(TRUE)
         $(RM) $(TARGET_LIBS)
-        $(RM) $(TARGET_TESTS)
+        $(RM) $(TARGET_PROGS)
 
 #   remove everything which can be regenerated
 #   by "./configure && make all"


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

*** /dev/null    Thu Oct 28 07:33:00 2021
--- -    Thu Oct 28 07:36:03 2021
***************
*** 0 ****
--- 1,115 ----
+ /*
+ **  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.
+ **
+ **  l2tool.c: L2 command line tool
+ */
+ 
+ #include <stdio.h>
+ #include "l2.h"
+ 
+ static void die(l2_env_t *env, l2_result_t rv, char *fmt, ...)
+ {
+     va_list ap;
+     char *error;
+ 
+     va_start(ap, fmt);
+     fprintf(stderr, "l2tool:ERROR: ");
+     vfprintf(stderr, fmt, ap);
+     error = l2_env_strerror(env, rv);
+     fprintf(stderr, " (%s)\n", error);
+     va_end(ap);
+     exit(1);
+ }
+ 
+ int main(int argc, char *argv[])
+ {
+     l2_channel_t *ch;
+     char *spec;
+     l2_result_t rv;
+     l2_env_t *env;
+     char *cpLevel;
+     char caBuf[2048];
+     int nBuf;
+     char *cpMsg;
+     char *cp;
+     unsigned int nLevel;
+ 
+     /* minimal command line parsing */
+     if (argc != 2) {
+         fprintf(stderr, "l2tool:ERROR: invalid command line\n");
+         fprintf(stderr, "l2tool:USAGE: l2tool <specification>\n");
+         exit(1);
+     }
+     spec = argv[1];
+ 
+     /* create environment */
+     if ((rv = l2_env_create(&env)) != L2_OK)
+         die(env, rv, "failed to create environment");
+ 
+     /* create channel tree */
+     if ((rv = l2_spec(&ch, env, spec)) != L2_OK)
+         die(env, rv, "failed to parse specification");
+ 
+     /* open channel tree */
+     if ((rv = l2_channel_open(ch)) != L2_OK)
+         die(env, rv, "failed to open channel tree");
+     
+     /* loop over stdin */
+     while (fgets(caBuf, sizeof(caBuf), stdin) != NULL) {
+         /* strip newline */
+         nBuf = strlen(caBuf);
+         caBuf[nBuf-1] = '\0';
+ 
+         /* parse logging level */
+         nLevel  = L2_LEVEL_INFO;
+         cpLevel = "info";
+         cpMsg   = caBuf;
+         if (caBuf[0] == '<') {
+             if ((cp = strchr(caBuf+1, '>')) == NULL)
+                 die(env, rv, "unterminated level prefix");
+             *cp++ = '\0';
+             cpLevel = caBuf+1;
+             cpMsg   = cp;
+         }
+         if (l2_util_s2l(cpLevel, strlen(cpLevel), ',', &nLevel) != L2_OK)
+             die(env, rv, "invalid level prefix");
+ 
+         /* perform log operation(s) */
+         if ((rv = l2_channel_log(ch, nLevel, "%s", cpMsg)) != L2_OK)
+             die(env, rv, "failed to log message to channel tree");
+     }
+ 
+     /* destroy channel tree */
+     if ((rv = l2_channel_destroy(ch)) != L2_OK)
+         die(env, rv, "failed to destroy channel tree");
+ 
+     /* destroy environment */
+     if ((rv = l2_env_destroy(env)) != L2_OK)
+         die(env, rv, "failed to destroy environment");
+ 
+     return 0;
+ }
+ 


ossp-pkg/l2/l2tool.pod -> 1.1

*** /dev/null    Thu Oct 28 07:33:00 2021
--- -    Thu Oct 28 07:36:03 2021
***************
*** 0 ****
--- 1,82 ----
+ ##
+ ##  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.
+ ##
+ ##  l2tool.pod: L2 tool manual page
+ ##
+ 
+ =pod
+ 
+ =head1 NAME
+ 
+ B<l2tool> - L2 loggin tool
+ 
+ =head1 VERSION
+ 
+ OSSP L2 L2_VERSION_STR
+ 
+ =head1 SYNOPSIS
+ 
+ B<l2tool>
+ I<specification>
+ 
+ =head1 DESCRIPTION
+ 
+ The B<l2tool> program is a little helper utility which reads log
+ messages from F<stdin> and writes it to a channel tree specified via the
+ channel tree I<specification>.
+ 
+ =head1 OPTIONS
+ 
+ B<l2tool> accepts the following options:
+ 
+ =over 4
+ 
+ =item B<--help>
+ 
+ Prints the short usage information.
+ 
+ =item B<--version>
+ 
+ Prints the version number and date of the installed l2(3) library.
+ 
+ ...
+ 
+ =back
+ 
+ =head1 EXAMPLE
+ 
+ =head1 SEE ALSO
+ 
+ l2(3).
+ 
+ =head1 AUTHOR
+ 
+  Ralf S. Engelschall
+  rse@engelschall.com
+  www.engelschall.com
+ 
+ =cut
+ 

CVSTrac 2.0.1