Remove UtilStreamCopy()

This commit is contained in:
Jordan Bancino 2023-04-01 00:20:18 +00:00
parent f341fd2b6e
commit 7b3d537175
4 changed files with 3 additions and 41 deletions

View file

@ -301,37 +301,3 @@ UtilGetLine(char **linePtr, size_t * n, Stream * stream)
return UtilGetDelim(linePtr, n, '\n', stream); return UtilGetDelim(linePtr, n, '\n', stream);
} }
size_t
UtilStreamCopy(Stream * in, Stream * out)
{
size_t bytes = 0;
int c;
while (1)
{
c = StreamGetc(in);
if (StreamEof(in))
{
break;
}
if (StreamError(in))
{
if (errno == EAGAIN)
{
StreamClearError(in);
continue;
}
else
{
break;
}
}
StreamPutc(out, c);
bytes++;
}
return bytes;
}

View file

@ -52,7 +52,4 @@ extern ssize_t
extern ssize_t extern ssize_t
UtilGetLine(char **, size_t *, Stream *); UtilGetLine(char **, size_t *, Stream *);
extern size_t
UtilStreamCopy(Stream *, Stream *);
#endif /* TELODENDRIA_UTIL_H */ #endif /* TELODENDRIA_UTIL_H */

View file

@ -59,7 +59,7 @@ HttpHandle(HttpServerContext * cx, void *args)
StreamPutc(StreamStdout(), '\n'); StreamPutc(StreamStdout(), '\n');
bytes = UtilStreamCopy(HttpServerStream(cx), StreamStdout()); bytes = StreamCopy(HttpServerStream(cx), StreamStdout());
StreamPutc(StreamStdout(), '\n'); StreamPutc(StreamStdout(), '\n');
StreamPrintf(StreamStdout(), "(%lu bytes)\n", bytes); StreamPrintf(StreamStdout(), "(%lu bytes)\n", bytes);

View file

@ -33,7 +33,6 @@
#include <HashMap.h> #include <HashMap.h>
#include <HttpClient.h> #include <HttpClient.h>
#include <Uri.h> #include <Uri.h>
#include <Util.h>
#define FLAG_HEADERS (1 << 0) #define FLAG_HEADERS (1 << 0)
@ -182,7 +181,7 @@ main(int argc, char **argv)
return 1; return 1;
} }
UtilStreamCopy(in, HttpClientStream(cx)); StreamCopy(in, HttpClientStream(cx));
StreamClose(in); StreamClose(in);
} }
@ -216,7 +215,7 @@ main(int argc, char **argv)
StreamPutc(StreamStdout(), '\n'); StreamPutc(StreamStdout(), '\n');
} }
UtilStreamCopy(HttpClientStream(cx), StreamStdout()); StreamCopy(HttpClientStream(cx), StreamStdout());
HttpClientContextFree(cx); HttpClientContextFree(cx);
UriFree(uri); UriFree(uri);