OSSP CVS Repository

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

Check-in Number: 2929
Date: 2002-Nov-29 13:58:59 (local)
2002-Nov-29 12:58:59 (UTC)
User:mlelstv
Branch:
Comment: more testing

PR: Submitted by: Reviewed by: Approved by: Obtained from:

Tickets:
Inspections:
Files:
ossp-pkg/sio/Makefile      1.3 -> 1.4     3 inserted, 0 deleted
ossp-pkg/sio/sio_test2.c      added-> 1.1

ossp-pkg/sio/Makefile 1.3 -> 1.4

--- Makefile     2002/11/24 19:41:17     1.3
+++ Makefile     2002/11/29 12:58:59     1.4
@@ -12,6 +12,9 @@
 sio_test: sio_test.o sio_sa.o sio_buffer.o sio_hello.o sio_bio.o sio.o al.o lib_sa/sa.o
         $(CC) $(CFLAGS) -o sio_test sio_test.o sio_sa.o sio_buffer.o sio_hello.o sio_bio.o sio.o al.o lib_sa/sa.o -lssl -lcrypto
 
+sio_test2: sio_test2.o sio_fd.o sio_buffer.o sio_zlib.o sio_sio.o sio.o al.o
+        $(CC) $(CFLAGS) -o sio_test2 sio_test2.o sio_fd.o sio_buffer.o sio_zlib.o sio_sio.o sio.o al.o -lz
+
 lib_sa/sa.o: lib_sa/sa.c
         $(CC) $(CFLAGS) -c -Ilib_sa -o lib_sa/sa.o lib_sa/sa.c
 


ossp-pkg/sio/sio_test2.c -> 1.1

*** /dev/null    Sat Nov 23 02:17:39 2024
--- -    Sat Nov 23 02:18:14 2024
***************
*** 0 ****
--- 1,118 ----
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/file.h>
+ #include <unistd.h>
+ 
+ #include "al.h"
+ #include "sio.h"
+ 
+ extern sio_module_t sio_module_fd;
+ extern sio_module_t sio_module_zlib;
+ extern sio_module_t sio_module_buffer;
+ extern sio_module_t sio_module_sio;
+ 
+ #define e(f) rc = f; printf("%s = %s\n",#f, sio_error(rc)); fflush(stdout);
+ #define s(f) src = f; printf("%s = %s\n",#f, sa_error(src)); fflush(stdout);
+ 
+ int main(int argc, char *argv[])
+ {
+     int fd;
+     sio_rc_t rc;
+ 
+     sio_t *sio;
+     sio_stage_t *sios_fd, *sios_buffer, *sios_zlib;
+ 
+     sio_t *sio2;
+     sio_stage_t *sios2_sio;
+     al_label_t data_label, error_label, eof_label;
+ 
+     char buf[513];
+     size_t buflen;
+     int level;
+     size_t actual;
+ 
+ #ifdef WRITE
+     fd = open("output", O_WRONLY|O_TRUNC|O_CREAT, 0666);
+ 
+     {
+         int i;
+         for (i=0; i<sizeof(buf)-16; i += 16)
+             sprintf(buf+i,"Hello world %03.3d\n",i);
+         buf[i] = '\0';
+     }
+ 
+ #else
+     fd = open("output", O_RDONLY);
+ #endif
+ 
+     e(sio_create(&sio));
+     e(sio_create_stage(sio, &sio_module_fd, &sios_fd));
+     e(sio_create_stage(sio, &sio_module_zlib, &sios_zlib));
+     e(sio_create_stage(sio, &sio_module_buffer, &sios_buffer));
+ 
+     e(sio_configure_stage(sio, sios_fd, "fd", &fd));
+     buflen = 512;
+     e(sio_configure_stage(sio, sios_fd, "buflen", &buflen));
+ 
+     buflen = 200;
+     e(sio_configure_stage(sio, sios_buffer, "outputsize", &buflen));
+     e(sio_configure_stage(sio, sios_buffer, "inputsize", &buflen));
+ 
+     buflen = 200;
+     e(sio_configure_stage(sio, sios_zlib, "outputsize", &buflen));
+     e(sio_configure_stage(sio, sios_zlib, "inputsize", &buflen));
+     level = 0;
+     e(sio_configure_stage(sio, sios_zlib, "outputlevel", &level));
+     level = -1;
+     e(sio_configure_stage(sio, sios_zlib, "inputlevel", &level));
+ 
+     e(sio_create(&sio2));
+     e(sio_create_stage(sio2, &sio_module_sio, &sios2_sio));
+ 
+     e(sio_label(sio, SIO_LN_DATA, &data_label));
+     e(sio_label(sio, SIO_LN_ERROR, &error_label));
+     e(sio_label(sio, SIO_LN_EOF, &eof_label));
+     e(sio_configure_stage(sio2, sios2_sio, "upstream", sio));
+     e(sio_configure_stage(sio2, sios2_sio, "mydatalabel", data_label));
+     e(sio_configure_stage(sio2, sios2_sio, "myerrorlabel", error_label));
+     e(sio_configure_stage(sio2, sios2_sio, "myeoflabel", eof_label));
+ 
+     e(sio_attach(sio2, sios2_sio, SIO_MODE_READWRITE));
+ 
+     {
+         e(sio_attach(sio, sios_fd, SIO_MODE_READWRITE));
+         e(sio_attach(sio, sios_zlib, SIO_MODE_READWRITE));
+         e(sio_attach(sio, sios_buffer, SIO_MODE_READWRITE));
+ 
+ #ifdef WRITE
+         e(sio_write(sio2, buf, strlen(buf), &actual));
+         e(sio_push(sio2));
+ #else
+         do {
+             actual = 0;
+             e(sio_read(sio2, buf, sizeof(buf), &actual));
+             printf("actual = %d\n",actual);
+             fwrite(buf, actual, 1, stdout);
+             printf("\n");
+         } while (sio_flag(sio2, SIO_FLAG_EOF) == SIO_FALSE);
+ #endif
+ 
+         e(sio_detach(sio, sios_buffer));
+         e(sio_detach(sio, sios_zlib));
+         e(sio_detach(sio, sios_fd));
+     }
+ 
+     e(sio_detach(sio2, sios2_sio));
+ 
+     e(sio_destroy_stage(sio2, sios2_sio));
+     e(sio_destroy(sio2));
+ 
+     e(sio_destroy_stage(sio, sios_buffer));
+     e(sio_destroy_stage(sio, sios_zlib));
+     e(sio_destroy_stage(sio, sios_fd));
+     e(sio_destroy(sio));
+ 
+     close(fd);
+ 
+     return 0;
+ }

CVSTrac 2.0.1