OSSP CVS Repository

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

ossp-pkg/l2/l2_test.c 1.20 -> 1.21

--- l2_test.c    2001/09/13 16:19:06     1.20
+++ l2_test.c    2001/09/14 15:40:04     1.21
@@ -34,6 +34,8 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <syslog.h>
+#include <unistd.h>
+#include <fcntl.h>
 
 #include "l2.h"
 
@@ -67,6 +69,7 @@
     l2_channel_t *chBuf;
     l2_channel_t *chFile;
     l2_channel_t *chSyslog;
+    l2_channel_t *chPipe;
 #ifdef WITH_SOCKET
     l2_channel_t *chSock;
 #endif
@@ -75,6 +78,7 @@
 #endif
     l2_stream_t *st;
 
+    int pipdesc[2]; /* For use with our pipe channel test */
     /*
      * Typical steps to use a buffered file logging stream
      */
@@ -122,12 +126,24 @@
     if (l2_channel_configure(chFile, "path,append,perm", "l2_test.log", TRUE, 0644) != L2_OK)
         die("failed to configure file channel");
 
+    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");
+
     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");
 
+    if (l2_channel_stack(chPrefix, chPipe) != L2_OK)
+        die("failed to stack pipe channel on top of prefix channel");
+    
     if (l2_channel_open(chPrefix) != L2_OK)
         die("failed to open channel stack");
 
@@ -177,6 +193,8 @@
     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