diff options
-rw-r--r-- | broadcast.c | 4 | ||||
-rw-r--r-- | ingest.c | 4 | ||||
-rw-r--r-- | stream.h | 17 |
3 files changed, 23 insertions, 2 deletions
diff --git a/broadcast.c b/broadcast.c index c31112e..280a552 100644 --- a/broadcast.c +++ b/broadcast.c @@ -33,6 +33,8 @@ #include <util.h> #endif +#include "stream.h" + static struct termios saveTerm; static void restoreTerm(void) { tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm); @@ -113,7 +115,7 @@ int main(int argc, char *argv[]) { if (writeSize < readSize) errx(EX_IOERR, "short write(%d)", remote); totalSize += readSize; - if (totalSize > 1024 * 1024) { + if (totalSize >= STREAM_SIZE) { buf[0] = CTRL('L'); writeSize = write(pty, buf, 1); if (writeSize < 0) err(EX_IOERR, "write(%d)", pty); diff --git a/ingest.c b/ingest.c index 9fa754d..6ba387b 100644 --- a/ingest.c +++ b/ingest.c @@ -22,6 +22,8 @@ #include <sysexits.h> #include <unistd.h> +#include "stream.h" + int main(int argc, char *argv[]) { if (argc < 2) return EX_USAGE; const char *path = argv[1]; @@ -49,7 +51,7 @@ int main(int argc, char *argv[]) { char buf[4096]; ssize_t totalSize = 0; - while (totalSize < 1024 * 1024) { + while (totalSize < STREAM_SIZE) { ssize_t readSize = read(remote, buf, sizeof(buf)); if (readSize < 0) err(EX_IOERR, "read(%d)", remote); if (!readSize) return EX_OK; diff --git a/stream.h b/stream.h new file mode 100644 index 0000000..d719b7b --- /dev/null +++ b/stream.h @@ -0,0 +1,17 @@ +/* Copyright (c) 2018, Curtis McEnroe <programble@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#define STREAM_SIZE (1024 * 1024) |