OSSP CVS Repository

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

Check-in Number: 849
Date: 2001-Sep-04 21:35:20 (local)
2001-Sep-04 19:35:20 (UTC)
User:ms
Branch:
Comment: Array bug fixes and code to test sockets.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_ch_syslog.c      1.12 -> 1.13     5 inserted, 5 deleted
ossp-pkg/l2/l2_test.c      1.10 -> 1.11     36 inserted, 9 deleted

ossp-pkg/l2/l2_ch_syslog.c 1.12 -> 1.13

--- l2_ch_syslog.c       2001/09/04 19:18:49     1.12
+++ l2_ch_syslog.c       2001/09/04 19:35:20     1.13
@@ -67,7 +67,7 @@
 static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
 {
     l2_ch_syslog_t *cfg;
-    l2_param_t pa[3];
+    l2_param_t pa[6];
     l2_result_t rv;
 
     /* parameter checks */
@@ -77,10 +77,10 @@
     /* feed and call generic parameter parsing engine */
     L2_PARAM_SET(pa[0], ident,   CHARPTR,  &cfg->pszIdent);
     L2_PARAM_SET(pa[1], logopts, INT,      &cfg->iLogopt);
-    L2_PARAM_SET(pa[1], facility, INT,     &cfg->iFacility);
-    L2_PARAM_SET(pa[1], priority, INT,     &cfg->iPriority);
-    L2_PARAM_SET(pa[1], maskpriority, INT, &cfg->iMaskpri);
-    L2_PARAM_END(pa[2]);
+    L2_PARAM_SET(pa[2], facility, INT,     &cfg->iFacility);
+    L2_PARAM_SET(pa[3], priority, INT,     &cfg->iPriority);
+    L2_PARAM_SET(pa[4], maskpriority, INT, &cfg->iMaskpri);
+    L2_PARAM_END(pa[5]);
     rv = l2_util_setparams(pa, fmt, ap);
 
     return rv;


ossp-pkg/l2/l2_test.c 1.10 -> 1.11

--- l2_test.c    2001/09/04 14:56:25     1.10
+++ l2_test.c    2001/09/04 19:35:20     1.11
@@ -28,6 +28,12 @@
 */
 
 #include <stdio.h>
+
+#include <sys/types.h>   /* following group of includes are for */
+#include <sys/socket.h>  /* socket testing only                 */
+#include <netinet/in.h>
+#include <netdb.h>
+
 #include "l2.h"
 
 static void die(char *fmt, ...)
@@ -58,21 +64,45 @@
 {
     l2_channel_t *chBuf;
     l2_channel_t *chFile;
+    l2_channel_t *chSock;
     l2_stream_t *st;
 
     /*
      * Typical steps to use a buffered file logging stream
      */
 
-    if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL)
-        die("failed to create buffer channel");
+    if ((st = l2_stream_create()) == NULL)
+        die("failed to create stream");
 
-    if ((chFile = l2_channel_create(&l2_handler_file)) == NULL)
-        die("failed to create file channel");
+/* Atenzione! Before doing any socket testing, make sure you have a valid */
+/* end point listening, or else you will only get an error message when   */
+/* the thing tries to connect.                                            */
+/*    if ((chSock = l2_channel_create(&l2_handler_socket)) == NULL)
+        die("failed to create socket channel");
+
+    if (l2_channel_configure(chSock, "ipversion,host,port", AF_INET,\
+        "localhost", 2002) != L2_OK)
+        die("failed to configure socket ipv4 channel");
+
+    if (l2_channel_configure(chSock, "ipversion,host,port", AF_INET6,\
+        "0123:4567:4455:6677:8899:AABB:9876:5432", 2002) != L2_OK)
+        die("failed to configure socket ipv6 channel");
+
+    if (l2_channel_open(chSock) != L2_OK)
+        die("failed to open socket channel");
+
+    if (l2_stream_channel(st, chSock, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK)
+        die("failed to attach first channel into stream");
+*/
+    if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) /* Buffer */
+        die("failed to create buffer channel");
 
     if (l2_channel_configure(chBuf, "size", 100) != L2_OK)
         die("failed to configure buffer channel");
 
+    if ((chFile = l2_channel_create(&l2_handler_file)) == NULL)   /* File   */
+        die("failed to create file channel");
+
     if (l2_channel_configure(chFile, "path,append,perm", "l2_test.log", TRUE, 0644) != L2_OK)
         die("failed to configure file channel");
 
@@ -82,11 +112,8 @@
     if (l2_channel_open(chBuf) != L2_OK)
         die("failed to open buffer channel");
 
-    if ((st = l2_stream_create()) == NULL)
-        die("failed to create stream");
-
     if (l2_stream_channel(st, chBuf, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK)
-        die("failed to attach channel into stream");
+        die("failed to attach second channel into stream");
 
     if (l2_stream_levels(st, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK)
         die("failed to set global logging level");
@@ -94,7 +121,7 @@
     if (l2_stream_formatter(st, 'k', formatter, NULL) != L2_OK)
         die("failed to configure formatter for %%x");
 
-    if (l2_stream_log(st, L2_LEVEL_PANIC, "test %s %{foo}k", "foo", 12345) != L2_OK)
+    if (l2_stream_log(st, L2_LEVEL_PANIC, "Checking localhost %s %{myparm}k\n", "foo", 12345) != L2_OK)
         die("failed to log message to stream");
 
     if (l2_stream_destroy(st) != L2_OK)

CVSTrac 2.0.1