OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_test.c versions 1.23 and 1.24
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_test.c 1.23 -> 1.24

--- l2_test.c    2001/09/14 19:11:00     1.23
+++ l2_test.c    2001/09/18 14:38:51     1.24
@@ -34,7 +34,7 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <syslog.h>
-#include <unistd.h>
+#include <unistd.h>      /* unistd and fcntl included for pipes */
 #include <fcntl.h>
 
 #include "l2.h"
@@ -74,84 +74,42 @@
 #ifdef WITH_PIPE
     l2_channel_t *chPipe;
 #endif
-#ifdef WITH_SOCKET
     l2_channel_t *chSock;
-#endif
 #ifdef WITH_SMTP
     l2_channel_t *chSmtp;
 #endif
     l2_stream_t *st;
 
-    int pipdesc[2]; /* For use with our pipe channel test */
     /*
      * Typical steps to use a buffered file logging stream
      */
-
     if ((st = l2_stream_create()) == NULL)
         die("failed to create stream");
 
-#ifdef WITH_SOCKET
-    /* 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, "protocol,ipversion,host,port",\
-        IPPROTO_TCP, AF_INET, "localhost", 2002) != L2_OK)
-        die("failed to configure socket ipv4 channel");
-#if 0
-    if (l2_channel_configure(chSock, "protocol,ipversion,host,port",\
-          IPPROTO_TCP, AF_INET6, "0:0:0:0:0:0:0:1", 2002) != L2_OK)
-          die("failed to configure socket ipv6 channel");
-#endif
-    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_LEVEL_NONE) != L2_OK)
-        die("failed to attach first channel into stream");
-#endif
-
     if ((chPrefix  = l2_channel_create(&l2_handler_prefix)) == NULL) /* Prefix */
         die("failed to create prefix channel");
 
     if (l2_channel_configure(chPrefix, "prefix,timezone", "[%d-%m-%Y/%H:%M:%S] %L test[%P]: ", "local") != L2_OK)
         die("failed to configure prefix channel");
 
-    if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) /* Buffer */
+    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   */
+    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");
 
-#ifdef WITH_PIPE
-    if (pipe(pipdesc))
-        die("pipe() call failed");
-
-    if ((chPipe = l2_channel_create(&l2_handler_pipe)) == NULL)   /* Pipe */
-        die("failed to create pipe channel");
-
-    if (l2_channel_configure(chPipe, "pipe", pipdesc[1]) != L2_OK)
-        die("failed to configure pipe channel");
-#endif
-
     if (l2_channel_stack(chFile, chBuf) != L2_OK)
         die("failed to stack buffer channel on top of file channel");
     
     if (l2_channel_stack(chBuf, chPrefix) != L2_OK)
         die("failed to stack prefix channel on top of buffer channel");
 
-#ifdef WITH_PIPE
-    if (l2_channel_stack(chPrefix, chPipe) != L2_OK)
-        die("failed to stack pipe channel on top of prefix channel");
-#endif
-    
     if (l2_channel_open(chPrefix) != L2_OK)
         die("failed to open channel stack");
 
@@ -159,7 +117,7 @@
         die("failed to attach channel stack into stream");
 
 #ifdef WITH_SYSLOG
-    if ((chSyslog = l2_channel_create(&l2_handler_syslog)) == NULL)   /* Syslog */
+    if ((chSyslog = l2_channel_create(&l2_handler_syslog)) == NULL)  /* Syslog */
         die("failed to create syslog channel");
 
     if (l2_channel_configure(chSyslog, "ident,facility,target,remotehost,logpid",
@@ -173,8 +131,44 @@
         die("failed to attach channel syslog into stream");
 #endif
 
+#ifdef WITH_PIPE
+    if ((chPipe = l2_channel_create(&l2_handler_pipe)) == NULL)      /* Pipe */
+        die("failed to create pipe channel");
+
+    if (l2_channel_configure(chPipe, "pipe", pipdesc[1]) != L2_OK)
+        die("failed to configure pipe channel");
+
+    if (l2_channel_open(chPipe) != L2_OK)
+        die("failed to open pipe channel");
+
+    if (l2_stream_channel(st, chPipe, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK)
+        die("failed to attach channel pipe into stream");
+#endif
+
+#ifdef WITH_SOCKET
+    /* 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)   /* Socket */
+        die("failed to create socket channel");
+
+    if (l2_channel_configure(chSock, "protocol,ipversion,host,port",\
+        IPPROTO_TCP, AF_INET, "localhost", 2002) != L2_OK)
+        die("failed to configure socket ipv4 channel");
+#if 0
+    if (l2_channel_configure(chSock, "protocol,ipversion,host,port",\
+          IPPROTO_TCP, AF_INET6, "0:0:0:0:0:0:0:1", 2002) != L2_OK)
+          die("failed to configure socket ipv6 channel");
+#endif
+    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_LEVEL_NONE) != L2_OK)
+        die("failed to attach channel socket into stream");
+#endif
+
 #ifdef WITH_SMTP
-    if ((chSmtp = l2_channel_create(&l2_handler_smtp)) == NULL)   /* SMTP */
+    if ((chSmtp = l2_channel_create(&l2_handler_smtp)) == NULL)      /* SMTP */
         die("failed to create smtp channel");
 
     if (l2_channel_configure(chSmtp, "rcpt,host,port", "rse@engelschall.com", "en1", "25") != L2_OK)
@@ -202,8 +196,6 @@
     if (l2_stream_destroy(st) != L2_OK)
         die("failed to destroy stream");
 
-    close(pipdesc[1]); /* Close the locally made pipe file descriptor */
-    close(pipdesc[0]); /* Close the locally made pipe file descriptor */
     return 0;
 }
 

CVSTrac 2.0.1