2 * CUnit - A Unit testing framework library for C.
3 * Copyright (C) 2001 Anil Kumar
5 * This library is open source software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
19 #include <sys/select.h>
25 #include <sys/types.h>
27 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
43 #include <sys/utsname.h>
47 typedef void testfunc(int Sock);
51 #include "../lib/libcitadel.h"
57 int msock; /* master listening socket */
60 int n_Lines_to_read = 0;
64 char ip_addr[256]="0.0.0.0";
68 static void StreamEncode(void)
73 const char *Err = NULL;
78 memset(&ReadBuffer, 0, sizeof(IOBuffer));
79 memset(&WriteBuffer, 0, sizeof(IOBuffer));
80 ReadBuffer.fd = fileno(stdin);
81 WriteBuffer.fd = fileno(stdout);
82 ReadBuffer.Buf = NewStrBufPlain(NULL, SIZ*2);
83 WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ*2);
85 int fdin = fileno(stdin);
86 int fdout = fileno(stdout);
94 else if (DeBase64 == 0)
96 else if (DeBase64 == 1)
100 vStream = StrBufNewStreamContext(ST, &Err);
102 while (!done && (fdin >= 0) && (fdout >= 0) && (!feof(stdin)))
105 done = StrBuf_read_one_chunk_callback(fdin,
107 &ReadBuffer) < (SIZ * 4) -1 ;
108 if (IOBufferStrLength(&ReadBuffer) == 0)
115 ret = StrBufStreamTranscode(ST, &WriteBuffer, &ReadBuffer, NULL, -1, vStream, done, &Err);
117 while (IOBufferStrLength(&WriteBuffer) > 0)
119 err = StrBuf_write_one_chunk_callback(fdout,
124 } while (IOBufferStrLength(&ReadBuffer) > 0);
128 StrBufDestroyStreamContext(ST, &vStream, &Err);
130 FreeStrBuf(&ReadBuffer.Buf);
131 FreeStrBuf(&WriteBuffer.Buf);
138 int main(int argc, char* argv[])
141 setvbuf(stdout, NULL, _IONBF, 0);
144 while ((a = getopt(argc, argv, "z:b")) != EOF)
150 DeZip = *optarg == 'x';
154 DeBase64 = *optarg == 'x';
167 /// run -z 1 < ~/testfile1.txt > /tmp/blarg.z